-
Notifications
You must be signed in to change notification settings - Fork 0
/
Calculator.py
29 lines (26 loc) · 1006 Bytes
/
Calculator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import math
print("Welcome to my calculator! Input two numbers and a sign, and this program will compute it!") #Instructions
print('\n\n')
userInput = input("Want to calculate? C to begin!\n")
if(userInput == "C" or userInput == "c"):
num1 = int(input("Number 1: "))
num2 = int(input("Number 2: "))
sign = input("Sign: ")
if(sign == "+" or sign == "plus"):
print(num1, "+", num2, '=', num1+num2)
if(sign == "-" or sign == "minus"):
print(num1, "-", num2, '=', num1-num2)
if(sign == "*" or sign == "X" or sign == "times" or sign == "x"):
print(num1, "X", num2, '=', num1*num2)
if(sign == "/" or sign == "divide"):
if(num2 == 0):
print(num1, "÷", num2, '= undefined')
else:
print(num1, "÷", num2, '=', num1/num2)
if(sign == "%" or sign == "percentage"):
if(num2 == 0):
print('undefined')
else:
print(num1, "÷", num2, '=', num1/num2*100, "%")
else:
print("Goodbye! Have a nice day!")