Creating an Instance of a Class in Python

How can you create an instance of the pet class in Python?

Which line of code will correctly create an instance of the pet class as defined below?

class pet:
def __init__(self,strSpecies,strName):
self.species = strSpecies
self.petName = strName

A) myPetA = pet('dog', 'Spot')

B) myPetA = pet(self, 'dog', 'Spot')

C) myPetA = new pet('dog', 'Spot')

D) myPetA .pet() = 'dog', 'Spot'

Answer:

myPetA = pet(self, 'dog', 'Spot')

The correct line of code that will create an instance of the pet class is myPetA = pet(self, 'dog', 'Spot'). Option B is correct.

← Boot a cisco ios 2900 series router in rom monitor mode Keeping your film emulation clean removing silver halide crystals →