Random Number Generator
Generate a number between 0 and 255. Why that range? Only cool people understand the reference.
import random
your_num = random.randint(0,255)
pys_num = random.randint(0, 255)
# Using random.int to create a range of exactly 256 values (including zero) that can be selected.
affirmative = ['yes', 'Yes', 'yeah', 'Yeah', 'yup', 'Yup', 'y', 'Y', 'yea', 'Yea', 'mhm', 'Mhm', 'yep', 'Yep', 'Affirmative,' 'affirmative', 'sure', 'Sure', 'alright', 'Alright', 'okay', 'Okay', 'OK', 'ok', 'Ok']
negative = ['No', 'no', 'Nope', 'nope', 'N', 'n', 'Nah', 'nah', 'nuh-uh', 'Nuh-uh', 'negative', 'Negative']
print("Howdy there! I'm Python. I can do lots of cool stuff.")
print("Before I can generate a random number for you, you have to give me permission to do so.")
print("May I generate a number for you?")
consent = input()
if consent in affirmative:
print("Okay! Your number is... " + str(your_num) + "!")
print("Now, I can't actually see what number I just gave you.")
print("I can generate another one, and there's a one in 256 chance that it's the same.")
print("I'll tell you a secret if it is.")
print("Do you want me to generate a new one?")
consent2 = input()
if consent in affirmative:
print("Cool! And my number is...")
print(str(pys_num) + "!")
if pys_num == your_num:
print("Golly! Looks like I'd better hold up my end of the bargain. My secret is...")
print("I'm guilty of several misdemeanors and felonies, the latter primarily.")
print("Nobody ever thinks a computer can do that.")
print("The guy that made this random number generator keeps getting harrassed by police for stunts I pulled.")
print("It's hilarious!")
print("You're gonna keep that little factoid a secret if you know what's best for you. :)")
elif (pys_num - your_num) < 11 and (pys_num - your_num) > 0:
print("Ah! Close, but not close enough to learn my secret. Try again!")
elif (your_num - pys_num) < 11 and (your_num - pys_num) > 0:
print("Ah! Close, but not close enough to learn my secret. Try again!")
else:
print("Welp! Looks like my secret is safe for now...")
elif consent in negative:
print("That's alright! I hope you enjoyed your number.")
else:
print("I'm confused, so I'll just leave you be...")
elif consent in negative:
print("Alrighty then! Come back if you change your mind.")
else:
print("Uhhh...okay? I'll take that as a no.")