Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,103 +1,92 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
if "my_text" not in st.session_state:
|
4 |
-
st.session_state.my_text = ""
|
5 |
-
|
6 |
-
def submit():
|
7 |
-
st.session_state.my_text = st.session_state.widget
|
8 |
-
st.session_state.widget = ""
|
9 |
-
|
10 |
-
st.text_input("Enter text here", key="widget", on_change=submit)
|
11 |
-
|
12 |
-
query = st.session_state.my_text
|
13 |
|
14 |
-
st.
|
15 |
-
|
16 |
-
if 'responses' not in st.session_state:
|
17 |
-
st.session_state['responses'] = []
|
18 |
|
19 |
-
|
20 |
-
|
|
|
21 |
|
22 |
-
|
23 |
-
|
24 |
|
25 |
-
#
|
26 |
-
u = float(input("Enter the initial velocity (u) in metres per second: "))
|
27 |
if u < 0:
|
28 |
-
|
29 |
elif u > 0:
|
30 |
-
|
31 |
-
|
32 |
-
|
|
|
|
|
|
|
33 |
|
34 |
-
#
|
35 |
-
v = float(input("Enter the final velocity (v) in metres per second: "))
|
36 |
if v < 0:
|
37 |
-
|
38 |
elif v > 0:
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
|
43 |
-
#
|
44 |
-
|
45 |
-
|
46 |
|
|
|
47 |
if u < 0:
|
48 |
if v == u:
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
elif v < u:
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
elif v == 0:
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
elif v > u and v < 0:
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
elif v > u and v > 0:
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
elif u > 0:
|
70 |
if v == u:
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
elif v > u:
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
elif v == 0:
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
elif v < u and v > 0:
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
elif v < u and v < 0:
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
elif u == 0:
|
92 |
if v == u:
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
elif v > u:
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
elif v < u:
|
101 |
-
|
102 |
-
|
103 |
-
|
|
|
1 |
+
import streamlit as st
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
+
st.title("Self Learn Kinematics")
|
|
|
|
|
|
|
4 |
|
5 |
+
# Display introduction
|
6 |
+
st.write("If velocity value is positive, the object is travelling to the right.")
|
7 |
+
st.write("If velocity value is negative, the object is travelling in the opposite direction to the left.")
|
8 |
|
9 |
+
# Input for initial velocity, u
|
10 |
+
u = st.number_input("Enter the initial velocity (u) in metres per second:", step=0.1, format="%.1f")
|
11 |
|
12 |
+
# Determine the initial direction
|
|
|
13 |
if u < 0:
|
14 |
+
initial_direction = "travelling to the left"
|
15 |
elif u > 0:
|
16 |
+
initial_direction = "travelling to the right"
|
17 |
+
else:
|
18 |
+
initial_direction = "at rest"
|
19 |
+
|
20 |
+
# Input for final velocity, v
|
21 |
+
v = st.number_input("Enter the final velocity (v) in metres per second:", step=0.1, format="%.1f")
|
22 |
|
23 |
+
# Determine the final direction
|
|
|
24 |
if v < 0:
|
25 |
+
final_direction = "travelling to the left"
|
26 |
elif v > 0:
|
27 |
+
final_direction = "travelling to the right"
|
28 |
+
else:
|
29 |
+
final_direction = "at rest"
|
30 |
|
31 |
+
# Display initial and final velocities information
|
32 |
+
st.write(f"Initial velocity (u): {u} m/s means object is {initial_direction} with a speed of {abs(u)} m/s.")
|
33 |
+
st.write(f"Final velocity (v): {v} m/s means object is {final_direction} with a speed of {abs(v)} m/s.")
|
34 |
|
35 |
+
# Determine and display the motion description based on the conditions
|
36 |
if u < 0:
|
37 |
if v == u:
|
38 |
+
st.write("u < 0, v = u")
|
39 |
+
st.write("Object was initially travelling to the left.")
|
40 |
+
st.write("Object continued travelling to the left with constant speed.")
|
41 |
elif v < u:
|
42 |
+
st.write("u < 0, v < u")
|
43 |
+
st.write("Object was initially travelling to the left.")
|
44 |
+
st.write("Object continued travelling to the left, accelerated and increased its speed.")
|
45 |
elif v == 0:
|
46 |
+
st.write("u < 0, v = 0")
|
47 |
+
st.write("Object was initially travelling to the left.")
|
48 |
+
st.write("Object continued travelling to the left, decelerated, decreased its speed and stopped.")
|
49 |
elif v > u and v < 0:
|
50 |
+
st.write("u < 0, v > u and v < 0")
|
51 |
+
st.write("Object was initially travelling to the left.")
|
52 |
+
st.write("Object continued travelling to the left, decelerated and decreased its speed.")
|
53 |
elif v > u and v > 0:
|
54 |
+
st.write("u < 0, v > u and v > 0")
|
55 |
+
st.write("Object was initially travelling to the left.")
|
56 |
+
st.write("Object continued travelling to the left, decelerated, decreased its speed and stopped.")
|
57 |
+
st.write("Object then accelerated and travelled to the right.")
|
58 |
elif u > 0:
|
59 |
if v == u:
|
60 |
+
st.write("u > 0, v = u")
|
61 |
+
st.write("Object was initially travelling to the right.")
|
62 |
+
st.write("Object continued travelling to the right with constant speed.")
|
63 |
elif v > u:
|
64 |
+
st.write("u > 0, v > u")
|
65 |
+
st.write("Object was initially travelling to the right.")
|
66 |
+
st.write("Object continued travelling to the right, accelerated and increased its speed.")
|
67 |
elif v == 0:
|
68 |
+
st.write("u > 0, v = 0")
|
69 |
+
st.write("Object was initially travelling to the right.")
|
70 |
+
st.write("Object continued travelling to the right, decelerated, decreased its speed and stopped.")
|
71 |
elif v < u and v > 0:
|
72 |
+
st.write("u > 0, v < u and v > 0")
|
73 |
+
st.write("Object was initially travelling to the right.")
|
74 |
+
st.write("Object continued travelling to the right, decelerated and decreased its speed.")
|
75 |
elif v < u and v < 0:
|
76 |
+
st.write("u > 0, v < u and v < 0")
|
77 |
+
st.write("Object was initially travelling to the right.")
|
78 |
+
st.write("Object continued travelling to the right, decelerated, decreased its speed and stopped.")
|
79 |
+
st.write("Object then accelerated and travelled to the left.")
|
80 |
elif u == 0:
|
81 |
if v == u:
|
82 |
+
st.write("Object was initially at rest.")
|
83 |
+
st.write("u = 0, v = u")
|
84 |
+
st.write("Object continued resting.")
|
85 |
elif v > u:
|
86 |
+
st.write("Object was initially at rest.")
|
87 |
+
st.write("u = 0, v > u")
|
88 |
+
st.write("Object accelerated and increased its speed to travel to the right.")
|
89 |
elif v < u:
|
90 |
+
st.write("Object was initially at rest.")
|
91 |
+
st.write("u = 0, v < u and v < 0")
|
92 |
+
st.write("Object accelerated and increased its speed to travel to the left.")
|