Course Home
Announcements
Check Yourself
Python Errors in English
CodeSkulptor FAQ
Reflections

Online Lessons

Related Links

Online Development

Lessons

Reference

eBooks

Announcements

Friday, July 15

EXPO! Today!

Your priority for your EXPO! project should be to save a version that works, even if it doesn't have all the features you want to add. Remember, there is no such thing as an ultimate version of Word, or Excel, or Minecraft, or Windows. There are just versions. In general, users would rather have you fix bugs before adding any features.

Once you have a version that is complete, test it for bugs. Then ask someone else to test it. When you are satisfied that it is ready to demo, save your demo version. After that, you can work on adding features, or do some Codecademy, CodingBat, or continue working through the Google material on the course web site (Lists, Dictionaries, List Comprehensions, File I/O, Regular Expressions, Utilities).

You can also check out Google's Python Class.

Another thing you can work on is An Introduction to Interactive Programming in Python (Part 1) on the Coursera web site.

Lunch begins at 11:00, so you'll need to start lining up at 10:40.

Course Examples

A lot of our examples start with this simplegui template.

Here are two different complete versions of Pong:

Student Creations

What's next?

Review Material

We've covered a huge amount of material in a very short period of time. You can revisit tjleone.com any time to review material. I've also added new videos specifically for people who want to review. They feature a different presenter so you can get a fresh take on the material.

ebooks

There are links to ebooks in the left margins of each of the tjleone.com course pages. My favorite is Python the Hard Way.

Python Options After This Course
What if I want to continue to make games with simplegui?
  1. You can continue to use CodeSkulptor for as long as you want. The only caveat is that you have to keep track of where your programs are in the cloud, the class website will not (once the next class starts).Olivier Pirson has written a module SimpleGUICS2Pygame which provides simplegui on a normal Python implementation, using PyGame (which is downloadable) as a basis.
  2. The CodeSkulptor docs also include some pointers to using TKinter and Pygame to convert your code by yourself (select tabs SimpleGui --> Pygame and SimpleGui --> Tkinter). Click on the Demos button in CodeSkulptor, then click on the SimpleGUI->Pygame for info on Pygame or SimpleGUI->tkinter for info on Tkinter.
What are Tkinter and Pygame?

Tkinter is the standard Python interface to the Tk GUI toolkit. If you're running a standard version of Python (like the one you run from IDLE or the terminal), you don't need to install it. You can just import the module. this Tkinter page for more details.

Pygame is a set of Python modules designed for writing games that run locally on your computer (in IDLE or in your terminal). It requires download and installation.

Future courses

I hope everyone in this class will continue to pursue courses in programming and computer science. A good way to introduce yourself to Java is the Greenfoot class that I teach on Saturdays through CTD. Brian Meyers teaches an awesome Java Honors course as part of the summer program. If you're particularly interested in graphics, I also teach an AWE course that uses Java with different images, including animated GIFs.

Try out some Java

For the Saturday Java class, I use video lessons from the Joy of Code web site This site is a blog, so the videos are arranged backwards. The first lesson is on page 8. When you're done with page 8, you move on to page 7, and so on, until you get to page 1.

Thursday, July 14

Surveys Today

Complete your self-evaluation.

Then, take this survey to let us know how the session went for you.

Wednesday, July 13

Examples from this morning

Bouncing off the edge

Collions

Latest and greatest base classes...

...used with sample from yesterday...

...and the new template.

Tuesday, July 12

Codecademy or CodingBat

We'll spend some time this morning on Codecademy. If you have finished the unit on classes, you can work on some other Codecademy unit or do some CodingBat.

New classes added to base classes

Here is the sample we worked on today with images added.

New template

Use this template to use the base classes we looked at today.

Review Quizlet

Griffin suggested yesterday that we do a big review quizlet challenge. Today we'll have a review of the last couple of quizlets. Tomorrow we'll do more. On Thursday, we'll do a super-duper one!

Secret Message

Try to decode the following secret message without running it in CodeSkulptor:

s = "thought python" 
t = "Harold Birnbaum"
u = "@,#$!%^"
v = "daytime aura"
w = "element London"

p = t[:2] + s[8] + s[8:10] + t[6:10] + s[:2] + v[:3] + u[1] + w[7]
q = w[8] + v[8:-1] + w[:2] + u[4]

print p + q

Variations on Pong

Could you use the ImageView base class to modify Pong to draw the paddles as images?

Could you add more balls to the game to make it more interesting? How would you keep track of a list of balls and collisions with the paddles?

Interested in doing more with images, including animation? Scroll down the More CodeSkulptor page.

Monday, July 11

Some base classes

An object oriented approach for our game would typically include some base classes for geometric objects.

We'll take a closer look at these this morning. We'll start by looking at the circle example from last week.

We'll also see how to use these CodeSkulptor pages as modules. How might we use the Circle, Rectangle and Text classes as base classes for the Ball, Paddle and Scoreboard in Pong?

Here's are working versions of Pong (1) without classes and (2) with classes.

Images

