Files
Python/Object Oriented Programming/building our first class.py
2021-02-27 20:28:14 +05:30

21 lines
484 B
Python

#Today we will learn how to create a class and other attributes of class
#Below is the method how classes are defined
class Student:
pass
#Below is the method to create object , Here Varun and rohan are two objects of Class Student
Varun = Student()
larry = Student()
# Now after creating objects we can use them to call variables
Varun.name = "Harry"
Varun.std = 12
Varun.section = 1
larry.std = 9
larry.subjects = ["hindi", "physics"]
print(Varun.section, larry.subjects)