ClavinJune

LuckCounter gs

May 23rd, 2017
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.89 KB | None | 0 0
  1. #!/usr/bin/python
  2. """
  3. input output
  4. 5 artihmatic operation
  5. 5 kinds of data types
  6. 5 string manipulation
  7. """
  8. def splash():
  9.     print " _               _       ____                  _            "
  10.     print "| |   _   _  ___| | __  / ___|___  _   _ _ __ | |_ ___ _ __ "
  11.     print "| |  | | | |/ __| |/ / | |   / _ \| | | | '_ \| __/ _ \ '__|"
  12.     print "| |__| |_| | (__|   <  | |__| (_) | |_| | | | | ||  __/ |   "
  13.     print "|_____\__,_|\___|_|\_\ \____\___/ \__,_|_| |_|\__\___|_|   by cv17-1"
  14.     print "Let's count your luck!\n\n\n\n"
  15.  
  16. def clear():
  17.     for i in range(0,25):
  18.         print ""
  19.  
  20. def main():
  21.     #1 boolean
  22.     always = True
  23.     #2 char
  24.     letters = ['b','c','d','f','g','h','j','k','l','m','n','p','q','r','s','t','v','w','x','y','z']
  25.     clear()
  26.     splash()
  27.     while always:
  28.         # input
  29.         #3 string
  30.         try:
  31.             name = raw_input("What's your name? ")
  32.         except:
  33.             exit(2)
  34.         if ' ' in name:
  35.             #1 string manipulation
  36.             name = name.split()
  37.             #2 string manipulation
  38.             name = "".join(e for e in name)
  39.         #3 string manipulation
  40.         words = len(name)
  41.         #output
  42.         print "Okay, you have a %d letters name" %(words)
  43.         #1 arithmatic
  44.         #4 integer
  45.         mid = words/2
  46.         #2 arithmatic
  47.         if words%2 == 0:
  48.             #4 string manipulation
  49.             name = name[:mid]
  50.         else:
  51.             #5 string manipulation
  52.             name = name[mid:]
  53.         #6 string manipulation
  54.         name = name[:-1]
  55.         for i in letters:
  56.             #7 string manipulation
  57.             name = name.replace(i, 'k')
  58.         #8 string manipulation
  59.         name = name.upper()
  60.         print "We change your name a bit into '%s' to check your luck today!" %(name)
  61.         #9 string manipulation
  62.         luck = name.count('k')
  63.         #10 string manipulation
  64.         if name.endswith('K'):
  65.             print "Wow, such a beautiful name!"
  66.         #5 arithmatic
  67.         # / % + - * =
  68.         #5 float
  69.         luck = luck+10/4*2-1/words+mid+50.75
  70.         print '_'*80
  71.         #6 arithmatic >
  72.         if luck > 100:
  73.             luck = 100
  74.         print "WoW! you've got " + str(luck) + "\x25 for your name!"
  75. main()
Add Comment
Please, Sign In to add comment