On this page:

  1. Lesson 1: Functions
    1. Lecture Notes on Functions
    2. Practice Set on Functions
  2. Lesson 2: Variables
    1. Lecture Notes on Variables
      1. Clip #1
      2. Clip #2
      3. Clip #3
    2. Practice Set on Variables
      1. Hello
      2. Add
      3. Hello 2
      4. What??
      5. Custom Calculator
  3. Lesson 3: String Functions
    1. Lecture Notes on String Functions
    2. Practice Set on String Functions
      1. Hello 3
      2. Indoor Voice
      3. Making Faces

Lesson 1: Functions

Lecture Notes on Functions

  1. Grab a paper copy of the template for Lecture Notes on Functions (or print one from here).
  2. 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

  1. Write and run the program from the end of the lecture.
  2. Make a custom mad-libs.
    • try multiple inputs
    • try something like print("Hello " + name + "!")

Lesson 2: Variables

Lecture Notes on Variables

  1. Grab a paper copy of the template for Lecture Notes on Variables (or print one from here).
  2. 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

  1. Type cd. This takes you to your home directory, no matter where you are.
  2. Type ls to confirm. You should see just the kitchen directory.
  3. Make a new directory called 1-python. (that’s a ONE, not an L… that’ll help later with sorts).
  4. cd into that directory and type code hello.py.
  5. Write a short python program that prints hello world. (Feel free to add a creative touch.)

Add

If you are feeling:

Less Comfy

  1. Make sure you are in the directory called 1-python.
  2. Create a file called add.py
  3. 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

  1. Make sure you are in the directory called 1-python.
  2. Create a file called hello2.py
  3. 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

  1. Make sure you are in the directory called 1-python.
  2. Create a file called what.py
  3. 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 of int().
  • 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

  1. Grab a blank sheet of paper and take notes on the important elements.
  2. 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.