-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexamples.py
More file actions
75 lines (59 loc) · 1.71 KB
/
examples.py
File metadata and controls
75 lines (59 loc) · 1.71 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
n = input('Please enter a name: ')
a = int(input('Please enter the age: '))
t = int(input('Please enter the patient\'s temperature: '))
class Patient:
def __init__(self, n, a, t):
self.name = n
self.age = a
self.temperature = t
def display(self):
print(f'Hello {n}')
print(f'Your age is {a} years old.')
print(f'Your body temperature is {t} degrees celsius')
p1 = Patient(n, a, t)
p1.name
p1.age
p1.temperature
p1.display()
class Student:
def __init__(self, name, age, **scores):
self.name = name
self.age = age
self.scores = scores
def display(self):
print('Hello', self.name)
print('You are', self.age)
print('You had', self.scores)
def marks(self):
for x, y in self.scores.items():
print(f'{x} Score: {y} marks')
def averages(self):
y = self.scores.values()
y1 = sum(y) / 4
print(f'Your average score is {y1} ')
if y1 <= 10:
print('You have failed.')
else:
print('You have passed.')
s_1 = Student(name='Willow', age=12, maths=20, history=18, spelling=15, comprehension=12)
s_1.display()
s_1.marks()
s_1.averages()
print('------------')
print('------------')
s_2 = Student(name='Will', age=13, maths=20, history=18, spelling=19, comprehension=11)
s_2.display()
s_2.marks()
s_2.averages()
print('------------')
print('------------')
s_3 = Student(name='Paul', age=15, maths=9, history=18, spelling=10, comprehension=7)
s_3.display()
s_3.marks()
s_3.averages()
print('------------')
print('------------')
s_4 = Student(name='Wendy', age=15, maths=15, history=10, spelling=10, comprehension=17)
s_4.display()
s_4.marks()
s_4.averages()