Functions and List

Functions and List

Example Code - Functions and Lists
Classes and inheritance can be advanced concepts that are difficult to understand and apply. This example code will step you through the process of developing a solution that uses classes and inheritance to solve a real world problem.
Write a guessing game that will randomly generate a number between 0 and 1000. The user tries to guess the random number and is given feedback regarding whether their guess is too high or too low. When the user correctly guesses the number, the number of guesses that it took should be printed along with a list of all of the guesses that were made.
One of the first steps that we want to take in accomplishing the problem/task is to develop a general plan. We will develop our plan using pseudocode and then fill in the code necessary to accomplish the specified task. , What pseudocode
# import necessary modules

# Generate a random number

# Get and process Guess from user

# Add the number to the list of guesses

# Check the guess

# Repeatedly get a new guess and check it until the guess is correct

# Print the Results
Do not expect your pseudocode to be perfect the first time. The pseudocode you see above went through several iterations. The final iteration of the pseudocode is shown so that you can see the most complete and accurate version that reflect the code that will be developed. Remember, coding and pseudocoding is an iterative process.
What would the flowchart for this code look like? A flowchart for this code will not be provided, but you are highly encouraged to think about or develop a flowchart to help you understand the solution and how the program will flow.
Basic Functionality
The following block of code implements the basic functionality of our guessing game. There are some core elements missing, but this is an important series of steps on the path to a viable solution. The entire block of code is shown below and detailed explanations...

Similar Essays