We'll also look at adding images to your projects. You can add images from the internet or put your own images on dropbox. I'll show you how I did that to get blanket_love1 and blanket_love2 onto dropbox and into CodeSkulptor

Here's the example we worked on in class

Matt's idea

Matt thought it would be cool to be able to put circles on the screen wherever you click. Here's some code that does that using the Circles class we made this morning.

Friday, July 8

Buttons

This morning I'll do a mini-lesson on adding buttons to CodeSkulptor programs. We'll start with our blank CodeSkulptor template. This is the best template to start with when you're building something from scratch.

Here's a link to the button program we built together this morning.

Appointment Today

I have an appointment this morning. I'll be heading out around 9:15am and will be back a little after 10:00. During that time:


if not codecademy_unit_11.is_finished():
	codecademy_unit_11.finish()
elif not quizlet_live.is_preparation_complete():
	quizlet_live.complete_preparation()
else:
	choose_from(['Continue Pong exercise from yesterday', 
    			 'Modify examples from CodeSkulptor docs', 
                 'Do more Codecademy',
                 'Try creating a project of your own design in CodeSkulptor'])

Quizlet Live

Here is the Quizlet to study for today's Quizlet Live:

Self-Evaluation

It's time for another Self-Evaluation! Fill out this form to let me know how you feel about your progress so far.

Thursday, July 7

Date Fashion

The Logic-1 > date_fashion problem was a tough one. We'll go over it as a group.

Circles and Rectangles

Let's take another look at how we draw circles and rectangles in CodeSkulptor. How would we add circles to the other corners? Could we move some vertices of the rectangle and not others?

Pong without any class

This morning, we'll start working on a version of Pong that doesn't use classes. You'll need to share expertise between teams, so we'll change up the groups. If you're in a group of three, it might work best to have one Navigator and two Drivers. Make sure both Drivers complete each step correctly.

We'll just work on this for one Pomodoro to get a feel for how the work is done without classes. After we've learned about classes, we'll make a complete version of Pong with classes.

Here are the teams for this morning:

  • ['Ralph', 'Griffin', 'Nina']
  • ['Matt', 'Rick', 'Zachary']
  • ['Geoffrey', 'Lucas', 'Aran']
  • ['Graham', 'Carlo', 'Davin']
  • ['Mihika', 'Natasha', 'Ashton']
  • ['Laurel', 'Felicia']

When setting up work for your team, it might be helpful to have the navigator read the directions, have the driver write the code, and have the third person look over the reference material to make sure you're copying in the pieces you need to put the project together.

Reference projects for Pong

Read over the reference project for your group and be ready to help add your bit to the final version of Pong.

Before You Make Any Other Changes

Change the comment in your template to make sure keep track of which browser window contains the template you are working on. The comment should include the names of the members of your team.

Directions for Navigator: Adding the Ball

For the following steps, you should use the Reference Page for Ball.Note: In general, you should not use line numbers to guide your copying. Look carefully at the code in both the Ball project and the template to decide where different lines of code should be copied.

  1. Add code to the program template that draws a ball in the middle of the Pong table. To do this, we need to (a) initialize the value of ball_pos, and then (b) draw the circle at ball_pos.
    • Look on line 16 of the Ball project to see how ball_pos is initialized. Copy that code to the correct location on the template.
    • Next, copy line 70 from the Ball project to the correct place in the template.
    • Test to make sure the ball is drawn on the canvas.
  2. Make the ball move across the screen. To do this,
    • Copy line 17 from the Ball project to the correct place on the template. This line initializes ball_vel.
    • Copy lines 59 and 60 to the correct place on the template. These lines update the ball position.
    • Test to make sure the ball moves across the screen.
  3. Add code to the function spawn_ball that spawns a ball in the middle of the table and assigns the ball a random velocity. If the direction variable has the value LEFT, then make the ball move left instead of right. To do this, copy lines 22 through 27 from the Ball project to the correct place in the template.
  4. Add a call to spawn_ball in the function new_game which starts a game of Pong. To do this, copy line 47 from the Ball project to the correct place in the program template. Note that the program template also includes an intial call to new_game in the main body of your program to get a game going immediately.
  5. Copy the code that tests to see if the ball has collided with the top and bottom walls. This code is on lines 37 to 43 of the Ball project.
  6. Copy the code that tests to see if the ball has collided with the left or right gutters. This code is on lines 29 to 35 of the Ball project.
  7. Copy the code that respawns the ball when it hits a gutter or bounces it when it hits the top or bottom of the canvas. To do this, copy lines 62 to 67 to the correct place in the template.

Directions for Navigator: Adding the Paddle

