bouncing ball
To upload files, please first save the app
import streamlit as st
import numpy as np
# Bouncing Ball Simulation
st.title("Bouncing Ball Simulation")
# Parameters
height = st.slider("Initial Height (m):", 0.1, 10.0, 5.0)
g = 9.81
bounce_factor = 0.7
# Time settings
time_step = 0.1
max_time = 10
# Simulation
times = np.arange(0, max_time, time_step)
heights = []
current_height = height
for t in times:
if current_height > 0:
heights.append(current_height)
# Update height based on physics
current_height -= g * time_step
else:
# Ball bounces
current_height = -current_height * bounce_factor
# Display results
st.line_chart(heights)
st.write("Final Heights:", heights[-1])
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?