import streamlit as st st.title("Simple Calculator App") name = st.text_input("Enter your name", "Type here...") st.write(f"Hello, {name}! Welcome to the calculator app.") st.subheader("Select a number") # The slider returns the number the user selects x = st.slider("Choose a value for x", 0, 100, 25) # min, max, default st.subheader("Type a number") # The number_input returns the number the user types y = st.number_input("Enter a value for y", 0, 100, 10) # min, max, default st.subheader("Choose an operation") # The selectbox returns the string of the selected option operation = st.selectbox( "What operation do you want to perform?", ('Add', 'Subtract', 'Multiply', 'Divide') # The options ) # Perform calculation based on the widget values st.write(f"Performing calculation: `{x} {operation} {y}`") if operation == 'Add': result = x + y elif operation == 'Subtract': result = x - y elif operation == 'Multiply': result = x * y elif operation == 'Divide' and y != 0: result = x / y else: result = "Cannot divide by zero" st.success(f"The result is: **{result}**")