Mastering Python Basics: Unlocking the Power of Static Methods

The GardenOfEden class defines the garden, including the presence of the forbidden tree.
The static attribute forbidden_tree_present determines whether the forbidden tree exists in the garden or not.
The eat_forbidden_fruit static method checks the value of forbidden_tree_present and prints a message accordingly, simulating the action of eating the forbidden fruit.
By changing the value of forbidden_tree_present, we can control the behavior of the eat_forbidden_fruit method, simulating the presence or absence of the forbidden tree in the garden.

Пікірлер