Course Home

Video Lessons

Related Links

Online Development




Bits and Blocks Level 2: Logo to Python

  • For students completing grades 4-6. Middle school students may also apply.
  • Course Description:
  • In this course, students build computer games with a programming language that is used daily to drive the Google search engine, YouTube and applications at NASA and the New York Stock Exchange. This course builds on programming experience that students have already developed by building games in MicroWorlds with the Logo programming language. In the previous Bits and Blocks course, students built games using the predefined classes and simplified framework of the MicroWorlds development environment. In this course, students will learn to build classes from scratch as they develop their own game engine. This understanding of object-oriented programming will serve them in further Python development and can readily be applied to other object-oriented languages like Java and Objective-C.
  • Note: Additional $120 lab fee is required.
  • Course number 38
  • Requirements:
    Prerequisite: Successful completion of Bits & Blocks course or equivalent
    Admission Criteria: ≥ 95% national percentile rank in math on standardized achievement test; EXPLORE test; or Admission Portfolio.
  • Course Dates: July 21, 2013 August 9, 2013
  • Location: Evanston Campus
  • view syllabus

Course Formats

In addition to whole class, small group and one-on-one discussions, lessons are delivered in a range of online formats to support independent study and differentiate instruction based on your needs.

  • Video Lessons on various topics
  • Readings with problem-solving tips
  • Examples of solutions to sample problems in text and MicroWorlds project formats
  • Problems for you to solve, with solutions
  • Study Material for Exams with solutions
  • Support Material for Project Development including online documents and sample projects
  • iGoogle Accounts for communicating your reflections, questions and concerns about the course and its content, and receiving help
  • Course workspace with more details on course requirements

Python in Your Browser

For this course, we will use a web-based development environment for our work with Python. This environment is called CodeSkulptor. It runs on recent versions of Chrome, Firefox and Safari browsers (sorry, it does not work with Internet Explorer). Python support in this environment is slightly different from standard support, and not all Python libraries have been implemented in CodeSkulptor. However, CodeSkulptor does supply all the support needed for the development of cool games as well as support for porting games developed in CodeSkulptor to more traditional Python development environments and libraries (like Pygame).

Logo and Python

Logo and Python are two of the computer programming languages taught at the Center for Talent Development. Since its inception in the 1960s, Logo has been used primarily as a learning tool for elementary school children. However, it has many powerful capabilities that make it suitable for use in advanced mathematics and computer science courses, and has been used for these purposes at high school, undergraduate and graduate levels.

Python is used daily to drive the Google search engine, YouTube and applications at NASA and the New York Stock Exchange. In the previous Bits and Blocks course, you built games using the predefined classes and simplified framework of the MicroWorlds development environment. In this course, you will learn to build classes from scratch as they develop their own game engine. This understanding of object-oriented programming will serve them in further Python development and can readily be applied to other object-oriented languages like Java and Objective-C.

On this page, I'm writing up comparisons between Logo and Python to help Logo programmers make the move to Python.

The learning objectives of the course are guided by the documents Computing Curricula 2001: Computer and Computer Science Curriculum 2008: An Interim Revision of CS 2001, from the Joint Task Force on Computing Curricula. The Computing Curricula volumes are developed jointly by the ACM and IEEE Computer Society on cycles of about 10 years. Work on the next volume, Computer Science 2013, began in 2010.

This page does not include anything about software development methodologies like agile or design patterns or refactoring or any of that stuff. That will come at another time on another page.

Learning Objectives

  • Data models
  • Control structures
  • Order of execution
  • Encapsulation
  • Relationships among encapsulated components
  • Testing and debugging
  • Programming languages and paradigms
  • Tools (compilers, editors, debuggers)

Classroom Activities

Before diving into the content, I want to be clear that the classroom activities will continue to revolve around student interest, as they did in the first Bits and Blocks course. Most of this content is taught in the context of project work because it's stuff kids need to know in order to build cool projects. Some content is also shared in short lessons, videos and online readings. Kids have a lot of fun in my classes. They also learn a lot and are proud of the projects they build.

Not all of the content below will be covered in the course. I always plan for more content than I can possibly include in a single course because I want to make sure everybody gets their fill. Not all kids will receive all of the same content

In other words, this is an explanation of the nutritional value of the class, not its flavor.

MicroWorlds and CodeSkulptor

Computers languages are used to translate human ideas into machine actions. Part of this translation is done by people. We have an idea of something we want the computer to do, and we write a program to tell the computer how and when to do it.

