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.
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...
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.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 1 images
Recommended textbooks for you
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 Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
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 Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
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
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY