Skip to content

Latest commit

 

History

History
43 lines (29 loc) · 1.32 KB

building-command-line-applications.rst

File metadata and controls

43 lines (29 loc) · 1.32 KB

Building command line applications

To build a command line application, you need to learn the following modules:

Problems

Problem Write a program echo.py that takes one or more words as command line arguments and prints them back. If an optional flag -r or --repeats is specified followed by number of repeats, the message should be repeated so many times.

$ python echo.py Hello World
Hello World

$ python echo.py -r 2 Hello World
Hello World
Hello World

$ python echo.py --repeats 2 Hello World
Hello World
Hello World

Problem Extend the above echo.py program by adding additional flag -u or --upper-case, which converts the message to upper case before printing.

$ python echo.py Hello World
Hello World

$ python echo.py -u Hello World
HELLO WORLD

$ python echo.py -u -r 2 Hello World
HELLO WORLD
HELLO WORLD