Skip to content

Commit

Permalink
Merge pull request #52 from panchadeep/master
Browse files Browse the repository at this point in the history
Created a  new Calculator program using Python
  • Loading branch information
fineanmol committed Oct 6, 2020
2 parents 7554000 + e3e94d2 commit 5c4bf86
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
30 changes: 30 additions & 0 deletions Cal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
class Calculator:
def addition(self,x,y):
return x+y
def subtraction(self,x,y):
return x-y
def multiplication(self,x,y):
return x*y
def division(self,x,y):
if y==0:
return "not valid (Denominator is 0)"
return x/y
c=Calculator()
flag="Y"
while flag=="Y" or flag=="y":
print("1)Addition\n2)Subtraction\n3)Multiplication\n4)Division\n")
choice=int(input("Enter the operator from above: "))
a,b=input("Enter two operands seperated by space : ").split()
a=int(a)
b=int(b)
if choice==1:
print(f"Sum is {c.addition(a,b)}")
elif choice==2:
print(f"Difference is {c.subtraction(a,b)}")
elif choice==3:
print(f"Product is {c.multiplication(a,b)}")
elif choice==4:
print(f"Division is {c.division(a,b)}")
else:
print("Please enter correct input")
flag=input("\nTo calculate again enter 'Y' or enter any key to exit : ")
3 changes: 2 additions & 1 deletion Contributors.html
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ <h1 class="animated rubberBand delay-4s">Contributors</h1>
<a class="box-item" href="https://github.com/senshiii"><span>Sayan Das</span></a>
<a class="box-item" href="https://github.com/Shagufta08"><span>Shagufta Iqbal</span></a>
<a class="box-item" href="https://github.com/ishgary"><span>Ishant Garg</span></a>
<a class="box-item" href="https://github.com/<Sauvic016>"><span>Sauvic P Choudhury </span></a>
<a class="box-item" href="https://github.com/<Sauvic016>"><span>Sauvic P Choudhury </span></a>
<a class="box-item" href="https://github.com/<panchadeep>"><span>Panchadeep Mazumder</span></a>
<!--
Add here
format : <a class="box-item" href="https://github.com/<your-username>"><span>Your Name</span></a>
Expand Down

0 comments on commit 5c4bf86

Please sign in to comment.