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

Online Lessons

Related Links

Online Development

Lessons

Reference

Wednesday, July 26

CodingBat Pair Programming

We'll go through match_ends from list1.py as a group. With your pair programming partner, do count_evens from List-2.

CodeSkulptor Pair Programming

To prepare for this exercise, we'll start with a closer look at the parts of a CodeSkuptor program, especially:

  • creating a frame
  • registering handlers
  • starting a frame

Open this Pong paddle program.

If you can't download the file, click here and copy and paste the code that appears.

  • Move the paddle all the way to right side of the canvas. Make sure you can still see the whole paddle.
  • Add tests so that the paddle doesn't go off the screen.
  • Add code to the draw method that draws a circle in the middle of the canvas for your Pong ball.

Extra Challenge #1

Make the ball move.

Extra Challenge #2

Make the ball bounce off the top and bottom of the canvas, but let it go through the side walls.

Extra Challenge #3

Make the ball bounce off the paddle

Extra Challenge #4

Add a second paddle to the left side of the canvas.

Quizlet Live

Here's the quiz to take after Quizlet Live.

Artificial Emotions

Researchers have been working hard to develop artificial intelligence. Do you think we should try to develop artificial emotions? Why do humans have emotions? Would emotions be a good thing for machines to have? Why or why not?

Tuesday, July 25

Lists

Today we're going to check out lessons on lists and more lists from Google's Python Class.

After that, download list1.py and try working the exercises.

It's OK if you do not complete all the functions, and there are some additional functions to try in list2.py.

Quizlet Live

After Quizlet Live, take this quiz.

Monday, July 24

Outdoor Safety

Avoiding unnecessary roughness, and what to do if someone is injured.

Using IDLE

Before we begin our first lesson from Google's Python Class, let's make sure we can:

  • Run an existing python program, such as hello.py
  • Run the Python interpreter interactively, so you can type code right at it

Strings Review: String Basics

After we work through String Basics, download string1.py and we'll walk through the donuts exercise.

Strings Review: String Slices

When that work is complete, we'll work through the video on String Slices and make pairs to work through both_ends and fix_start. If you finish those, try more of the exercises in the file. If you finish those, go to CodingBat and do some more exercises from String-1.

Codecademy

Everyone should finish Lists & Dictionaries today. If you don't get through it during the day, work on it for homework.

Quizlet Live

CodeSkulptor Pair Programming

  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?

Switch Roles

  1. Starting at line 10, add these lines:

    WIDTH = 300

    HEIGHT = 200

    FONT_SIZE = 48

  2. Add this line to your draw handler after position[0] += 1:
    
            if position[0] >= WIDTH:
                    position[0] = 0
    
    
  3. Test the program. What happens? Why?
  4. 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)
    
    
  5. Test out your change. What happens? Why?
  6. It would be nice if clicking the button could toggle the text back and forth between "Welcome!" and "Good job!"
  7. Try changing your click() function like so:
    def click():
        global message
        if message == "Welcome!":
            message = "Good job!"
        else:
            message = "Welcome!"
    

Programming with the turtle module

Check out A Visual Introduction to Python to learn how to program with the turtle module.

Friday, July 21

Python installations

Today let's make sure everybody has a local version of Python installed. By the way, who is Eric Idle, and why is IDLE named after him?

Self evaluation

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

Quizlet Live Today

To be ready for today's Quizlet Live, you must complete all Codecademy exercises in Lists and Dictionaries through number 9, More with 'for'

After Quizlet Live, take this quiz

CodingBat Pair Programming

We'll do List-1 > first_last6 together as a group, then pair up for same_first_last and make_pi.

Thursday, July 20

An interesting error

What does it mean when you get the error "maximum recursion depth exceeded"?

Video lesson

This morning, use the video below to modify this CodeSkulptor program. If the program won't open for you in CodeSkulptor, you can open this page to copy and paste the code into CodeSkulptor.

When you're finished working through the video, you should have a Python app with a button that makes the circle grow.

Button Challenges

  • Add a button that makes the circle shrink
  • Add a button that changes the fill color of the circle to red.
  • Add a button that makes the line around the circle thicker or thinner.
  • Add a button that moves the circle left or right (Hint: you will need to use center_point[0])
  • Add a button that moves the circle up or down (Hint: you will need to use center_point[1])

