Skip to lesson content

PYTHON / LESSON 1 OF 18

Course orientation

Read the explanations, work through the examples, and complete the student tasks.

Learning goals

Understand what a program does, follow the edit and run cycle, and distinguish source code from output. The cover describes a beginner to advanced path. Treat this as a progression: basic syntax first, data structures next, then reusable programs and automation.

Explanation

A program is a set of instructions. Python evaluates expressions such as 4 + 6 and calls functions such as print to perform actions. In a code example, quoted text is a string. A line beginning with # is a comment for the reader. Comments do not appear in the output.

Practice with a tiny change at a time. Read an example, predict its result on paper, run it, and compare. When a result differs, inspect the exact line rather than randomly changing several lines. Programming improves through explanation as well as execution.

Example 1 Your learning card

Save this as learning_card.py after setting up Python in Lesson 2, or run it in an existing Python editor.

# Describe your learning goal.
print("My Python learning card")
print("Student: Ayesha")
print("Goal: build useful automation")
print("Minutes of practice:", 20 + 25)

Expected output:

My Python learning card
Student: Ayesha
Goal: build useful automation
Minutes of practice: 45

The first three calls print text. The last call receives two arguments: a label and the calculated number 45. print inserts a space between them.

Example 2 Text and arithmetic are different

print(8 + 2)
print("8 + 2")
print("Python", "practice")

Expected output is 10, then the literal text 8 + 2, then Python practice, each on a separate line. Quotation marks change how Python interprets the contents.

Common mistakes

Use straight quotation marks in code. Curly word processor quotes can cause syntax errors. Keep parentheses balanced. A .py file contains code, not the displayed output or the surrounding triple backticks.

Student tasks

1. Create a learning card with your own name, one goal, and the total minutes from three practice sessions. The minutes must be calculated, not typed as a precomputed total.

2. Print 12 multiplied by 3 as a calculation and as literal text. Confirm that the two lines differ.

3. Deliberately remove one closing parenthesis, run the file, and record the error. Restore the parenthesis and verify the program runs.

Completion check: submit two working examples and explain the difference between code and output in two sentences.