Practical Coding in Python

Learn to write and validate your own code

Darren Kessner, PhD

(revised September 1, 2025)

Previous: Circle

Coding Exercises: Classes and Objects

Person

Write a Person class that includes the following:

Write some test code that instantiates some Person objects and demonstrates that the functions are working properly.

ScoreKeeper

Write a ScoreKeeper class that includes the following:

Write some test code that instantiates a ScoreKeeper object and tests its functions.

Magic Eight Ball

Write a MagicEightBall class that includes the following:

Write some code that instantiates a MagicEightBall object and asks it some important questions.

Rectangle

Write a Rectangle class that includes the following:

Write test code to demonstrate that your Rectangle class functions all work properly.

Bonus Challenge: Vector

Write a Vector class that represents a two-dimensional vector \(\vec{v} = \left<x, y\right>\).

Include the following:

Be sure to write code to verify that your functions are all doing what they’re supposed to be doing.


Next: