-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclass object.py
More file actions
76 lines (51 loc) · 2.39 KB
/
class object.py
File metadata and controls
76 lines (51 loc) · 2.39 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
class Student:
Name = 'Paul'
Age = 18
print(Student.Name)
print(Student.Age)
print(f"Name: {Student.Name} Age: {Student.Age}")
class Employees:
Name = 'Brian K. Maine'
Salary = 10000000
MaritalStatus = 'Complicated'
print(f"{Employees.Name} earns Ksh. {Employees.Salary} and his status is {Employees.MaritalStatus}")
class Parents:
FirstName = 'John'
LastName = 'Kimani'
parent1 = Parents()
print(parent1.FirstName)
class Parent:
def __init__(self, FirstName, LastName):
self.FirstName = FirstName
self.LastName = LastName
parent1 = Parent('John', 'Kimani')
parent2 = Parent('Boniface', 'Lee')
parent3 = Parent('Lilian', 'Lou')
print(f"Parent 1: {parent1.FirstName} {parent1.LastName}")
print(f"Parent 2: {parent2.FirstName} {parent2.LastName}")
print(f"Parent 3: {parent3.FirstName} {parent3.LastName}")
class Presidents:
def __init__(self, PrefixName, FirstName, LastName, SuffixName):
self.PrefixName = PrefixName
self.FirstName = FirstName
self.LastName = LastName
self.SuffixName = SuffixName
President1 = Presidents('H.E Hon Mzee', 'Jomo', 'Kenyatta', '')
President2 = Presidents('H.E Hon', 'Daniel Toroitich', 'Arap Moi', 'PHD')
President3 = Presidents('H.E Hon', 'Emilio', 'Mwai Kibaki', '')
President4 = Presidents('H.E Hon', 'Uhuru Muigai', 'Kenyatta', '')
President5 = Presidents('H.E Hon Dr', 'William Kipchirchir', 'Arap Samoei Ruto', 'PHD')
print(
f"Our first president was {President1.PrefixName} {President1.FirstName} {President1.LastName} {President1.SuffixName}, followed by {President2.PrefixName} {President2.FirstName} {President2.LastName} {President2.SuffixName},then {President3.PrefixName} {President3.FirstName} {President3.LastName} {President3.SuffixName}, {President4.PrefixName} {President4.PrefixName}, {President4.FirstName} {President4.LastName} {President4.SuffixName} and the current president is {President5.PrefixName} {President5.FirstName} {President5.LastName} {President5.SuffixName}")
class Person:
def __init__(self, first_name, last_name, age):
self.first_name = first_name
self.last_name = last_name
self.age = age
def full_name(self):
print(f"{self.first_name} {self.last_name} is {self.age} years old.")
def display(self):
print(f"{self.age}")
Person1 = Person('Grace', 'Kuria', 29)
print(Person1.full_name())
print(Person1.display())