dekyos

Beer Song Practice Exercise

Apr 10th, 2017
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.73 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. """
  3. Created on Mon Apr 10 13:29:11 2017
  4. Beer Song
  5. @author: phillip
  6. """
  7. from time import sleep
  8.  
  9. def typew(words):
  10.     for char in words:
  11.         sleep(0.05)
  12.         print(char,sep='',end='')
  13.        
  14. word = "bottles"
  15. for beer_num in range(99, 0, -1):
  16.     typew(" ".join([str(beer_num), word, "of beer on the wall..","\r\n"]))
  17.     typew(" ".join([str(beer_num), word, "of beer.","\r\n"]))
  18.     typew("Take one down..\r\n")
  19.     typew("Pass it around.\r\n")
  20.     if beer_num == 1:
  21.         typew("No more bottles of beer on the wall!")
  22.     else:
  23.         new_num = beer_num -1
  24.         if new_num == 1:
  25.             word = "bottle"
  26.         typew(" ".join([str(new_num), word, "of beer on the wall.\r\n\r\n"]))
Advertisement
Add Comment
Please, Sign In to add comment