Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

0\', etc) dictionary as its single return the total number of students enrolled

ID: 3903794 • Letter: 0

Question

0', etc) dictionary as its single return the total number of students enrolled in all classes Ul3 iat represent the total number of students iuel class. Write a function called total enrolment that takes such a input parameter. The function williterate over the dictionary and 3. Consider the Bucket class defined below class Bucket: ''A Bucket holds some water '' water0 capacity- 100 # amount of water the bucket can hold # amount of water in the bucket Write a function total_water that takes a list of Buckets as input. The function will return the sum of all the water in all the buckets in the input list. For example, bl Bucket () b2 Bucket () b1.water 12 b2.water 8 calling total_water [bl,b2] ) will retum 20.

Explanation / Answer

class Bucket: water = 0 capacity = 100 def new_bucket(water, capacity): b = Bucket() b.water = water b.capacity = capacity return b def load_buckets(filename): buckets = [] with open(filename, 'r') as f: for line in f: words = line.strip().split(',') buckets.append(new_bucket(int(words[0]), int(words[1]))) return buckets