Chapter 7 Exercise Set 1: Doctest ExercisesΒΆ
In each of the following exercises, write Python code to make the doctests pass.
class Student: """ >>> student = Student('Gizelle', 'Day', 11) >>> student.fname 'Gizelle' >>> student.lname 'Day' >>> student.grade 11 """
class Polynomial: """ >>> p1 = Polynomial() >>> print(p1) '0' >>> p2 = Polynomial([3, 1, 5]) >>> print(p2) '3x^2 + x + 5' >>> p3 = Polynomial([2, 3, 1, 5]) >>> print(p3) '2x^3 + 3x^2 + x + 5' >>> p4 = Polynomial([2, 0, 3, 7, 2]) >>> print(p4) '2x^4 + 3x^2 + 7x + 2' """