{ Object Oriented Programming in Python Exercises. }

Part 1

Answer the following questions.

  • What is a class?
  • What is an instance?
  • What is encapsulation?
  • What is abstraction?
  • What is inheritance?
  • What is multiple inheritance?
  • What is polymorphism?
  • What is method resolution order or MRO?

Part 2

Create a deck of cards class. Internally, the deck of cards should use another class, a card class. Your requirements are:

  • The Deck class should have a deal method to deal a single card from the deck
  • After a card is dealt, it is removed from the deck.
  • There should be a shuffle method which makes sure the deck of cards has all 52 cards and then rearranges them randomly.
  • The Card class should have a suit (Hearts, Diamonds, Clubs, Spades) and a value (A,2,3,4,5,6,7,8,9,10,J,Q,K)

For solutions to these exercises, click here.

When you're ready, move on to File I/O Introduction

Continue

Creative Commons License