0% found this document useful (0 votes)
14 views1 page

Object

prog

Uploaded by

Amol Adhangale
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views1 page

Object

prog

Uploaded by

Amol Adhangale
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

What is Object:

Physical existence of a class is nothing but object. We can create any number of
objects for a class.
Syntax to create object: referencevariable = classname()
Example: s = Student()
What is Reference Variable:
The variable which can be used to refer object is called reference variable.
By using reference variable, we can access properties and methods of object.
Program: Write a Python program to create a Student class and Creates an object to
it. Call the
method talk() to display student details
1) class Student:
2)
3) def __init__(self,name,rollno,marks):
4) self.name=name
5) self.rollno=rollno
6) self.marks=marks
7)
8) def talk(self):
9) print("Hello My Name is:",self.name)
10) print("My Rollno is:",self.rollno)
11) print("My Marks are:",self.marks)
12)
13) s1=Student("amol",101,80)
14) s1.talk()

You might also like