For the following steps, you should use the Reference Page for Paddle.Note: In general, you should not use line numbers to guide your copying. Look carefully at the code in both the Ball project and the template to decide where different lines of code should be copied.

  1. Add code that draws the left and right paddles in their respective gutters. To do this, we need to (a) initialize the values of paddle1_pos and paddle2_pos, (b) create the list of points needed to draw the paddles, and (c) draw the paddles. To do this,
    • Copy lines 30 and 31 from the Paddle project to the correct place in the template.
    • Copy lines 22 through 25 from the Paddle project to the template. The paddle_point_list function creates a list points needed to draw a paddle.
    • Copy lines 49 and 50 from the Paddle project to the correct place in the template.
    • Test the program to make sure it works. You should still have the moving ball appear, but now you should also see a paddle in the middle of each gutter.
  2. Add code to change the values of paddle1_vel and paddle2_vel (the velocities of the two paddles). To do this,
    • Copy lines 32 and 33 from the Paddle project to the correct place in the template.
    • Copy lines 15 to 20 from the Paddle project to the correct place in the template. These functions give the recipe for updating the paddle position.
    • Copy lines 45 and 46 from the Paddle project to the correct place in the template. These lines actually call the update function.
    • Update the values of the two vertical velocities using key handlers. The "w" and "s" keys should contol the vertical velocity of the left paddle with the "Up arrow" and "Down arrow" key should control the velocity of the right paddle. In our version of Pong, the left paddle moves up at a constant velocity if the "w" key is pressed and moves down at a constant velocity if the "s" is pressed and is motionless if neither is pressed. To achieve this effect, you will need to use both a keydown and a keyup handler to increase or decrease the vertical velocity in an appropriate manner. Copy lines 52 to 72 from the Paddle project to the template. Make sure you replace the keyup and keydown functions that are already in the template. You should already have code in the template to register the keydown and keyup handlers.
    • Test the code to make sure you can move the paddles.

Directions for Navigator: Adding the Scoreboard

Here is some code to test to see if the ball is hitting the paddle:


def ball_hits_paddle():
    return ball_hits_left_paddle() or ball_hits_right_paddle()

def ball_hits_left_paddle():
    return ball_hits_left_gutter() and ball_in_y_range_of_paddle(paddle1_pos[1])

def ball_hits_right_paddle():
    return ball_hits_right_gutter() and ball_in_y_range_of_paddle(paddle2_pos[1])

def ball_in_y_range_of_paddle(paddle_y):
    return ball_pos[1] >= paddle_y and ball_pos[1] <= paddle_y + PAD_HEIGHT

Add the function definitions above to your template.

For the following steps, you should use the Reference Page for Paddle.Note: In general, you should not use line numbers to guide your copying. Look carefully at the code in both the Ball project and the template to decide where different lines of code should be copied.

  1. Initialize global variables score1 and score2 to 0 in the function new_game. To do this, copy lines 27 and 28 to the correct place in the template.
  2. Copy lines 52 and 53 from the Scoreboard project to the correct place in the template. Test to make sure that a 0 appears on both the left and right sides of the canvas.
  3. Update the score if the ball hits the gutter. To do this, copy the following lines to the correct place in the template:
    
        if ball_hits_paddle():
            ball_vel[0] = - ball_vel[0]
        elif ball_hits_left_gutter():
            score2 += 1
            spawn_ball(RIGHT)
        elif ball_hits_right_gutter():
            score1 += 1
            spawn_ball(LEFT)
        elif ball_hits_top() or ball_hits_bottom():
            ball_vel[1] = -ball_vel[1]
    
    You will have to replace some existing code in order to do this. Test to make sure that the score is updated properly.

Wednesday, July 6

Clock

Here's a version of a cool CodeSkulptor app that Nina and Ralph found. I added some variables so you can make it work for different time zones.

CodeSkulptor Examples from Yesterday

Here are a couple of examples based on ideas that you guys came up with yesterday:

  • Ashton thought is would be cool to be able to make a circle grow
  • Mihika thought about making the circle rotate through a set of colors. This is one of those programs that works better with a timer.
  • Felicia thought it would be nice to get a group of circles all moving together. Ashton came up with an algorithm using a loop to make this work.

Nina found another issue with running CodeSkulptor in her browser. Let's hear what problem she ran into and how she fixed it.

Building on Felicia's Idea

Here are the steps to build a group of circles that move together.

  1. Start with the circles example
  2. Ashton thought of drawing in a loop...
  3. ...so all the positions could be easily changed
  4. Felicia made the canvas bigger. She also made changes to some other features of the circles, like size and color that I can't remember.
  5. You can change the y position as well as the x position.
  6. And you can add a wrapping effect.

If you have working programs that you'd like to share, email me the link so I can put them on the site. We can also talk about more ideas as they come up.

Preparation for Pong: Specialty Teams

Today we'll set up specialty teams for different parts of the Pong project. Specialists need a working program that involves their specialty and they need to be able to explain how it works. Teams are:

Paddle: Key Control Team

Your assignment is to make sure every member of your team has a CodeSkulptor program that allows the user to use arrow keys to move a rectangle on a canvas.

Team members: ['Matt', 'Geoffrey', 'Graham', 'Ralph', 'Mihika', 'Laurel']

Ball: Motion and Bouncing Team

Your assignment is to make sure every member of your team has a CodeSkulptor program with a ball that moves around the canvas and bounces off the sides.

Team members: ['Lucas', 'Natasha', 'Griffin', 'Felicia', 'Rick', 'Carlo']

Scoreboard: Text drawing, buttons, and timers

