Page 38 -
P. 38
starting to code
This code is a guessing-game program. Study it carefully, and
opposite each line of code in the program, write down what you
think the code does. If you’re not sure what a particular line of
code does, don’t worry, but try to guess anyway. One line has
already been entered to get you started:
print("Welcome!")
g = input("Guess the number: ")
Convert the input to a number.
guess = int(g)
if guess == 5:
print("You win!")
else:
print("You lose!")
print("Game over!")
This code is written in
release 3 of the Python
programming language, which
is used throughout this book.
you are here 4 3