214 Creating objects from a class
What does the term instantiation mean in object-oriented programming?
In the LightSwitch example, what does
oLightSwitch = LightSwitch()do?
Explain the difference between a class and an object using the
LightSwitchexample.
Write a Python line of code that creates a third LightSwitch object called
oLightSwitch3.
If
oLightSwitch1andoLightSwitch2are both instances of LightSwitch, what happens tooLightSwitch2.switchIsOnwhen you calloLightSwitch1.turnOn()?
Look at this code and predict what will be printed:
Write a short code snippet that creates two
LightSwitchobjects, turns one on, and prints the state of both.
Last updated
Was this helpful?