Try to add the buttons on your own, but if you need help, you can use this template to start yourself off.

For more help, see the video below.

What do I do when I'm done?

  • You can experiment some more with buttons and drawing.
  • You can check out this CodeSkulptor program. If the program won't open for you in CodeSkulptor, you can cut and paste this code. See if you can explain how the code works.
  • You can work on Codecademy

This morning's trinket

CodingBat Pair Programming

We'll do a Logic-1 problem together. Then we'll choose pairs to work a couple more Logic-1 problems.

Wednesday, July 19

CodingBat Pair Programming

This morning I want to spend more time talking about how CodingBat works before we get started. We'll review a couple of String-1 problems and do a Logic-1 problem together. Then we'll choose pairs to work a couple of Logic-1 problems.

CodeSkulptor Pair Programming

Driver will work start with our moving ball exercise from yesterday. If the program won't load in CodeSkulptor, cut and paste this program.

Instructions to be read by Navigator

  1. Run the program. Notice that we now have a button in the control area that says "Click me". Does anything happen when you click the button? Look at the code. Where does the program tell CodeSkulptor to add a button? Why doesn't the button do anything?
  2. Why isn't the circle moving? Look at the values of dx and dy.
  3. Let's start the circle moving by adding code to the click function. How do you know that the click function will be called when a button is pressed?
  4. Change the line in the click function that says pass to make it say global dx, dy. After global dx, dy, add a line that says dx = 1 and a line that says dy = 1.
  5. Run the program again and try clicking the button.

Switch roles one more time

  1. Let's get the circle to bounce when it hits the edge of the canvas.
  2. First, you should notice that you can change the movement of the circle in the x direction by changing the sign of dx, and you can change the movement of the circle in the y direction by changing dy. Why?
  3. When should we change movement in the x direction? When we hit the left or right side of the canvas. For a first try, change your draw handler to look like this:
    
    def draw_handler(canvas):
        global x, y, dx, dy
        x += dx
        y += dy
        if x <= 0 or x >= canvas_width:
            dx = -dx
        elif y <= 0 or y >= canvas_height:
            dy = -dy
        canvas.draw_circle((x,y), radius, line_width, line_color, fill_color)
    
  4. Challenge #1: Do you notice how this bouncing isn't quite right? Can you change the conditions so that the ball bounces right when it hits the edge of the canvas?
  5. Challenge #2: Can you put two circles on the canvas that bounce when they hit each other?

Homework options

In addition to the usual options of Codecademy or CodingCombat, you can also check out this Python Hour of Code

Tuesday, July 18

Homework Check-in

Any problems with homework last night? When you get stuck on an exercise, a good resource is the Python Discussion Forum.

CodeSkulptor Review

We'll over the work people did on CodeSkulptor in pair programming yesterday.

CodingBat Pair Programming Assignment

I created CodingBat logins for everybody last night. You log in with your email address.

We'll create random pairs and do two CodingBat assignments. Then, you will do the following:

  • Decide which of you will be the Navigator and which be the Driver for the first assignment.
  • For the first assignment, the Driver needs to log in to CodingBat and go to the first String-1 exercise on the CodingBat site, called hello_name.
  • To log in, use your email account for id/email. I'll give you the password in class.You must be logged in so that your progress can be tracked properly
  • Navigator and driver should complete this exercise.
  • When you are finished with hello_name, Navigator and Driver should switch roles.
  • The new Driver should log in to CodingBat and do the next exercise in String-1 called make_abba.

When you are done, make sure that both of you have complete working answers for both exercises.

Quizlet.live later today

Be sure you're familiar with the Strings material for our Quizlet Live session.

After Quizlet.live, test yourself on the string methods with this TestMoz quiz. Don't forget to sign in with your first and last name.

Pair Programming with CodeSkulptor: Refactoring

When you go to CodeSkulptor.org you see an example of a program you can run that has a click method. The first line inside the click method says global message. In this pair programming exercise, you'll see how the global keyword can help you make a circle move around the screen.

The Driver should open this program.

Instructions to be read by Navigator

