Spaces:
Runtime error
Runtime error
File size: 5,677 Bytes
923d8e4 4484ebb 923d8e4 4484ebb 923d8e4 4484ebb 2b7310d b1eef16 2b7310d 923d8e4 2b7310d b1eef16 2b7310d b1eef16 2b7310d b1eef16 2b7310d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
import streamlit as st
st.title("Self Learn Kinematics")
# Display introduction
st.write("If velocity value is positive, the object is travelling to the right.")
st.write("If velocity value is negative, the object is travelling in the opposite direction to the left.")
# State variables to hold input values and results
if 'u' not in st.session_state:
st.session_state.u = 0.0
if 'v' not in st.session_state:
st.session_state.v = 0.0
# Input for initial velocity, u
u = st.number_input("Enter the initial velocity (u) in metres per second:", value=st.session_state.u, step=0.1, format="%.1f")
# Input for final velocity, v
v = st.number_input("Enter the final velocity (v) in metres per second:", value=st.session_state.v, step=0.1, format="%.1f")
# Buttons for submitting and clearing inputs
if st.button("Submit"):
st.session_state.u = u
st.session_state.v = v
# Determine the initial direction
if st.session_state.u < 0:
initial_direction = "travelling to the left"
elif st.session_state.u > 0:
initial_direction = "travelling to the right"
else:
initial_direction = "at rest"
# Determine the final direction
if st.session_state.v < 0:
final_direction = "travelling to the left"
elif st.session_state.v > 0:
final_direction = "travelling to the right"
else:
final_direction = "at rest"
# Display initial and final velocities information
st.write(f"Initial velocity (u): {st.session_state.u} m/s means object is {initial_direction} with a speed of {abs(st.session_state.u)} m/s.")
st.write(f"Final velocity (v): {st.session_state.v} m/s means object is {final_direction} with a speed of {abs(st.session_state.v)} m/s.")
# Determine and display the motion description based on the conditions
if st.session_state.u < 0:
if st.session_state.v == st.session_state.u:
st.write("u < 0, v = u")
st.write("Object was initially travelling to the left.")
st.write("Object continued travelling to the left with constant speed.")
elif st.session_state.v < st.session_state.u:
st.write("u < 0, v < u")
st.write("Object was initially travelling to the left.")
st.write("Object continued travelling to the left, accelerated and increased its speed.")
elif st.session_state.v == 0:
st.write("u < 0, v = 0")
st.write("Object was initially travelling to the left.")
st.write("Object continued travelling to the left, decelerated, decreased its speed and stopped.")
elif st.session_state.v > st.session_state.u and st.session_state.v < 0:
st.write("u < 0, v > u and v < 0")
st.write("Object was initially travelling to the left.")
st.write("Object continued travelling to the left, decelerated and decreased its speed.")
elif st.session_state.v > st.session_state.u and st.session_state.v > 0:
st.write("u < 0, v > u and v > 0")
st.write("Object was initially travelling to the left.")
st.write("Object continued travelling to the left, decelerated, decreased its speed and stopped.")
st.write("Object then accelerated and travelled to the right.")
elif st.session_state.u > 0:
if st.session_state.v == st.session_state.u:
st.write("u > 0, v = u")
st.write("Object was initially travelling to the right.")
st.write("Object continued travelling to the right with constant speed.")
elif st.session_state.v > st.session_state.u:
st.write("u > 0, v > u")
st.write("Object was initially travelling to the right.")
st.write("Object continued travelling to the right, accelerated and increased its speed.")
elif st.session_state.v == 0:
st.write("u > 0, v = 0")
st.write("Object was initially travelling to the right.")
st.write("Object continued travelling to the right, decelerated, decreased its speed and stopped.")
elif st.session_state.v < st.session_state.u and st.session_state.v > 0:
st.write("u > 0, v < u and v > 0")
st.write("Object was initially travelling to the right.")
st.write("Object continued travelling to the right, decelerated and decreased its speed.")
elif st.session_state.v < st.session_state.u and st.session_state.v < 0:
st.write("u > 0, v < u and v < 0")
st.write("Object was initially travelling to the right.")
st.write("Object continued travelling to the right, decelerated, decreased its speed and stopped.")
st.write("Object then accelerated and travelled to the left.")
elif st.session_state.u == 0:
if st.session_state.v == st.session_state.u:
st.write("Object was initially at rest.")
st.write("u = 0, v = u")
st.write("Object continued resting.")
elif st.session_state.v > st.session_state.u:
st.write("Object was initially at rest.")
st.write("u = 0, v > u")
st.write("Object accelerated and increased its speed to travel to the right.")
elif st.session_state.v < st.session_state.u:
st.write("Object was initially at rest.")
st.write("u = 0, v < u and v < 0")
st.write("Object accelerated and increased its speed to travel to the left.")
# Clear button
if st.button("Clear"):
st.session_state.u = 0.0
st.session_state.v = 0.0
st.experimental_rerun() # Rerun the script to reset the input fields and clear the output
|