-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproblems10.py
More file actions
101 lines (88 loc) · 2.41 KB
/
problems10.py
File metadata and controls
101 lines (88 loc) · 2.41 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
# Progrma to display sum of two number using OOP consept
class Number:
def sum(self):
return self.a + self.b
num = Number()
num.a = 12
num.b = 34
s = num.sum()
print(s)
# Program of Railway form
class RailwayFrom:
fromType = "RailwayFrom"
def printData(self):
print(f"Name is {self.name}")
print(f"Train is {self.train}")
rajApplication = RailwayFrom()
rajApplication.name = "Rajkuamr"
rajApplication.train = "Garibrath Express"
rajApplication.printData()
# Program to implement a game
class Remote():
pass
class Player:
def moveRigh(self):
pass
def moveLeft(self):
pass
def moveTop(self):
pass
remote1 = Remote()
player1 = Player()
if(remote1.isLeftPressed()):
player1.moveLeft()
# Progrma to display class attribute of employee
class Employee:
company = "Google"
raj = Employee()
kumar = Employee()
print(raj.company)
p = kumar.company
print(p)
Employee.company = "Microsoft"
print(raj.company)
print(kumar.company)
# Program to display instance attribute (First prefence of instance attribute)
class Employee:
company = "Google"
salary = 100
raj = Employee()
kumar = Employee()
raj.salary = 300
kumar.salary = 400
print(raj.salary)
print(kumar.salary)
# Program for understand self parameter
class Employee:
company = "Google"
def getsalary(self):
print("Salary is 100k")
raj = Employee()
raj.getsalary()
print(raj.company)
# Progrma for static method
class Demo:
company = "Google"
def getsalary(self , signature):
print(f"Salary is {self.salary} and Company is {self.company}\n{signature} ")
@staticmethod
def greet(): # static method is remove self keyword
print("Good Morning, sir")
raj = Demo()
print(raj.company)
raj.salary = 10000
raj.getsalary("Thanks!")
raj.greet()
# Program for __init__ constructor
class Jay:
def __init__(self,name,salary,subunit):
self.name = "Raj"
self.salary = 100
self.subunit = "YouTube"
print("This is __init__ constructor , automatically exectue this fuction when object intilize")
def getdetail(self):
print(f"The Name of Employee is {self.name}")
print(f"The Salary of Employee is {self.salary} ")
print(f"The Subunit of Employee is {self.subunit} ")
raj = Jay("Raj",100,"YouTube")
raj.getdetail()