TORONTO KIDS COMPUTER CLUB | Friday 16:15 Python Practice – 23.03.03.
21820
post-template-default,single,single-post,postid-21820,single-format-standard,ajax_fade,page_not_loaded,,no_animation_on_touch,qode-theme-ver-7.6.2,wpb-js-composer js-comp-ver-6.10.0,vc_responsive

Friday 16:15 Python Practice – 23.03.03.

08 Mar Friday 16:15 Python Practice – 23.03.03.

Question 1:

  1. Create a Python class Person with attributes: name and age of type string.
  2. Create a display() method that displays the name and age of an object created via the Person class.
  3. Create a child class Student which inherits from the Person class and which also has a section attribute.
  4. Create a method displayStudent() that displays the name, age and section of an object created via the Student class.
  5. Create a student object via an instantiation on the Student class and then test the displayStudent method.

Question 2:

Create a Rocket class with two attributes: name and destinationSpaceRocket class is the inherited class from the base class Rocket. Besides the two attributes the base class has, SpaceRocket class has an attribute maker.

The Rocket class has a method called launch(), it returns a string like “Falcon 9(which is name) is launched to low Earth orbit(which is destination)”

The SpaceRocket class has a method called get_maker(), it returns a string like “Falcon 9(which is name) is launched by Space X(which is the maker)”

Write a main program to test your program

No Comments

Sorry, the comment form is closed at this time.