To build a command line application, you need to learn the following modules:
sys
- Module of the week -- specifically the Runtime environment
argparse
fileinput
-
The program
alarm.py
pops up a user-specified message after 2 minutes. The message can be any piece of text, and is displayed calling the (ficticious) functionalert()
. When the user typesalarm.py Switch off your laptop
, write a program that callsalert('Switch off your laptop', seconds=120)
. -
We want to allow the user to specify how many seconds later the alarm should be set. So, for example, if we type:
alarm.py --seconds=30 Hello
... change the program to call
alert('Hello', seconds=30)
. If--seconds
is not specified, it sets--seconds
to 120 seconds. -
The user may want the alarm to be specified at multiple times. So, if we type:
alarm.py --seconds=10 --seconds=20 Hello
... change the program to call
alert('Hello', seconds=10)
followed byalert('Hello', seconds=20)
.