Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # classes are definition for data format
- # you can create your own data type
- # person -> name, id, age
- # students -> name, roll no, age
- # computer -> proccessor, ram, gpu, os
- # Bruce - 2 - 18
- class Student:
- def __init__(self, n, r, a): # constructor of the class
- self.name = n
- self.roll_no = r
- self.age = a
- def introduction(self):
- print("Hello my name is", self.name,"I am", self.age, "years old and my roll number is", self.roll_no)
- # tur = Turtle()
- b = Student("Bruce", 2, 18) # creating object of the class / creating instance of the class
- c = Student("Alfred", 1, 23)
- # print(b.name)
- b.introduction()
- c.introduction()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement