-
Notifications
You must be signed in to change notification settings - Fork 1
/
SimpleCalculatorGame.py
108 lines (100 loc) · 3.43 KB
/
SimpleCalculatorGame.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import sys
running = True
choosing = True
def main_menu():
'''Main menu options.'''
while running:
print("\nChoose your desired operation:")
print("\nEnter '1' = Addition")
print("Enter '2' = Substraction")
print("Enter '3' = Multiplication")
print("Enter '4' = Division")
print("Enter 'quit' = quit\n")
cmd = str(input("Enter command : "))
if cmd == '1':
operation('Addition', '+')
elif cmd == '2':
operation('Substraction', '-')
elif cmd == '3':
operation('Multiplication', '*')
elif cmd == '4':
operation('Division', '/')
elif cmd == 'quit':
mainmenu_quit()
elif cmd == 'hack':
steinsgate()
else:
print('\n', "'", cmd, "'", "is not an option. But that's cool, you're thinking outside of the box\n")
def mainmenu_quit():
'''When quitting at the main menu.'''
print("Are you sure? 'yes' or 'no'")
cmd = str(input("\nEnter command : "))
if cmd == 'yes':
print('Quit!' * 500000)
sys.exit(0)
elif cmd == 'no':
print('\n What would you like to do?')
main_menu()
elif cmd == 'hack':
steinsgate()
else:
print('\n', "'", cmd, "'", 'is not an option. Here are your choices:', '\n')
main_menu()
def operation(woperator, soperator):
'''Lets the user do an operation that will result in 69. Humour > 9000.'''
print("\n", woperator)
try:
first = float(input("Enter first number :"))
second = float(input("Enter second number :"))
result = 69.0
print('\n', first, soperator, second, '=', result, '\n')
after_operation(woperator, soperator)
except ValueError:
print("Is that a number? Suit yourself...\n")
first = str(input("Enter first number :"))
second = str(input("Enter second number :"))
result = 69.0
print('\n', first, soperator, second, '=', result, '\n')
after_operation(woperator, soperator)
def after_operation(woperator, soperator):
'''Options after the operation.'''
while choosing:
print("Enter 'again' = Another", woperator)
print("Enter 'back' for Menu")
print("Enter 'quit' to quit\n")
cmd = str(input("Enter command : "))
if cmd == 'back':
break
elif cmd == 'quit':
quitting(woperator, soperator)
break
elif cmd == 'again':
operation(woperator, soperator)
break
elif cmd == 'hack':
steinsgate()
else:
print("\n", "'", cmd, "'", "is not an option. Are you iliterate? Here's the menu. \n")
break
#I do know how to write illiterate.
def quitting(woperator, soperator):
'''Quitting when not at main menu.'''
print("Are you sure? 'yes' or 'no'")
cmd = str(input("\nEnter command : "))
if cmd == 'yes':
print('Quit!' * 500000)
sys.exit(0)
elif cmd == 'no':
after_operation(woperator, soperator)
elif cmd == 'hack':
steinsgate()
else:
print('\n', "'", cmd, "'", 'is not an option. Why are you like this?', '\n')
def steinsgate():
'''Fun reference to Steins;Gate.'''
print(' El Psy Congroo' * 100000)
def welcome():
'''Welcome message.'''
print('\n WELCOME TO SIMPLE CALCULATOR \nPlease have fun with this SIMPLE CALCULATOR.')
welcome()
main_menu()