Chapter 7 Exercise Set 1

Doctest Exercises

In each of the following exercises, write Python code to make the doctests pass.

  1. class Polynomial:
        """
          >>> p1 = Polynomial()
          >>> print(p1)
          '0'
          >>> p2 = Polynomial([3, 1, 5])
          >>> print(p2)
          '3x^2 + x + 5'
        """