Problem 125199 · easy · Level 01 Prerequisites & Setup

Weighted Grade

lists · zip · sum-by-hand

A course grade combines several scores, each with a weight. Write weighted_grade(scores, weights) that multiplies each score by the weight at the same position, adds the products up, and returns the total as a float rounded to 2 decimal places. Two empty lists give 0.0.

Examples

Input:  scores = [90, 80], weights = [0.6, 0.4]
Output: 86.0

Input:  scores = [], weights = []
Output: 0.0

Constraints

  • len(scores) == len(weights)
  • 0 <= len(scores) <= 5000

Goals

  • Multiply matching items from two lists
  • Accumulate a total and round it
Starting Python…