#Python program to demonstrate static methods #(i)Static method with paramenters class stud: def __init__(self): self.rno = 1 self.name = 'Rahul' def display(self): print(self.rno) print(self.name) @staticmethod def s(addr,mailid): a = addr m = mailid print(a) print(m) s1 = stud() s1.display() s1.s('Neredmet','rahul.bunny2106@gmail.com') #Python program to demonstrate static methods #(ii)Static method without paramenters class stud: def __init__(self): self.rno = 1 self.name = 'Rahul' def display(self): print(self.rno) print(self.name) @staticmethod def s(): print("BSC-HDS") s1 = stud() s1.display() s1.s()
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter