Wednesday, February 12, 2020

how to declare class in python

class Student:
    def __init__(self,x,y,z):
        self.name=x
        self.rollno=y
        self.marks=z
    def display(self):
        print("name:",self.name)
        print("rollno:",self.rollno)
        print("marks:",self.marks)
 
     
s=Student("anil",100,90)
s.display()

output:
name: anil
rollno: 100
marks: 90

How to write a basic functions in python



No comments:

Post a Comment

python class topic video