Created
February 27, 2014 03:32
-
-
Save modalsoul/9243860 to your computer and use it in GitHub Desktop.
Pythonで99 bottles
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/python | |
| def plural(num): | |
| if num == 0: | |
| return "No more bottles" | |
| elif num == 1: | |
| return "1 bottle" | |
| else: | |
| return str(num) + " bottles" | |
| def overLylic(num): | |
| return plural(num) + " of beer on the wall, " + plural(num).lower() + " of beer." | |
| def underLylic(num): | |
| if num == 0: | |
| return "Go to the store and buy some more, 99 bottles of beer on the wall." | |
| else: | |
| return "Take one down and pass it around, " + plural(num-1).lower() + " of beer on the wall." | |
| for num in reversed(range(0, 4)): | |
| print "" | |
| print overLylic(num) | |
| print underLylic(num) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment