Lecture 1
Important bit here is to connect to scratch as much as possible. Hence, the slides in Lecture Resources are an important collateral. Some theory before live coding:
- Source Code
- Machine Code
- Compiler (
C) vs Interpreter (Python): don't bother much, anyways they won't understand, just briefly talk about it - Start with simple
print("hello, world")and compare toSayblock in Scratch (not on demo yet) - GUI vs CLI (what type of programs they are going to build, draw parallels with
lsetc. in terminal)
Live
Use the terminal
touch hello.py
cat hello.py # empty
echo "print('hello, world')" # just to remind this will just print
echo "print('hello, world')" >> hello.py
cat hello.py # only 1 line of source code
## run the source code
python hello.py # python3 in their Ubuntu based laptops
# hello, world
Break down the line:
print("hello, world") # f(x)
Explain function, argument, and why the shape of argument in Scratch is an oval (to resemble the braces in code). Also, explain side effects and output.
Then move on to use input to ask for name and print hello, name. Use this slide as a reference:

- Explain concatenation ("a" + "b" = "ab", but 1 + 2 = 3, i.e. python is smart) in brief.
- Explain variables (
answer).
Then take the below example, explain them line by line, then ask them to turn their laptops on!
name = input("What is your name?")
age = input("What is your age?")
print("Hello, " + name + "." + "You are " + age + " years old."
It is time for them to create a simple python file using terminal, open it using open and copy the exact content on the screen. Then save and run.
Ask them to make mistakes on purpose
So they get exposure to reading error messages
- Change
printtoPrint(name error)
REPL Session
Ask them to just run python3 without any filename. Ask them to run as asked:
2*22+72**55/25//2age = 2,age = age + 1,age(will print the age)age = input(...),age,age = age + 1[IMPORTANT]- Explain the difference (
18vs'18') and the error - Show using
intfunction
- Explain the difference (
exit
Naming Variables
Three rules they should have by heart for naming variables in python:
- Must not start with a number
- Must not contain any special character other than underscore
_ - Must not be a reserved keyword (e.g.
if)
Take a few valid and invalid examples in REPL and help them apply these rules.
Syntax Highlighting
Ubuntu text editor will already do this so, explain in brief. Open the file in VS Code and show syntax highlighting and other perks (red squiggly lines).
Homework
Write a python program:
- Ask for side of square, print area and perimeter
- Same for circle (float)
- Absolute value of a give number (hint to check python manual on student manual wiki)
- Ask for price and print discounted price if discount is 15%.
Share link and ask to install VS Code 😎
Lecture 2
Variables re-iterated with the box analogy. Python makes a box, applies a label (variable name), and puts the value in the box. What if the box doesn't exist and you ask python for it anyways? (NameError)
Data Types
- String
- Number: int, float
Operators
- Arithmetic operations:
+,-.*,/,//,** - Logical Operators (
and,or,not)- Introduce and Connect
booleandata type here
- Introduce and Connect
- Comparison operations:
<,>,>=,<=,==(explain why not=)!= - Assignment operators:
=,+=,-=, etc. (show with an example)
Help practice operators with output and trace table based questions, e.g.
a = 2
b = 5
b = a + b
a = b ** 2
print(a, b)
Homework
Lecture 3
Review the worksheets submitted and do all questions explaining them things they missed and how they should have approached the problems.
Ended with:
end,sepinprintwith examples. Gave them a worksheet with 100+ problems to sprint in a day or two: Worksheet 2