11 Bottles of Beer Song: Writing and testing functions

Few songs are as annoying as “99 Bottles of Beer on the Wall.” Hopefully you’ve never had to ride for hours in a van with middle school boys who like to sing this. I have. It’s a fairly simple song that we can write an algorithm to generate. This will give us an opportunity to play with counting up and down, formatting strings, and--new to this exercise--writing functions and tests for those functions!

Our program will be called bottles.py and will take one option, -n or --num, which must be a positive int (the default will be 10). The program should print all the verses from --num ...

Get Tiny Python Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.