Skip to content

Commit f7893b6

Browse files
committed
Added a new .py file for classes in python(OOP)
1 parent f97b3a2 commit f7893b6

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#Today we will learn how to create a class and other attributes of class
2+
#Below is the method how classes are defined
3+
class Student:
4+
pass
5+
6+
#Below is the method to create object , Here Varun and rohan are two objects of Class Student
7+
Varun = Student()
8+
larry = Student()
9+
10+
# Now after creating objects we can use them to call variables
11+
Varun.name = "Harry"
12+
Varun.std = 12
13+
Varun.section = 1
14+
larry.std = 9
15+
larry.subjects = ["hindi", "physics"]
16+
print(Varun.section, larry.subjects)
17+
18+
19+
20+

0 commit comments

Comments
 (0)