ยปCore Development>Code coverage>Tools/demo/beer.py

Python code coverage for Tools/demo/beer.py

#countcontent
1n/a#!/usr/bin/env python3
2n/a
3n/a"""
4n/aA Python version of the classic "bottles of beer on the wall" programming
5n/aexample.
6n/a
7n/aBy Guido van Rossum, demystified after a version by Fredrik Lundh.
8n/a"""
9n/a
10n/aimport sys
11n/a
12n/an = 100
13n/aif sys.argv[1:]:
14n/a n = int(sys.argv[1])
15n/a
16n/adef bottle(n):
17n/a if n == 0: return "no more bottles of beer"
18n/a if n == 1: return "one bottle of beer"
19n/a return str(n) + " bottles of beer"
20n/a
21n/afor i in range(n, 0, -1):
22n/a print(bottle(i), "on the wall,")
23n/a print(bottle(i) + ".")
24n/a print("Take one down, pass it around,")
25n/a print(bottle(i-1), "on the wall.")