Skip to content

Assignment: I Am Thinking of a Number...Line By Line Walkthrough

sleepinghungry edited this page Mar 7, 2017 · 4 revisions

###Line By Line Walkthrough

Line 1:

Create a variable that will keep track if the game is over or not and set it to the boolean value True or False. This will be used the the following while statement in order to either keep the game going or end the game.

Line 2:

Use the while keyword, the variable you created above, and a colon to start the while statement. You may or may not want to use the not keyword to negate your variable from Line 1.

Line 3:

Create a variable that will store the guess prompted by the input() command. In the input() command, include text to ask a user for a number.

Line 4:

Use the int() command to turn the guess from text into a integer. And then store that integer into the variable you created in Line 3.

Line 5:

Use the if keyword, your guess variable, the less than operator, the correct number, and a colon to start the if statement.

Line 6:

Use an indent and a print() command to let the user know the guess was too low.

Line 7:

Use the elif keyword, your guess variable, the greater than operator, the correct number, and a colon to start the elif statement

Line 8:

Use an indent and a print() command to let the user know the guess was too high.

Line 9:

Use the else keyword and a colon to start the else statement

Line 10:

Use an indent and a print() command to let the user know the guess was correct.

Line 11:

Use an indent and your variable from Line 1 to end the game.

BWX Game Engine pages

Python Pages

Step By Step Guides

Building Conditionals

Lectures

Explaining Conditionals

Assignments

I Am Thinking of a Number...

Clone this wiki locally