Your assignment is to make sure every member of your team has a CodeSkulptor program that displays a counter that is updated by a timer. You should be able to reset the counter to 0 by pushing a button.

Team members: ['Nina', 'Zachary', 'Aran', 'Davin', 'Ashton']

I recommend that you pair off and do pair programming within your team, then compare notes when you're done. When you have a single version of your team project that makes you happy, be sure to share it with all of your teammates. Each team will demo their work and explain their code later today.

To combine the ball, paddle, and scoreboard, we will put them into classes and combine the objects made from those classes. Everyone should get started on the Classes lesson in Codecademy the next time you get onto Codecademy.

Preparation for Pong: Specialty Teams

Today we'll set up specialty teams for different parts of the Pong project. Specialists need a working program that involves their specialty and they need to be able to explain how it works. Teams are:

Paddle Team

Your assignment is to make sure every member of your team has a CodeSkulptor program that allows the user to use arrow keys to move a rectangle on a canvas.

Team members: ['Matt', 'Geoffrey', 'Graham', 'Ralph', 'Mihika', 'Laurel']

Start with the Ball velocity example.

  1. Remove conditions in the draw handler and the keydown handler that allow left and right movement, since our paddles will only go up or down.
  2. Get rid of the acc variable in the keydown handler. Set vel[1] to 5 when the down arrow is pressed and -5 when the up arrow is pressed.
  3. Add a key release handler to set the velocity to 0 when a key is released. You will need to do this for each key that is pressed.
  4. Instead of drawing a circle, draw a rectangular polygon. What changes do you need to make to move the polygon and keep its shape?
  5. Add a test to the draw handler to keep the rectangle inside the canvas.

Here is a complete Paddle program.

Ball Team

Your assignment is to make sure every member of your team has a CodeSkulptor program with a ball that moves around the canvas and bounces off the sides.

Team members: ['Lucas', 'Natasha', 'Griffin', 'Felicia', 'Rick', 'Carlo']

Start with this project with scrolling text.

  1. Note how x, y, dx, and dy are used in this version.
  2. Make a circle move across the screen instead of text.
  3. Make the circle move in a random direction by setting dx to random.randrange(-10,10) and dy to random.randrange(-10,10). See Standard Modules->Random Module->random.randrange if you'd like to know more about randrange.
  4. When the circle hits a side of the frame, it make it bounce back. Consider this:
    • The center of the ball hits the left side of the frame when x == 0.
    • The center of the ball hits the right side of the frame when x == FRAME_WIDTH.
    • The center of the ball hits the top of the frame when y == 0.
    • The center of the ball hits the bottom of the frame when y == FRAME_HEIGHT.
    • You can reverse the x direction of the ball by setting dx to -dx.
    • You can reverse the y direction of the ball by setting dy to -dy.

The circle doesn't bounce until its center hits the edge of the frame. How could you take the radius of the ball into account to make a more realistic bounce?

Here is a complete Ball program.

Scoreboard Team

Your assignment is to make sure every member of your team has a CodeSkulptor program that displays a counter that is updated by pressing a button. You should be able to reset the counter to 0 by pushing a button.

Team members: ['Nina', 'Zachary', 'Aran', 'Davin', 'Ashton']

Work in pairs. Start with the opening CodeSkulptor page.

  1. Change the variable name message to the word score everywhere in your code.
  2. Make sure the code still works.
  3. Instead of setting score to "Welcome", set it to 0.
  4. Try running your code. What happens?
  5. Use the str function to change your draw handler as shown below.

        def draw(canvas):
                canvas.draw_text(str(score), [50,112], 48, "Red")

Change your button handler to add points to the score:


                def click():
                        global score
                        score += 1

Test out your code. Does the score go up when you click?

Something else to try

Can you change your code so to use a timer to increase the score instead of the button handler?

Here's a complete scoreboard program.

CodingBat Do's and Don'ts

Do
  • Use the function header exactly as given
  • Use all parameters as given
  • Use a return statement to provide your answer
  • Indent with the space bar
  • Use literals for parts of the solution that don't change
  • Use parameters for parts of the solution that change
Don't
  • Change the function header
  • Leave out any parameters in your solution
  • Use a print statement to provide your answer
  • Indent with the tab key

Pair program with a partner from your team to complete the following CodingBat exercises:

Codecademy

For Codecademy, wherever you are now, you should skip ahead to UNIT 11: INTRODUCTION TO CLASSES. We will need to understand classes in order to assemble our final Pong game.

Tuesday, July 5

Conduct outside the classroom

Living and learning on a university campus requires maturity. Not every college student is up for it, and it can be a real challenge for students your age. I've seen some very mature behavior in the hallways and outside at recess. It's important that this same level of maturity be demonstrated everywhere on campus. If there are any questions about expectations that we cannot resolve with a particular student, we arrange for them to talk with Sherry for further clarification.

Expo

For expo, students usually show a CodeSkulptor game they made, and maybe some program based on Google's Python Class. You've already seen some exerpts of this class in videos like yesterday's video on the List Basics page.

Quizlet Live Study Material

