18.10. Chapter AssessmentΒΆ

The function mySum is supposed to return the sum of a list of numbers (and 0 if that list is empty), but it has one or more errors in it. Use this space to write test cases to determine what errors there are. You will be using this information to answer the next set of multiple choice questions.

The class Student is supposed to accept two arguments in its constructor:
  1. A name string

  2. An optional integer representing the number of years the student has been at Michigan (default:1)

Every student has three instance variables:
  1. self.name (set to the name provided)

  2. self.years_UM (set to the number of years the student has been at Michigan)

  3. self.knowledge (initialized to 0)

There are three methods:
  • .study() should increase self.knowledge by 1 and return None

  • .getKnowledge() should return the value of self.knowledge

  • .year_at_umich() should return the value of self.years_UM

There are one or more errors in the class. Use this space to write test cases to determine what errors there are. You will be using this information to answer the next set of multiple choice questions.

Before you keep reading...

Runestone Academy can only continue if we get support from individuals like you. As a student you are well aware of the high cost of textbooks. Our mission is to provide great books to you for free, but we ask that you consider a $10 donation, more if you can or less if $10 is a burden.

You have attempted 1 of 8 activities on this page