Problem 1 (Student grades) – 15 marks Write a program which allows the user to enter the final grades of a students in a class. After entering the grades, the user should be able to calculate...

Its in the file


Problem 1 (Student grades) – 15 marks Write a program which allows the user to enter the final grades of a students in a class. After entering the grades, the user should be able to calculate statistics on the grades that they have entered. Specifically, this program should have the following functionality. 1.1 Menu (2-marks) The program should display the following menu to the user:  Please select an option from the following menu (1, 2, 3, 4, 5, or 6):  1. Enter grade of a student 2. Display list of students 3. Calculate average grade of the class 4. Display name of student with the highest grade 5. Display name of student with the lowest grade 6. Quit This menu should be displayed repeatedly until the user picks option 6 from the menu. When option 6 is selected, the program should end. 1.2 Entering grade (4-marks) When the user selects the “Enter grade of a student” option from the menu, the program should prompt the user for the following information about a student: · Student ID · Student Name · Final Grade After the user enters the requested information, the program should save this information, so it can be used later in the program. You may save the information entered in a List or a dictionary. However, saving it in a dictionary will make it easier to implement the remaining functionality of the program. 1.3 Display list of students (1-mark) When the “Display list of students” option is selected from the menu, the program should display the list of students that the user has entered. 1.4 Calculate average grade (3-marks) When the “Calculate average grade” option is selected from the menu, the program should compute average of all the final grades entered and display the average to the user. 1.5 Display name of student with the highest grade (3-marks) When the “Display name of student with the highest grade” option is selected from the menu, the program should display the name of the student that has the highest grade. 1.6 Display name of student with the lowest grade (2-marks) When the “Display name of student with the lowest grade” option is selected from the menu, the program should display the name of the student that has the lowest grade. 1.7 [BONUS] Reading grades from a file (6-marks) Add an option to the menu called “Load grades”. When this menu option is selected, the program should read student grade information from a text file and save it in the program. The user should then be able to perform computations on this information (e.g., calculate average, highest grade, lowest grade) Specifically, the text file should contain the following information for each student: student ID, student Name, student Grade. You may structure the text file in any format that you like, however the following is a suggested format (a sample text file is also provided as an attachment to this assignment): Student ID, Student Name, Student Grade 134021, Jane Doe, 95 819201, John Doe, 78 918932, Mary Jane, 67  When reading a file in this format, you can ignore the first line as it contains the headers of the information. To process each line of a text file of this format, you can use String functions that we looked in week 11. One of these functions, which you may find helpful is strip(). This function removes a newline ("\n") character at the end of a line that is read from the file. It can be used as follows: clean_line = line.strip() if line is a variable that holds the contents of a line that is read from the text file. Write your code in a file named a5q1.py and save it on your computer. Follow the instructions in the “Submission” section to learn how to add this file into the main .zip file which will be submitted. Sample output: The following is output from a sample run of the program that you can use to test your program. User input is highlighted for emphasis. =================================================  Please select an option from the following menu  ================================================= 1. Enter grade of a student 2. Display list of students 3. Calculate average grade of the class 4. Display name of student with the highest grade 5. Display name of student with the lowest grade 6. Quit Enter an option from the menu (1, 2, 3, 4, 5, or 6): 1 Enter the student's ID: 1234567890 Enter the student's name: Jane  Enter the student's grade: 95 =================================================  Please select an option from the following menu  ================================================= 1. Enter grade of a student 2. Display list of students 3. Calculate average grade of the class 4. Display name of student with the highest grade 5. Display name of student with the lowest grade 6. Quit Enter an option from the menu (1, 2, 3, 4, 5, or 6): 2 The students in our list are:  1234567890  :  ['Jane ', '95'] =================================================  Please select an option from the following menu  ================================================= 1. Enter grade of a student 2. Display list of students 3. Calculate average grade of the class 4. Display name of student with the highest grade 5. Display name of student with the lowest grade 6. Quit Enter an option from the menu (1, 2, 3, 4, 5, or 6): 1 Enter the student's ID: 3492010320 Enter the student's name: John Doe Enter the student's grade: 87 =================================================  Please select an option from the following menu  ================================================= 1. Enter grade of a student 2. Display list of students 3. Calculate average grade of the class 4. Display name of student with the highest grade 5. Display name of student with the lowest grade 6. Quit Enter an option from the menu (1, 2, 3, 4, 5, or 6): 2 The students in our list are:  1234567890  :  ['Jane ', '95'] 3492010320  :  ['John Doe', '87'] =================================================  Please select an option from the following menu  ================================================= 1. Enter grade of a student 2. Display list of students 3. Calculate average grade of the class 4. Display name of student with the highest grade 5. Display name of student with the lowest grade 6. Quit Enter an option from the menu (1, 2, 3, 4, 5, or 6): 3 The average grade of all the students is:  91.0 =================================================  Please select an option from the following menu  ================================================= 1. Enter grade of a student 2. Display list of students 3. Calculate average grade of the class 4. Display name of student with the highest grade 5. Display name of student with the lowest grade 6. Quit Enter an option from the menu (1, 2, 3, 4, 5, or 6): 4 The student with the highest grade is:  Jane  =================================================  Please select an option from the following menu  ================================================= 1. Enter grade of a student 2. Display list of students 3. Calculate average grade of the class 4. Display name of student with the highest grade 5. Display name of student with the lowest grade 6. Quit Enter an option from the menu (1, 2, 3, 4, 5, or 6): 5 The student with the highest grade is:  John Doe =================================================  Please select an option from the following menu  ================================================= 1. Enter grade of a student 2. Display list of students 3. Calculate average grade of the class 4. Display name of student with the highest grade 5. Display name of student with the lowest grade 6. Quit Enter an option from the menu (1, 2, 3, 4, 5, or 6): 6 >> Sample output for the bonus question:  =================================================  Please select an option from the following menu  ================================================= 1. Enter grade of a student 2. Display list of students 3. Calculate average grade of the class 4. Display name of student with the highest grade 5. Display name of student with the lowest grade 6. Load grades 7. Quit Enter an option from the menu (1, 2, 3, 4, 5, 6, or 7): 6 =================================================  Please select an option from the following menu  ================================================= 1. Enter grade of a student 2. Display list of students 3. Calculate average grade of the class 4. Display name of student with the highest grade 5. Display name of student with the lowest grade 6. Load grades 7. Quit Enter an option from the menu (1, 2, 3, 4, 5, 6, or 7): 2 The students in our list are:  134021  :  [' Jane Doe', ' 95'] 819201  :  [' John Doe', ' 78'] 918932  :  [' Mary Jane', ' 67'] Problem 2 (Guessing game) – 10 marks In this problem, you will implement the guessing game from Assignment 1. You may use the flowchart or pseudo-code that you developed in Assignment 1 to help you break down the problem and plan its implementation.  In this guessing game, a player must repeatedly guess numbers (an input operation) until they have guessed a secret number. The program should work as follows: · The program sets the secret number to be 63 · The user is asked to guess the secret number · The user enters their guess · When the user has guessed the number correctly, the ‘program’ should output “You Win!” before ending. · If their guess is incorrect, the program should give them a hint of whether their guess is “lower” or “higher” than the secret number, and ask them to guess the number again.  · The programs keep running until the user enters the correct guess or presses -1  to quit.  Write your code in a file named a5q2.py and save it on your computer. Follow the instructions in the “Submission” section to learn how to add this file into the main .zip file which will be submitted. Sample output: The following is output from a sample run of the program that you can use to test your program. User input is highlighted for emphasis. Guess the secret number or press q to quit: 34 Your guess is less than the secret number. Try guessing higher. Guess the secret number or press q to quit: 78 Your guess is higher than the secret number. Try guessing lower. Guess the secret number or press q to quit: 23 Your guess is less than the secret number. Try guessing higher. Guess the secret number or press q to quit: 45 Your guess is less than the secret number. Try guessing higher. Guess the secret number or press q to quit: 65 Your guess is higher than the secret number. Try guessing lower. Guess the secret number or press q to quit: 54 Your guess is less than the secret number. Try guessing higher. Guess the secret number or press q to quit: 63 You Win! Problem 3 (Password game) –10 marks In this problem you will implement a
Dec 10, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here