programming is really not my thing.
we use python and wing to write the codes.
for weeks now i have tried to master this "magic game" and i cannot get it to work. originally i had a functioning game that worked fine within python but my lecturer wants me that i use this easygui and now things are a mess. i really hope someone can help me out here because its utter frustrating that i nearly failed an exam because of this.
thats what i have so far:
# This is a guess the number game.
import easygui as eg
answer = eg.enterbox('What is your name?')
eg.enterbox('OK, '+answer + '! Guess a number between 1 and 10')
#eg.enterbox ("Guess a number between 1 and 10:")
import random
guessesTaken = 0
#print('What is your name?')
number = random.randint(1, 10)
#print('OK, ' + myName + ', Guess a number between 1 and 10')
while guessesTaken < 1:
#print('Guess.') # There are four spaces in front of print.
answer = eg.enterbox('')
guess = int(number)
guessesTaken = guessesTaken + 3
if guess < number:
eg.enterbox('Too low. Try again.') # There are eight spaces in front of print.
if guess > number:
eg.enterbox('Too high. Try again.')
if guess == number:
break
if guess == number:
guessesTaken = str(guessesTaken)
eg.msgbox('Well done young Padawan. You guessed ' + guessesTaken + ' times!')
if guess != number:
number = str(number)
eg.msgbox('No. The number was ' + number)
we use python and wing to write the codes.
for weeks now i have tried to master this "magic game" and i cannot get it to work. originally i had a functioning game that worked fine within python but my lecturer wants me that i use this easygui and now things are a mess. i really hope someone can help me out here because its utter frustrating that i nearly failed an exam because of this.
thats what i have so far:
# This is a guess the number game.
import easygui as eg
answer = eg.enterbox('What is your name?')
eg.enterbox('OK, '+answer + '! Guess a number between 1 and 10')
#eg.enterbox ("Guess a number between 1 and 10:")
import random
guessesTaken = 0
#print('What is your name?')
number = random.randint(1, 10)
#print('OK, ' + myName + ', Guess a number between 1 and 10')
while guessesTaken < 1:
#print('Guess.') # There are four spaces in front of print.
answer = eg.enterbox('')
guess = int(number)
guessesTaken = guessesTaken + 3
if guess < number:
eg.enterbox('Too low. Try again.') # There are eight spaces in front of print.
if guess > number:
eg.enterbox('Too high. Try again.')
if guess == number:
break
if guess == number:
guessesTaken = str(guessesTaken)
eg.msgbox('Well done young Padawan. You guessed ' + guessesTaken + ' times!')
if guess != number:
number = str(number)
eg.msgbox('No. The number was ' + number)