# My teacher has set us this work and I will be locked in the basement if I can't do it

#1

• Computer generates random number
• Tell the user if they’re wrong or right
• If right say well done
• If it’s wrong tell them to go higher or lower
• If the guess is higher, say “lower”
• If the guess is lower, say “higher”

#2

print("Welcome to guess the number!")

name = input("\nWhat is your name?")
print("\nHello", name,"!")

from random import *

count = 0
guess = 0

number = randint(1,100)

while guess != number:
guess = int(input("What is thou's guess?"))
if guess > number:
print("Lower")

``````    count += 1

elif guess < number:
print("Higher")

count += 1

else:
print("Well done,", name,"! You made", count," attemmpts to find the number!")``````

#3

Try this here

``````from random import randint

#=======================================================================================#
""" This method makes sure the user enter a number and nothing else
if the user enter anything other than a number then it will prompt
for the right input
"""
while(True):
try:
break
except ValueError:
answer = input("What is that number?\n>>>")
#======================================================================================#

exit = False
runs,correct_guesses  = 0,0
record = dict()

print("|--------------------------------------|")
print("|         RANDOM GUESSING GAME         |")
print("|   push a negative integer to exit    |")
print("|--------------------------------------|")

while(exit != True):

# define the range of the computers random guess
computer_guess = randint(0, 50)
print("The computer has guessed a number")
answer = input("What is that number?\n>>>")

attempts = 1

# sentinel to exit
exit = True
else:
print("Wrong. Make a higher guess")
print("Wrong. Make a lower guess")

#sentinel to exit
exit = True
break
attempts+=1
else:
print("Well done")
correct_guesses+=1
runs+=1

#store the results of the quiz in a dictionary
record["run "+str(runs)] = [attempts, computer_guess]
print()
print("|--------------------------------------|")
print("|          Session Terminated          |")
print("|--------------------------------------|")
print("Guesses made by computer ", runs)
print("Correct guesses", correct_guesses)
print("record of attempts below\n")
for i in sorted(record):

if you get an error on the user input just change the `input`(python 3) to `raw_input`(python 3).
You can modify the code and add as much aesthetics as you want

#4

Try this!

``````def why_my_homework_is_not_done(reason):

if reason == "procrastination":
print "Maybe I deserve to be locked in the basement so I can reflect on how to make better use of my time"
elif reason == "I don't understand it":
print "Maybe I should ask for assistance instead of asking for someone to do it for me."
print "Maybe I should take advantage of being locked in the basement to open my textbook and study a little bit more."
print "Maybe I should ask a peer to come home so we can code side by side and help each other out while being locked in the basement together."
else:
print "Maybe I should stop trying to find excuses and give my homework one more shot."``````

Worked for me! Sure it will work for you too!

#5

Why would you be locked in the basement what?!?!

#6

Don't worry, I doubt he will be really locked into a basement...

I believe he said that to stress how important the assignment was and that he badly needed help with it very quickly...

...Well... At least I hope he was not locked into a basement... But that would explain why he never replied to any of the help we provided him...! ahah just kidding

#7

Phew, I'm out I managed to dig a tunnel out of there. Thanks for the help I passed and am now working for ISBN! @denisaltroy @rydan