Today's Quizlet Live is based on the material on the More CodeSkulptor page. The complete set of terms is in the Quizlet below:

Individual Quizzes

After Quizlet Live, take these individual quizzes:

Random Pair Programming Partners

I have written a Python program that I will use to randomly assign pair programming partners. I'll run the program each day so that you get a different programming partner each day. Later in the course, when you've learned more Python, I'll share the program with you.

The reason for random partners is to help you to develop the skill of working with a range of people. You can still choose where you sit during individual work periods. Here are the pairs for today:

('Matt', 'Laurel')
('Griffin', 'Carlo')
('Natasha', 'Ashton')
('Grace', 'Felicia')
('Aran', 'Ralph')
('Rick', 'Graham')
('Mihika', 'Lucas')
('Zachary', 'Davin')
('Nina', 'Geoffrey')

Codeskulptor Pair Programming

You should try running your program at each step to see what happens. Is it what you expect?

  1. Open up this simplegui template.
  2. Change the comment at the top of your code page to say "# SimpleGUI draw program". You will use all the other comments exactly as they are. It is important that you place your code together with comments that describe it. Do not change or remove any other comments in this program.
  3. Open the CodeSkulptor Documentation by clicking the Docs button.
  4. Click on the Graphics tab.
  5. Select "SimpleGUI Module — Canvas".
  6. Click on the Operations link labeled "canvas.draw_polyline".
  7. Copy the definition of the draw handler to your CodeSkulptor program. It should appear under the comment "# Define event handler functions".
  8. Copy the statement that creates a frame to your CodeSkulptor program. It should appear under the comment "# Create a frame".
  9. Copy the statement that registers the draw handler. It should appear under the comment "# Register event handlers".
  10. Copy the code that starts the frame. It should appear under the comment "# Start frame and timers".
  11. Save your work by pressing the Save icon. You can bookmark your current page or copy and paste your code into a local file that you open in a text editor like NotePad++ (for Windows) or TextWrangler (for Mac). To be even safer, do both.

At this point, your code should look like this:

Run the program and make sure it works. Fix any bugs.

Navigator and driver should now switch roles. You can do this by sharing the link to your program, or just switch seats. Then complete the following:

  1. In the line frame = simplegui.create_frame('Testing', 100, 100), it's not clear what the number 100 is for, or why it appears two times. Let's add global variables to clarify. Put the following lines under the comment "# Define global variables (program state)":
    
    canvas_width = 100
    canvas_height = 100
    
  2. Run the program to make sure it still works.
  3. Now change the line that creates the frame by replacing the first 100 with canvas_width and the second 100 with canvas_height. That makes things a little clearer, doesn't it?
  4. Now let's resize the canvas by changing the values of the global variables:
    
    canvas_width = 300
    canvas_height = 300
    
  5. Run the program to make sure that the canvas size changed. Make sure it changes, and make sure you can explain why it changed.
  6. Change the name of the frame from 'Testing' to 'Simple Drawing Program'

Make sure your program looks like this:

Navigator and driver should now switch roles again.

  1. Our goal to allow the user to draw a single poly line with mouse clicks. Let's get rid of one of the poly lines. Remove the code that draws the blue poly line.
  2. Our code should now draw a single red poly line with points in the list [(10, 20), (30, 20), (90, 70)]. To allow the user to draw poly lines interactively, we need to be able to add points to the list. Let's create a global variable for the points in the poly line. Below the definition of the global variable canvas_height, let's define a global variable called points:
    
    points = [(10, 20), (30, 20), (90, 70)]
    
  3. Now we can use the variable points in our call to draw_poly_line:
    
        canvas.draw_polyline(points, 12, 'Red')
    
  4. Run your code to make sure it still works. If there are problems, fix them.

Here is what your code should look like now:

Navigator and driver switch roles one more time.

  1. We need to add a mouse click handler so the user can add points to the poly line by clicking the mouse on the canvas. Add this definition after the definition of draw_handler:
    
     def click(pos):
    	pass
    
  2. This function doesn't do anything right now. We'll fill it in a minute. First, we need to remember to register it. Add the following line after the line that registers the draw handler:
  3. 
    frame.set_mouseclick_handler(click)
    
  4. Make sure your program still runs. Correct any errors.
  5. Now we can modify our click function so that it adds a point to our points list. Change it to look like this:
    
    def click(pos):
        points.append(pos)
    

Now your program should look like this:

When you're finished, here are some other things to try:

  1. Change the starting value of your points variable.
  2. Create a button to change the color of the line you draw.
  3. Create a button to change the thickness of the line you draw.
  4. Try registering the draw handler as a drag handler
  5. Create a button clear the screen of any drawing.

Independent project

If you have time, you can start planning or coding a game of your own design. You can work on it alone or with a partner.

For a special challenge, try the Stopwatch: The Game

Monday, July 4

Soft skills

"You can be the smartest guy ever, but I don’t care. I need to be comfortable working every day with you." (So Much for Qualifications: Employers Hire People They Like, Time Magazine, December 2012).

