Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

python We have provided a template for your main program to help you get going. We encourage you to carefully review the template code and

python
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
We have provided a template for your main program to help you get going. We encourage you to carefully review the template code and ask us questions, because for the final project you will have to write your own main program code TODO 0: add an import statement to load the functions the menu =(1 \& TODo 1 : add the options from the instructions opt = None whille True: A print_main menu (....) + TODO 2: uncotrment, define the function, and call with the menu as an argument opt - input (n:i: Enter a menu option > ") opt - opt. upper() \# to allow us to input lower-or upper-case letters if ...: TODO 3 : check of the character utored in opt is in the menu dictionary print (f"WARNING: (opt) is an invalid menu option. (n ) continue print (f"You jelected option (opt) to > (the_menu[opt) ." ) if opt =t TODO 4i quit the program print ("GoodbyeI (n") break I exit the main 'while' loop Input ("i: : Press Enter to continue") Note that wherever you see : : : and > in the prompts, it denotes the call to the input () function. After ":: : Press Enter to cont inue" is displayed and the user presses Enter, the loop starts from the beginning, printing out the main menu again TODO 0 importing For both main py and tests py; you will need to import all functions from the function file, for which the syntax is the following Irom functions import . TOD0 1: Main Menu In this line of main. py, define a dictionary the_menu with the options below "T" : "Total grade" "L" : "Llat" "A" : "Add" "U" : "Update" "D" : "Delete" "g" 1 "Save the data" "R" : "Riestore daca from file" "g" : "puit thiu program" The values to the left of the colon : are the dictionary keys with the corresponding value stored atter the colon store both the keys and values of the dictionary as strings Make sure thot this is a local varioble, not a global variable You thould not use global variables anywhere in this mini-project TO00 2. Printing the main menu In this line of main,py, call the print_main_menu() function with the variable storing the menu dictionary as its only argument. The code for print_main_menu( ) will be in functions.py, but after finishing TODO 0 , its already imported and usable. TODO 3: Check if the menu option exists Here, modify the if branch so that the interior executes only if the character stored in the variable opt is a key in the dictionary the_menu. HINT You can use the keyword in. TODO 4: Quit the program Here, use the if condition to check If the character representing the option selected is the option for quitting the program. Backtoton Functions First, create the file functions. py need to copy and paste it into the function file. - The last function you need is get g grades () This will be addressed in LAB8.10 : - See LAB7.22 for hints on how to write get_List_avg ( ), which you will need in LAB 8.10. In the rest of the labs after 8.10, you willimplement the rest of the options and their functions, but for the checkpoint lab, this is all that's needed First, create the file tests.py Inside the test file you will need to write assert statements to check the correctness of each function in funct ions.py that returns values (We recommend using the structure for the assert statements that we showed you on Figure 5.12:1.) If your assert statements fail, your code is wrong, and the autograder on Gradescope will fail too. So if a correct assert statement shows you that your code is false, dont delete it. Fix your function instead Similarly, it's a good idea to write your own assertions. Gradescope will be testing edge cases, and if you write tests for them yourself, you wonit lose points to them. Tips: - If you see an AssertionError, check the line number that the error message pointed to - In IDLE, you can select the "Show Line Numbers" option from the top "Options' menu. Next steps Once you have assembled the template above and both your main program and the testing code runs without any errors, submit your files to Gradescope We hope that you have fun putting this miniproject together

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Horse Betting The Road To Absolute Horse Racing 2

Authors: NAKAGAWA,YUKIO

1st Edition

B0CFZN219G, 979-8856410593

More Books

Students also viewed these Databases questions