Python Code Output
Python Code Output
pro")
class car:
color = "black"
@staticmethod
def start():
print("car started")
@staticmethod
def stop():
print("car stoped")
class toyotacar(car):
def __init__(self, origin):
self.origin = origin
class cruiser(toyotacar):
def __init__(self, type, milege, control):
# super().__init__(origin)
self.type = type
self.milege = milege
self.control = control
# print(car1.origin)
print(car1.stop())
class A:
varA = "welcome to class A"
class B:
varB = "welcome to vlass B"
c1 = C()
c2 = C()
print(c1.varA)
print(c2.varA)
class student:
name = "rahul"
@classmethod
def changename(cls, name):
cls.name = name
s1 = student()
s2 = student()
s1.changename("anonymous")
print(s1.name)
print(student.name)
class student:
def __init__(self, phy, chem, maths):
self.phy = phy
self.chem = chem
self.maths = maths
@property
def cal_percentage(self):
return str(self.phy + self.chem + self.maths / 3) + " %"