The other part of the translation is done by the computer. The computer takes the program we've written and tries to translate it into machine code that it knows how to execute. Both of these tasks are aided by programming environments.

MicroWorlds and CodeSkulptor are programming environments used in Bits and Blocks Level 2. MicroWorlds was made to support Logo programming. CodeSkulptor supports programming in Python. They both give programmers a window that shows what happens when the program is run. In MicroWorlds, this is called the Main Window. There is no graphics display area built into CodeSkulptor. Instead, programmers must create and show windows themselves.

In MicroWorlds, programmers can place backgrounds, turtles, text boxes and other objects on the Main Window by using the tool bar. CodeSkulptor does not provide this facility. However, both MicroWorlds and CodeSkulptor allow programmers to create objects automatically.

Both MicroWorlds and CodeSkulptor have areas where programmers can write their programs. In MicroWorlds, programs are written in Procedure tabs for the project and for individual turtles. In CodeSkulptor, programs are written in the Editor.

In CodeSkulptor, the work of the MicroWorlds Command Center is shared by the Editor and the Console area. As mentioned above, the Editor is the area where you write programs. In this way, it is like the Procedures tabs. However, you can also write instructions in the Editor and run them directly the way you do in the MicroWorlds Command Center.

However, MicroWorlds uses the Command Center for message to and from the environment. For example, if you send MicroWorlds a show command from the Command Center, a word or list is written to the Command Center. Error messages are also written to the Command Center. In CodeSkulptor, message to the environment are written in the Editor, while message from the environment are written to the Console area.

Objects and Classes

In computer programming, an object is something that stores information and knows how to do certain things. A class of objects is a group of objects that all store the same kind of information and know how to do the same kinds of things. Whenever we create a new object of a certain class, we say that we have created an instance of that class.

A turtle in Logo might be considered an object. We can ask any turtle for information about itself, or change that information. For example, we can use procedures like heading or pos to tell us which way the turtle is pointing and where it located on the screen, and we can use setheading and setpos to change its heading and position. In addition to knowing certain things about itself, there are certain actions that the turtle knows how to perform. For example, a turtle can turn right or left and move forward or backward in the direction it is facing.

Most modern versions of Logo allow programmers to create multiple turtles. Each turtle may have a different heading and position, but each turtle keeps track of its heading and position, and each turtle knows how to move forward and backward and turn right or left. Every time you add a new turtle to your main window in MicroWorlds (using the tool bar or the newturtle procedure), you are creating a new instance of the turtle class.

A Logo procedure that has already been written for you (like forward, or pos) is called a primitive. A class that has already been written for you is a predefined class. Turtles in Logo are something like a predefined class.

In addition to turtles, MicroWorlds provides text boxes, buttons and other things that you can add to your main window with your mouse or using the commands newtext, newbutton, newcheckbox, newdropdown, newlistbox, newpage, newroundbuttonset, or newslider. Whenever you create one of these objects, it is automatically given a name such as "t1 for turtles, "text1 for text boxes and so on, and you can give these objects a name of your choice. These object names allow you to give commands or get information from particular objects.

You can write your Python code in a functional way, like you do with Logo, or you can write classes and subclasses. A subclass is a class that inherits data fields and behavior from another class. This allows procedure in Python to be associated with a particular object or a particular class.

For example, suppose you had a Python class named Turtle that had data fields for heading, position, and size. This Turtle class also includes procedures like forward and right. Let's say we also have a method called defend that tells the turtle to pull in its head, tail and legs.

Now suppose we want some of our turtles to be snapping turtles. Snapping turtles can't fit their whole bodies inside their shells, so they snap at their enemies instead. In Python, we could create a subclass called SnappingTurtle. As a subclass of Turtle, any instance of SnappingTurtle would inherit all the data fields of a Turtle (heading, position and size) and all the behaviors of a Turtle (like forward and right).

We could also overwrite the Python class's defend method by writing a new defend method for the SnappingTurtle subclass that makes it snap at an enemy instead of pulling into its shell.

Now, when a turtle is under attack, we don't need to think about what kind of turtle it is. We can just invoke the defend method. If it's regular Turtle, it knows it should pull into its shell. If it's a SnappingTurtle, it knows it should snap.

In MicroWorlds, we can do something like subclassing by using private procedures in a turtle's backpack or using turtle variables to decide what kind of turtle we're talking to, but as we'll see, this kind of subclassing is quite limited compared to that available in a fully object-oriented programming language like Python.

