File size: 599 Bytes
b152d54
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import streamlit as st
import random

# Display a title and instructions
st.title('Random Number Generator')
st.write('Click the button to generate a new random number.')

# When the button is clicked, Streamlit reruns the script from the top.
# Thus, we generate a new random number on each run.
if st.button('Refresh Number'):
    random_number = random.randint(1, 100)
    # Display the random number in the app.
    st.write(f'Random Number: {random_number}')
else:
    # Initial message before button is pressed for the first time.
    st.write('Press the button to generate a random number.')