Python Homework

In this homework you need to complete a few simple Python exercises. Before you begin, please refer to the Python lessons on the course website:

  1. Python Introduction
  2. Python for Big Data
  3. Python cmd module

Exercise 1

Finish implementing the Calculator class by adding multiply and divide methods.

Exercise 2

Create a command-line interpreter, mycmd, that has the following commands:

  1. deploy
  2. kill
  3. benchmark
  4. report

Each command should simply print out its name to the screen.

Exercise 3

In the tutorial on Python for big data, you saw how to plot a histogram of the ages of people who received traffic citations in Q1 2016. Generate the same histogram with the pygal Python module.

Submission

  • For residential students, please have this ready on your GitHub accounts by class time on Monday, February 20th. We will pick students at random to demonstrate their solutions.
  • For online students, you don’t need to submit anything to us. However, we still strongly encourage you to do these exercises. They will help you get up to speed in Python if you’re not familiar with it; or if you are, they might introduce you to some modules that you haven’t used before. Of course, if you have any questions about the exercises, please discuss them with the AIs during office hours or on Piazza.