Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
print("If velocity value is positive, object is travelling to the right.")
|
| 2 |
+
print("If velocity value is negative, object is travelling in the opposite direction to the left.")
|
| 3 |
+
|
| 4 |
+
# Ask for input for initial velocity, u
|
| 5 |
+
u = float(input("Enter the initial velocity (u) in metres per second: "))
|
| 6 |
+
if u < 0:
|
| 7 |
+
d = "travelling to the left"
|
| 8 |
+
elif u > 0:
|
| 9 |
+
d = "travelling to the right"
|
| 10 |
+
elif u == 0:
|
| 11 |
+
d = "at rest"
|
| 12 |
+
|
| 13 |
+
# Ask for input for final velocity, v
|
| 14 |
+
v = float(input("Enter the final velocity (v) in metres per second: "))
|
| 15 |
+
if v < 0:
|
| 16 |
+
d = "travelling to the left"
|
| 17 |
+
elif v > 0:
|
| 18 |
+
d = "travelling to the right"
|
| 19 |
+
elif v == 0:
|
| 20 |
+
d = "at rest"
|
| 21 |
+
|
| 22 |
+
# Print the values to confirm
|
| 23 |
+
print(f"Initial velocity (u): {u} m/s means object is {d} with a speed of {abs(u)} m/s.")
|
| 24 |
+
print(f"Final velocity (v): {v} m/s means object is {d} with a speed of {abs(v)} m/s.")
|
| 25 |
+
|
| 26 |
+
if u < 0:
|
| 27 |
+
if v == u:
|
| 28 |
+
print("u < 0, v = u")
|
| 29 |
+
print("Object was initially travelling to the left.")
|
| 30 |
+
print("Object continued travelling to the left with constant speed.")
|
| 31 |
+
elif v < u:
|
| 32 |
+
print("u < 0, v < u")
|
| 33 |
+
print("Object was initially travelling to the left.")
|
| 34 |
+
print("Object continued travelling to the left, accelerated and increased its speed.")
|
| 35 |
+
elif v == 0:
|
| 36 |
+
print("u < 0, v = 0")
|
| 37 |
+
print("Object was initially travelling to the left.")
|
| 38 |
+
print("Object continued travelling to the left, decelerated, decreased its speed and stopped.")
|
| 39 |
+
elif v > u and v < 0:
|
| 40 |
+
print("u < 0, v > u and v < 0")
|
| 41 |
+
print("Object was initially travelling to the left.")
|
| 42 |
+
print("Object continued travelling to the left, decelerated and decreased its speed.")
|
| 43 |
+
elif v > u and v > 0:
|
| 44 |
+
print("u < 0, v > u and v > 0")
|
| 45 |
+
print("Object was initially travelling to the left.")
|
| 46 |
+
print("Object continued travelling to the left, decelerated, decreased its speed and stopped.")
|
| 47 |
+
print("Object then accelerated and travelled to the right.")
|
| 48 |
+
elif u > 0:
|
| 49 |
+
if v == u:
|
| 50 |
+
print("u > 0, v = u")
|
| 51 |
+
print("Object was initially travelling to the right.")
|
| 52 |
+
print("Object continued travelling to the right with constant speed.")
|
| 53 |
+
elif v > u:
|
| 54 |
+
print("u > 0, v > u")
|
| 55 |
+
print("Object was initially travelling to the right.")
|
| 56 |
+
print("Object continued travelling to the right, accelerated and increased its speed.")
|
| 57 |
+
elif v == 0:
|
| 58 |
+
print("u > 0, v = 0")
|
| 59 |
+
print("Object was initially travelling to the right.")
|
| 60 |
+
print("Object continued travelling to the right, decelerated, decreased its speed and stopped.")
|
| 61 |
+
elif v < u and v > 0:
|
| 62 |
+
print("u > 0, v < u and v > 0")
|
| 63 |
+
print("Object was initially travelling to the right.")
|
| 64 |
+
print("Object continued travelling to the right, decelerated and decreased its speed.")
|
| 65 |
+
elif v < u and v < 0:
|
| 66 |
+
print("u > 0, v < u and v < 0")
|
| 67 |
+
print("Object was initially travelling to the right.")
|
| 68 |
+
print("Object continued travelling to the right, decelerated, decreased its speed and stopped.")
|
| 69 |
+
print("Object then accelerated and travelled to the left.")
|
| 70 |
+
elif u == 0:
|
| 71 |
+
if v == u:
|
| 72 |
+
print("Object was initially at rest.")
|
| 73 |
+
print("u = 0, v = u")
|
| 74 |
+
print("Object continued resting.")
|
| 75 |
+
elif v > u:
|
| 76 |
+
print("Object was initially at rest.")
|
| 77 |
+
print("u = 0, v > u")
|
| 78 |
+
print("Object accelerated and increased its speed to travel to the right.")
|
| 79 |
+
elif v < u:
|
| 80 |
+
print("Object was initially at rest.")
|
| 81 |
+
print("u = 0, v < u and v < 0")
|
| 82 |
+
print("Object accelerated and increased its speed to travel to the left.")
|