Python Day02
Python Day02
C-COD-240
Day 02
First project
1.4
Day 02
delivery method: pythond02 on Github
• The totality of your source files, except all useless files (binary, temp files, obj
files,...), must be included in your delivery.
• Error messages have to be written on the error output, and the program should
then exit with the 84 error code (0 if there is no error).
1
EXERCISE 01 (2PTS)
File to hand in: python_d02/time_01/display_time.py
Create a function “display_time”. It takes as argument a date in epoch format (in seconds since 01/01/1970
00:00).
2
EXERCISE 02 (3PTS)
File to hand in: python_d02/classes_modules_01/email.py
3
EXERCISE 03 (3PTS)
File to hand in: python_d02/classes_modules_02/email.py,
python_d02/classes_modules_02/sendable.py,
python_d02/classes_modules_02/sms.py
Copy the previous code of Email, but rename the class to “Sendable” and the file to “sendable.py”.
Now, you have to create two files with two classes “Email” and “Sms”.
Furthermore, in Sendable, add a method “send”. It sets the attribute “sent_at” to the current Time, but only
one time.
Calling this method twice must raise an Exception “DataAlreadySent” with no message.
Note: Be sure to import the modules required before using the classes
4
EXERCISE 04 ( 3PTS )
File to hand in: python_d02/classes_modules_03/email.py,
python_d02/classes_modules_03/private.py,
python_d02/classes_modules_03/sendable.py,
python_d02/classes_modules_03/sms.py
Then, create a new class “Private” like “Email”. But when the method “sent” is called, you should not trigger
any spying action, not even change sent_at.
But it still has to raise an error if the message is sent twice. Be smart.
5
EXERCISE 05 (3PTS)
File to hand in: python_d02/class_modules_04/email.py,
python_d02/class_modules_04/sendable.py,
python_d02/class_modules_04/sms.py,
python_d02/class_modules_04/private.py
6
EXERCISE 06 (3PTS)
File to hand in: python_d02/classes_modules_05/email.py,
python_d02/classes_modules_05/private.py,
python_d02/classes_modules_05/sendable.py,
python_d02/classes_modules_05/sms.py,
python_d02/classes_modules_05/sendable_box.py
SendableBox has an class function “recv”, taking as argument a Sendable and has to distribute it.
7
EXERCISE 07 (3PTS)
File to hand in: python_d02/classes_modules_06/contact.py