Game Instructions

Tap a tile to toggle its color. When a tile changes nearby tiles may change as well. Each move affect multiple tiles. The target is to turn all tiles into yellow in the fewest steps possible.

Press 'j' to show/hide the game. Press 'i' to show/hide the instructions. Press 't' to show/hide the top score table.

Steps: 0

Top Scores

Name Steps
Press J to toggle the game, I to toggle instructions, and T to toggle the top scores

Congratulations!

You solved the puzzle in 0 steps!

Success!

Score submitted successfully!

Error

Failed to submit score. Please try again.

Private Attributes in Python

Python allows us to define private attributes in our class (private instance variables). Outside the scope of the class it won’t be possible to access them. In order to create private attributes we should prefix their names with two underscores (‘__’).

class Rectangle:
    def __init__(self,w=10,h=10):
        self.__width = w
        self.__height = h
    def area(self):
        return self.__width*self.__height

ob = Rectangle(3,4)
print(ob.area())
ob.__width = 10
print(ob.area())

The following video clip overviews this code sample and explains it step by step.

Share:

The Beauty of Code

Coding is Art! Developing Code That Works is Simple. Develop Code with Style is a Challenge!

Update cookies preferences