Spaces:
No application file
No application file
Commit
•
3b70215
1
Parent(s):
91c7e02
Create app.py geometric calci
Browse files- app.py geometric calci +40 -0
app.py geometric calci
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
|
3 |
+
def area_of_square(s):
|
4 |
+
return(s*s)
|
5 |
+
def area_of_circle(r):
|
6 |
+
return((24/7)*r*r)
|
7 |
+
def area_of_rectangle(l,b):
|
8 |
+
return(l*b)
|
9 |
+
def area_of_triangle(x,y):
|
10 |
+
return((1/2)*b*h)
|
11 |
+
|
12 |
+
st.title ("geometric calculator")
|
13 |
+
|
14 |
+
choice = st.radio("select your choice",("square","circle", "rectangle", "triangle"))
|
15 |
+
|
16 |
+
if choice == "square":
|
17 |
+
s = st.number_input("enter the length of side square")
|
18 |
+
if st.button ("calculate"):
|
19 |
+
result = area_of_square(s)
|
20 |
+
st.write("area", result)
|
21 |
+
|
22 |
+
elif choice =="circle":
|
23 |
+
r = st.number_input("enter the radius of circle")
|
24 |
+
if st.button ("calculate"):
|
25 |
+
result = area_of_circle(r)
|
26 |
+
st.write ("area", result)
|
27 |
+
elif choice == "rectangle":
|
28 |
+
l = st.number_input ("enter the length of rectangle")
|
29 |
+
b = st.number_input ("enter the breathe of rectangle")
|
30 |
+
if st.button("calculate"):
|
31 |
+
result = area_of_rectangle(l,b)
|
32 |
+
st.write ("area", result)
|
33 |
+
elif choice == "triangle":
|
34 |
+
x = st.number_input ("enter the base of triangle")
|
35 |
+
y = st.number_input ("enter the height of triangle")
|
36 |
+
if st.button ("calculate"):
|
37 |
+
result = area_of_triangle(x,y)
|
38 |
+
st.write ("area", result)
|
39 |
+
|
40 |
+
st.write ("result is",result)
|