-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
37 additions
and
19 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 |
---|---|---|
@@ -1,30 +1,48 @@ | ||
# MiniCalc by swmwy | ||
operation = input("Choose an operation: a for addition, s for subtraction, m for multiplication, and d for division.\n") | ||
|
||
if operation == 'd': | ||
operation = 'division' | ||
minicalc = True | ||
|
||
elif operation == 'a': | ||
operation = 'division' | ||
while minicalc = True: | ||
|
||
elif operation == 's': | ||
operation = 'subtraction' | ||
operation = input("Choose an operation: a for addition, s for subtraction, m for multiplication, and d for division.\n") | ||
|
||
elif operation == 'm': | ||
operation = 'multiplication' | ||
if operation == 'd': | ||
operation = 'division' | ||
|
||
else: | ||
print("Error: could not detect operation. (Hint: Make sure the letter is lowercase.)") | ||
elif operation == 'a': | ||
operation = 'division' | ||
|
||
num1 = input("Enter the first number:") | ||
elif operation == 's': | ||
operation = 'subtraction' | ||
|
||
num2 = input("Enter the second number:") | ||
elif operation == 'm': | ||
operation = 'multiplication' | ||
|
||
if operation == 'division': | ||
if num1 == 0: | ||
print("Divide by 0 error.") | ||
elif num2 == 0: | ||
print("Divide by 0 error.") | ||
else: | ||
solution = num1 / num2 | ||
print("Error: could not detect operation. (Hint: Make sure the letter is lowercase.)") | ||
|
||
num1 = input("Enter the first number:") | ||
|
||
num2 = input("Enter the second number:") | ||
|
||
int(num1) | ||
int(num2) | ||
|
||
if operation == 'division': | ||
if num1 == 0: | ||
print("Divide by 0 error.") | ||
elif num2 == 0: | ||
print("Divide by 0 error.") | ||
else: | ||
solution = num1 / num2 | ||
|
||
if operation == 'subtraction': | ||
solution = num1 - num2 | ||
|
||
if operation == 'addition': | ||
solution = num1 + num2 | ||
|
||
if operation == 'multiplication': | ||
solution = num1 * num2 | ||
|
||
print(solution) |