Let Us Just Dive Right In

Get a taste of Python code.

Let art meet computing

An artist only needs a drawing board, some colors, and a little bit of creative imagination.

Press + to interact
Our drawing board with nine rows and nine columns
Our drawing board with nine rows and nine columns

Let’s create a drawing board with one line of Python code. Click the “Run” button below to see what is created.

Press + to interact
board.draw()

Since we have a board now, let’s add colors to it.

Press + to interact
board.draw()
board.color(1 ,1 ,"red")
board.color(1, 9, "black")

In the third line of the code, board.color(1, 9, "black"), 1 represents the row number, and 9 represents the column number, which needs to be colored black. The complete code draws two squares on the board. One square is red, and the other is black. We can surely add another.

Let’s say we want to draw another square, this time on the 9th row and 9th column, and we want it to be in green color. We know you guessed it already; we’d have to add another line of Python code. Why don’t we add board.color(9, 9, "green") in the code widget below?

Press + to interact
board.draw()
board.color(1 ,1 ,"red")
board.color(1, 9, "black")

A smiley emoji

If we know how to draw one little square, eventually, we can draw anything on this 9 × 9 drawing board. How about the following smiley emoji?

Press + to interact
Pixelated smiley
Pixelated smiley

We’ve written the following code in Python that aims to pull this off. Run the code once to see the output of the code. Your challenge will be to fix the eyes and teeth of the emoji and make it smile again.

Press + to interact
board.draw()
board.color(2, 7, "black")
board.color(5, 2, "black")
board.color(6, 3, "black")
board.color(7, 4, "black")
board.color(7, 6, "black")
board.color(6, 7, "black")
board.color(5, 8, "black")

The aftertaste

Here’s what we have gathered from the lesson:

The computer is a very efficient machine. Nevertheless, it is the coder’s job to use the right language and the right instructions to make them do something useful or creative for us. That is why we learn how to code!