Spaces:
Runtime error
Runtime error
print("If velocity value is positive, object is travelling to the right.") | |
print("If velocity value is negative, object is travelling in the opposite direction to the left.") | |
# Ask for input for initial velocity, u | |
u = float(input("Enter the initial velocity (u) in metres per second: ")) | |
if u < 0: | |
d = "travelling to the left" | |
elif u > 0: | |
d = "travelling to the right" | |
elif u == 0: | |
d = "at rest" | |
# Ask for input for final velocity, v | |
v = float(input("Enter the final velocity (v) in metres per second: ")) | |
if v < 0: | |
d = "travelling to the left" | |
elif v > 0: | |
d = "travelling to the right" | |
elif v == 0: | |
d = "at rest" | |
# Print the values to confirm | |
print(f"Initial velocity (u): {u} m/s means object is {d} with a speed of {abs(u)} m/s.") | |
print(f"Final velocity (v): {v} m/s means object is {d} with a speed of {abs(v)} m/s.") | |
if u < 0: | |
if v == u: | |
print("u < 0, v = u") | |
print("Object was initially travelling to the left.") | |
print("Object continued travelling to the left with constant speed.") | |
elif v < u: | |
print("u < 0, v < u") | |
print("Object was initially travelling to the left.") | |
print("Object continued travelling to the left, accelerated and increased its speed.") | |
elif v == 0: | |
print("u < 0, v = 0") | |
print("Object was initially travelling to the left.") | |
print("Object continued travelling to the left, decelerated, decreased its speed and stopped.") | |
elif v > u and v < 0: | |
print("u < 0, v > u and v < 0") | |
print("Object was initially travelling to the left.") | |
print("Object continued travelling to the left, decelerated and decreased its speed.") | |
elif v > u and v > 0: | |
print("u < 0, v > u and v > 0") | |
print("Object was initially travelling to the left.") | |
print("Object continued travelling to the left, decelerated, decreased its speed and stopped.") | |
print("Object then accelerated and travelled to the right.") | |
elif u > 0: | |
if v == u: | |
print("u > 0, v = u") | |
print("Object was initially travelling to the right.") | |
print("Object continued travelling to the right with constant speed.") | |
elif v > u: | |
print("u > 0, v > u") | |
print("Object was initially travelling to the right.") | |
print("Object continued travelling to the right, accelerated and increased its speed.") | |
elif v == 0: | |
print("u > 0, v = 0") | |
print("Object was initially travelling to the right.") | |
print("Object continued travelling to the right, decelerated, decreased its speed and stopped.") | |
elif v < u and v > 0: | |
print("u > 0, v < u and v > 0") | |
print("Object was initially travelling to the right.") | |
print("Object continued travelling to the right, decelerated and decreased its speed.") | |
elif v < u and v < 0: | |
print("u > 0, v < u and v < 0") | |
print("Object was initially travelling to the right.") | |
print("Object continued travelling to the right, decelerated, decreased its speed and stopped.") | |
print("Object then accelerated and travelled to the left.") | |
elif u == 0: | |
if v == u: | |
print("Object was initially at rest.") | |
print("u = 0, v = u") | |
print("Object continued resting.") | |
elif v > u: | |
print("Object was initially at rest.") | |
print("u = 0, v > u") | |
print("Object accelerated and increased its speed to travel to the right.") | |
elif v < u: | |
print("Object was initially at rest.") | |
print("u = 0, v < u and v < 0") | |
print("Object accelerated and increased its speed to travel to the left.") |