Vocabulary
Fill in the Blank
Debugging
Methods and Constructors
Inheritance
100

This word represents the characteristics or properties of an object.

attribute

100

_______ Bicycle():

     def __init__(self, myMake):

          self.make = myMake

class

100

class Soda():

     def __init__(self, myBrand, myFlavor, myPrice):

          self.brand = myBrand

          self.flavor= myFlavor

          self.price= myPrice

soda1 = Soda()

When making the object, it needs arguments.

ex.: soda1 = Soda("Coke", "Cherry", 2.99)

100

What is the first parameter of all methods?

self

100

What is the function used to call a parent class?

super()

200

A code template or "blueprint" used to create objects.

class

200

class Person():

     def __init__(self, myName, myAge):

          self.name= myName

          self.age = myAge

dude = ________("Joey", 13)

Person

200

class Pet():

     def __init__(self, mySpecies, myName):

          self.species = mySpecies

          self.name = myName

     def printInfo(self):

          print("Species:", self.species)

          print("Name:", self.name)

fido = Pet("dog", "Fido")

print(fido)

You don't want to print an object directly. Instead, use the printInfo() method:

fido.printInfo()

200
What name do all constructors have?

__init__

200

A _________ class is more general, while a ________ class is more specific.

parent; child

300

One specific instance of a class.

Object

300

class Vehicle():

     def __init__(self, myColor, myModel):

          _______.color = myColor

          _______.model = myModel

self

300

class Player():

     def __init__(self, myX, myY):

          self.x= myX

          self.y= myY

          self.score= 0

player1 = Player(100, 200, 0)

A player is constructed with only the x and y as attributes; the points do not need to be specified as that is already done inside the body of the constructor. Should be:

player1 = Player(100, 200)

300

A method is a __________ that is placed inside a _________.

function; class

300

What happens if a method is defined in the parent class but not in the child class?

The child class inherits the method automatically without any changes.

400

This word describes the ability of one class to acquire all the attributes and methods of another class.

Inheritance

400

class Pet():

     def __init__(self, mySpecies, myName):

          self.species = mySpecies

          self.name = myName

     def changeName(_______________):

          self.name = newName

self, newName

400

class Animal():

     def __init__(self, myName):

          self.name = myName

     def growl(self):

          print("Grrr.... says", myName)

myName is a parameter in the constructor, not growl(). It should use self.name instead.

400

Write a method, called ageUp that increases an attribute called age by 1.

def ageUp(self):

    self.age += 1

400

What is it called when a child class executes its own version of a method rather than the one in the parent class. 

Overriding a method

500

What do we call the period in between an object and an attribute or method, such as:

self.name

Dot operator
500

class Animal():

     def __init__(self, myName):

          self.name = myName

     def growl(self):

          print("Grrr.... says", myName)

______________ #creates an Animal named Fido

______________ #makes Fido growl

fido = Animal("Fido")

fido.growl()

500

class Animal():

     def __init__(self, myName):

          self.name = myName

class Cat():

     def __init__(self, myName, myBreed):

          super().__init__(myName)

          self.breed = myBreed

The parent class is never indicated. Should be:

class Cat(Animal):

500

Write a constructor to be placed in a Coin class. The Coin should have three attributes (x, y, and points). A Coin can start at any (x, y) position, but should ALWAYS start with 5 points when created.

def __init__(self, myX, myY):

     self.x = myX

     self.y = myY

     self.points = 0

500

What is the purpose of inheritance?

To allow child classes to reuse, extend, or customize functionality from a parent class without rewriting code.