Menu
×
×
Correct!

Exercise:

We have used the Student class to created an object named x.

What is the correct syntax to execute the printname method of the object x?

class Person: def __init__(self, fname): self.firstname = fname def printname(self): print(self.firstname) class Student(Person): pass x = Student("Mike") x.printname()

Not Correct

Click here to try again.

Correct!

Next ❯
class Person:
  def __init__(self, fname):
    self.firstname = fname

  def printname(self):
    print(self.firstname)

class Student(Person):
  pass

x = Student("Mike")


  
  
  




Go to w3schools.com
Reset Score
Close This Menu

Completed 0 of 95 Exercises:

PYTHON Syntax
PYTHON Comments
PYTHON Variables
PYTHON Data Types
PYTHON Numbers
PYTHON Strings
PYTHON Booleans
PYTHON Operators
PYTHON Lists
PYTHON Tuples
PYTHON Sets
PYTHON Dictionaries
PYTHON If...Else
PYTHON While Loops
PYTHON For Loops
PYTHON Functions
PYTHON Lambda
PYTHON Classes
PYTHON Inheritance
PYTHON Modules





×

Reset the Score?

This will reset the score of ALL 95 exercises.

Are you sure you want to continue?



×

Congratulations!

You have finished all 95 PYTHON exercises.

Share your score on facebook: