-
Notifications
You must be signed in to change notification settings - Fork 0
/
py_basic_calculator
51 lines (44 loc) · 1.89 KB
/
py_basic_calculator
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
def my_calculator():
command = input("Type start to start the calculator program: ")
if command == "start":
while True:
print("""********************************************************************
Hello, welcome to the basic calculator
1) Enter Stop to exit the program
2) Enter any number in first
3) Enter an operator from +, -, *, /, //, %
4) Enter any number in second""")
stop_command = input("Enter stop to exit program: ")
if stop_command == "stop":
break
else:
first_num = int(input("Enter the First number: "))
operator = input("Enter the operator: ")
second_num = int(input("Enter the Second number: "))
if operator == "+":
print()
print(f"Sum of the numbers are: {first_num + second_num}")
elif operator == "-":
print()
print(f"Sum of the numbers are: {first_num - second_num}")
elif operator == "*":
print()
print(f"Sum of the numbers are: {first_num * second_num}")
elif operator == "/":
print()
print(f"Sum of the numbers are: {first_num / second_num}")
elif operator == "//":
print()
print(f"Sum of the numbers are: {first_num // second_num}")
elif operator == "%":
print()
print(f"Sum of the numbers are: {first_num % second_num}")
else:
print()
print("Invalid number")
else:
print()
print("plz type start to start the basic calculator program")
print()
my_calculator()
my_calculator()