Skip to content
Open
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
15 changes: 15 additions & 0 deletions programs/Python/calculator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#Program for calculator in python
a=int(input("Enter first no.- "))
b=int(input("Enter second no.- "))
operator=input("Enter the operation you want to perform ")
if(operator == "+"):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

space before "(" in all the subsequent if or elif statements.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just that, you want spaces there?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is one of the best practices we use for writing the code.

print("Sum is->",a+b,end="\n")
elif(operator == "-"):
print("Difference is->",a-b,end="\n")
elif(operator == "*"):
print("Multiplication is->",a*b,end="\n")
elif(operator == "/"):
print("Division is->",a/b,end="\n")

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unnecessary line

else:
print("Invalid operator")