-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimpleCalculator.py
More file actions
58 lines (57 loc) · 1.35 KB
/
SimpleCalculator.py
File metadata and controls
58 lines (57 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
def circle():
r=int(input("Enter Radius: "))
area=3.148*r*r
p=2*3.14*r
print("Area is : ",area)
print("Perimeter is : ",p,"\n")
def rectangle():
l=int(input("Enter Length : "))
b=int(input("Enter Breadth : "))
area=l*b
p=2*(l+b)
print("Area is : ",area)
print("Perimeter is : ",p,"\n")
def square():
s=int(input("Enter Side: "))
area=s*s
p=4*s
print("Area is : ",area)
print("Perimeter is : ",p,"\n")
def add():
a=int(input("Enter a: "))
b=int(input("Enter b: "))
print("Addition is: ",a+b)
def sub():
a=int(input("Enter a: "))
b=int(input("Enter b: "))
print("Subtraction is: ",a-b)
def divide():
a=int(input("Enter a: "))
b=int(input("Enter b: "))
print("Division is: ",a/b)
def mul(a,b):
a=int(input("Enter a: "))
b=int(input("Enter b: "))
print("Multiplication is: ",a*b)
while True:
print("The Options are:\n 1:Rectangle 2:Circle 3:Square\n 4:Addition 5:Subtract 6:Divide 7:Multiply \n 0:Exit\n")
opt=int(input("Choose: "))
if opt==1:
rectangle()
elif opt==2:
circle()
elif opt==3:
square()
elif opt==4:
add()
elif opt==5:
sub()
elif opt==6:
divide()
elif opt==7:
mul()
elif opt==0:
print("Exit initiated")
break
else:
c='Invalid'