English

Consider the following class definition: class Yourclass marks=10 name= "ABC" def __init__(self,marks,name): self.marks=marks self.name=name def display(self): print marks print name.

Advertisements
Advertisements

Question

Consider the following class definition:

class Yourclass
       marks=10
       name= "ABC"
       def __init__(self,marks,name):
              self.marks=marks
              self.name=name
       def display(self):
              print marks
              print name

Give the statement to create an object of class Yourclass.

Very Short Answer
Advertisements

Solution

YC = Yourclass(10, "ABC")

This passes 10 for marks and "ABC" for name to __init__.

shaalaa.com
  Is there an error in this question or solution?
Chapter 3: Classes in Python - EXERCISE [Page 63]

APPEARS IN

CBSE Computer Science with Python [English] Class 12
Chapter 3 Classes in Python
EXERCISE | Q 17. | Page 63
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×