Mini-Project Description - Coursera
Mini-Project Description - Coursera
Mini-Project Description - Coursera
When discussing ranges in this mini-project, we will follow the standard Python
convention of including the low end of the range and excluding the high end of the
range. Mathematically, we will express ranges via the notation [, ) . The
square bracket of the left of the range indicates that the corresponding bound
should be included. The left parenthesis on the right of the range indicates that
corresponding bound should be excluded. For example, the range [, ) consists of
numbers starting at 0 up to, but not including 3. In other words 0, 1, and 2.
You will interact with your program using an input eld and several buttons. For this
project, we will ignore the canvas and print the computer's responses in the console.
Building an initial version of your project that prints information in the console is a
development strategy that you should use in later projects as well. Focusing on
getting the logic of the program correct before trying to make it display the
information in some nice way on the canvas usually saves lots of time since
debugging logic errors in graphical output can be tricky.
1. Add code to the program template that creates a frame with an input eld whose
handler has the name _. You will use this input eld to enter
guesses.
2. Add code to the event handler _() that takes the input string
, converts it to an integer, and prints out a message of the form
" " (or whatever the guess actually was). Hint: We have shown you
how to convert strings to numbers in the lectures.
From this minimal working version of Guess the number, the rest of this project
consists of adding extra functionality to your project. There are two improvements
that you will need to make to get full credit:
2. Your nal addition to Guess the number will be to restrict the player to a limited
number of guesses. After each guess, your program should include in its output
the number of remaining guesses. Once the player has used up those guesses,
they lose, the game prints out an appropriate message, and a new game
immediately starts. Since the strategy above for playing Guess the number
approximately halves the range of possible secret numbers after each guess, any
secret number in the range [, ) can always be found in at most
guesses where is the smallest integer such that ** >= - + . For
the range [, ) , is seven. For the range [, ) , is ten. In our
implementation, the function _() set the number of allowed guess to
seven when the range is [, ) or to ten when the range is [, ) . For more
of a challenge, you may compute from and using the functions
. and . in the module.
When your program starts, the game should immediately begin in the range
[, ). When the game ends (because the player either wins or runs out of
guesses), a new game with the same range as the last one should immediately begin
by calling _() . Whenever the player clicks one of the range buttons, the
current game should stop and a new game with the selected range should begin.
For more helpful tips on implementing this mini-project, please visit the Code Clinic
Tips page for this mini-project.
Your peers will assess your mini-project according to the rubric given below. To guide
you in determining whether your project satises each item in the rubric, please
consult the video that demonstrates our implementation of Guess the number.
Small deviations from the textual output of our implementation are ne. You should
avoid potentially confusing deviations (such as printing Too high or Too low
instead of Lower and Higher). Whether moderate deviations satisfy an item of the
grading rubric is at your peers' discretion during their assessment.
1 pt The game reads from the input eld and correctly prints it out.
3 pts The game correctly plays Guess the number with the range [, )
and prints understandable output messages to the console. Play three complete
games: 1 pt for each correct game.
2 pts The game includes two buttons that allow the user to select the range
[, ) or the range [, ) for the secret number. These buttons correctly
change the range and print an appropriate message. (1 pt per button.)
2 pts The game restricts the player to a nite number of guesses and correctly
terminates the game when these guesses are exhausted. Award 1 pt if the
number of remaining guesses is printed, but the game does not terminate
correctly.
1 pt The game varies the number of allowed guesses based on the range of the
secret number seven guesses for range [, ) , ten guesses for range
[, ) .
To help aid you in gauging what a full credit project might look like, the video lecture
on the Guess the number project includes a demonstration of our implementation
of this project. You do not need to validate that the input number is in the correct
range. (For this game, that responsibility should fall on the player.)
Mark as completed