At My Fingertips
In this activity we will compose a chessboard like this one:
Let's first start focusing on the text notation that identifies the cells.
Implement the following letter_row
function, so that it returns a graphic representing the horizontal " a b c d e f g " notation for the chessboard.
Notice that you also want to add empty square corners on the sides of the "a" and the "g" squares.
square_size
parameter indicates the size of each square in the chessboardtop
parameter is a boolean value: True
if the row should go on top of the chessboard, False
if it should go on the bottom.Use the given TEXT_COLOR
color for the color of the text and the TEXT_BACKGORUND
color for the background brown color. Use "Fira Sans" as the font.
Let's check how your implementation of the letter_row
function behaves:
Now let's implement the number_col
function that generates the vertical "1 2 3 4 5 6 7 8" notation.
square_size
parameter indicates the size of each square in the chessboardleft
parameter is a boolean value: True
if the notation should go on the left side of the chessboard, False
if it should go on the rightUse the given TEXT_COLOR
color for the color of the text and the TEXT_BACKGORUND
color for the background brown color.
Let's check how your implementation of the the number_col
function behaves:
Let's now focus on the central piece of the graphic: the actual chessboard.
Implement the chessboard_body
function so that it returns a chessboard with squares of the given square_width
.
Use the given WHITE
color for the bright tiles and the given BLACK
color for the dark tiles.
The chessboard should have a bright tile on the top left and on the bottom right to be oriented correctly.
Finally, let's combine all the solutions together to implement the chessboard
function! The function should return a chessboard surrounded by letter and number notations on all sides.
Use the letter_row
, number_col
and chessboard_body
functions in your chessboard
function.
This activity has been created by LuCE Research Lab and is licensed under CC BY-SA 4.0.
Chessboard
PyTamaro is a project created by the Lugano Computing Education Research Lab at the Software Institute of USI
Privacy Policy • Platform Version b744b47 (Tue, 08 Oct 2024 16:30:14 GMT)