A lot of software development is done in teams, including some of the development we will do in this class. To work effectively in teams, programmers make use of various soft skills. Here are some good soft skills to practice:

  • Listen. People are also more likely to listen to you if you listen to them first.
  • Pay attention to the comfort of others. People will let you know if you are making them more or less comfortable. Here are some ways to check yourself to make sure you are paying attention to the comfort of others.
  • Help other reach their goals. This could be something as simple as packing up or lining up quickly so that other people don't have to wait for you to go out on break. It also means sharing your expertise.
  • Be nice. Being nice contributes to more effective teams and a better learning experience for everyone.

In this classroom, we have a lot of excellent examples of people practicing soft skills. We can all learn from them. Notice the people you like to work and play with and think about why you work and play well together.

CodeSkulptor Demos

I saw that a lot of you enjoyed playing with the CodeSkulptor demos on Friday. Depending on how much progress we make this week, I'll try to set aside some time on this coming Friday, June 8, for more playing with demos. In the meantime, we'll leave demos alone during regular class hours so we have time to create our own cool games!

Quizlet Live

Today's Quizlet Live will be a special combination of the List Basics terms and the simplegui terms in the flash cards below. To prepare for today's Quizlet Live, work through the following two pages:

  1. List Basics
  2. Introduction to CodeSkulptor

Individual quizzes

There are two individual quizzes today. One on lists and one on simplegui.

Preparation for CodeSkulptor Pair Programming

  • Open CodeSkulptor
  • When you run the Python code that comes up, a window appears that says, "Welcome!". Change the code so that a different message appears when you start up the program. Run the program to make sure your change worked.
  • When you run the program and click the button that says "Click me", the message changes to say "Good job!" Change the message from "Good job!" to something else. Run the program again to make sure your change worked.
  • The color "Red" is used to draw the text of the messages. Change the color of the text. You can use any of the HTML colors including 'Aqua', 'Black', 'Blue', 'Fuchsia', 'Gray', 'Green', 'Lime', 'Maroon', 'Navy', 'Olive', 'Orange', 'Purple', 'Silver', 'Teal', 'White', or 'Yellow'.

After Preparation for Pair Programming

When you finish your preparation for paif programming, you can make other changes to the "Welcome!" CodeSkulptor program or work on Codecademy.

Pair Programming

Pair Programming Partners for today

('Lucas', 'Carlo')
('Aran', 'Mihika')
('Geoffrey', 'Felicia')
('Zachary', 'Grace')
('Griffin', 'Rafael')
('Graham', 'Nina')
('Natasha', 'Davin')
('Rick', 'Laurel')
('Ashton', 'Matthew')
  1. Open up codeskulptor.org
  2. On line 11, create a variable named position and intialize it to [50, 112]
  3. In the draw() event handler, replace [50, 112] with the variable position
  4. Test to make sure that the program still works.
  5. In the draw handler, add the line

    position[0] += 1

  6. Test the program again. What happens? Why?
  7. Starting at line 10, add these lines:

    WIDTH = 300

    HEIGHT = 200

    FONT_SIZE = 48

  8. Add this line to your draw handler after position[0] += 1:
    
            if position[0] >= WIDTH:
                    position[0] = 0
    
    
  9. Test the program. What happens? Why?
  10. We can make scrolling a little smoother if we start the text farther to the left. frame.get_canvas_textwidth(message, FONT_SIZE) will give us the length of the message string for the given FONT_SIZE. Try changing the if statement in your draw function to this:

    if position[0] >= WIDTH:

    
            position[0] = -frame.get_canvas_textwidth(message, FONT_SIZE)
    
    
  11. Test out your change. What happens? Why?
  12. It would be nice if clicking the button could toggle the text back and forth between "Welcome!" and "Good job!"
  13. Try changing your click() function like so:
    def click():
        global message
        if message == "Welcome!":
            message = "Good job!"
        else:
            message = "Welcome!"
    

CodingBat Pair Programming

Before completing any CodingBat exercise, make sure you are logged in with your tjleone.com email account so I can track your progress. Navigator reads the instructions and monitors tests. Driver writes the code. When the exercise is complete, make sure Navigator also has the correct code recorded.

Try to solve Logic-1 > cigar_party. Here are Trinket blocks that give one possible solution:

You can also press the "Show Hint" button for more help.

Try to solve String-1 > hello_name. The Trinket blocks might not be as much help for this one. Press the "Show Hint" button if you get stuck.

Friday, July 1

Self evaluation

Complete this Self Evaluation to let me know how you feel about what you've accomplished this week.

Why are there programming languages?

This morning we will discuss why we need special languages to talk to computers.

Codecademy goal

If you didn't get a chance to finish up Functions yet, that's your goal for today.

Pair Programming

Today we're going to do our first pair programming activities. To learn how pair programming works, we'll watch a video together as a group.

To prepare for pair programming, we will build some short functions with Trinket Blocks. Here is a function you will build:


def sleep_in(weekday, vacation):
    return not weekday or vacation

Watch this video to see how to build it:

Use pair programming to build the following function using blocks:

This is the CodingBat description of the function:

