What is the scope of each variable?

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

def __str__(self):
return self.species + " named " + self.petName

class petCarrier:
size = 'medium'
color = 'red'

The scope of petName is
.

The scope of color is
.

Answer :

Answer:

scope of pet name is limited to pet class and color is accessible to the whole program

Explanation:

Answer:

The scope of petName is local to the class pet.

The scope of color is accessible by all parts of the program.

Explanation:

The variable petName is local to the class, because the variable was created in a function whose name begins with two underscores.

The variable color, while created in the petCarrier class, is accessible to the entire function. It was not created in a function whose name begins with an underscore.

Correct answer edge 2020

Other Questions