Course outline
Module 1
Module 1: Getting Set Up Without the Headaches
Getting Set Up Without the Headaches
Knowledge check
Q1. Which of the following is the best first step when setting up Python on your computer?
- A. Download the newest beta version from a random forum post
- B. Download Python from the official python.org website ✓
- C. Copy Python files from a friend's computer
- D. Install a game engine and Python will come with it automatically
Why: The official python.org website provides trusted, up-to-date installers for Windows, macOS, and Linux, which avoids security risks and compatibility problems.
Q2. What does it mean when you type 'python --version' in a terminal and see a version number returned?
- A. Your computer has a virus
- B. Python is installed and accessible from your command line ✓
- C. You need to restart your computer
- D. Your internet connection is working
Why: A version number confirms that Python is installed and that your system can find it, so you're ready to start running code.
Q3. Why is a code editor like VS Code recommended over Notepad for beginners?
- A. Notepad cannot save text files
- B. Editors highlight syntax and catch some errors, making code easier to read and debug ✓
- C. Notepad is illegal to use for programming
- D. VS Code runs Python faster than Notepad
Why: Code editors color-code keywords, show line numbers, and often flag mistakes early, which saves time and frustration for new learners.
Q4. What is a virtual environment used for in Python?
- A. To play video games inside Python
- B. To isolate project dependencies so different projects don't interfere with each other ✓
- C. To make Python run on a smartphone
- D. To automatically write code for you
Why: Virtual environments keep each project's libraries and versions separate, preventing conflicts between projects that need different package versions.
Q5. If you see the error 'python is not recognized as an internal or external command' on Windows, what is the most likely cause?
- A. Python was never installed or was not added to the system PATH ✓
- B. Your keyboard is broken
- C. Your monitor resolution is too low
- D. Python only works on Linux
Why: This error usually means the terminal cannot locate Python, which happens when it was not installed or the installer's 'Add Python to PATH' option was skipped.
Module 2
Module 2: Variables: Labeled Boxes for Your Stuff
Variables: Labeled Boxes for Your Stuff
Knowledge check
Q1. Which of these best describes a variable in Python?
- A. A permanent value that can never be changed
- B. A labeled container that stores a value you can refer to later ✓
- C. A type of loop that repeats code forever
- D. A function that prints text to the screen
Why: A variable is a name attached to a value, like a labeled box that holds your stuff so you can find and use it later.
Q2. Which line correctly creates a variable named age and stores the number 25 in it?
- A. 25 = age
- B. age = 25 ✓
- C. age == 25
- D. store age 25
Why: In Python, the assignment operator is a single equals sign, and the variable name goes on the left while the value goes on the right: age = 25.
Q3. What will print(name) output after this code runs?
name = "Sam"
name = "Alex"
- A. Sam
- B. Alex ✓
- C. Sam Alex
- D. An error occurs
Why: Assigning a new value to an existing variable replaces the old one. The box called name now holds "Alex", so that is what gets printed.
Q4. Which of these is a valid variable name in Python?
- A. 2nd_place
- B. my-score
- C. total_points ✓
- D. class
Why: Variable names cannot start with a digit, cannot contain hyphens, and cannot be reserved keywords like class. total_points uses only letters and an underscore, so it is valid.
Q5. What is the value of total after this code runs?
x = 4
y = 3
total = x + y
x = 10
Why: total is calculated as 4 + 3 = 7 at the moment that line runs. Changing x afterward does not update total, because total stored the result of the earlier calculation.
Module 3
Module 3: Making Decisions with If Statements
Making Decisions with If Statements
Knowledge check
Q1. Which keyword starts a conditional statement in Python?
- A. when
- B. if ✓
- C. check
- D. look
Why: In Python, the if keyword begins a conditional statement. The code indented under the if line runs only when the condition after it is True.
Q2. What will this code print?
age = 20
if age >= 18:
print("Adult")
A) Nothing
B) Adult
C) age >= 18
D) An error occurs
- A. Nothing
- B. Adult ✓
- C. age >= 18
- D. An error occurs
Why: Since age is 20, the condition age >= 18 is True, so the indented print statement runs and outputs Adult.
Q3. Which operator checks whether two values are equal in an if statement?
Why: A single = assigns a value to a variable, while == compares two values and returns True or False. Using = in a condition causes an error.
Q4. What does the else block do?
- A. It runs when the if condition is True
- B. It runs when the if condition is False ✓
- C. It always runs
- D. It repeats the if block
Why: The else block runs only when the if condition evaluates to False, giving your program an alternative path to follow.
Q5. What is the indentation role in an if statement?
- A. It makes the code look neater but has no effect
- B. It tells Python which lines belong to the if block ✓
- C. It sets the value of the condition
- D. It is only required for comments
Why: Python uses indentation to determine which lines belong to a block. Lines indented under the if statement run only when its condition is True.
Module 4
Module 4: Repeating Tasks Without Repeating Yourself
Repeating Tasks Without Repeating Yourself
Knowledge check
Q1. Which Python keyword is used to repeat a block of code a fixed number of times over a sequence?
- A. repeat
- B. for ✓
- C. loop
- D. while_each
Why: The 'for' keyword lets you iterate over each item in a sequence such as a list, range, or string, running the indented block once per item.
Q2. What does range(3) produce when used in a for loop?
- A. The numbers 1, 2, 3
- B. The numbers 0, 1, 2 ✓
- C. The numbers 0, 1, 2, 3
- D. The number 3 three times
Why: range(3) generates integers starting at 0 and stops before 3, so it yields 0, 1, and 2. Python counting from zero is a common source of confusion for beginners.
Q3. What does the 'while' loop do?
- A. It runs once and then stops automatically
- B. It repeats a block as long as a condition is True ✓
- C. It loops through every item in a list
- D. It defines a new function
Why: A while loop keeps running its indented block as long as its condition evaluates to True, so it is useful when you do not know in advance how many repetitions you need.
Q4. Inside a loop, what does the 'break' statement do?
- A. It pauses the program for one second
- B. It skips only the current iteration
- C. It exits the loop immediately ✓
- D. It causes an error
Why: break stops the loop entirely and moves execution to the code after the loop. To skip just one iteration and continue with the next, you would use continue instead.
Q5. What is the output of this code?
for letter in 'hi':
print(letter)
- A. hi
- B. h i
- C. h and i on separate lines ✓
- D. An error, because strings cannot be looped
Why: Strings are sequences, so the for loop visits each character in turn. The print function outputs 'h' on one line and 'i' on the next.
Module 5
Module 5: Lists: Keeping Track of Many Things
Lists: Keeping Track of Many Things
Knowledge check
Q1. Which of the following creates a list in Python that holds three fruit names?
- A. fruits = ("apple", "banana", "cherry")
- B. fruits = ["apple", "banana", "cherry"] ✓
- C. fruits = {"apple", "banana", "cherry"}
- D. fruits = <"apple", "banana", "cherry">
Why: Lists in Python are created with square brackets [ ] and items separated by commas. Parentheses create a tuple, curly braces create a set or dictionary, and angle brackets are not valid Python syntax for lists.
Q2. What will print(colors[0]) output if colors = ["red", "green", "blue"]?
- A. green
- B. blue
- C. red ✓
- D. Error
Why: Python lists are zero-indexed, meaning the first item is at position 0. So colors[0] refers to "red", the first item in the list.
Q3. Which list method adds a single item to the end of an existing list?
- A. add()
- B. insert()
- C. append() ✓
- D. push()
Why: The append() method adds one item to the end of a list. Python lists do not have add() or push() methods, and insert() requires specifying a position where the item should go.
Q4. What is the value of len(numbers) if numbers = [4, 8, 15, 16, 23, 42]?
Why: The len() function returns the number of items in a list. This list contains six numbers: 4, 8, 15, 16, 23, and 42, so the length is 6, not the last value 42.
Q5. What does the slice my_list[1:3] return if my_list = ["a", "b", "c", "d", "e"]?
- A. ["a", "b", "c"]
- B. ["b", "c"] ✓
- C. ["b", "c", "d"]
- D. ["c", "d"]
Why: Slicing with [start:stop] includes the item at the start index and stops before the stop index. So [1:3] includes indexes 1 and 2, which are "b" and "c".
Module 6
Module 6: Functions: Teaching Python Your Own Tricks
Functions: Teaching Python Your Own Tricks
Knowledge check
Q1. What keyword is used to define a function in Python?
- A. func
- B. def ✓
- C. function
- D. define
Why: In Python, functions are defined using the keyword def, followed by the function name and parentheses. For example: def greet():
Q2. What does a function return if it has no return statement?
- A. 0
- B. An empty string
- C. None ✓
- D. An error is raised
Why: When a function finishes without a return statement, Python automatically returns None, which represents the absence of a value.
Q3. Given def add(a, b): return a + b, what does add(3, 4) evaluate to?
Why: The arguments 3 and 4 are assigned to a and b, and the function returns their sum, 7. Note that with numbers, + performs addition, not concatenation.
Q4. What is a parameter with a default value, such as def greet(name='friend'), useful for?
- A. It makes the function run faster
- B. It forces the caller to always provide a value
- C. It lets the caller omit that argument, using the default instead ✓
- D. It prevents the function from returning anything
Why: Default values let you call greet() with no argument and have name set to 'friend' automatically, while still allowing greet('Sam') to override it.
Q5. Which statement about variables defined inside a function is true?
- A. They are accessible from anywhere in the program
- B. They exist only within that function (local scope) ✓
- C. They are automatically saved between program runs
- D. They can only store numbers
Why: Variables created inside a function are local to it. They disappear once the function finishes, which keeps functions self-contained and prevents accidental interference with other code.
Module 7
Module 7: Automating a Boring Task End to End
Automating a Boring Task End to End
Knowledge check
Q1. Which Python module is most commonly used to read and write files on disk when automating a boring task?
- A. socket
- B. os ✓
- C. threading
- D. random
Why: The os module (along with the built-in open() function) provides tools for working with files and folders, such as listing directory contents, checking whether a path exists, and creating new folders. Socket handles network connections, threading handles concurrent execution, and random generates random numbers, so none of those are the right fit for managing files.
Q2. What does the line `for filename in os.listdir(folder):` do?
- A. It deletes every file inside the folder
- B. It creates a new file for each item in the folder
- C. It loops through the names of all items in the folder, one at a time ✓
- D. It copies the folder to a new location
Why: os.listdir(folder) returns a list of the names of files and subfolders inside the given folder. The for loop then assigns each name to the variable filename in turn, letting you process each item one at a time. It does not delete, create, or copy anything by itself.
Q3. Why is it a good practice to test an automation script on a copy of your files before running it on the originals?
- A. Python cannot run on original files
- B. Copies run faster than originals
- C. A bug could delete, overwrite, or scramble important files, and a copy protects your real data ✓
- D. Copies automatically fix errors in the script
Why: Automation runs fast and repeats actions across many files, so a small mistake in the logic can cause large-scale damage like deleting or overwriting data. Testing on a copy lets you find and fix those mistakes without risking your originals. Python works fine on original files, and copies do not fix script errors.
Q4. In an end-to-end automation script, what is the purpose of a 'dry run' mode?
- A. To run the script without an internet connection
- B. To make the script run as fast as possible
- C. To print or log what the script would do without actually making changes ✓
- D. To permanently lock files so they cannot be edited
Why: A dry run shows the planned actions, such as which files would be moved or renamed, without performing them. This lets you check the script's behavior safely before committing to real changes. It has nothing to do with internet access, speed, or locking files.
Q5. Which approach best describes an 'end-to-end' automation of a boring task?
- A. Writing a script that handles the entire workflow, from finding the input to producing the final result, without manual steps in between ✓
- B. Automating only the very first step and doing everything else by hand
- C. Writing separate scripts for every individual file in the folder
- D. Recording your mouse movements and replaying them later
Why: End-to-end automation means a single process covers the whole task: gathering the inputs, performing the work, and delivering the output, with no manual handoffs in the middle. Automating only one step leaves manual work behind, writing a separate script per file defeats the purpose, and recording mouse movements is fragile and not a true script-based workflow.