The parameter weekday is True if it is a weekday, and the parameter vacation is True if we are on vacation. We sleep in if it is not a weekday or we're on vacation. Return True if we sleep in.

Monkey Trouble

Now try this one with your pair programming partner. The Navigator should read the instructions while the Driver builds the blocks using Trinket Blocks


def monkey_trouble(a_smile, b_smile):
    return a_smile == b_smile

Here are the steps for the Navigator to read:

  1. Trash any blocks that are currently on the screen.
  2. Make sure the >_View Code tab is selected.
  3. From the Functions menu, grab the function that returns a value and add it to your workspace.
  4. Click on the function name do_something and change the it to monkey_trouble.
  5. Click on the gear icon and add the parameters a_smile and b_smile.
  6. From the Logic menu, choose the block with the = sign and add it to your workspace.
  7. From the Variables menu, choose a_smile and b_smile and add them to the = block.
  8. Add the = block to the return connector of your monkey_trouble function.

This is the CodingBat description of the function:

We have two monkeys, a and b, and the parameters a_smile and b_smile indicate if each is smiling. We are in trouble if they are both smiling or if neither of them is smiling. Return True if we are in trouble.

Sum Double

Navigator and Driver should switch roles before you begin this one. See how much you can figure out without instructions. The Navigator's role for this exercise is more like the Navigator you saw in the video.


def sum_double(a, b):
    result = a + b
    if a == b:
        return 2 * result
    else:
        return result

What do you think this function does? Here is the CodingBat description:

Given two int values, return their sum. Unless the two values are the same, then return double their sum.

Thursday, June 30

Spare headphones?

Another class is looking for headphones. Let's figure out how many extras we have to spare.

Lanyards

Hannah talked with Sherry to clarify the rules about lanyards. Here they are:

Q1. would be ok for the students to leave their lanyards near them on the desk while in the class room (or hold them, so long as they're visible), provided those taking the students out of the classroom do a lanyard check.  Otherwise, they must be around their necks at all times.  Is this correct?

A1. Yes 

Q2. If they are holding them not around their necks but visibly (even playing outside, for example) is that okay?  

A2. No

Q3. What about putting them inside their shirts to run around?

A3. Yes

Codecademy goal for today

The Codecademy goal for today is to complete Unit 4 (Functions and Taking a Vacation).

Quizlet Live

Today's Quizlet will be based on the Quizlet on the Truth Tables page. It might help to check out the video on that page before going over the flash cards.

Casual Fridays

I like to wear a Hawaiian shirt on Fridays. Feel free to wear something fun tomorrow. Just be sure to follow the CTD dress code:

  • CTD ID must be worn at all times.
  • Shirts and shoes must be worn at all times
  • Tops and bottoms must meet—no stomachs showing.
  • Underwear must not be visible.
  • Shorts or skirts must be an appropriate length.
  • All shirts must have two straps or sleeves (no spaghetti straps). Low-cut, revealing shirts are not allowed.
  • Clothing must not display profanity or offensive slogans/symbols.
  • Shoes must not have wheels.
  • Other clothing may be deemed inappropriate by CTD permanent staff.

Wednesday, June 29

Outdoor Safety

Let's share some ideas about avoiding injuries during outside breaks.

TED talk

This morning I'll share an Amy Cuddy video.

Codecademy goal for today

The goal for today is completion of Unit 3 (Conditionals and Flow Control and PygLatin). After you've finished Unit 3, you can continue with Codecademy or work on CodeCombat or Trinket.

Quizlet Live

Today's Quizlet Live will be based on the Quizlet on the Basic Operators page.

Here's your basic operators quiz

Tuesday, June 28

Quizlet Live Today

This afternoon, we're going to have a Quizlet Live session. To prepare, work through the material on the Strings page of this site.

After Quizlet Live, take the quiz on the Strings page.

Understanding Python Error Messages

Python error messages can be helpful if you learn how to read them. I've added a resource that explains some common errors. We'll take a look at a few of them together and see how they can help us debug our programs.

Getting Help

People have been using some great strategies for directing their own learning. Here are a few that I've seen:

  • Check the Python Discussion Forum.
  • Try Google. If you type in the word "Python" followed by your question, you'll often get just the answer you need.
  • Try experimenting. Sometimes you just need to try out different things in a Python console or script.
  • Ask a classmate. Someone else in class might have already come across the same problem and found a solution.

If you've exhausted these possibilities, follow these steps to make the most efficient use of your guide's time:

  • Be ready to demonstrate the problem. Make sure the problem is still happening and you know how to make it happen. We can't help you fix a problem if you can't show it to us.
  • Be ready to explain what you've already done to try to solve the problem. That way, your instructor or TA can eliminate possibilities that need to be explored.

Don't suffer in silence! Everybody runs into trouble at some point. Remember Linus's Law: "given enough eyeballs, all bugs are shallow".

What if I don't have anything to do?

If you're not sure what you should be working on at any point in the day, here are some ideas:

  • Work on material from any of the course web pages. Be sure you're familiar with the Strings material for this afternoon's Quizlet Live session.
  • Continue working on Codecademy
  • Play CodeCombat. If you choose to work on CodeCombat, you are expected to create an account to keep track of your progress.
  • Another thing you might like to try is trinket.io.

Monday, June 27

Welcome to Python Programming: From Games to Google!

We will spend the morning getting acquainted with each other and start exploring Python.

Logistics

  • Bathroom. Students need to be accompanied by an adult to the bathroom. Your class guides (TJ, Grace, and Hannah) would like to be available as much as possible to help you with your work, so we'll schedule whole class bathroom breaks. One of us will accompany anyone any time they need to go, but try to go during scheduled breaks.
  • Outdoor breaks. Outdoor breaks will coincide with scheduled bathroom breaks. During that time, you will take your break with two of your class guides while the third watches the computers. You will either go to the bathroom or hang out in the area designated by your guides. You must be in sight of a guide at all times. What's a good time? You arrive in the classroom at 8:30am and leave for lunch at 11:10am. After morning break, we'll have an outdoor break. For afternoon breaks, we need to pick a time between 12:10 and 2:45
  • Pomodoro breaks. We will also take short Pomodoro breaks so we have some kind of break every 25 minutes or so.
  • Food and Drink. Students can bring food and drink for break time. You can drink water in the classroom if it is in a water bottle.
  • Lunch. Students will leave for lunch with their TAs at 11:10am and return to the classroom at 12:10. This will give you time to walk to the cafeteria, eat, and then have some time to hang out or play outside.
  • Laptops cannot be left unattended. If your instructor and TAs are all leaving the room the same time as you, you'll have to take your laptop with you.
  • Noise Level. There are Northwestern students and faculty at work in this building. Noise level should be adjusted appropriately, especially in hallways.
  • Homework. CTD requires one hour of homework per day. We'll go over details this afternoon, when it will make more sense.
  • Headphones. If you have your own ear buds or headphones, you are welcome to bring them. Otherwise, headphones will be provided to you.

Getting to Know Each Other

Let's take some time this morning to learn a little about each other.

Fill out this survey so we have an idea the knowledge you have to share and what you want to learn.

How do you learn best?

Getting Started

You don't need to install Python to program in Python. Here's how to get started:

  • Log in to the gmail account that has been created for you. For most of you, your account will look like this:

        <your first name>@tjleone.com

    For example, my email address is tj@tjleone.com. I needed to a the first letter of your last name for two of you. Catherine's account is catherineb@tjleone.com. Matthew's account is matthewm@tjleone.com.
  • Log in to Codecademy and start learning some python!
  • After you've done a few lessons, feel free to do some more, or go to the first page of this sites lessons, Explore Python to do some free exploration in Python.

Getting Help

We'll discuss different ways to get help from your peers, class guides, and the internet. For now, a good Codecademy resource is the Python Discussion Forum. You can also raise your hand. Guides will try to work with students in an order and length of time that seems fair. We'll work out a more formal way of spreading our expertise as the course goes forward.

Review of survey

Some time after our first break, we'll go over the survey as a group

Ground Rules

Every work environment needs ground rules to keep things running smoothly. Here are some to get us started:

  • Treat others as you would like to be treated.
  • Respect other people and their property.
  • Laugh with anyone, but laugh at no one.
  • Be responsible for your own learning.
  • Do not disturb people who are working.

We'll discuss ground rules throughout the course, and add or change rules as needed.

What should be the consequences for breaking a rule? Here are three types I use:

  • You break it, you fix it.If something is taken, it should be returned. If something is broken, it should be replaced. If someone is physically or emotionally hurt, the damage should be repaired.
  • Temporary loss of privilege. If someone misuses bandwidth, they temporarily lose internet access.
  • Take a break. Sometimes students need some time away from a situation to clear their heads.

Any other ideas?

What should be the consequences for following the rules? We'll discuss this more in days to come.

Developing Talent

Since we're part of the Center for Talent Development, we need to discuss how to make this classroom a good place for developing talent. This is another topic we'll come back to throughout the course.

  • Everyone in this room has demonstrated the potential to develop cool software. Your job over the next three weeks is to develop that talent.
  • Each of you are already at different points in developing that potential. It will take more or less effort for you to develop your talent in different parts of the course. The thing to focus on is maintaining the effort to improve.
  • In order to create an atmosphere that supports continual development, part of your job is to encourage others.

Where Did Python Get Its Name?

Python was not named for the snake. It's inventor, Guido van Rossum, had a different Python in mind.

Python Setup

You can do most of the Python exercises through your browser, but at some point in the course, you'll probably want to run Python locally. Check out this web page to see if you already have Python installed and make sure you have the right version. If you need help with installation, Jimmy and I will be available, and there will probably be other students who can help you as well.

A local version of Python won't be necessary until some of the later activities. As long you have a working browser, you'll be able to complete all the activities for at least the first week.

Homework

For your homework, you can:

  • Work on material from any of the course web pages
  • Continue working on Codecademy
  • Play CodeCombat. If you choose to work on CodeCombat, you are expected to create an account to keep track of your progress.
  • Another thing you might like to try is trinket.io.

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.