Share
Embed
I was a teacher for a month
I taught programming to children for a month. I loved the experience, and also learnt a few things from it.
Bonus: what tools exists nowadays to assist both teachers and newcomers? (with a Ruby bias, as this was presented before a Ruby meetup).
Video available at http://skillsmatter.com/podcast/home/lrug-pablo-basero-moreno
Pablo Brasero
March 11, 2013
Transcript
37 slides
-
1 I was a teacher for a month LRUG 11
March 2013 Pablo Brasero Moreno (Google me up: pablobm) -
2 What was it that I did exactly? • Organised
by Yali Sassoon @yalisassoon • I signed up to spend 5 afternoons teaching programming to children – Weekly lessons – Ages 13-18 – Ended up being 4 lessons only • Burlington Danes school, Hammersmith • Sessions about 1:30 hours – Actually varied a depending on the willpower of the students -
3 Was this volunteer work? Well, not technically thx New
Bamboo for sending me to the school <3<3<3 xxx -
4 What we did and learned • What tools did
we use? • What was the format of the lessons? • How receptive were the students? • What was more difficult for them? • What technologies exist for this task? -
5 What tools did we use? Python Pygame Yes, Python.
I know this is LRUG I'll get to Ruby later Yes, Python. I know this is LRUG I'll get to Ruby later -
6 Why Python? • Clear and explicit – "There should
be one—and preferably only one— obvious way to do it" • Relatively easy to install and use on Windows – Install Python. Install Pygame. Done – You get items in the startup menu and all • Free and open source • Many resources on the web for it, for all levels -
7 What was the format of the lessons? • No
introductory lecture – Tried to avoid boring “lecture” format • Got them in front of computers from the start – 1-3 children per computer • Gave them an exercise sheet with some very simple programs • We walked around, answering questions and generally helping out -
8 This was a classroom setting • Audience was a
classroom of teenagers • Varying ages and experiences with computers • Varying degrees of interest • Not the same as teaching your own children in a one-to-one setting • My total experience in the field is 4 lessons – Call it 7 hours -
9 So for example fahrenheit = ⏎ raw_input("Enter a temperature
in ⏎ Fahrenheit degrees: ") celsius = ⏎ (float(fahrenheit) - 32) * 5 / 9 print "The temperature ⏎ in Celsius is", celsius -
10 One step further temp = raw_input("Enter a temperature: ")
unit = raw_input("What is the unit ⏎ of temperature?: ") if unit == 'f': result = (float(temp) - 32) * 5 / 9 else: result = float(temp)*9/5+32 print "The converted temperature is", ⏎ result -
11 One step further temp = raw_input("Enter a temperature: ")
unit = raw_input("What is the unit ⏎ of temperature?: ") if unit == 'f': result = (float(temp) - 32) * 5 / 9 else: result = float(temp)*9/5+32 print "The converted temperature is", ⏎ result First contact with if/else. They need to crash into it in order to really understand it. -
12 One step further temp = raw_input("Enter a temperature: ")
unit = raw_input("What is the unit ⏎ of temperature?: ") if unit == 'f': result = (float(temp) - 32) * 5 / 9 else: result = float(temp)*9/5+32 print "The converted temperature is", ⏎ result The equality operator -
13 One step further temp = raw_input("Enter a temperature: ")
unit = raw_input("What is the unit ⏎ of temperature?: ") if unit == 'f': result = (float(temp) - 32) * 5 / 9 else: result = float(temp)*9/5+32 print "The converted temperature is", ⏎ result “f” != “ f” -
14 One step further temp = raw_input("Enter a temperature: ")
unit = raw_input("What is the unit ⏎ of temperature?: ") if unit == 'f': result = (float(temp) - 32) * 5 / 9 else: result = float(temp)*9/5+32 print "The converted temperature is", ⏎ result Proceeding from the previous exercise, this will remain called “fahrenheit”, introducing confusion -
16 Day 1 postmortem • Difficult and frustrating to students
• They want to build something fun – ie: games, not silly command line programs • We needed something more compelling – this meant we needed a program with graphics • Enter Pygame -
17 Presentation warning • Three pages three of code follow
• I'll try to make as painless as possible • This is just for some context! – Don't exert yourselves much – Just get the gist • But first: demo time! -
18 import pygame pygame.init() pygame.key.set_repeat(1, 50) screen = pygame.display.set_mode([640, 640])
circle_x = 320 circle_y = 320 font = pygame.font.Font(None, 50) message = font.render("", 1, (0,0,0)) # Main loop follows → Set up -
19 keep_running = True while keep_running: # (…) Event handling
would go here (…) screen.fill([255, 255, 255]) pygame.draw.circle( screen, [0,0,0], [circle_x, circle_y], 20) screen.blit(message, [10, 10]) pygame.display.flip() pygame.display.quit() Main loop -
20 Event handling for event in pygame.event.get(): if event.type ==
pygame.QUIT: keep_running = False if event.type == pygame.KEYDOWN: if event.key == pygame.K_LEFT: circle_x -= 5 # (…) Ditto for right, up and down (…) key_name = pygame.key.name(event.key) text = 'You pressed the key "' ⏎ + key_name + '"' message = font.render(text, 1, (0,0,0)) -
21 Things that can be done • Don't let the
circle disappear offscreen • Add additional objects to make for other elements of a game • Change colours or shapes of the objects • Detect collisions • Draw a star field -
22 Execution in sequence screen.fill([255, 255, 255]) pygame.draw.circle( screen, [0,0,0],
[circle_x, circle_y], 20) screen.blit(message, [10, 10]) pygame.display.flip() -
23 Code blocks for event in pygame.event.get(): if event.type ==
pygame.QUIT: keep_running = False if event.type == pygame.KEYDOWN: if event.key == pygame.K_LEFT: circle_x -= 5 -
24 Physics if event.key == pygame.K_LEFT: circle_x -= 5 if
event.key == pygame.K_RIGHT: circle_x += 5 if event.key == pygame.K_UP: circle_y -= 5 if event.key == pygame.K_DOWN: circle_y += 5 -
25 And more... • Programs start getting large – Functions
• How to handle several similar objects? – Arrays (requires good understanding of loops) • How to do something that hasn't been specifically addressed? – The Noble Art Of Looking Up For Documentation – You don't need a programming language, you need the language of programming • Ditto for interpreting errors -
26 Thus ended the 4 sessions • This is not
for everyone – Some students didn't get what they expected – And that's just fine • Some students really enjoyed it! – We got a relatively advanced working game – Without arrays, objects or functions! • And of course we as teachers can improve -
28 Python + Pygame • Easy to install on Windows
• Provides full environment (IDLE) – Editor, language shell and “run” command • “Real” tool. You can get quite far just with these • It's even possible to create executables – Not trivial though -
29 Ruby alternatives to Pygame? • Installing Ruby on Windows
is not trivial • Provide your own text editor • Requires use of the console Yes, but... -
30 Rubygame • Directly inspired by Pygame • Project “in
hibernation indefinitely” • Mailing list somewhat alive (not much) -
31 • https://github.com/jlnr/gosu • Ruby and C++ library • Active
forums and updated tutorials • Possible to create executables • Also see http://ruby4kids.com/ – Independent effort that uses Gosu – Not very active nowadays – Offers screencasts and other resources – Demo time! -
32 require 'gosu' class GameWindow < Gosu::Window def initialize super
640, 480, false self.caption = "Gosu Tutorial Game" end def update; end def draw; end end GameWindow.new.show -
33 • Created by _why • Self-contained environment • Built
using Shoes – a simple GUI toolkit also by _why • Three modules 1.Basic programing with a Turtle-type DSL 2.Basic Ruby 3.Basic Shoes • Conceived with a social element • Demo time! -
34 Hackety Hack cons • Very short • Buggy... and
_why is not with us anymore to fix it :-( • Website “social” area also abandoned • A successor appeared, http://kidsruby.com, but has similar problems -
35 Hope for Hackety Hack • There is an active
effort to revive Shoes • And then Hackety Hack with it Check out http://shoesrb.com/ -
36 Scratch • Language and environment created at MIT •
Programs are “written” using a graphical interface • Programs can be published as Flash apps • Social factor with very active community • Used by http://www.codeclub.org.uk/ • Final demo time! -
37 That's enough for now! Thanks Pablo Brasero Moreno (Google
me up: pablobm)