Tuesday, October 25, 2011

Major Languages Used for Teaching and Working


According to Wesley Chun from Google,  the main languages used at Google for production work are:

  • C++
  • Java
  • Python
Main languages used for teaching children are:
  • scratch
  • Alice
  • Visual Basic
  • Python
In this video, Wesley Chun is using video to teach a class to children.  It gives an overview of Google App Engine.  There's also some examples of how Python is used at places like Google and Yahoo.  

for loops


I've been working with my student on for loops.  The concept is taking some time to fully understand.

I spent some of the day researching other teaching guides, including videos from the Khan Academy.

the main python.org site also has a nice list of learning material for beginners that are non-programmers.

The materials that I've looked at and like are:


Friday, October 21, 2011

pygame audio problems

Last night, my student was having problems loading differing audio formats into pygame.mixer.Sound("filename").  We tried mp3, ogg, and wav formats.  After researching this on the web, I found out that other people have this same problem.  I downloaded audacity and saved the audio files as .wav files, even the .wav files that I got from the Internet.  We got the sound to work on Mac OS X and Linux Ubuntu.

The pygame.mixer.music.load() and pygame.mixer.music.play modules seem to be more robust.  We've got Linkin Park playing as the background music.  I recently noticed that the song has explicity lyrics in it.  I need to get my student to change the music. 

Pyglet - Alternative to Pygame

I've been reading more about Pyglet, an alternative to Pygame based on OpenGL.  Although there seems to be more documentation around Pygame, it might be because Pyglet is newer.  From looking at the documentation, it doesn't seem like Pyglet support joysticks or gamepads.  Since, I've been planning to have the next project be a first person shooter with joystick support, I will probably stick with Pygame for now.

When I have more time, I plan to check out PyOpenGL and cocos2d.

Update Dec 2013: Check out this post on kivy.

Wednesday, October 19, 2011

Advanced Scratch - Build Your Own Blocks

BYOB, or Build Your Own Blocks, is an offshoot of Scratch.  There's more functionality than scratch.

Get a Gamepad Working with pygame.joystick

Since my 7th grade son loves to play Call of Duty 2 on the XBox 360, I've been thinking of incorporating the gamepad input device into his lessons.   

While I was going through the Panda3D manual, I found this reference to the Pygame joystick module.
"While Panda3D has mouse and keyboard support, it is best to look to the open source community for joystick support. Pygame is an open-source module that contains joystick support that may be easily included into a Panda3D application. Pygame may be found at http://www.pygame.org."

Since the Panda3D developers suggested that their community use the Pygame joystick module,I felt more confident that learning more about this module would be time well spent.  I already had a Logitech Rumblepad USB gamepad which I purchased a few years ago for my son to play Halo 2 on Windows Vista.  

I found a short tutorial here on the use of pygame.joystick.  

Using the tutorial as a reference, I created a lesson based on a screenshot of Call of Duty 2 as a background image in my Pygame window and a crosshair target that moves around the screen with the left thumbpad.  



Here's some example code.

 

Here's a video of a python / pygame shooter game working with a Rumblepad.  The game author is 13 years old.




Use Blender to Create 3D Objects

Since I gave my 7th grade student an introduction to 3D Python programming using Panda3D, I also reviewed the basics of Blender.  After the introduction, we moved back to focusing on 2D programming using Pygame.  I wasn't planning on going back to Blender for several months.  However, in the evening, my student mentioned that one of his friends from soccer was using Blender to model a 3D head for use in a 3D Java game he was developing.  My student's friend is a competitive 7th grader that loves talking about the virtues of Java compared to Python.  The friend quickly pointed out that although Panda3D wasn't a Java system, he was already working with 3D frameworks using the Java 3D classes.  Well, at least they have a common ground in Blender.

Scratch for Early Elementary Students

Scratch is a graphical IDE that lets children build programs by moving blocks around a screen.  I've been having a good experience with a first grade girl.  Scratch does require children to be able to read English words.  The system makes it easy to control graphics, sound, and keyboard input.  There's a fairly good subset of the features that my 7th grade student is getting with Pygame.  I've got it running both on Mac and Linux.  Scratch also works on Windows.  The biggest problem I've had so far is actually getting the student to manipulate, drag and drop, the icons from the toolbox into the main pane.  She's been using a trackpad on the teaching system and it's difficult right now for her to control it.  

Tuesday, October 18, 2011

Panda3D - Framework for 3D Games


Panda3D is an open source framework with Python APIs.  Children can get a taste for 3D programming.

The framework was developed by the Carnegie Mellon Entertainment Technology Center and Disney.  However, the Carnegie Mellon group is doing most or all of the development and promotion now.

There's a nice tutorial in the manual.

This package is more oriented to game programming compared to vPython.

My middle school student went through the tutorial in about an hour.  The panda walks.

