Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- This project outputs a story based on the character length of their inputs.
- Visit my Wordpress at ellenleescience.wordpress.com
- """
- import sys
- def character(word):
- return len(word) - word.count(' ')
- # subtract the number of empty spaces just in case someone puts their full name
- def primeQ(n):
- # we need to find whether the number of letters if prime for later
- # 1 and 0 are not prime, and negatives are impossible
- if n < 2:
- return False
- else:
- # divide n by every number from 2 to n, since a prime can only be divided by 1 itself
- for i in range(2,n):
- # if the remainder is zero for any number, it is not a prime number
- if n % i == 0:
- return False
- return True
- # if n passes every test, it is prime
- name = raw_input('Enter your name: ')
- nameLetters = character(name)
- month = raw_input('Enter your birth month: ')
- monthLetters = character(month)
- color = raw_input('Enter your favorite color: ')
- colorLetters = character(color)
- # now we determine if nameLetters is prime for later
- if primeQ(nameLetters) == True:
- nameValue = 1
- elif nameLetters % 2 == 0:
- nameValue = 2
- else:
- nameValue = 3
- answer = raw_input('This is what you entered:\n'
- + 'name: ' + name + '\nmonth: ' + month + '\ncolor: ' + color
- + '\nIs this correct? Enter Y or N.\n')
- if answer == 'Y':
- print('Beginning...\n')
- else:
- print('Sorry. Please try again.')
- sys.exit()
- # the rest of the story is determined by nameValue and whether each Letters value is odd or even
- if nameValue == 1:
- print(name + ' is synthetically created on a cloudy ' + month + ' day.')
- print(name + ' is actually a robot. ' + name + ' is mistakenly adopted by their current family.')
- elif nameValue == 2:
- print(name + ' is born on a stormy ' + month + ' night.')
- print(name + ' is abandoned by their family. They are raised by stray dogs.')
- else:
- print(name + ' is born on a sunny ' + month + ' day.')
- print(name + ' lives with a happy family until their parents die in an accident in the lab.')
- if colorLetters % 2 == 0:
- print(name + ' is removed from school for their concerningly erratic behavior. '
- + name + ' burns down the psychiatric ward and escapes to Europe with a fake identity.')
- else:
- print(name + "'s teachers say that they are gifted. " + name + ' becomes a young oil tycoon'
- + ' and becomes the youngest billionaire in the world. Climate change worsens.')
- print(name + ' gets married and has ' + str(colorLetters) + ' children.')
- if monthLetters % 2 == 0:
- print(name + ' pokes a button and accidentally kills 6.5 billion people. The world is in a crisis.')
- else:
- print(name + ' finds a cure to rabies, but their research is stolen. They never recieve credit.')
- if nameValue != 1:
- print(name + ' lives to the ripe age of ' + str(monthLetters*9) + '.')
- print("Cause of death:")
- if colorLetters % 2 == 0:
- print('tripped on a banana peel')
- else:
- print('hit by a meteor')
- else:
- print(name + ' falls in a pool and dies at the age of ' + str(monthLetters*9) + '.')
- print(name + ' will be greatly missed. The end.')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement