-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClass Input Return Math Functions IIII.py
More file actions
48 lines (34 loc) · 1.32 KB
/
Class Input Return Math Functions IIII.py
File metadata and controls
48 lines (34 loc) · 1.32 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
import math
class Math:
def __init__(self,user_input1,user_input2):
self.user_input1 = user_input1 # attribute1 property:
self.user_input2 = user_input2 # attribute2 property:
def return_answer(self):
return (
f'{self.user_input1+self.user_input2}\n'\
f'{self.user_input1-self.user_input2}\n'\
f'{self.user_input1*self.user_input2}\n'\
f'{self.user_input1/self.user_input2}\n'\
f'{self.user_input1**self.user_input2}\n'\
f'{pow(self.user_input1,self.user_input2)}\n'\
f'{math.sqrt(self.user_input2)}')
class Great_work(Math):
def __init__(self,user_input1,user_input2,user_input3):
super().__init__(user_input1,user_input2)
self.user_input3 = user_input3 # super attribute3 property:
def return_super(self):
return self.user_input3
message = (
'Please type a number, the press enter: ',
'Please type a second number, then press enter: ',
'Numbers only please:','Great Work!!')
while True:
try:
user_input1 = int(input(message[0]).strip())
user_input2 = int(input(message[1]).strip())
break
except ValueError:
print(message[2])
answer = Math(user_input1,user_input2).return_answer()
great_work = Great_work(user_input1,user_input2,message[3]).return_super()
print(f'{answer}\n{great_work}')