-
Notifications
You must be signed in to change notification settings - Fork 203
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from shubhankar-shandilya-india/Python-Project
Calculator by Python #3
- Loading branch information
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# This function performs additiion | ||
def add(a, b): | ||
return a + b | ||
# This function performs subtraction | ||
def subtract(a, b): | ||
return a - b | ||
# This function performs multiplication | ||
def multiply(a, b): | ||
return a * b | ||
# This function performs division | ||
def divide(a, b): | ||
return a / b | ||
print("Select an operation.") | ||
print("+") | ||
print("-") | ||
print("*") | ||
print("/") | ||
# User input | ||
choice = input("Enter operator to use:") | ||
A = int(input("Enter first number: ")) | ||
B = int(input("Enter second number: ")) | ||
if choice == '+': | ||
print(A,"+",B,"=", add(A,B)) | ||
elif choice == '-': | ||
print(A,"-",B,"=", subtract(A,B)) | ||
elif choice == '*': | ||
print(A,"*",B,"=", multiply(A,B)) | ||
elif choice == '/': | ||
print(A,"/",B,"=", divide(A,B)) | ||
else: | ||
print("Invalid input") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Basic Calculator | ||
|
||
## I Have made this Calculator by Python | ||
|
||
### First of all i take the input of operator (+,-,*,/) | ||
|
||
### Then we take inout of bot operand | ||
|
||
### Then the value goes to function as per the operand entered | ||
|
||
![Screenshot (45)](https://user-images.githubusercontent.com/78155393/193403781-2ca655e7-1ddf-4e9e-ad0c-e344fd4899dd.png) | ||
|
||
## Hence the result is printed |