In the Welcome! example we saw how the global keyword was used with the message variable in the button handler so we could change the message. We're going to make x and y global in our draw handler so we can change the values of x and y.

  1. Put your cursor at the end of line 14 by clicking at the end of that line (after the colon) with your mouse. Press Enter
  2. Add a line that says global x, y. This will allow you to change the global variables x and y inside the draw_handler function.
  3. After the line with the global statement, add a line that says x += 1.
  4. Run the program. What happens? Why?
  5. After the line that says x += 1, add a line that says y += 1. What do you think will happen? Why?
  6. Run the program. Did it do what you expected? Why or why not?

Time to switch roles

It would be cool if the circle could bounce whenever it hit the edge of the canvas. The program we have now makes the circle go off the screen because we always add 1 to x and we always add 1 to y. To be able to change the values we add to x and y, we will replace the 1 we add to x with a variable dx. We'll replace the 1 we add to y with the variable dy.

This part of our exercise will not change the way program works. The changes below make our code clearer and more flexible so that we can implement bouncing tomorrow. These kinds of changes are called refactoring.

  1. Under the statement fill_color = 'White', add a line that says dx = 1. The variable dx is commonly used to stand for the change in x.
  2. Add another line that says dy = 1.
  3. Change the line that says x += 1 to say x += dx.
  4. Change the line that says y += 1 to say y += dy.
  5. Run your program to make sure it still works correctly.
  6. What happens when you change the values of dx and dy?

We are now ready to make the ball bounce when it reaches the edge of the screen. In order to do that, we'll need to use conditionals.

Monday, July 17

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, and Sarah) 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. We'll make time each day to get outside. You'll leave for lunch around 10:45am so you can be in the lunch room by 11:00am. We will also take an afternoon break outdoors around 1:25pm
  • 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 10:45am and return to the classroom around noon. 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:

  • Send an email to tj@tjleone.com so I'm sure I have your correct email address. If you don't have email, let us know and we'll set you up.
  • Get your Codecademy login from TJ or Sarah. Log in to Codecademy and start learning some python!
    • If you already have a Codecademy account: Give us your Codecademy login name. If you've already started on Codecademy Python exercises, pick up where you left off.
    • If you haven't done any Python exercises in Codecademy but you already know some Python: Look at the categories in the course syllabus. Is there anything there that you haven't learned about yet, or would like to review? Skip to that section. Not sure if you know the material in a section? Try working on a project in that section (for example, for the Python Syntax section, try the Tip Calculator). If you need help completing it, you might need to go over the lessons for that section (for example, the Python Syntax lessons for Python Syntax).
    • If you feel that you know all the material in the Codecademy lessons, do some exercises from Warmup-1 or Warmup-2 in CodingBat. Make sure you get a login name first and make sure you are set up properly so you can get credit for your progress!
  • After you've done a few exercises, feel free to do some more, or check out the material below that compares Python to other programming languages.

Comparing Python to Other Programming Languages

Here is a nice overview of Python using an environment similar to Scratch. It's a good place to start if you've mostly programmed in Scratch or if you haven't programmed at all.

If you have experience with Java or some object-oriented flavor of C (such as C++, C# or Objective-C) or with JavaScript, Here is some material that compares the basics of Java and 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

Pair Programming

We'll watch a video on pair programming. If time permits, we'll start our first pair programming activity today. While you work, remember the pair programming do's and don'ts:

Pair programming Do's and Don"ts

Do

  1. Talk
  2. Listen
  3. Rotate Roles
  4. Be Patient
  5. Respect
  6. Take Breaks
  7. Prepare
  8. Clean
  9. Have Fun

Don"t

  1. Be Bossy
  2. Be Intimidated
  3. Be Quiet
  4. Suffer in Silence

Pair programming instructions

  • Pairs will be randomly assigned by a program written in Python.
  • The Driver for each pair will open up the first Python program.
  • The Navigator will open up this form
  • As you work through this program, you will be prompted to switch seats with your partner in order to switch laptops and roles.
  • If you were the Driver, you are now the Navigator. Continue filling out the form your partner was using.
  • If you were the Navigator, you are now the Driver. Continue working on the program your partner was using. When your partner tells you it's time top open a new program, open the Python program with variables.

Code of Conduct

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, Sarah 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.

Code Combat

Sarah will show you how to get into CodeCombat and join the class.

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.