Week-long Lesson Plan (Monday–Friday)
This week, students will learn how to write and use functions in Python. They will also learn to collaborate using GitHub by working in a shared public repository provided by the teacher. Each day builds foundational Python skills, emphasizes best practices, and promotes collaborative coding.
| Material | Where to Find / Notes |
|---|---|
| Computer with Internet | School computer lab or personal device |
| GitHub Account | Sign up here |
| Python 3 Interpreter | Download here |
| Public GitHub Repo URL | Provided by teacher (e.g., https://github.com/teacher/repo) |
| GitHub Docs | GitHub Docs |
| Python Docs | Python Functions |
| Code | Description |
|---|---|
| CS.3A.1 | Decompose problems and create algorithms using sequences, selections, and iterations. |
| CS.3A.2 | Write and modify code in a procedural programming language (Python). |
| CS.3A.3 | Collaborate using version control systems (e.g., GitHub) for code development. |
| CS.3A.5 | Test and debug programs, and document code appropriately. |
-
Introduction to Functions
- Read the Python Functions Tutorial.
- Discuss the purpose of functions in programming.
- Teacher demonstrates a simple function in Python.
-
GitHub Setup
- Ensure you have a GitHub account.
- Go to the provided public repo URL and fork the repository to your own account (How to Fork).
- Clone your fork to your local machine (Cloning Instructions).
-
First Python Function
- In your cloned repo, create a file named
first_function.py. - Write a function called
greet()that prints"Hello, World!". - Commit your changes and push to your repo (How to Commit and Push).
- In your cloned repo, create a file named
- Read about function arguments: Python Function Arguments.
- Write a function named
greet_name(name)that prints"Hello, <name>!"in your repo.
- Computer with Python and Git installed
- GitHub account
- URL of the class public repo
-
Review Homework
- Share and discuss solutions for
greet_name(name).
- Share and discuss solutions for
-
Function Parameters and Return Values
- Teacher explains parameters and
returnvalues in functions. - Modify
greet_nameto return the greeting string instead of printing it.
- Teacher explains parameters and
-
Collaboration on GitHub
- Create a new branch in your fork called
add-functions(Branching Guide). - Write a function
add(a, b)that returns the sum of two numbers. - Commit and push the changes to your branch.
- Create a new branch in your fork called
- Write another function in your branch called
subtract(a, b)that returns the difference. - Prepare a short (3-4 sentences) explanation of when to use the
returnstatement.
- Access to yesterday’s files
- GitHub repo (forked and cloned)
- Internet connection
-
Peer Review via Pull Requests
- Read: About Pull Requests.
- Open a pull request to submit your
add-functionsbranch changes to the main branch of your fork. - Pair up with another student to review each other's code on GitHub (Reviewing PRs).
- Leave at least one comment or suggestion.
-
Function Scope
- Teacher introduces the concept of variable scope within functions.
- Write a function
multiply(a, b)in your branch. - In your pull request, reply to your partner’s comment or suggestion.
- Access to GitHub and your fork
- Peer partner assigned by teacher
-
Merge Pull Requests
- Teacher reviews how to merge pull requests (Merging PRs).
- Merge your pull request after peer review is complete.
-
Refactoring and Code Organization
- Move all your functions into a new file called
math_functions.py. - Add a docstring to each function (Python Docstrings).
- Move all your functions into a new file called
-
Testing Functions
- Teacher introduces basic testing by writing a few test calls in a
test_math_functions.pyfile.
- Teacher introduces basic testing by writing a few test calls in a
- Write a function
divide(a, b)that returns the result of division. - Update your test file to test all four functions: add, subtract, multiply, divide.
- GitHub and your fork
- Python interpreter
-
Showcase & Reflection
- Demonstrate your functions and tests to the class.
- Reflect on what you learned about functions and using GitHub for collaboration.
-
Documentation and Next Steps
- Add a
README.mdfile explaining how to use your functions. - Teacher summarizes best practices for writing and collaborating on code.
- Add a
- Finish any incomplete tasks from the week.
- Prepare for a quiz on functions and basic GitHub workflow next week.
- Final versions of your code and tests
- Class time for presentations