Exam #3 logistics and preparation

As a reminder, the midterm will consist of one coding part (50 minutes).  You are encouraged to study all previous activities and labs, textbook chapters and reading quizzes, and programming assignments. 

This secondary practice exam is available as well as the primary practice exam on this page.

Objectives

Students will be able to...

  • Meet any objectives from HW 5-8.
  • Compute stats over a list.
  • Write nested/chained if-else statements.
  • Use lists and loops (for and while)
  • Work with strings

Logistics

  • You must use a Linux lab machine and log in with  student. It's strongly recommended that you practice the sample exam in the lab so there will be no surprises on exam day.

  • During the exam, you may only access Gradescope and the provided reference sheet.

  • The use of any pre-existing code (other than that provided as part of the exam), other documents/pages/sites, and/or other programs will be considered a violation of the Honor Code.
  • You may only use a terminal/shell window, Thonny and a web browser. The only page you may load in the WWW browser is the course submission site.

  • Your code need not comply with the course style guidelines and need not include comments.

  • At the end of the exam, you will submit your code via https://gradescope.com . You may not use Gradescope for any other purpose (e.g., looking at code from prior assignments) during the exam.

  • Your last submission is the one that will be graded. No limit will be placed on the number of submissions but, obviously, you must complete the exam during the class period and submissions take time.

Grade Calculator

When calculating grades, teachers often want to know what the class average is and may want to separate scores into different grading categories. You will be performing both of those functions in your code today.

For the purpose of the exam, you must write one program grade_calculator.py. This program will implement two functions:

  • average - This function will take a single list of floats. It will return a float value that is the average of all valid entries in the provided list. Some entries in the list may be equal to -1.0, representing students who have dropped the course. You may assume that the list will contain at least one valid entry. For example:

    print(average([-1.0, 100.0, 90.0])) # Prints 95.0
    print(average([50.0, 90.0]))        # Prints 70.0
    print(average([-1.0, 100.0, -1.0])) # Prints 100.0
  • grade_totals - This function will take a list of tuples where each tuple represents the score for a single assignment. The first entry in each tuple represents the category associated with the assignment, for example: "Lab" or "HW". The second entry will be a float representing the numeric score. The function must return a string that prints the category name followed by a colon and space then the total score in that category followed by a return character.  All output should be in a single string return value and floating point numbers should be formatted to 2 decimal places.

    For example:

    scores = [("Lab", 100.0), 
              ("HW", 80),
              ("Lab", 90)]
    totals = grade_totals(scores)
    
    print(totals)      
    ''' Prints:
    Lab: 190.00
    HW: 80.00
    '''

    Note that "HW" and "Lab" are only examples. Any valid string may be used as a category title.

Back to Top