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