I like the mission of the Carnegie Mellon Entertainment Technology Center:

To foster leadership in education and research that combines technology and fine arts to create new processes, tools, and vision for storytelling and entertainment.

Sunday, October 9, 2011

Bruce Eckel's Python Patterns

From this free book, by Bruce Eckel I also learned about code dojos.

https://bitbucket.org/BruceEckel/python-3-patterns-idioms

Tuesday, October 4, 2011

John Miller Dissertation on Python for Computer Literacy


This paper discusses why python is appropriate to use as a teaching language. It's fairly tedious to read it and pull out the gems.  The author meanders down different paths.

Here's a few things that caught my attention.


In a review of literature of teaching high school computer programming,
Taylor (1991) identified five interrelated steps taken in the creation of a
functional computer program:

  1. Problem definition 
  2. Algorithm design 
  3. Code writing
  4. Debugging
  5. Documentation

At this stage, I'm just working on Code writing.  Although I have much further to go with my student, I can see how the other steps such as Algorithm design might be useful.

Other things I want to think about more:

  • teaching the use of code templates
  • working in teams
  • planning before coding
  • writing code to be read by human beings in addition to the machine
Three types of programming knowledge:
  • syntactic
  • conceptual
  • strategic
The document gains some steam at page 69, section 2.2 Teaching Programming.


http://www.python.org/files/miller-dissertation.pdf

Pygame - Minimal Code For Screen Exercise

The minimal code required to set the screen up in pygame.  I've been trying to get my son to do this from memory.  This is a short repetitive exercise.  I like it because it uses a while loop and a for loop in addition to two ways of importing libraries.  It also gives a satisfying black window when it is run.  My student created five programs using this exact code, with the use of a printout of the code.  He ran each code to test it.  I was surprised that he seemed to enjoy the drill.  He ended up turning the printout over to try and do as much from memory as possible.    I intend to keep up with this drill and even created another drill with rectangles.





   1    import pygame, sys
   2    from pygame.locals import *
   3    
   4    pygame.init()
   5    pygame.display.set_mode((800, 600), 0, 32)
   6    
   7    while True:
   8        for event in pygame.event.get():
   9            if event.type == QUIT:
  10                pygame.quit()
  11                sys.exit()
  12        pygame.display.update()




Monday, October 3, 2011

Random Triggers for Falling Objects

I spent an hour tonight working with

time.time()

from the time module to create a timer for the game.  I'm using the elapsed time and a random number as the trigger to get the fish to drop a bomb.

The random number is generated with

random.randint(1, 8)


This was a bit more involved than I had anticipated.  I got the clock to work by creating a clock object and a gameClock function.  I then passed the clock object to the gameClock for updating.  The program is getting increasingly difficult to manage.  However, the playability is getting better.

In the original version, I used a random number that I stored in bomb.trigger and the bomb.rect.centerx value.  The end result is the same so far.  However, it's easier to change the frequency of the bomb drops using time.  I can simply shorten the time delay to cause the bombs to drop more frequently.

Wednesday, September 28, 2011

Scripting Language Versus Compiled Language

After reviewing some of the basic slides that John Zelle put up about Teaching Computer Science with Python, my student asked me what a scripting language was.  I compared Python to C and then threw in Java, a byte compiled language, to round out the comparison.

Program in C.

/* Hello World program */
#include<stdio.h>
main()

{   

printf("Hello World");


}

 Since we're on a Mac, the command in the terminal is:

gcc -o helloworld helloworld.c

Program in Java

class HelloWorldApp{     
public static void main(String[] args) {         
System.out.println("Hello World!"); // Display the string.    

}

}
byte compile the Java code:
javac HelloWorldApp.java

Run it:
java HelloWorldApp
Python

print ("Hello World")




Tuesday, September 27, 2011

Visual Python


I've been working with my son to develop 3D objects with VPython.  It's super cool and really rewarding.

This is the entire program for the green cylinder above:

from visual import *
rod = cylinder(radius= 1)
rod.green = .9
rod.red = 0
rod.blue = 0
It will also work with just this:
from visual import *

cylinder()


Awesome set of videos on learning to use visual python.

The only tricky part was that the visual library only worked with 32 bit Python.  Since I'm on Mac OS X, Snow Leopard, I had a 64 bit version of Python 2.7 installed.  I'm using a 32 bit version of Python 3.1 on the Mac in order to run visual.

You can find out what the architecture is with this:

>>> import platform

>>> platform.architecture()

('32bit', '')

>>> 


John Zelle and Python Programming: An Introduction to Computer Science




More awesomeness from John Zelle - found his slides for  Python Programming: An Introduction to Computer Science, 2nd Edition.

The book is great and the slides were a really nice find.  In addition to the slides for individual chapters to the book, the slides from SIGCSE 2003 were also incredible.