Python program to demonstrate static methods with and without parameters

PHOTO EMBED

Thu Sep 28 2023 18:41:12 GMT+0000 (Coordinated Universal Time)

Saved by @bvc #undefined

#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()
content_copyCOPY