Course Home Online Lessons
Related LinksOnline DevelopmentLessonsReference |
What's next?Congratulations on completing Python: Games to Google! Here are some ideas for continuing your adventures in coding:
Friday, August 4EXPO! 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. Student WorkThese are the latest versions I have of your work. If you have a more recent version, would like to post a different project instead, or would like to post an additional project, send it to me and I'll put it on the site.
What We Have DoneCodecademy, CodingBat, CodeSkulptor, Monty Python, Projects, Improvement of web crawler What We Have LearnedMath and Physics
Programming Paradigms
Programming Concepts
What do we do when we're done with our Expo projects?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 work on any Codecademy or CodingBat exercises you haven't completed. To deepen your Python knowledge and programming skills see the Python for Everybody Specialization, a series of Python courses from the University of Michigan on the Coursera web site. The Pong activity we did in class was based on an assignment in this Coursera course offered by professors at Rice University. You can check out Google's Python Class. Thursday, August 3Course SurveyLet us know what you think about your Summer Program experience by taking this survey Self-evaluationFill out this self-evaluation to let us know how you feel about your performance this session. How Google Search WorksThe video below explains the role of spiders in a Google search. In class, we'll see how you can use BeautifulSoup and Python to find links on a web page and how to follow links like a spider does. Sample problem for following links with following_links.py: Start at https://python-data.dr-chuck.net/known_by_Fikret.html Pair programming: Improving following_links.pyThe following_links.py file often fails when run against https://www.tjleone.com. Can you make it work better? Pair programming: Improving Click LinesOne of the examples from the CodeSkulptor docs (Control Objects->Set the Mouse Input Handler) is Click Lines. It has the beginnings of a draw program. Customize it by adding text input boxes to:
Can you make your program check the input to make sure it is valid? For example, what are the valid colors you can use for drawing lines in CodeSkulptor? What is a good message to give to the user if the input is not valid? Can you make the message show up in a text label? Cycling through colorsWednesday, August 2Adding a Background ImageAgar.ioHere is the beginnings of an Agar.io game that Dorian and I worked on this morning.
Image InspectorYou can use this program to help figure out the parameters you need to get your image to show up correctly. If the program won't load properly in CodeSkulptor, you can copy and paste the code from this page. Tuesday, August 1Game OverRecall this code from Codecademy(Functions - 6. Practice Makes Perfect):
We'll review the terms function definition and function call and how we can use functions calling functions to make a Game Over screen for Pong. Pair Programming: Pong to BreakoutJiawei had the idea of modifying Pong to make it into a Breakout game. This makes a great pair programming activity, because it makes you think about how Pong works and makes you use what you know about CodeSkulptor, classes, lists, and functions. The bricks for a game of Breakout have some things in common with the paddles in Pong:
The differences are:
One strategy for making new objects that are similar to other objects is to inheritance. In this activity, we'll create a Brick class that is a subclass of Paddle. In order to handle lots of bricks, we'll put all our bricks in a list and use for loops to look at each brick to check for collisions with the ball and to see if the brick should be drawn. Starter Code for DriverThe driver should start with the complete version of Pong from our last pair programming activity. Instructions for NavigatorOur current Pong game has three classes: the Circle class, the Ball class, and the Paddle class. Look at these three classes. What keyword do you need to define a class? How can you tell that the Ball class is derived from from the Circle class? Our Brick class will be just like our Paddle class, except we need an instance variable to keep track of whether or not the brick should drawn. To do this, we derive it from the Paddle class. Below the Paddle class, add a Brick class. Your header should begin with the keyword Remove the code in the draw handler that draws paddle2. Run the program. Make sure that you can no longer see paddle2. Switch RolesFind the Find the statement in Run the program and make sure you didn't break anything. Why can't you see the brick? Add the code to the draw handler to draw the brick. You should also add a test to make sure the brick is visible. Use the is_visible instance variable of the brick object. Switch RolesAfter the code that draws the brick, you should add code to determine whether brick and ball have collided: To test our code, let's make the brick really long so the ball can hit it easily. Create a new global variable called BRICK_HEIGHT. In the section where we set PADDLE_HEIGHT = 80, make the BRICK_HEIGHT 200. You should also create a variable called BRICK_WIDTH. For now, you can let the BRICK_WIDTH be 8. Find the code in Test out the code to see if it works. Try changing the BRICK_WIDTH and make sure the code still works. Switch RolesNow that we have one brick working, let's figure out how to make a bunch of bricks. Instead of a The first thing we'll need is a list. Find the code in
Now we need to change the draw handler to use the bricks list. It will stil only draw one brick for now. Try this: Next steps to consider
Sample Projects from Past Classes
The Python turtle moduleYou are welcome to continue working on Breakout, or do any work you have left on Codecademy or CodingBat. If you would like to try something else, you can work on Python programming with turtles. Here are some other resources for learning how to use the turtle module:
Monday, July 31Goals for this weekI looked over everyone's self-evaluations this weekend. You've set some good goals for yourselves! Games to GoogleIf you're interested in learning more about how Google works and how to build a simple web crawler in Python, prepare by making sure you've completed the File I/O unit by tomorrow morning. If you've completed the File I/O unit in Codecademy, you can further prepare with the "Dicts and Files" material from Google's Python Class. Codecademy and CodingBatSome people were interested in making more progress in Codecademy and CodingBat. Feel free to spend as much time on that as you like. Just make sure that you're saving your Codecademy work as you go, since we've gotten a warning from Codecademy that work you've done might be erased this week (however, your record of progress won't change). CodeSkulptor Project IdeasOther people wanted to do more work with CodeSkulptor. Are you looking for CodeSkulptor project ideas, or help with work on your project idea? See below. Working with ImagesToday we'll look at the game shell Zuul for CodeSkulptor that you can use to create illustrated adventure games (You can click here for code to copy and paste if you can't open the other link in CodeSkulptor). You can use this program to help figure out the parameters you need to get your image to show up correctly. If the program won't load properly in CodeSkulptor, you can copy and paste the code from this page. Customizing PongA couple of people had the idea of make a Game Over screen for Pong. Here's some sample code that might help with that. If that program doesn't open properly in CodeSkulptor, you can copy and paste the code on this page. From Tic tac toe to Battleship?Here's a CodeSkulptor tic tac toe game for you to experiment with. Could you use it to make a CodeSkulptor version of Battleship? PygLatinHere's another project idea: Create a simplegui version of PygLatin that uses an input handler to get a word and then displays the word in the canvas with draw_text(). Here's some video help:
Game Classes I'm Working OnHere is a program with some classes I'm working on to help create more interesting games, in case you'd like to check it out. Friday, July 28Week 2 Self-EvaluationComplete this self-evalution CodeSkulptor Pair Programming: Pong with classesHere's a Pong template with classes. If you can't bring up this program in CodeSkulptor, you can click here for code that you can copy and paste into CodeSkulptor. To prepare for this exercise, we'll do a walkthrough of the classes you will use. Notice the parameters needed to instantiate objects or call methods on those objects, if any. You will notice that the ball is instantiated in the spawn_ball function, and the paddles are instantiated in the new_game function. Instructions for Navigator
Switch Roles
Save Codecademy Work for EXPO!According to email from Codecademy, your progress in their Python course will be kept, but the code you've written will be removed some time during the week of August 1, which is next week. Everyone should save at least one Codecademy project (PygLatin, Taking a Vacation, A Day at the Supermarket, Student Becomes the Teacher, Battleship, Practice Makes Perfect, Exam Statistics, or anything from later lessons). Save the lesson to a file in IDLE, and make sure you can run it and explain what it does. QuizletAfter Quizlet Live, take this quiz. Class and Instance VariablesGenerally speaking, instance variables are for data unique to each instance and class variables are for attributes and methods shared by all instances of the class: class Dog:
kind = 'canine' # class variable shared by all instances
def __init__(self, name):
self.name = name # instance variable unique to each instance
>>> d = Dog('Fido')
>>> e = Dog('Buddy')
>>> d.kind # shared by all dogs
'canine'
>>> e.kind # shared by all dogs
'canine'
>>> d.name # unique to d
'Fido'
>>> e.name # unique to e
'Buddy'
Homework ideasIf you haven't finished Introduction to Classes in Codecademy, you should work on that. If you have finished Introduction to Classes, you can go back and complete other lessons in Codecademy that you haven't gotten to yet. You can work on CodingBat problems you haven't tried. You can check out the game shell Zuul for CodeSkulptor that you can use to create illustrated adventure games (You can click here for code to copy and paste if you can't open the other link in CodeSkulptor). Here is some code to help with adding images to CodeSkulptor. You can also check out the Google Python Class. There are some interesting problems in the Dicts and files section and beyond. Thursday, July 27CodeSkulptor Pair ProgrammingFor this exercise, we'll start with this simple pong template. This program implements the requirements and challenges from yesterday's exercise, except for Extra Challenge #4, so there's only one paddle and one player. If the player misses the ball with the paddle, the ball goes to the middle of the screen so the player can try again. If the ball goes off the court on the left, it disappears, and you have to quit out of the window and start a new game. To prepare for today's exercise, we'll review how it works. If you can't open the file in CodeSkulptor, click here and copy and paste the code that appears. As you work through the code, keep an eye out for comments that start like this:
Instructions for NavigatorIn this simple version of Pong, there is only one paddle and one player. Your task is to add scoring. At the beginning of the game, the score is 0. The player should score when the ball goes off the screen to left. At that point, the score should be updated and the new score should be drawn. At the same time, the ball should move back to the middle of screen so that the player can continue playing.
Switch Roles
CodingBat Pair ProgrammingDo one problem from String-1, then switch roles and do another one. Codecademy Goal for TodayGet through Introduction to Classes. If you're finished with Classes, you can do more Codecademy or CodingBat, develop Pong further, or check out some of these CodeSkulptor videos. Artificial EmotionsResearchers 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? HomeworkApogee students are expected to do one hour of homework. Job One is to finish Introduction to Classes in Codecademy. After that is done, you can do any of the following:
Wednesday, July 26CodingBat Pair ProgrammingWe'll go through match_ends from list1.py as a group. With your pair programming partner, do count_evens from List-2. CodeSkulptor Pair ProgrammingTo prepare for this exercise, we'll start with a closer look at the parts of a CodeSkuptor program, especially:
Open this Pong paddle program. If you can't download the file, click here and copy and paste the code that appears.
Extra Challenge #1Make the ball move. Extra Challenge #2Make the ball bounce off the top and bottom of the canvas, but let it go through the side walls. Extra Challenge #3Make the ball bounce off the paddle Extra Challenge #4Add a second paddle to the left side of the canvas. Quizlet LiveHere's the quiz to take after Quizlet Live. Tuesday, July 25ListsToday 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 LiveAfter Quizlet Live, take this quiz. Monday, July 24Outdoor SafetyAvoiding unnecessary roughness, and what to do if someone is injured. Using IDLEBefore we begin our first lesson from Google's Python Class, let's make sure we can:
Strings Review: String BasicsAfter we work through String Basics, download string1.py and we'll walk through the donuts exercise. Strings Review: String SlicesWhen 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. CodecademyEveryone should finish Lists & Dictionaries today. If you don't get through it during the day, work on it for homework. Quizlet LiveCodeSkulptor Pair Programming
Switch Roles
Programming with the turtle moduleCheck out A Visual Introduction to Python to learn how to program with the turtle module. Friday, July 21Python installationsToday 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 evaluationComplete this Self Evaluation to let me know how you feel about what you've accomplished this week. Quizlet Live TodayTo 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 ProgrammingWe'll do List-1 > first_last6 together as a group, then pair up for same_first_last and make_pi. Thursday, July 20An interesting errorWhat does it mean when you get the error "maximum recursion depth exceeded"? Video lessonThis 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
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?
This morning's trinketCodingBat Pair ProgrammingWe'll do a Logic-1 problem together. Then we'll choose pairs to work a couple more Logic-1 problems. Wednesday, July 19CodingBat Pair ProgrammingThis 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 ProgrammingDriver 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
Switch roles one more time
Homework optionsIn addition to the usual options of Codecademy or CodingCombat, you can also check out this Python Hour of Code Tuesday, July 18Homework Check-inAny problems with homework last night? When you get stuck on an exercise, a good resource is the Python Discussion Forum. CodeSkulptor ReviewWe'll over the work people did on CodeSkulptor in pair programming yesterday. CodingBat Pair Programming AssignmentI 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:
When you are done, make sure that both of you have complete working answers for both exercises. Quizlet.live later todayBe 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: RefactoringWhen 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 The Driver should open this program. Instructions to be read by NavigatorIn 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.
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.
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 17Welcome to Python Programming: From Games to Google!We will spend the morning getting acquainted with each other and start exploring Python. Logistics
Getting to Know Each OtherLet'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 StartedYou don't need to install Python to program in Python. Here's how to get started:
Comparing Python to Other Programming LanguagesHere 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 HelpWe'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 surveySome time after our first break, we'll go over the survey as a group Pair ProgrammingWe'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"tsDo
Don"t
Pair programming instructions
Code of ConductEvery work environment needs ground rules to keep things running smoothly. Here are some to get us started:
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:
Any other ideas? What should be the consequences for following the rules? We'll discuss this more in days to come. Developing TalentSince 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.
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 SetupYou 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 CombatSarah will show you how to get into CodeCombat and join the class. HomeworkFor your homework, you can:
About the Center for Talent DevelopmentCenter 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. |