kinematics / app.py
mathslearn's picture
Update app.py
6d09466 verified
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.")
# Input for initial velocity, u
u = st.number_input("Enter the initial velocity (u) in metres per second:", step=0.1, format="%.1f")
# Determine the initial direction
if u < 0:
initial_direction = "travelling to the left"
elif u > 0:
initial_direction = "travelling to the right"
else:
initial_direction = "at rest"
# Input for final velocity, v
v = st.number_input("Enter the final velocity (v) in metres per second:", step=0.1, format="%.1f")
# Determine the final direction
if v < 0:
final_direction = "travelling to the left"
elif 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): {u} m/s means object is {initial_direction} with a speed of {abs(u)} m/s.")
st.write(f"Final velocity (v): {v} m/s means object is {final_direction} with a speed of {abs(v)} m/s.")
# Determine and display the motion description based on the conditions
if u < 0:
if v == 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 v < 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 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 v > u and 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 v > u and 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 u > 0:
if v == 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 v > 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 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 v < u and 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 v < u and 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 u == 0:
if v == u:
st.write("Object was initially at rest.")
st.write("u = 0, v = u")
st.write("Object continued resting.")
elif v > 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 v < 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.")