Μετάβαση στο κεντρικό περιεχόμενο
elearn.ellak.gr
  • Αρχική
  • Περισσότερα
Αυτή τη στιγμή χρησιμοποιείτε πρόσβαση επισκέπτη
Σύνδεση
Αρχική
  1. Ανοιχτά Μαθήματα στα Ελληνικά
  2. python_ellak_greek
  3. Ενότητα 7
  4. Εργασία 7.1
Ανάθεση εργασίας

Εργασία 7.1

Εργασία 7.1

Απαιτήσεις ολοκλήρωσης
Λάβετε βαθμό

We have learned how to create classes and objects.

Create a new program, test it and upload it using your name and followed by AS7.1 in the programs file name. As an example a programs filename could be Name_Surname_AS7.1.py

For your effort you will be graded and you will have another try if you want to get a better grade. Passing grade is 60%

The program should start with three class definitions, then code that will create instances of each class.

Write code that defines a class named Animal:

  •         Add an attribute for the animal name.
  •         Add an eat() method for Animal that prints ``Munch munch.''
  •         A make_noise() method for Animal that prints ``Grrr says [animal name].''
  •         Add a constructor for the Animal class that prints ``An animal has been born.''

A class named Cat:    

  •         A make_noise() method for Cat that prints ``Meow says [animal name].''
  •         A constructor for Cat that prints ``A cat has been born.''
  •         Modify the constructor so it calls the parent constructor as well.

A class named Dog:

  •         A make_noise() method for Dog that prints ``Bark says [animal name].''
  •         A constructor for Dog that prints ``A dog has been born.''
  •         Modify the constructor so it calls the parent constructor as well.

A main program with:

  •         Code that creates a cat, two dogs, and an animal.
  •         Sets the name for each animal.
  •         Code that calls eat() and make_noise() for each animal. 

python classes video

◄ Λίστα ελέγχου ενότητας 7
Φύλλο εργασιών 07 ►
Αυτή τη στιγμή χρησιμοποιείτε πρόσβαση επισκέπτη (Σύνδεση)
Περίληψη διατήρησης δεδομένων
Λήψη εφαρμογής κινητού
Με την υποστήριξη του Moodle