Skip to content
This repository was archived by the owner on Nov 30, 2022. It is now read-only.

Commit 9cba968

Browse files
authored
SImple_calculator
1 parent f46dfa8 commit 9cba968

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

Scripts/Simple_calculator.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#first define the functions
2+
#for 2 digits oprations
3+
def add(x, y):
4+
return x+y
5+
def sub(x,y):
6+
return x-y
7+
def mul(x,y):
8+
return x*y
9+
def div(x,y):
10+
return x/y
11+
def power(x,y):
12+
return pow(x, y)
13+
14+
#take input from user
15+
print("Select opration:")
16+
print("1.add")
17+
print("2.subtract")
18+
print("3.multiply")
19+
print("4.divide")
20+
print("5.power")
21+
select=input("Enter any one Choice from 1 to 5 :")
22+
23+
num1=int(input("Enter the Num1:"))
24+
num2=int(input("Enter the Num2:"))
25+
26+
if select=="1":
27+
print(num1,"+",num2,"=", add(num1,num2))
28+
elif select=="2":
29+
print(num1,"-",num2,"=", sub(num1,num2))
30+
elif select=="3":
31+
print(num1,"x",num2,"=", mul(num1,num2))
32+
elif select=="4":
33+
print(num1,"/",num2,"=", div(num1,num2))
34+
elif select=="2":
35+
print(num1,"*",num2,"=", power(num1,num2))
36+
else :
37+
print("Not a valid input! tru again")

0 commit comments

Comments
 (0)