Py.Cafe

bhargavi-30-git/

streamlit-calculator

Interactive Calculator

DocsPricing
  • sum/
  • app.py
  • requirements.txt
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import streamlit as st
a=st.number_input("Enter the first number: ")
b=st.number_input("Enter the second number:")
op=st.selectbox(label="select",options=["add","subtraction","multiply","divide"])

if st.button("Calculate"):
    if op =="add":
        c=a+b
        st.header("The sum is:"+str(c))
    elif op=="subraction":
        c=a-b
        st.header("The sub is:"+str(c))
    elif op=="multiply":
        c=a*b
        st.header("The multiply is:"+str(c))
    else:
        if b==0:
            st.error('dont ')
        c=a/b
        st.header("The divide is:"+str(c))