Sunday, March 2, 2014

First Week of Python for 9 Year Old Girl

My 9 year old daughter is on day 7 of her Python learning experiment. The classes are going extremely well. Her typing is still the biggest obstacle, especially when she tries to hit ( ) with the correct fingers. The = sign is also a bit of an issue.
I reviewed lesson 2, drill 1 with her tonight. She’s completed 5 drills from lesson 1, which means that I had her start from a blank screen five times and type the same code in. It’s been smooth. I’m surprised.
Since lesson 2 is almost the same as lesson 1, she’s typed basically the same code in six times. I keep waiting for her to get bored. It hasn’t happened yet. She seems strangely interested in the IDE, mouse and keyboard.
She wanted to extend lesson 2 with different colored rectangles. In order to generate the colors, she used an online color generator. I’ve since installed both Gpick and Gcolor2 to allow her to pick the colors from the desktop.
import pygame,sys

pygame.init()

size = (480, 320)
screen = pygame.display.set_mode(size)

RED = (255,0, 0)
GREEN = (0, 200, 0)
PURPLE = (157, 0, 254)
player_rect = pygame.Rect(150, 160, 80, 80)
r = pygame.Rect(10, 160, 80, 80)
r2 = pygame.Rect(300, 160, 80, 80)


while True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
            sys.exit()

    pygame.draw.rect(screen, GREEN, player_rect)
    pygame.draw.rect(screen, RED, r)
    pygame.draw.rect(screen, PURPLE,r2)
    pygame.display.update()

No comments:

Post a Comment