magic method in python

Python Magic Method 0

Python Magic Method

Program 1 #Magic(Dunder) Mehods in Python class Employee: def __init__(self,id,name,salary): self.id=id self.name=name self.salary=salary def __str__(self): s=”Emp ID: {} EMP Name: {} EMP Salary : {}” s=s.format(self.id,self.name,self.salary) return(s) # def __repr__(self): # s=”Employee ID: {}Employee...

Magic Method in Python with Examples 0

Magic Method in Python with Examples

Program 1 class Student: def __init__(self,rno,name,course): self.rno=rno self.name=name self.course=course def __str__(self): s=”Roll No of Student ={} , Name of Student ={} , Course of Student ={}” s=s.format(self.rno,self.name,self.course) return s def __repr__(self): s=”Roll No={} ,...