Skip to content

Instantly share code, notes, and snippets.

@meggangreen
Last active September 22, 2017 21:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meggangreen/efaa71ef7b6914651e4b0ec0273333f1 to your computer and use it in GitHub Desktop.
Save meggangreen/efaa71ef7b6914651e4b0ec0273333f1 to your computer and use it in GitHub Desktop.
HB-Prework-2.py created by meggangreen - https://repl.it/L2Rw/34
# Throwback MASH
# A note to my grader: I realized while typing in the children section that this isn't really a choose-your-own-adventure story. But it does have if-elif-else statements and input and lists. Plus I had fun making it. I hope you can find it in your heart to be nice in the grading =)
def inputcheck(entry,listn,fmt):
unique = 2
valid = 5
if fmt == 'str' :
for listi in listn :
if entry == listi :
unique = 0
elif fmt == 'int' :
try:
entry = int(entry)
if entry < 0 or entry > 10 :
valid = 0
for listi in listn :
if entry == listi :
unique = 0
except:
valid = 0
return unique + valid
# import time module
import time
print """Let's take a retro journey back to the '80s and play MASH!\nMASH is fortune-telling game whose name stands for "Mansion-Apartment-Shack-House" -- ie the four types of housing you can end up in.\n\nWhen you're ready to have your future predicted, type your name and press 'Enter'."""
# user
uname = raw_input('What\'s your name? ').upper()
print '\nSending your entry as energy to the universe ...'
# pause program then add space
# http://pythoncentral.io/pythons-time-sleep-pause-wait-sleep-stop-your-code/
# https://www.quora.com/Is-there-a-Clear-screen-function-in-Python
time.sleep(1)
print '\n' * 3
# homes
home = ['MANSION','APARTMENT','SHACK','HOUSE']
# partners
part = []
print 'Okay, %s, enter the name of a person with whom you\'d love to share your life. You can choose \'No One\' or a non-romantic friend, whatever you like.' % (uname)
part.append(raw_input('Partner name: ').upper())
i = 0
while i < 3 :
if i < 2 :
parti = raw_input('And another partner name (must be unique). ').upper()
else :
parti = raw_input('And now a person whom you mildly despise (a different name). ').upper()
if inputcheck(parti,part,'str') == 7 :
part.append(parti)
i += 1
else :
print '%s is already an entry. Please choose a unique name.' % (parti)
# pause then clear screen
print '\nSending your entries as energy to the universe ...'
time.sleep(1.5)
print '\n' * 3
# children
chld = []
i = 0
while i < 3 :
if i == 0 :
chldi = raw_input('Okay, %s, enter a number between 0 and 10 of the number of children you\'d like to raise. ' % (uname))
elif i < 3 :
chldi = raw_input('And another number (must be unique). ')
chresult = inputcheck(chldi,chld,'int')
if chresult == 7 :
chld.append(int(chldi))
i += 1
elif chresult == 2 :
print 'Please use the number keypad to enter a number between 0 and 10.'
elif chresult == 5 :
print '%d is already an entry. Please enter a unique number.' % (chdi)
else :
print 'Hmm ... nope, I don\'t understand. Please try again.'
print 'For fun, we\'ll also add the possiblity of 37 children.'
chld.append(37)
# pause then clear screen
print '\nSending your entries as energy to the universe ...'
time.sleep(1.5)
print '\n' * 3
# careers
carr = []
print 'Okay, %s, enter a career path or job title you\'d love to have. This could be \'Independently Wealthy Superstar\' or \'Home Maker\', the world is your oyster.' % (uname)
carr.append(raw_input('Job title: ').upper())
i = 0
while i < 3 :
if i < 2 :
carri = raw_input('And another job title (must be unique). ').upper()
else :
carri = raw_input('And now a job you definitely do not want (altogether different). ').upper()
if inputcheck(carri,carr,'str') == 7 :
carr.append(carri)
i += 1
else :
print '%s is already an entry. Please choose a unique job.' % (carri)
# pause then clear screen
print '\nSending your entries as energy to the universe ...'
time.sleep(1.5)
print '\n' * 3
# spiral count
i = 0
while i < 5 :
cnt = raw_input('Finally, %s, concentrate on your future and use your psychic energy to choose an integer from 1 to 99. Enter that number here. ' % (uname))
i += 1
try:
int(cnt)
except:
if i == 4 :
print '\nSorry you\'re having trouble. Try again later.'
import sys
sys.exit()
else :
print '\nTry again.'
cnt = int(cnt)
if ( cnt < 1 or cnt > 99 ) and i < 4 :
print '\nTry again.'
elif i == 4 :
print '\nSorry you\'re having trouble. Try again later.'
import sys
sys.exit()
else :
i = 10
cnt = int(cnt) % 4
# calculate - pause - clear
print '\nGazing into the crystal ball ... this will take approximately 7 seconds ... '
time.sleep(7.2)
print '\n' * 3
print 'Well, %s, you asked for your fortune ...' % (uname)
print 'You and %s live together in a/an %s. Cozy. Your home will be filled with the pitter patter of the little feet of %d children. You fill your days being a/an %s. Hopefully it\'s enough because %s is a total free-loading mooch. Cheers!' % (part[cnt], home[cnt], chld[cnt], carr[cnt], part[cnt])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment