Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created a new Calculator program using Python #52

Merged
merged 2 commits into from
Oct 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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