For this challenge, you will extend the existing program so that players scores are saved to and read from a text file (scores.txt). You should ask for the player's name at the start of each new game and use it to load their previous high score. If they manage to beat their personal best while playing, ask them if they would like to update the leaderboard and do so if prompted. To do this, you should create two new functions: • A function to retrieve the existing high score for the current player called: get_score. This should take a single argument, the players name and return their high score. If they don't have a high score return 0 or None. Players without a previous high score should always be asked whether they would like to store their score. • A function to save a new high score for the current player called: save_score. This should take two arguments (the players name and score). The function does not need to have a return value, but should handle writing the latest score to the text file and closing it. If a player already has a lower score saved in the file, update it instead. Your game will also need a more robust menu, it should contain options to: play the game, load the leaderboard or quit. Players should return there after games or viewing the leaderboard. Hints: • When the player loads the leaderboard, you will need to read the text file used to store the data and present the information in a tabular format so that it's easy to read. • Selecting the option to quit should close the program after printing a goodbye message.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

 the output is in first image. the second image consists of question that i need answer of. two functions  def get_score(): and def save_score(): need to be done. please build these two functions so that the output like in first image is obtained. program should be in python3 version. 

 

Example Implementation (input in red):
Loading word list from file...
55900 words loaded.
Welcome to Hangman Ultimate Edition
Do you want to Play (p) view the leaderboard (1) or quit (q): p
Score
Name
7
Matthew Howell
Herbert Daly
3
Hiran Patel
Would you like to play (p) or view the leaderboard (1): p
What is your name: Matthew Howell
I am thinking of a word that is 2 letters long
You have 6 guesses left.
Available letters: abcdefghijklmnopqrstuvwxyz
Please guess a letter: a
Good guess: a
---
You have 6 guesses left.
Available letters: bcdefghijklmnopqrstuvwxyz
Please guess a letter: n
Good guess: an
Congratulations, you won!
Your total score for this game is: 9
A new personal best! Would you like to save your score (y/n): y
Ok, your score has been saved.
Do you want to Play (p) view the leaderboard (l) or quit (q) : q
Thanks for playing, goodbye!
Transcribed Image Text:Example Implementation (input in red): Loading word list from file... 55900 words loaded. Welcome to Hangman Ultimate Edition Do you want to Play (p) view the leaderboard (1) or quit (q): p Score Name 7 Matthew Howell Herbert Daly 3 Hiran Patel Would you like to play (p) or view the leaderboard (1): p What is your name: Matthew Howell I am thinking of a word that is 2 letters long You have 6 guesses left. Available letters: abcdefghijklmnopqrstuvwxyz Please guess a letter: a Good guess: a --- You have 6 guesses left. Available letters: bcdefghijklmnopqrstuvwxyz Please guess a letter: n Good guess: an Congratulations, you won! Your total score for this game is: 9 A new personal best! Would you like to save your score (y/n): y Ok, your score has been saved. Do you want to Play (p) view the leaderboard (l) or quit (q) : q Thanks for playing, goodbye!
For this challenge, you will extend the existing program so that players scores are saved to and
read from a text file (scores.txt). You should ask for the player's name at the start of each new
game and use it to load their previous high score. If they manage to beat their personal best while
playing, ask them if they would like to update the leaderboard and do so if prompted.
To do this, you should create two new functions:
• function to retrieve the existing high score for the current player called: get_score.
This should take a single argument, the players name and return their high score. If they
don't have a high score return 0 or None. Players without a previous high score should
always be asked whether they would like to store their score.
• A function to save a new high score for the current player called: save_score. This
should take two arguments (the players name and score). The function does not need to
have a return value, but should handle writing the latest score to the text file and closing
it. If a player already has a lower score saved in the file, update it instead.
Your game will also need a more robust menu, it should contain options to: play the game, load
the leaderboard or quit. Players should return there after games or viewing the leaderboard.
Hints:
• When the player loads the leaderboard, you will need to read the text file used to store the
data and present the information in a tabular format so that it's easy to read.
• Selecting the option to quit should close the program after printing a goodbye message.
Transcribed Image Text:For this challenge, you will extend the existing program so that players scores are saved to and read from a text file (scores.txt). You should ask for the player's name at the start of each new game and use it to load their previous high score. If they manage to beat their personal best while playing, ask them if they would like to update the leaderboard and do so if prompted. To do this, you should create two new functions: • function to retrieve the existing high score for the current player called: get_score. This should take a single argument, the players name and return their high score. If they don't have a high score return 0 or None. Players without a previous high score should always be asked whether they would like to store their score. • A function to save a new high score for the current player called: save_score. This should take two arguments (the players name and score). The function does not need to have a return value, but should handle writing the latest score to the text file and closing it. If a player already has a lower score saved in the file, update it instead. Your game will also need a more robust menu, it should contain options to: play the game, load the leaderboard or quit. Players should return there after games or viewing the leaderboard. Hints: • When the player loads the leaderboard, you will need to read the text file used to store the data and present the information in a tabular format so that it's easy to read. • Selecting the option to quit should close the program after printing a goodbye message.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY