-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathClassOps.py
More file actions
34 lines (28 loc) · 917 Bytes
/
ClassOps.py
File metadata and controls
34 lines (28 loc) · 917 Bytes
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
class student:
schoolname = "JPIS"
def __init__(self,eng,mat,sci):
self.eng = eng
self.mat = mat
self.sci = sci
def average(self):
return (self.mat+self.sci+self.eng)/3
#Getter Method of class - similar to get of properties
#THese are also called as accessors as they get values
def get_eng(self):
return self.eng
#setter method of class is similar to set of properties
#these are also called as mutators as they modify values
def set_eng(self,newval):
self.eng = newval;
#method to access class variable - key word is cls
@classmethod
def schoolInfo(cls):
return cls.schoolname
#static method
@staticmethod
def info():
return("This is a static method")
aryaa = student(97,98,99)
print(aryaa.average())
print(student.info())
print(student.schoolInfo())