File size: 439 Bytes
28232e2
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
import streamlit as st

# Define a function to calculate the square of a number
def calculate_square(number):
    return number * number

# Add a text input widget for users to input a number
number_input = st.number_input("Enter a number:")

# When the user inputs a number, calculate and display its square
if number_input is not None:
    square = calculate_square(number_input)
    st.write(f"The square of {number_input} is {square}")