-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmulti_function_computer.py
More file actions
176 lines (176 loc) · 7.65 KB
/
Copy pathmulti_function_computer.py
File metadata and controls
176 lines (176 loc) · 7.65 KB
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
import math
def window():
print("+-------------------------------------------------+\n| To Add Numbers : Enter [1] |\n| To Subtract Numbers : Enter [2] |\n| To Multiply Numbers : Enter [3] |\n| To Divide Numbers : Enter [4] |\n| To Use Power in Number : Enter [5] |\n| To Find Module of Numbers : Enter [6] |\n| To Find Average of Numbers : Enter [7] |\n| To Find Biggest Number b/w Numbers : Enter [8] |\n| To Find Smallest Number b/w Numbers : Enter [9] |\n| To Find Square root of Number : Enter [10] |\n| To View History : Enter [11] |\n| To Delete History : Enter [12] |\n| To Exit : Enter [13] |\n+-------------------------------------------------+\n")
return
#_______________________________________________________________________
def user_input_main_menu():
input_main_menu = input("Enter the Number where you want to go: ")
return input_main_menu
#_______________________________________________________________________
def check_int(input_main_menu):
if input_main_menu.isdigit():
input_main_menu = int(input_main_menu)
if input_main_menu > 13 or input_main_menu < 1:
print("Invalid Input! Error: chose a number that is not b/w 1 to 13.")
return None , False
else:
return input_main_menu , True
else:
print("Invalid Input! Error: Wrote something that is not a number!")
return None , False
#_______________________________________________________________________
def main_menu():
window()
a = None
checking, is_right = check_int(user_input_main_menu())
if is_right:
a = front_menu(checking)
if a:
return True
else:
print("Invalid Input!")
if a:
return True
#_______________________________________________________________________
def front_menu(checking):
if checking == 1:
output_front_menu = user_input_front_menu()
sum_input(*output_front_menu)
elif checking == 2:
output_front_menu = user_input_front_menu()
subtract_input(*output_front_menu)
elif checking == 3:
output_front_menu = user_input_front_menu()
multiply_input(*output_front_menu)
elif checking == 4:
output_front_menu = user_input_front_menu()
divide_input(*output_front_menu)
elif checking == 5:
output_front_menu = user_input_front_menu()
square_input(*output_front_menu)
elif checking == 6:
output_front_menu = user_input_front_menu()
module_input(*output_front_menu)
elif checking == 7:
output_front_menu = user_input_front_menu()
average_input(*output_front_menu)
elif checking == 8:
output_front_menu = user_input_front_menu()
max_input(*output_front_menu)
elif checking == 9:
output_front_menu = user_input_front_menu()
min_input(*output_front_menu)
elif checking == 10:
output_front_menu = user_input_front_menu()
sqrt_input(*output_front_menu)
elif checking == 11:
for key, value in History.items():
print(f"{key} => {value}")
elif checking == 12:
print("Clearing History...")
History.clear()
print("History Cleared!")
elif checking == 13:
print("Exiting...")
return True
#_______________________________________________________________________
def user_input_front_menu():
input_front_menu = input("Enter the numbers seperated by [,]: ").split(",")
output_front_menu = []
for i in range(len(input_front_menu)):
output_front_menu.append(int(input_front_menu[i]))
return output_front_menu
#_______________________________________________________________________
def sum_input(*output_front_menu):
total_sum = sum(output_front_menu)
print(f"Sum of Number is: {total_sum}")
History[first_name].append(f"Sum of Number is: {total_sum}")
return
#______________________________________________________________________
def subtract_input(*output_front_menu):
total_subtraction = output_front_menu[0]
for i in range(1,len(output_front_menu)):
total_subtraction -= output_front_menu[i]
print(f"Subtract of Numbers are: {total_subtraction}")
History[first_name].append(f"Subtract of Numbers are: {total_subtraction}")
return
#______________________________________________________________________
def multiply_input(*output_front_menu):
total_multiply = output_front_menu[0]
for i in range(1,len(output_front_menu)):
total_multiply *= output_front_menu[i]
print(f"Multiply of Numbers are: {total_multiply}")
History[first_name].append(f"Multiply of Numbers are: {total_multiply}")
return
#______________________________________________________________________
def divide_input(*output_front_menu):
total_divide = output_front_menu[0]
for i in range(1,len(output_front_menu)):
if output_front_menu[i] != 0:
total_divide /= output_front_menu[i]
else:
total_divide = "Not Defined"
break
print(f"Divide of Numbers are: {total_divide}")
History[first_name].append(f"Divide of Numbers are: {total_divide}")
return
#______________________________________________________________________
def square_input(*output_front_menu):
power = output_front_menu[0]
for i in range(1,len(output_front_menu)):
power **= output_front_menu[i]
print(f"Power of Numbers are: {power}")
History[first_name].append(f"Power of Numbers are: {power}")
return
#______________________________________________________________________
def module_input(*output_front_menu):
total_module = output_front_menu[0]
for i in range(1,len(output_front_menu)):
total_module %= output_front_menu[i]
print(f"Module of Numbers are: {total_module}")
History[first_name].append(f"Module of Numbers are: {total_module}")
return
#______________________________________________________________________
def average_input(*output_front_menu):
total_sum = sum(output_front_menu)
total_average = total_sum/len(output_front_menu)
print(f"Average of Numbers are: {total_average}")
History[first_name].append(f"Average of Numbers are: {total_average}")
return
#______________________________________________________________________
def max_input(*output_front_menu):
total_max = max(output_front_menu)
print(f"Biggest of Numbers are: {total_max}")
History[first_name].append(f"Biggest of Numbers are: {total_max}")
return
#______________________________________________________________________
def min_input(*output_front_menu):
total_min = min(output_front_menu)
print(f"Smallest of Numbers are: {total_min}")
History[first_name].append(f"Smallest of Numbers are: {total_min}")
return
#______________________________________________________________________
def sqrt_input(*output_front_menu):
box = []
for i in range(len(output_front_menu)):
box.append(math.sqrt(output_front_menu[i]))
print(f"Sqrt of following Numbers are: {box}")
History[first_name].append(f"Sqrt of following Numbers are: {box}")
return
#______________________________________________________________________
def name():
full_name = input("Enter your name: ").capitalize().strip()
name = full_name.split(" ")
first_name = name[0]
return first_name
#----------------------------------------------------------------------
History = {}
first_name = name()
if first_name not in History:
History[first_name] = []
else:
print(f"Welcome back {first_name}!")
while True:
a = main_menu()
if a:
break