Skip to content. | Skip to navigation

Personal tools

Python

Tuesday, June 21

Plan

Diablo Valley College is having severe network problems, so the kids' computers are unusable today.

Dave shows his Roomba, the robotic vacuum cleaner

Is it a computer?

Discussion of programming

What decisions? State? Loops?


Animusic, play tracks from DVD

How was this done? What programming is involved


Kids introduce selves, talk about programming experience


Program demos

Teaching assistants

Chris

Ian

Mine (source in DBSchools project on sourceforge.net)

Math quiz multiplayer game

others (see Java Run dialog)

Run python client to connect to Java server


Introduction to Python (Python class)


Reflection

We watched a Roomba robotic vacuum cleaner and talked about how it works--what kind of programming it must contain.


We discussed how big time commercial games take many talented people a long time to develop, and how though we will learn a lot in our short time together, we mustn't expect to create a game of commercial quality--or anywhere near it.


Despite the college's network troubles, we did manage to get started with Python. We learned how to start IDLE (the application we use to create our Python programs) and to enter simple statements to create and change variables. We looked at some sample pygame (www.pygame.org) programs.


Wednesday, June 22

Plan

Presentation: Introduction to programming, demonstration of some Python programs, using IDLE in interactive mode
Lab: Starting and using IDLE

Presentation: setting variables and displaying their values (integers, reals, strings)

a=1
a
b=2
a+b
print a+b
d=7.5
name='Dave'

Lab: Practice creating and manipulating variables

Presentation: Guessing game program
Lab: Open, examine, and run the program
QuickQuiz: How the guessing game program works

Presentation: Creating a program in a .py file on the file server
Lab: Create a folder with your name in class files\dave\python, and put a program there, l1-1.py. The program should have a single statement:
print 'Hello, world'

Presentation: Prompting for different types of input

name = raw_input('What is your name? ')
health = input('Enter health value: ')
dist = input('Enter distance: ')

Lab: Practice prompting for input. Create a program, l1-2.py, which shows that you can prompt for input and then do something with it (display it, use it in a formula, etc.)
   

Reflection

We reviewed creating and displaying simple variables from within the interpreter. Then we learned to create, save and run a new program. We created a guessing game program (see another announcement for the code), which taught us about variables, loops, random numbers, and conditional statements.


Thursday, June 23

Plan

Continue Lesson from Wednesday
Assignment: create a program which asks questions and then does different things depending on what the answers are (input, raw_input, if).

Reflection

I reviewed print, input and if. Kids made a variety of questionaire-style games using input, raw_input, print, and if. Some learned to use ranges of numeric values.


Tuesday, June 28

Plan

Remember the old game Madlibs? We will do something inspired by that:

The program has lists of nouns, adjectives, adverbs and verbs. It produces a story by inserting random choices form the lists at key places. For example:

One day a [adjective] [noun] came to our home. My dad opened the door [adverb]. We were all surprised when the visitor asked if it could [verb].

Get the idea?


Reflection

We learned how to create lists of words, like:
nouns = ['Cat', 'House', 'Flower']

and how to randomly choose with:
from random import choice
choice(nouns)

and how to make a sentence:
print 'We opened the door and saw a ' + choice(nouns) + '.'

Kids added another part of speech and made a variety of interesting programs.


Wednesday, June 29

Plan

Simple graphics using John Zelle's graphics module.

Reflection


Having the kids download the graphics.py module and save it in the right directory turned to be more of an ordeal than I expected. It took probably ten minutes, instead of the one or two that I expected. Once that was done we made steady progress, creating circles, points and lines. I showed how to make a loop to generate a lot of circles and points, the points at random locations.

Thursday, June 30

Plan

Getting started with Pygame

Reflection

The kids went to pygame.org and explored, and ran and made simple modifications to the pygame examples. Some commented that they were impressed by some of the games they saw on pygame.org. I showed the bouncing ball example from pygame.org and explained parts of it. I asked them to play with it and see if they could figure out how to change sizes, speed and colors, and to put in their own graphic. Many did very well, and nearly all learned some new things.


Tuesday, July 5

Plan


Let's take a look at Squeak, for a little "cross training."

Unstructured student exploration: python.org, pygame.org, example pygame programs. Students find what interests them most.

Reflection


We learned some beginning Squeak concepts and skills. I think it was good for the kids not on the Squeak class, but perhaps not the best use of time for those already in it. Kids found and learned about some interesting games written in Python with Pygame.

We found that Diablo Valley College is now censoring students' view of the Internet, and has blocked access to many of the games we want to study. (We found it a modest challenge to route around the censorship.) I explained to the kids how people who abuse the system (college kids who just play games, while others who want to write a paper or a computer program wait for access, for example), cause hassles for legitimate users of the system (my class of kids learning to program games, in this case), who must jump through hoops to get their work done.


Wednesday, July 6

Plan

After exploring Pygame a bit yesterday, today we'll step back to something simple and manageable, and write a little math problems game combined with a simple graphic that illustrates the player's progress in the game.

Topics: random numbers, graphics.py GraphWin, Circle, draw, move, formatting text strings (%), while, if

Reflection


This was generally sucessful, although we didn't get as far as the graphical part of the game. We got bogged down a bit in: print "You have %d ice cream cones. " % (5)

Thursday, July 7

Plan

Test: Write one or more programs that use as many of the following language features as you can, and show them to Dave or a TA. You may use your notes, python.org, the help in Idle, and dbschools.com as resources. You must work alone. If your parents are with you, you may quietly describe what you're doing (don't give anything away to the people sitting next to you), but they may not help you.

print
if
variables
input, raw_input
lists
random.choice, random.randrange
GraphWin, Circle

Math quiz game lesson, continued

Reflection


Several students did very well on the test, most met some of the objectives, some just a few, and one none. I didn't tell the kids there would be a test, or ask them to study, but hoped they would remember or at least have taken notes or be able to find answers in my online notes or other online resources. Perhaps I need to require everyone to take notes (check for a notebook at the beginning of every class).

I continued the math quiz game lesson, by adding a little ball that rises with the correct answers, and falls with incorrect ones. One student and one parent showed the ability to multiple 1-digit by 2-digit numbers in their heads.

It is my sense that nearly all of the kids found the class fun and useful. For a few I think it really sparked an interest. Some have asked me about other classes, so their kids can continue.