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...

Making great stuff takes time and $$. If you appreciate the book you are reading now and want to keep quality materials free for other students please consider a donation to Runestone Academy. We ask that you consider a $10 donation, but if you can give more thats great, if $10 is too much for your budget we would be happy with whatever you can afford as a show of support.

You have attempted 1 of 8 activities on this page