This program makes use of the creation of a random number as well as simple file handling, such as writing the scores to file, and then sorting the file
Example of creation of a random number
#generate a random number import random #this needs to go at the start of your code bingo=(random.randint(0,20)) #generate a random number from 0 to 20
Read the task instructions that are included in the comments in the code, and then get started!
You can either edit and code online in repl.it or alternatively, you can simply cut and paste the below into your own python file
Solve the challenge on repl.it""" ==============TASK First, Create a Menu as below: ======Main Menu 1........Play Game 2........View Players and Scores record 3........Quit 1. Get the computer to generate a random number between 1 and 20 2. Ask the user to enter their full name 3. The user can then start to guess what the number is (their tries are recorded) 4. On correctly guessing the randomly generated number, their final tries are recorded 5. The user's name and no. of tries are stored to a file in the format: user's name no.of.tries Joe Bloggs 5 Kara Smith 17 6. Sort and display the high scores in ascending order (lowest no.of tries first) """ #generate a random number see below: # def mainmenu(): print(""" =========MAIN MENU========""") print("+-------------------------------------+") print("| Please select an option: |") print("| 1 - Play Game |") print("| 2 - View Scores |") print("| 3 - Quit |") print("----------------------------------------") mainmenu()
A sample flow chart (design) for this particular challenge could look like:
Test No. | Description | Test Data(input) | Expected Outcome | Actual Outcome | Further Action? |
---|---|---|---|---|---|
1 | |||||
2 | |||||
3 | |||||
4 | |||||
5 |