What is the code for this program
Part 1: Basic Game – Your solution should correctly accomplish all the following: 1. Initialize all variables and named constants at the top of your program 2. Display a user-friendly message to your user explaining the rules and what to expect 3. Create a random number for the user to guess and repeatedly ask the user until the correct number is entered. Your program should give helpful feedback to the user on an incorrect guess When the user guesses correctly, your program should: Notify the user of the correct guess Display the number of guesses it took Display all their prior guesses in a user-friendly message (do not simply print the raw list variable itself) 4. Ask the user if they wish to play again and restart the game if that is the user’s desire. If not, provide a user-friendly closing message. Hint: Make sure to reset all variables needed to play the game. You may choose whatever range of numbers you prefer provided you use the appropriate random module function. Keep in mind the range should make sense to be fun and challenging. Guessing between 1-5 is not exactly fun. Whatever range you choose, the program should choose, not the user. Do not ask the user what range they would like. They’ll always choose a small range to win
Part 2: Best Score – Up to 15 points
Your game should also implement a "best score" system that keeps track of the user’s best (lowest)
guess across all games played. This should be a separate variable from the number of guesses it took the
user to correctly guess the number. This part is broken into two sections:
1. Memory-based best guess (worth up to 5 out of 15 possible points)
The best guess will be set at the end of the first game and checked after each
subsequent game.
If the program ends and is restarted, this variable will be rest.
2. File-based best guess (worth the remaining 10 points)
The best guess variable is loaded from a file (if available) when the program starts.
If the file is unavailable, a message should be displayed and your program should still
continue to correctly run without the file, using only the variable.
At the end of each game when the best guess is checked, your program should save the
new best guess, if it was achieved by the user.
If the file didn’t exist previously, the program should now create it.
The filename should be stored in a named constant
Accomplishing this part correctly will earn you 75 of the 100 points for this project.
The following requirements are not optional:
Use comments at the top of your program to indicate your name, program name and
description
Declare and initialize all variables and named constants at the top of your program or function
Comment the meaning of all variables as they are created
Store all values used in calculations and print statements as assigned variables or named
constants using use appropriate case
DO NOT use global variables. Pass values into your functions and use a return values from them
Have user-friendly input requests and feedback to the user to fully explain what is expected
All output should use F-Strings and be formatted in a user-friendly manner for reading
Only use code we have covered in this course to date; No other statements may be used!
Use correct grammar and appropriate spacing for all prompts
Have the program set the range of numbers - NOT the user!
Required functions:
You should utilize at least three functions:
1. A main() function
2. A function for the actual game play