-
Notifications
You must be signed in to change notification settings - Fork 12.4k
/
Copy pathadvanced_calculator.py
391 lines (304 loc) · 11.1 KB
/
advanced_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
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
# This is like making a package.lock file for npm package.
# Yes, I should be making it.
__author__ = "Nitkarsh Chourasia"
__version__ = "0.0.0" # SemVer # Understand more about it
__license__ = "MIT" # Understand more about it
# Want to make it open source but how to do it?
# Program to make a simple calculator
# Will have to extensively work on Jarvis and local_document and MongoDb and Redis and JavaScript and CSS and DOM manipulation to understand it.
# Will have to study maths to understand it more better.
# How can I market gtts? Like showing used google's api? This is how can I market it?
# Project description? What will be the project description?
from numbers import Number
from sys import exit
import colorama as color
import inquirer
from gtts import gTTS
from pygame import mixer, time
from io import BytesIO
from pprint import pprint
import art
import date
# Find the best of best extensions for the auto generation of the documentation parts.
# For your favourite languages like JavaScript, Python ,etc,...
# Should be able to print date and time too.
# Should use voice assistant for specially abled people.
# A fully personalised calculator.
# voice_assistant on/off , setting bool value to true or false
# Is the operations valid?
# Validation checker
class Calculator:
def __init__(self):
self.take_inputs()
def add(self):
"""summary: Get the sum of numbers
Returns:
_type_: _description_
"""
return self.num1 + self.num2
def sub(self):
"""_summary_: Get the difference of numbers
Returns:
_type_: _description_
"""
return self.num1 - self.num2
def multi(self):
"""_summary_: Get the product of numbers
Returns:
_type_: _description_
"""
return self.num1 * self.num2
def div(self):
"""_summary_: Get the quotient of numbers
Returns:
_type_: _description_
"""
# What do we mean by quotient?
return self.num1 / self.num2
def power(self):
"""_summary_: Get the power of numbers
Returns:
_type_: _description_
"""
return self.num1**self.num2
def root(self):
"""_summary_: Get the root of numbers
Returns:
_type_: _description_
"""
return self.num1 ** (1 / self.num2)
def remainer(self):
"""_summary_: Get the remainder of numbers
Returns:
_type_: _description_
"""
# Do I have to use the '.' period or full_stop in the numbers?
return self.num1 % self.num2
def cube_root(self):
"""_summary_: Get the cube root of numbers
Returns:
_type_: _description_
"""
return self.num1 ** (1 / 3)
def cube_exponent(self):
"""_summary_: Get the cube exponent of numbers
Returns:
_type_: _description_
"""
return self.num1**3
def square_root(self):
"""_summary_: Get the square root of numbers
Returns:
_type_: _description_
"""
return self.num1 ** (1 / 2)
def square_exponent(self):
"""_summary_: Get the square exponent of numbers
Returns:
_type_: _description_
"""
return self.num1**2
def factorial(self):
"""_summary_: Get the factorial of numbers"""
pass
def list_factors(self):
"""_summary_: Get the list of factors of numbers"""
pass
def factorial(self):
for i in range(1, self.num + 1):
self.factorial = self.factorial * i # is this right?
def LCM(self):
"""_summary_: Get the LCM of numbers"""
pass
def HCF(self):
"""_summary_: Get the HCF of numbers"""
pass
# class time: # Working with days calculator
def age_calculator(self):
"""_summary_: Get the age of the user"""
# This is be very accurate and precise it should include proper leap year and last birthday till now every detail.
# Should show the preciseness in seconds when called.
pass
def days_calculator(self):
"""_summary_: Get the days between two dates"""
pass
def leap_year(self):
"""_summary_: Get the leap year of the user"""
pass
def perimeter(self):
"""_summary_: Get the perimeter of the user"""
pass
class Trigonometry:
"""_summary_: Class enriched with all the methods to solve basic trignometric problems"""
def pythagorean_theorem(self):
"""_summary_: Get the pythagorean theorem of the user"""
pass
def find_hypotenuse(self):
"""_summary_: Get the hypotenuse of the user"""
pass
def find_base(self):
"""_summary_: Get the base of the user"""
pass
def find_perpendicular(self):
"""_summary_: Get the perpendicular of the user"""
pass
# class Logarithms:
# Learn more about Maths in general
def quadratic_equation(self):
"""_summary_: Get the quadratic equation of the user"""
pass
def open_system_calculator(self):
"""_summary_: Open the calculator present on the machine of the user"""
# first identify the os
# track the calculator
# add a debugging feature like error handling
# for linux and mac
# if no such found then print a message to the user that sorry dear it wasn't possible to so
# then open it
def take_inputs(self):
"""_summary_: Take the inputs from the user in proper sucession"""
while True:
while True:
try:
# self.num1 = float(input("Enter The First Number: "))
# self.num2 = float(input("Enter The Second Number: "))
pprint("Enter your number")
# validation check must be done
break
except ValueError:
pprint("Please Enter A Valid Number")
continue
# To let the user to know it is time to exit.
pprint("Press 'q' to exit")
# if self.num1 == "q" or self.num2 == "q":
# exit() # Some how I need to exit it
def greeting(self):
"""_summary_: Greet the user with using Audio"""
text_to_audio = "Welcome To The Calculator"
self.gtts_object = gTTS(text=text_to_audio, lang="en", tld="co.in", slow=False)
tts = self.gtts_object
fp = BytesIO()
tts.write_to_fp(fp)
fp.seek(0) # Reset the BytesIO object to the beginning
mixer.init()
mixer.music.load(fp)
mixer.music.play()
while mixer.music.get_busy():
time.Clock().tick(10)
# Here OOP is not followed.
def user_name(self):
"""_summary_: Get the name of the user and have an option to greet him/her"""
self.name = input("Please enter your good name: ")
# Making validation checks here
text_to_audio = "{self.name}"
self.gtts_object = gTTS(text=text_to_audio, lang="en", tld="co.in", slow=False)
tts = self.gtts_object
fp = BytesIO()
tts.write_to_fp(fp)
fp.seek(0) # Reset the BytesIO object to the beginning
mixer.init()
mixer.music.load(fp)
mixer.music.play()
while mixer.music.get_busy():
time.Clock().tick(10)
def user_name_art(self):
"""_summary_: Get the name of the user and have an option to show him his user name in art"""
# Default is to show = True, else False if user tries to disable it.
# Tell him to show the time and date
# print(art.text2art(self.name))
# print(date and time of now)
# Remove whitespaces from beginning and end
# Remove middle name and last name
# Remove special characters
# Remove numbers
f_name = self.name.split(" ")[0]
f_name = f_name.strip()
# Remove every number present in it
# Will have to practice not logic
f_name = "".join([i for i in f_name if not i.isdigit()])
# perform string operations on it for the art to be displayed.
# Remove white spaces
# Remove middle name and last name
# Remove special characters
# Remove numbers
# Remove everything
class unitConversion:
"""_summary_: Class enriched with all the methods to convert units"""
# Do we full-stops in generating documentations?
def __init__(self):
"""_summary_: Initialise the class with the required attributes"""
self.take_inputs()
def length(self):
"""_summary_: Convert length units"""
# It should have a meter to unit and unit to meter converter
# Othe lengths units it should also have.
# Like cm to pico meter and what not
pass
def area(self):
# This will to have multiple shapes and polygons to it to improve it's area.
# This will to have multiple shapes and polygons to it to improve it's area.
# I will try to use the best of the formula to do it like the n number of polygons to be solved.
pass
def volume(self):
# Different shapes and polygons to it to improve it's volume.
pass
def mass(self):
pass
def time(self):
pass
def speed(self):
pass
def temperature(self):
pass
def data(self):
pass
def pressure(self):
pass
def energy(self):
pass
def power(self):
pass
def angle(self):
pass
def force(self):
pass
def frequency(self):
pass
def take_inputs(self):
pass
class CurrencyConverter:
def __init__(self):
self.take_inputs()
def take_inputs(self):
pass
def convert(self):
pass
class Commands:
def __init__(self):
self.take_inputs()
def previous_number(self):
pass
def previous_operation(self):
pass
def previous_result(self):
pass
def clear_screen(self):
# Do I need a clear screen?
# os.system("cls" if os.name == "nt" else "clear")
# os.system("cls")
# os.system("clear")
pass
if __name__ == "__main__":
operation_1 = Calculator(10, 5)
# Operations
# User interaction
# Study them properly and try to understand them.
# Study them properly and try to understand them in very detailed length. Please.
# Add a function to continually ask for input until the user enters a valid input.
# Let's explore colorma
# Also user log ins, and it saves user data and preferences.
# A feature of the least priority right now.
# List of features priority should be planned.
# Documentations are good to read and understand.
# A one stop solution is to stop and read the document.
# It is much better and easier to understand.