kalyanpavan/String_Operations
0
1import streamlit as st2 3# Set the title of the app4st.title('Simple Calculator App')5 6# Input fields for the numbers7num1 = st.number_input('Enter the first number')8num2 = st.number_input('Enter the second number')9 10# Dropdown menu for selecting the operation11operation = st.selectbox('Select an operation', ('Add', 'Subtract', 'Multiply', 'Divide'))12 13# Perform the calculation based on the selected operation14result = None15if operation == 'Add':16 result = num1 + num217elif operation == 'Subtract':18 result = num1 - num219elif operation == 'Multiply':20 result = num1 * num221elif operation == 'Divide':22 if num2 != 0:23 result = num1 / num224 else:25 st.error('Error: Division by zero')26 27# Display the result28if st.button("calculate"):29 if result is not None:30 st.write(f'The result is: {result}')31 