subject

Assignment Overview This lab exercise provides practice with lists and functions in Python. You will work with a partner on this exercise during your lab session. Two people should work at one computer. Occasionally switch the person who is typing. Talk to each other about what you are doing and why so that both of you understand each step. Programming with Lists and Tuples Develop a Python program that will calculate and display information about exam scores for the students in a class, as described below. The program will read the file scores. txt (no error checking or prompting). Each line of the input file will represent one student and four exam scores, and will have the following format: Name (string, maximum of 20 characters: two words separated by one comma) Name (string, maximum of 20 characters: two words separated by one comma) Exam #x score (integer, range 0 to 100) The student's name will be in the first 20 characters of the line. The four exam scores will be separated by one or more blanks. For example: Hopper, Grace Knuth, Donald Goldberg, Adele Kernighan, Brian Liskov, Barbara 100 98 87 97 82 87 92 81 94 96 90 91 89 74 89 77 87 92 82 85 The program will assume that the input file contains no erroneous data. The program will read the contents of the input file and store the data set in a list of tuples, where each tuple will represent one student and will contain the following information: Name (str) Exam #1 score (int) Exam #2 score (int) Exam #3 score (int) Exam #4 score (int) Exam average (float) The program will assume that the input file contains no erroneous data. The program will read the contents of the input file and store the data set in a list of tuples, where each tuple will represent one student and will contain the following information: Name (str) Exam #1 score (int) Exam #2 score (int) Exam #3 score (int) Exam #4 score (int) Exam average (float) The type of each field within the tuple is listed: the student's name will be type str, the four exam scores will be type int, and the exam average will be type float. After reading and storing the data set, the program will display the following. Each line of student data will use this format string: ":20}{:6d) {:6d) {:6d) {:6d):10.2}" A table representing the data set, sorted alphabetically by name The final row will have the average of each exam with one decimal place. Name Goldberg, Adele Hopper, Grace Kernighan, Brian Knuth, Donald Liskov, Barbara Exam Mean Examl Exam2 Exam3 Exam4 94 96 90 91 100 98 87 97 89 74 89 77 82 87 92 81 87 97 81 85 90.4 90.4 87.8 86.2 Mean 92.75 95.50 82.25 85.50 87.50 * Demonstrate your completed program to your TA. On-line students should submit the completed program (named "lab06.py") for grading via the Mirmir system. Suggestions: Develop the program incrementally: a) Start by reading and displaying each line of the input file to make sure you are reading the data set a) Start by reading and displaying each line of the input file to make sure you are reading the data set correctly. b) Use the split string method to extract information from each line into a list. Print the list to prove that this step is working correctly d) Convert the exam scores to type int and calculate the student's average. Display those items to prove this step is working correctly. e) Create a tuple containing the six items for each student (name, exam scores, exam mean). Display the tuples to prove this step is working correctly. (Optionally, you may want to have the exam scores in a list so your tuple is (name, scores list, mean).) Append each tuple to a list. Display the list to prove this step is working correctly. g) Use the sort list method to re-order the tuples in the list. Display the list to prove this step is working correctly h) Use a for statement to display the contents of the list as a table (with appropriate formatting), i) Use a for statement to calculate the average of all scores on Exam #1, then display the results. Note that you could have calculated this average within the first loop, but we are explicitly requiring you to do this calculation by looping though your list of tuples. 1) Add the logic to calculate the average of all scores on Exam #2, then display the results. Hopper, Grace Knuth, Donald Goldberg, Adele Kernighan, Brian Liskov, Barbara 100 98 87 97 82 87 92 81 94 96 90 91 89 74 89 77 87 97 81 85

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 11:00
What is the foundation for proper monitoring, load balancing and routing in distributed systems
Answers: 3
question
Computers and Technology, 23.06.2019 15:00
Visually impaired individuals generally rely on the for navigation. thus, designers need to ensure that mouse-specific inputs, such as pointing, clicking, and hovering, can be done without a mouse.
Answers: 1
question
Computers and Technology, 24.06.2019 13:00
Which one of the following functions is not available on the autosum tool? sum average if max
Answers: 3
question
Computers and Technology, 24.06.2019 14:40
Create a function (prob3_6) that will do the following: input a positive scalar integer x. if x is odd, multiply it by 3 and add 1. if the given x is even, divide it by 2. repeat this rule on the new value until you get 1, if ever. your program will output how many operations it had to perform to get to 1 and the largest number along the way. for example, start with the number 3: because 3 is odd, we multiply by 3 and add 1 giving us 10. 10 is even so we divide it by 2, giving us 5. 5 is odd so we multiply by 3 and add one, giving us 16. we divide 16 (even) by two giving 8. we divide 8 (even) by two giving 4. we divide 4 (even) by two giving 2. we divide 2 (even) by 2 to give us 1. once we have one, we stop. this example took seven operations to get to one. the largest number we had along the way was 16. every value of n that anyone has ever checked eventually leads to 1, but it is an open mathematical problem (known as the collatz conjectureopens in new tab) whether every value of n eventually leads to 1. your program should include a while loop and an if-statement.
Answers: 3
You know the right answer?
Assignment Overview This lab exercise provides practice with lists and functions in Python. You wil...
Questions
question
Mathematics, 02.08.2019 02:30
Questions on the website: 13722367