Contents

Week 1: Introduction to Python — Setup, print, Variables, Data Types and Operators

Month 1 | Main goal: The student can write and run a small Python program that takes input, does calculations, and displays the results.

Teacher Preparation (read before the week starts)

  • Install on your first computer (the one you will share your screen from):
    1. Python 3.12 or later from https://www.python.org/downloads/windows/ — during installation tick "Add python.exe to PATH" (this is very important).
    2. VS Code from https://code.visualstudio.com/
    3. Inside VS Code: Extensions (Ctrl+Shift+X) → search for "Python" (by Microsoft) → Install.
  • Try it yourself first: open PowerShell and type python --version. If you see Python 3.12.x (or later), you are ready. If you see a Microsoft Store message or "not recognized", see the "Common mistakes" section of Session 1.
  • Create the folder C:\Users\<jina>\Documents\python_darasa\wiki01 — we will create files inside it in every session.
  • In Google Meet: try "Present now → A window → VS Code". Increase the VS Code font size: press Ctrl + = 3–4 times so the student can see clearly.
  • Read: https://docs.python.org/3/tutorial/introduction.html. Don't worry about understanding everything.
  • Ask the student to install Python and VS Code themselves. If they can't manage it, Session 1 will help them.

Week Goals (by the end of the week the student will be able to...)

  1. Install Python and VS Code, and run a .py file from VS Code and PowerShell.
  2. Use the REPL (>>>) to try out short pieces of code.
  3. Use print() and comments (#).
  4. Create variables and know the data types int, float, str, bool, and use type().
  5. Receive data with input() and convert data types (type conversion): int(), float(), str().
  6. Use arithmetic operators (+ - * / // % **), comparison operators (== != < > <= >=) and logical operators (and or not).
  7. Write a small complete program: e.g. a BMI calculator or a product price calculator.

Session 1 — Introduction, Setup, REPL, print and comments

Session flow

  1. Getting to know each other, course goals, how we will work (Meet + VS Code)
  2. What is Python? What is a program? Why Python?
  3. Setup: make sure Python + VS Code + the extension are installed for the student
  4. REPL: python in PowerShell, trying out calculations
  5. Short break
  6. First file salamu.py (greetings): print(), running it with ▶ and with python salamu.py
  7. Comments # and the first errors (SyntaxError, NameError)
  8. In-class exercise
  9. Q&A + homework

Explanation for the teacher (read this first)

  • A program is a list of instructions that the computer follows in order, line by line, from top to bottom.
  • Python is a programming language. We write instructions in a file ending in .py, then a program called the interpreter (python.exe) reads that file and carries out the instructions.
  • VS Code is an "editor" — it is like Microsoft Word, but for code. VS Code itself is not Python; it uses the Python you installed.
  • Terminal / PowerShell is a window for typing text commands. Inside VS Code you open it with Ctrl + ` (the key above Tab).
  • REPL (Read–Eval–Print Loop): when you type python in the terminal you get the >>> prompt. You type one line and Python answers immediately. It is like a "calculator for experiments". To exit: type exit() or press Ctrl+Z then Enter (Windows).
  • Key difference: the REPL shows values without print. In a file, you must use print() to see anything.
  • print() is a function that displays text on the screen. Text must be inside quotation marks, "..." or '...'.
  • A comment is a line starting with #. Python ignores it. It is there for humans to read.
  • Python is case-sensitive: print is not the same as Print.

Say this to the student

  • "Imagine the computer is a cook who knows nothing at all. You are the one writing the recipe (the program). The cook follows every step exactly as written — even if you make a mistake, the cook will follow your mistake! That's why we say a computer is a 'very fast fool'."
  • "Python is a language that both humans and computers understand easily. It is used by Instagram, YouTube, NASA, and in AI."
  • "VS Code is our notebook. The terminal is where we give the computer commands one at a time."
  • "The REPL is like talking to Python face to face: you ask, it answers immediately. A .py file is like writing it a long letter — it reads the whole thing, then acts on it."
  • "A comment is like a pencil note in the margin of your notebook — the teacher (Python) doesn't read it; it's for you."

Type this code live (share screen)

Step 1 — Checking that Python is there. Open PowerShell (or the terminal inside VS Code):

powershell
python --version

Expected output (the number may differ):

text
Python 3.12.7

If python doesn't work, try py --version (the Windows Python Launcher).

Step 2 — REPL.

powershell
python
python
>>> 2 + 3
5
>>> 10 * 4
40
>>> 7 / 2
3.5
>>> "Habari"
'Habari'
>>> print("Habari Tanzania")
Habari Tanzania
>>> exit()

Explain: "Look, 'Habari' (hello) was shown with quotes — the REPL shows the value itself. print shows 'clean' text without quotes."

Step 3 — First file. VS Code → File → Open Folder → choose wiki01. Create a new file salamu.py:

python
# Programu yangu ya kwanza
# Mwandishi: <jina la mwanafunzi>

print("Habari, dunia!")
print("Karibu kwenye darasa la Python")
print("Leo ni siku ya kwanza")

Press ▶ (Run Python File) at the top right. Output:

text
Habari, dunia!
Karibu kwenye darasa la Python
Leo ni siku ya kwanza

Then show the second way, in the terminal:

powershell
python salamu.py

Step 4 — print with several items.

python
print("Jina:", "Amina")          # print inaweka nafasi (space) kati ya vitu
print("Umri:", 20)
print(5 + 7)                      # inahesabu kwanza, kisha inaonyesha
print("5 + 7")                    # hii ni maandishi tu, haihesabu!
print()                           # mstari mtupu
print("Dar", "Arusha", "Mwanza", sep=" - ")
print("Hakuna mstari mpya", end=" ")
print("<- tuko mstari ule ule")

Output:

text
Jina: Amina
Umri: 20
12
5 + 7

Dar - Arusha - Mwanza
Hakuna mstari mpya <- tuko mstari ule ule

Step 5 — Quotes inside text.

python
print('Alisema "Asante"')
print("It's a nice day")
print("Mstari wa kwanza\nMstari wa pili")   # \n = mstari mpya
print("Jina:\tAmina")                       # \t = tab

Output:

text
Alisema "Asante"
It's a nice day
Mstari wa kwanza
Mstari wa pili
Jina:	Amina

Step 6 — Make a mistake on purpose so the student doesn't fear errors:

python
Print("Habari")
text
NameError: name 'Print' is not defined. Did you mean: 'print'?

"An error is not the enemy — it is Python telling you where the problem is. Read the last line first."

Questions to ask the student

  1. Question: What is the difference between the REPL and a .py file? — Answer: The REPL answers one line immediately and doesn't save your work; a file is saved and runs all at once.
  2. Question: What do print("3 + 4") and print(3 + 4) output? — Answer: The first gives 3 + 4 (text), the second gives 7 (a calculation).
  3. Question: What does a line starting with # do? — Answer: Nothing; it is a comment, and Python ignores it.
  4. Question: What happens if you write print(Habari) without quotes? — Answer: NameError, because Python thinks Habari is a variable name.
  5. Question: In what order does Python read a file? — Answer: Top to bottom, line by line.

Common mistakes

Mistake Error message Fix
Python was not added to PATH python : The term 'python' is not recognized... or it opens the Microsoft Store Reinstall with "Add python.exe to PATH" ticked, or use py instead of python. Close and reopen VS Code.
Typing Python code directly into PowerShell (not the REPL) print : The term 'print' is not recognized or a PowerShell error Type python first to enter the REPL, or put the code in a .py file.
Typing a PowerShell command inside the REPL >>> python salamu.py → SyntaxError: invalid syntax Exit the REPL with exit() first.
Forgetting quotes NameError: name 'Habari' is not defined Put text inside "...".
Mismatched quotes SyntaxError: unterminated string literal Start and end with the same mark: "..." or '...'.
Forgetting parentheses print "Habari" → SyntaxError: Missing parentheses in call to 'print' Use print("Habari").
Capital letters Print(...) → NameError Python is case-sensitive: print.
The file wasn't saved The program runs the old version Ctrl+S before running (or turn on File → Auto Save).

In-class exercise

  1. Create kadi.py (card) that displays an ID card: name, town, school/work, and something you like — each on its own line, with a comment at the top explaining what the file does.
  2. Use only one print (with \n) to display three lines: Moja, Mbili, Tatu (one, two, three).
  3. In the REPL, calculate: how many seconds are there in one day?
Answer
python
# kadi.py — inaonyesha kadi ya utambulisho
print("==== KADI YANGU ====")
print("Jina: Amina Juma")
print("Mji: Dodoma")
print("Shule: Sekondari ya Jamhuri")
print("Ninapenda: Mpira wa miguu")
print("====================")
python
print("Moja\nMbili\nTatu")
python
>>> 60 * 60 * 24
86400

Session 2 — Variables, Data Types, type(), input() and Type Conversion

Session flow

  1. Homework review (card + print)
  2. Variables: what they are, how to name them (naming rules), changing a value
  3. Data types: int, float, str, bool + type()
  4. Break
  5. input() — receiving data from the user
  6. Type conversion: int(), float(), str(), bool()
  7. In-class exercise
  8. Q&A + homework

Explanation for the teacher (read this first)

  • A variable is a name that holds (points to) a value. umri = 20 (umri = age) means "the name umri now holds 20". The = sign is not the "equals" of mathematics; it is assignment ("put"). The right-hand side is calculated first, then the result is stored in the name on the left.
  • You can change the value: umri = 21 — the old value is lost.
  • Naming rules: names start with a letter or _; they may contain letters, numbers and _; they cannot contain spaces or -; they cannot start with a number; they cannot be Python keywords (if, for, class...). Python style: snake_case (lowercase letters + _), e.g. jina_kamili (full name).
  • The 4 main data types:
    • int — whole numbers: 5, -3, 0, 1_000_000
    • float — numbers with decimals: 3.14, 2.0, -0.5
    • str (string) — text inside quotes: "Amina", "25" (this is a str, not a number!)
    • bool — only True or False (capital first letter)
  • type(x) tells you the type of x: type(5) → <class 'int'>.
  • input("ujumbe") pauses the program, shows the message, and waits for the user to type something and press Enter. It always returns a str — even if the user types 25, you get "25".
  • Type conversion: int("25") → 25; float("2.5") → 2.5; str(25) → "25"; int(3.9) → 3 (it cuts off the decimals, it doesn't round); int("2.5") → ValueError; bool(0) → False, bool("") → False, almost everything else → True.
  • Joining strings: "Habari " + "Amina" → "Habari Amina". But "Umri: " + 20 → TypeError. Fix: "Umri: " + str(20) or print("Umri:", 20).

Say this to the student

  • "A variable is like a labelled box. The label is the name (umri), and inside the box is the value (20). If you put in something new, the old thing is taken out."
  • "In Python we read the = sign as 'put'. x = 5 → 'put 5 into x'. It isn't a question, it's an instruction."
  • "Data types are like the kinds of goods at the market: fruit is weighed by the kilo (float), eggs are counted one by one (int), the shop's name is text (str), and 'is the shop open?' has a yes/no answer (bool)."
  • "input() is like a bank clerk handing you a form — whatever you write, the clerk receives it as text. If you want to do calculations, you have to convert it to a number."

Type this code live (share screen)

Step 1 — variables.py

python
jina = "Baraka"
umri = 19
urefu = 1.72
ni_mwanafunzi = True

print(jina)
print(umri)
print(urefu)
print(ni_mwanafunzi)

Output:

text
Baraka
19
1.72
True

Step 2 — Changing a value and using a variable in a calculation

python
umri = 19
print("Umri sasa:", umri)
umri = umri + 1          # chukua umri wa sasa, ongeza 1, weka tena kwenye umri
print("Mwaka ujao:", umri)

a = 10
b = a                    # b inapata 10
a = 99
print(a, b)              # b haibadiliki

Output:

text
Umri sasa: 19
Mwaka ujao: 20
99 10

Step 3 — type()

python
print(type(19))
print(type(1.72))
print(type("Baraka"))
print(type(True))
print(type("19"))        # angalia! hii ni str

Output:

text
<class 'int'>
<class 'float'>
<class 'str'>
<class 'bool'>
<class 'str'>

Step 4 — input() (file salamu2.py)

python
jina = input("Jina lako ni nani? ")
mji = input("Unaishi mji gani? ")
print("Karibu", jina, "kutoka", mji)

Sample run:

text
Jina lako ni nani? Neema
Unaishi mji gani? Mbeya
Karibu Neema kutoka Mbeya

Explain: "Notice the space after ? inside the message — it makes the user type after a space."

Step 5 — The problem with input and numbers (show the mistake first!)

python
umri = input("Una miaka mingapi? ")
print(type(umri))
print(umri + 1)
text
Una miaka mingapi? 20
<class 'str'>
TypeError: can only concatenate str (not "int") to str

Then fix it:

python
umri = int(input("Una miaka mingapi? "))
print(type(umri))
print("Mwaka ujao utakuwa na miaka", umri + 1)
text
Una miaka mingapi? 20
<class 'int'>
Mwaka ujao utakuwa na miaka 21

Step 6 — More conversion (REPL)

python
>>> int("42")
42
>>> float("3.5")
3.5
>>> int(7.9)
7
>>> round(7.9)
8
>>> str(100) + " shilingi"
'100 shilingi'
>>> "5" + "5"
'55'
>>> int("5") + int("5")
10
>>> bool(0), bool(5), bool(""), bool("hapana")
(False, True, False, True)
>>> int("2.5")
ValueError: invalid literal for int() with base 10: '2.5'
>>> int(float("2.5"))
2

Questions to ask the student

  1. x = 5 then x = x * 2 — what is x? — Answer: 10.
  2. What is type("3.14")? — Answer: <class 'str'> (it is inside quotes).
  3. Why does input() + a calculation cause an error? — Answer: input always returns a str; we must use int() or float().
  4. Which variable names are invalid: jina_1, 1jina, jina-kwanza, _siri, for? — Answer: 1jina (starts with a number), jina-kwanza (contains -), for (a Python keyword).
  5. What does int(9.99) give? — Answer: 9 (it cuts off, it doesn't round).
  6. What does "10" + "20" give? — Answer: "1020" — it joins the text.

Common mistakes

Mistake Error message Fix
Joining a str and an int TypeError: can only concatenate str (not "int") to str str(namba) or use a comma in print.
Using a variable before creating it NameError: name 'jumla' is not defined Assign a value first; check the spelling.
Converting "2.5" with int() ValueError: invalid literal for int() with base 10: '2.5' Use float().
The user types letters instead of a number ValueError: invalid literal for int() with base 10: 'ishirini' For now: tell them to type a number. (We will learn try/except later.)
true instead of True NameError: name 'true' is not defined True / False with a capital first letter.
A space inside a name jina kamili = "Ali" → SyntaxError: invalid syntax jina_kamili.
Reversing the sides: 5 = x SyntaxError: cannot assign to literal Name on the left, value on the right: x = 5.

In-class exercise

  1. Write a program that asks for a name and year of birth, then displays "Habari , mwaka 2026 utatimiza miaka " (Hello , in 2026 you will turn ).
  2. Ask for the price of an item (it may have decimals) and the quantity, and display the total.
  3. Without running anything, predict the type() of: 10, 10.0, "10", 10 > 5. Then confirm with code.
Answer
python
# zoezi 1
jina = input("Jina lako: ")
mwaka = int(input("Mwaka wa kuzaliwa: "))
umri = 2026 - mwaka
print("Habari", jina + ", mwaka 2026 utatimiza miaka", umri)
python
# zoezi 2
bei = float(input("Bei ya kitu kimoja: "))
idadi = int(input("Idadi: "))
jumla = bei * idadi
print("Jumla ni:", jumla)
python
# zoezi 3: int, float, str, bool
print(type(10), type(10.0), type("10"), type(10 > 5))
# <class 'int'> <class 'float'> <class 'str'> <class 'bool'>

Session 3 — Operators: Arithmetic, Comparison, Logical

Session flow

  1. Homework review (input + conversion)
  2. Arithmetic operators: + - * / // % **, order of operations (precedence), shortcuts +=
  3. Comparison operators: == != < > <= >= — the result is a bool
  4. Break
  5. Logical operators: and, or, not
  6. Mini project: BMI calculator / shop price calculator
  7. Review of the whole week
  8. Q&A + homework

Explanation for the teacher (read this first)

  • Arithmetic operators: | Operator | Meaning | Example | Result | |---|---|---|---| | + | add | 7 + 2 | 9 | | - | subtract | 7 - 2 | 5 | | * | multiply | 7 * 2 | 14 | | / | divide (the result is always a float) | 7 / 2 | 3.5 | | // | divide and take the whole number (floor division) | 7 // 2 | 3 | | % | remainder (modulo) | 7 % 2 | 1 | | ** | power | 7 ** 2 | 49 |

  • Remember: 10 / 2 → 5.0 (a float), not 5.

  • % is used a lot to find out whether a number is even: n % 2 == 0.
  • // and % together: 135 minutes = 135 // 60 hours (2) and 135 % 60 minutes (15).
  • Precedence (order): ** first, then * / // %, then + -. Parentheses () beat everything. It is like BODMAS.
  • Shortcuts: x += 5 is the same as x = x + 5. Also -=, *=, /=.
  • + and * on strings: "ha" * 3 → "hahaha".
  • Comparison operators return True or False: == (equal?), != (not equal?), <, >, <=, >=. Important: = assigns; == asks "are they equal?".
  • Logical operators:
    • A and B → True if both are True.
    • A or B → True if at least one is True.
    • not A → flips it: not True → False.
  • Python allows chained comparisons: 0 <= alama <= 100 (alama = marks).
  • Floats are not 100% exact: 0.1 + 0.2 → 0.30000000000000004. This is normal on all computers. Use round(x, 2).

Say this to the student

  • "// and % are like sharing 17 mangoes among 5 children: each child gets 17 // 5 = 3, and 17 % 5 = 2 are left over."
  • "== is a question: 'are these two the same?' The answer is yes (True) or no (False)."
  • "and is like a club bouncer saying: 'you must have a ticket and be over 18'. or is like a mother saying: 'I'll be happy if you bring bread or milk' — one is enough."
  • "not is like saying 'it is not true that...'."

Type this code live (share screen)

Step 1 — hesabu.py (calculations)

python
a = 17
b = 5
print("a + b =", a + b)
print("a - b =", a - b)
print("a * b =", a * b)
print("a / b =", a / b)
print("a // b =", a // b)
print("a % b =", a % b)
print("a ** 2 =", a ** 2)

Output:

text
a + b = 22
a - b = 12
a * b = 85
a / b = 3.4
a // b = 3
a % b = 2
a ** 2 = 289

Step 2 — Precedence

python
print(2 + 3 * 4)      # 14, si 20
print((2 + 3) * 4)    # 20
print(2 ** 3 ** 2)    # 512 (inaanza kulia: 3**2=9, 2**9=512)
print(10 - 4 / 2)     # 8.0

Step 3 — Real example: minutes to hours

python
dakika_zote = int(input("Weka dakika: "))
saa = dakika_zote // 60
dakika = dakika_zote % 60
print(dakika_zote, "dakika ni saa", saa, "na dakika", dakika)
text
Weka dakika: 135
135 dakika ni saa 2 na dakika 15

Step 4 — Shortcuts

python
salio = 10000
salio -= 2500      # umenunua vocha
salio += 5000      # umepokea pesa
print("Salio:", salio)    # Salio: 12500

Step 5 — Comparison

python
x = 10
print(x == 10)    # True
print(x != 10)    # False
print(x > 3)      # True
print(x <= 9)     # False
print("a" == "A") # False (case-sensitive)
alama = 75
print(0 <= alama <= 100)   # True
n = 8
print("Ni shufwa?", n % 2 == 0)   # Ni shufwa? True

Step 6 — Logical

python
umri = 20
ana_kitambulisho = True
print(umri >= 18 and ana_kitambulisho)   # True
print(umri < 18 or ana_kitambulisho)     # True
print(not ana_kitambulisho)              # False

mvua = False
jua = True
print("Naenda nje?", jua and not mvua)   # Naenda nje? True

Write this table on the screen (truth table):

text
A      B      A and B   A or B
True   True   True      True
True   False  False     True
False  True   False     True
False  False  False     False

Step 7 — Mini project: BMI (bmi.py)

python
# Kikokotoo cha BMI (Body Mass Index)
uzito = float(input("Uzito wako (kg): "))
urefu = float(input("Urefu wako (mita, mf. 1.70): "))

bmi = uzito / urefu ** 2
print("BMI yako ni:", round(bmi, 1))
print("Uzito wa kawaida (18.5 - 24.9)?", 18.5 <= bmi <= 24.9)
text
Uzito wako (kg): 65
Urefu wako (mita, mf. 1.70): 1.70
BMI yako ni: 22.5
Uzito wa kawaida (18.5 - 24.9)? True

Questions to ask the student

  1. What does 20 / 4 give? — Answer: 5.0 (a float).
  2. 20 % 6? — Answer: 2.
  3. How do you tell whether a number is odd? — Answer: n % 2 == 1 (or n % 2 != 0).
  4. True and False or True? — Answer: True (and happens first: False or True → True).
  5. The difference between = and ==? — Answer: = assigns a value; == compares and returns a bool.
  6. "5" == 5? — Answer: False — different types (str versus int).

Common mistakes

Mistake Error message Fix
Dividing by zero ZeroDivisionError: division by zero Make sure the divisor is not 0.
= instead of == inside print print(x = 5) → TypeError: 'x' is an invalid keyword argument for print() (newer versions: print() got an unexpected keyword argument 'x') Use == to compare.
Forgetting to convert input TypeError: unsupported operand type(s) for /: 'str' and 'int' float(input(...)).
Expecting / to give an int Result is 5.0 instead of 5 Use // if you want an int.
&&, ||, ! (from other languages) SyntaxError: invalid syntax Python uses and, or, not.
Order of calculation uzito / urefu * urefu gives back the weight itself (uzito = weight, urefu = height) Use urefu ** 2 or parentheses uzito / (urefu * urefu).
Being surprised by 0.1 + 0.2 0.30000000000000004 This is normal; use round().

In-class exercise

  1. Ask for a number of seconds (e.g. 3725), and display the hours, minutes and seconds.
  2. Ask for two numbers, and display whether the first is greater than the second, and whether both are positive (> 0).
  3. Shop price calculator: ask for an item's price and the quantity; if the total is over 50,000 the customer gets a discount — display True/False for whether they qualify, and the total after a 10% discount (for now calculate jumla * 0.9, where jumla = total).
Answer
python
# zoezi 1
sekunde_zote = int(input("Sekunde: "))
saa = sekunde_zote // 3600
baki = sekunde_zote % 3600
dakika = baki // 60
sekunde = baki % 60
print(saa, "saa,", dakika, "dakika,", sekunde, "sekunde")
# 3725 -> 1 saa, 2 dakika, 5 sekunde
python
# zoezi 2
a = float(input("Namba ya kwanza: "))
b = float(input("Namba ya pili: "))
print("Ya kwanza ni kubwa?", a > b)
print("Zote ni chanya?", a > 0 and b > 0)
python
# zoezi 3
bei = float(input("Bei: "))
idadi = int(input("Idadi: "))
jumla = bei * idadi
print("Jumla:", jumla)
print("Anastahili punguzo?", jumla > 50000)
print("Jumla baada ya punguzo la 10%:", jumla * 0.9)

Homework

(Session 1 homework is checked in Session 2, Session 2 homework in Session 3, and Session 3 homework in the next session.)

HW1 (after Session 1): Create shairi.py (poem) that displays one verse of a poem or song you like (4 lines), then a line of 20 * stars using print("*" * 20). Put a comment at the top.

HW2 (after Session 2): Create wasifu.py (profile) that asks for: name, age, height (metres), and whether they are a student (type "ndiyo"/"hapana", yes/no). Display each value and its type(). Then display their age in 10 years.

HW3 (after Session 3): Create kibadilishaji.py (converter): ask for an amount in Tanzanian shillings (TZS), convert it to dollars (USD) at the rate 1 USD = 2,600 TZS (use a variable KIWANGO, rate). Display the result to 2 decimal places. Also display True/False for whether the amount is enough to buy a 50-dollar item.

Answer
python
# shairi.py — ubeti wa shairi
print("Elimu ni bahari, haina mwisho kuogelea")
print("Kila siku ni safari, maarifa kujipatia")
print("Usichoke kusubiri, mafanikio yatakujia")
print("Python tutaijua, kwa bidii na subira")
print("*" * 20)
python
# wasifu.py
jina = input("Jina: ")
umri = int(input("Umri: "))
urefu = float(input("Urefu (m): "))
jibu = input("Wewe ni mwanafunzi? (ndiyo/hapana): ")
ni_mwanafunzi = jibu == "ndiyo"

print(jina, type(jina))
print(umri, type(umri))
print(urefu, type(urefu))
print(ni_mwanafunzi, type(ni_mwanafunzi))
print("Baada ya miaka 10 utakuwa na miaka", umri + 10)

Remember: bool("hapana") is True (a non-empty string) — that's why we use jibu == "ndiyo". Tell the student this is a good discussion question.

python
# kibadilishaji.py
KIWANGO = 2600
tzs = float(input("Kiasi (TZS): "))
usd = tzs / KIWANGO
print("Dola:", round(usd, 2))
print("Inatosha kununua kitu cha $50?", usd >= 50)

If you are asked a question you don't know

End-of-week checklist

  • The student has working Python 3.12+ and VS Code + the Python extension
  • Can run a file with ▶ and with python file.py in PowerShell
  • Knows how to enter and exit the REPL
  • Uses print() with several items, sep, end, \n
  • Writes comments #
  • Creates variables with correct names (snake_case)
  • Distinguishes int, float, str, bool and uses type()
  • Knows input() returns a str and uses int()/float()
  • Uses + - * / // % ** and understands precedence
  • Distinguishes = from ==, and uses and, or, not
  • Reads error messages (the last line) without fear