Python_and_Data_Analytics_NEC_Week6_Solved
1. Write a program named define_ that contains a class named Pet, which should have the following data attributes: name animal_type (Examples: 'dog', 'cat', 'bird', etc.) age The Petclass should have an __init__ method that creates these attributes. 2. Once you have written the class, write a program named our_ that creates three instances of the Pet class and prints each object's attributes. • (Extra Credit) Write a program named with the following atttributes • Main class named Mammals that prints: Mammals don't lay eggs • Sub class named Dogs that prints: Dogs bark • Sub class named Cats that prints: Cats hiss • Create an instance of all three classes • Print the three messages using the classes methods. • Use main method to start processing
Información del documento
- Subido en
- 15 de abril de 2023
- Número de páginas
- 2
- Escrito en
- 2022/2023
- Tipo
- Examen
- Contiene
- Preguntas y respuestas