14 Dec Monday 17:30 Python Practice – 22.12.12.
Question 1:
- Create a Python class Person with attributes: name and age of type string.
- Create a display() method that displays the name and age of an object created via the Person class.
- Create a child class Student which inherits from the Person class and which also has a section attribute.
- Create a method displayStudent() that displays the name, age and section of an object created via the Student class.
- Create a student object via an instantiation on the Student class and then test the displayStudent method.
Question 2:
Create a Rocketclass with two attributes: nameand destination. SpaceRocketclass is the inherited class from the base class Rocket. Besides the two attributes the base class has, SpaceRocketclass has an attribute maker.
The Rocketclass 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 SpaceRocketclass 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
Sorry, the comment form is closed at this time.