SHARE
TWEET

Python Input Game

ellenlee218 Feb 25th, 2017 (edited) 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. """
  2. This project outputs a story based on the character length of their inputs.
  3. Visit my Wordpress at ellenleescience.wordpress.com
  4. """
  5. import sys
  6. def character(word):
  7.     return len(word) - word.count(' ')
  8.      # subtract the number of empty spaces just in case someone puts their full name
  9. def primeQ(n):
  10.     # we need to find whether the number of letters if prime for later
  11.     # 1 and 0 are not prime, and negatives are impossible
  12.     if n < 2:
  13.         return False
  14.     else:
  15.         # divide n by every number from 2 to n, since a prime can only be divided by 1 itself
  16.         for i in range(2,n):
  17.             # if the remainder is zero for any number, it is not a prime number
  18.             if n % i == 0:
  19.                return False
  20.         return True
  21.         # if n passes every test, it is prime
  22.    
  23. name = raw_input('Enter your name: ')
  24. nameLetters = character(name)
  25. month = raw_input('Enter your birth month: ')
  26. monthLetters = character(month)
  27. color = raw_input('Enter your favorite color: ')
  28. colorLetters = character(color)
  29.  
  30. # now we determine if nameLetters is prime for later
  31. if primeQ(nameLetters) == True:
  32.     nameValue = 1
  33. elif nameLetters % 2 == 0:
  34.     nameValue = 2
  35. else:
  36.     nameValue = 3
  37.  
  38. answer = raw_input('This is what you entered:\n'
  39. + 'name: ' + name + '\nmonth: ' + month + '\ncolor: ' + color
  40. + '\nIs this correct? Enter Y or N.\n')
  41.  
  42. if answer == 'Y':
  43.     print('Beginning...\n')
  44. else:
  45.     print('Sorry. Please try again.')
  46.     sys.exit()
  47.  
  48. # the rest of the story is determined by nameValue and whether each Letters value is odd or even
  49. if nameValue == 1:
  50.     print(name + ' is synthetically created on a cloudy ' + month + ' day.')
  51.     print(name + ' is actually a robot. ' + name + ' is mistakenly adopted by their current family.')
  52. elif nameValue == 2:
  53.     print(name + ' is born on a stormy ' + month + ' night.')
  54.     print(name + ' is abandoned by their family. They are raised by stray dogs.')
  55. else:
  56.     print(name + ' is born on a sunny ' + month + ' day.')
  57.     print(name + ' lives with a happy family until their parents die in an accident in the lab.')
  58.  
  59. if colorLetters % 2 == 0:
  60.     print(name + ' is removed from school for their concerningly erratic behavior. '
  61.     + name + ' burns down the psychiatric ward and escapes to Europe with a fake identity.')
  62. else:
  63.     print(name + "'s teachers say that they are gifted. " + name + ' becomes a young oil tycoon'
  64.     + ' and becomes the youngest billionaire in the world. Climate change worsens.')
  65.  
  66. print(name + ' gets married and has ' + str(colorLetters) + ' children.')
  67. if monthLetters % 2 == 0:
  68.     print(name + ' pokes a button and accidentally kills 6.5 billion people. The world is in a crisis.')
  69. else:
  70.     print(name + ' finds a cure to rabies, but their research is stolen. They never recieve credit.')
  71.  
  72. if nameValue != 1:
  73.     print(name + ' lives to the ripe age of ' + str(monthLetters*9) + '.')
  74.     print("Cause of death:")
  75.     if colorLetters % 2 == 0:
  76.         print('tripped on a banana peel')
  77.     else:
  78.         print('hit by a meteor')
  79. else:
  80.     print(name + ' falls in a pool and dies at the age of ' + str(monthLetters*9) + '.')
  81.  
  82. print(name + ' will be greatly missed. The end.')
RAW Paste Data
Top