Multilevel inheritance in python A program as an example. Code - -------------------------------- class ElectronicDevice: refrigerator = 1000 def __init__(self, name, watt): self.name = name self.watt = watt def rupee_checker(self): a = 283 if self.watt < 1000: return f"Your Electrical Device consumes less than {a} units per year." elif self.watt > 1000: return f"Your Electrical Device consumes more than {a} units per year." elif self.watt == 1000: return f"Your Electrical Device consumes {a} units per year." class PocketGadget(ElectronicDevice): MaH = 3000 def __init__(self, name, mah): se...
Git Commands This is a complete list of commands which you will need to keep in mind. While using git. git confing --global user.name anant = For setting name for first time git confing --global user.email xyz@gmail.com = For setting Email. git config --global user.name = For getting name git config --global user.email = For getting email git init = For making the git repository at that directory. git add --a OR git add -A = For adding all untracked files to work stage git commit -m "Second commit new features added" = for committing the stage files repository. git status = For looking untracked files or not committed files on repository. git log = For looking all history commit's. rm -rf .git = For deleting all info about that repository which were in .git folder. ls = For looking all files in present working directory. pwd = For looking present working directory. git clone [Link of a repository from github] = For cloning means to download a copy from github to your pw...
Using class objects, Instance variables, and class variables, class methods and static method in python Code - ------------------------------------ class Students: number_of_buildings = 4 # def Majra(self): # return f"Number of toys are {self.toys}, and number of buildings are {self.number_of_buildings}" def __init__(self, name, aclass, section, rollnumber, school, stream): self.name = name self.standard = aclass self.section = section self.Roll_number = rollnumber self.School = school self.stream = stream def eye_checker(self): return f"Class is {self.standard}, and name is {self.name}" @classmethod def hello(cls, no_of_new_buildings): cls.numb...
Comments
Post a Comment