Another level of organization in Python is the module. Modules can contain classes and their functions or just a bunch of functions that are not associated with any particular class. The Pygame modules contain a great set of classes for game developers.

Procedures and Functions

Topics for this content area include the following:

MicroWorlds Logo Python
Procedure definition Function definitions
Invoking a procedure Function calls
Commands and reporters All functions return something
Identifying definitions of reporters by the OUTPUT key word Identifying return values by the RETURN key word
Identifying inputs from the first line of a procedure definition Identifying parameters in a function signature
Public and private procedures Functions can be defined outside of a class or as members of a class
Procedure name requirements (not numbers, not quoted) Function name requirements (followed by ()) and conventions (begin with lower case letter, mixed case)
Instruction lists can be invoked by other procedures including run, launch, carefully, forever, repeat, if, ifelse, ask, everyone Functions can be assigned to variables and invoked through the variable names

Order of Execution

Topics for this content area include the following:

MicroWorlds Logo Python
if, ifelse procedures if, else, elif keywords
repeat, dotimes, dolist, forever/stopme commands while, do/while, for keywords
equal? (=), less? (<), greater? (>) reporters ==, <, > operators
not, and, or reporters !, &&, || operators
Processes in MicroWorlds. cancel, done?, forever/stopme, launch, waituntil, when Processes and threads in Python
Event handling in MicroWorlds Logo is done through the Rules tab of the turtle's backpack, the button editor, and the color editor. Key strokes are detected by key? and captured by readchar. clickon/clickoff, broadcast, tell, message, sender, touchedturtle You can build your own event handlers in Python or use prebuilt ones like the pygame event handlers

List Processing

Both Logo and Python have sophisticated list processing capabilities. Here are some examples.

MicroWorlds Logo Python
make "letters [a b c] letters = ['a', 'b', 'c']
show last :lettersprint letters[-1]
show butlast :lettersprint letters.[:-1]
show list "x "yprint ['x', 'y']
show count :lettersprint len(letters)

Other Topics

Both Logo and Python are languages used to develop source code. Both are typically interpreted languages. You can execute instructions "on the fly" in the MicroWorlds Command Center or in the CodeSkulptor Editor.

CodeSkulptor does some syntax checking before it tries to execute a program. Some versions of Logo (like Berkeley Logo) provide a trace tool to help programmers find defects.

Both languages allow programmers to add comments to code.

Both languages provide extensive documentation on existing primitive procedures/classes and methods

Data in MicroWorlds Logo can be a word or a list. Python has more built-in types of data, like: byte, short, int, long, float, double, boolean, or char.

Variables in MicroWorlds Logo can be project variables, turtle variables, global variables, local variables or inputs. Variables in Python can be class variables, instance variables, local variables or parameters.

In Python, new objects are created with constructors. In MicroWorlds Logo, new objects are using special purpose procedures like newturtle, newtext and so on. To reference a particular object, we use ask in MicroWorlds Logo and dot notation in Python.

In MicroWorlds Logo, we assign values to project variables and turtle variables with setName and assign values to thing variables with make or let. In Python, assignment is made with the equal (=) sign. Important distinction: In MicroWorlds Logo, a single equal sign (=) is a boolean reporter, not an assignment operator. In Python, a single equal sign (=) is an assignment operator, and a double equal sign (==) returns a boolean value.

Strings in Python have quotes before and after the elements of the string. In MicroWorlds, a word begins with a single quote and ends when a space is encountered. Concatenation of Strings is done with a + in Python. Concatenation of words is done with the word reporter in Logo.

In Python you can represent collections of things as lists, tuples and dictionaries. Logo has lists. You can reference elements of a list in Python using an index in brackets. You can reference an element of a Logo list with primitive procedures first, last, and item. In Python, you can use dictionaries to index items by an object (for example, a string) instead of a number.

Both languages have ways of distinguishing between constants, variables, and procedure/method names.

Content Development

TJ Leone

About the Center for Talent Development

Center for Talent Development (CTD), housed at Northwestern University's School of Education and Social Policy, is an accredited learning center and research facility that identifies, educates and supports gifted students and their families and serves as a leader in gifted education. Learn more about the Center for Talent Development.

Leone Learning Systems, Inc. (LLS) is a North Shore company that provides online courses for kids anywhere and local teaching and tutoring services for students in Chicago and the Northern Suburbs of Chicagoland. LLS also provides a free geometry software package for children age 6 and up, and free resources for teachers and parents. This site includes information about classes taught, availability for tutoring, learning activities for kids, lesson plans, and ongoing software and curriculum research and development efforts.