Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
|
| 3 |
+
# Define a function to calculate the square of a number
|
| 4 |
+
def calculate_square(number):
|
| 5 |
+
return number * number
|
| 6 |
+
|
| 7 |
+
# Add a text input widget for users to input a number
|
| 8 |
+
number_input = st.number_input("Enter a number:")
|
| 9 |
+
|
| 10 |
+
# When the user inputs a number, calculate and display its square
|
| 11 |
+
if number_input is not None:
|
| 12 |
+
square = calculate_square(number_input)
|
| 13 |
+
st.write(f"The square of {number_input} is {square}")
|