On this page:
Lesson 1: Functions
Lecture Notes on Functions
- Grab a paper copy of the template for Lecture Notes on Functions (or print one from here).
- Complete the notes while you watch from 3:54 to 23:46 of this David Malan lecture on Functions (~20 min).
Practice Set on Functions
- Write and run the program from the end of the lecture.
- Make a custom mad-libs.
- try multiple inputs
- try something like
print("Hello " + name + "!")
Lesson 2: Variables
Lecture Notes on Variables
- Grab a paper copy of the template for Lecture Notes on Variables (or print one from here).
- Complete the notes while you watch the following THREE clips of David Malan talking about Variables (~21 min).
Clip #1
25:00 to 29:35, which is 5 minutes about printing on one line
Clip #2
1:03:05 to 1:10:17, which is 8 minutes about numbers
Clip #3
1:26:13 to 1:33:28, which is 8 minutes about creating your own custom functions
Practice Set on Variables
Hello
If you are feeling:
Less Comfy
- Type
cd. This takes you to your home directory, no matter where you are. - Type
lsto confirm. You should see just the kitchen directory. - Make a new directory called
1-python. (that’s a ONE, not an L… that’ll help later with sorts). cdinto that directory and typecode hello.py.- Write a short python program that prints hello world. (Feel free to add a creative touch.)
Add
If you are feeling:
Less Comfy
- Make sure you are in the directory called
1-python. - Create a file called
add.py - Write a python program that:
- Asks the user for two numbers
- Prints the result of adding those numbers together —
Hello 2
If you are feeling:
Less Comfy
- Make sure you are in the directory called
1-python. - Create a file called
hello2.py - Write a python program that:
- Defines a custom function that prints “hello, “ and the user’s name
- Asks the user for their name
- Calls the custom function to greet the user
What??
If you are feeling:
Mixed
- Make sure you are in the directory called
1-python. - Create a file called
what.py - Write a python program that:
- Asks the user for a noun and verb
- Puts them into a silly sentence using + concatenation, maybe something like:
- “Yesterday, my [noun] suddenly [verb] underwater.”
- “The sleepy [noun] accidentally [verb] upside down.”
- Prints “What??”
- Prints the same silly sentence again, but this time using print() with multiple arguments instead of the plus sign
Custom Calculator
If you are feeling:
More Comfy
In your 1-python directory, create one or more custom calculator programs.
- Handle decimal inputs with
float()instead ofint(). - Try implementing a complex formula from science or math or a sport or a game.
- Check out the
round()function here.
Lesson 3: String Functions
Lecture Notes on String Functions
- Grab a blank sheet of paper and take notes on the important elements.
- Complete the notes while you watch from 41:03 to 53:36 of this David Malan lecture on Functions (~13 min).
Practice Set on String Functions
Hello 3
If you are feeling:
Less Comfy
Write and run one of the programs shown in the lecture that uses .split() and .title().
Indoor Voice
If you are feeling:
Mixed
Do the Indoor Voice problem from Harvard’s CS50-P course, but you can skip the “How To Submit” part at the end.
Making Faces
If you are feeling:
More Comfy
Do the Making Faces problem from Harvard’s CS50-P course. See if you can do it via string functions (not if statements). Skip the “How To Submit” part at the end.