Development
Python Programming for Beginners
Variables, decisions, loops, functions, and small programs you can read.
Python Programming for Beginners starts from a blank file. You will write variables, decisions, loops, and functions, then put them together in short programs. No earlier coding course is assumed. Replay a lecture when a line does not behave the way you expected.
Course syllabus
01. First programs
- Install Python and run a file
The editor, the terminal, and a program that prints one line.
- A folder for this course
Keep each exercise in its own file so you can find it tomorrow.
- What a program actually is
A file of instructions the computer follows from top to bottom.
- Print a result you can read
A message that says what the program did, not only that it finished.
- Comments for the next reader
A short note above a line that will look odd in a week.
- Read a traceback
The file name, the line number, and the sentence that says what broke.
- Fix one error at a time
Change the line the traceback names, then run the file again.
- Save before you run
The terminal runs the file on disk, not the unsaved tab.
02. Variables and types
- Names and values
A name that points at a value you want to use again.
- Text and numbers
A word in quotes is not the same thing as a number you can add.
- Why the type matters
Adding two numbers and joining two pieces of text are different jobs.
- Convert a value on purpose
Turn keyboard text into a number only when the text really is a number.
- Ask for input
Read one line from the person running the program.
- A clear printed answer
Say what the number means, not just the digits.
- Names you can say out loud
A name that tells you the value, so you do not need a comment.
- Reuse a value instead of retyping it
Store the result once and use the name in the next lines.
03. Decisions
- A condition that is true or false
A comparison the program can answer yes or no.
- Decisions with if
Run a block only when the condition holds.
- An else for the other path
What the program does when the condition does not hold.
- More than two branches
Choose among several cases without stacking a mess of copies.
- Compare text carefully
Spaces and capital letters change what a match means.
- Combine two checks
Both must be true, or either one is enough. Pick the one you mean.
- A small decision exercise
A price and a discount that only apply when the rule says so.
04. Loops
- Repeat with a while loop
Keep going until a condition becomes false.
- Make sure the loop can stop
Something inside the loop has to change, or it never ends.
- Loop a known number of times
A range when you already know how many passes you need.
- Skip or leave early
Continue to the next pass, or break when the work is already done.
- A running total
Add into one variable as the loop walks the numbers.
- Do not copy the same lines
If you pasted the block twice, it wants to be a loop.
- A loop you can explain
Say when it starts, what changes, and when it stops.
05. Functions
- Name a piece of work
A function is a labelled block you can run by name.
- Parameters
Values the caller passes in, so the function is not stuck to one number.
- Return a result
Send a value back. Printing is not the same as returning.
- Call one function from another
Small functions that do one job, used by a larger one.
- A default when the caller omits a value
A sensible fallback that is still visible in the definition.
- Keep the main file short
The bottom of the file should read like the steps of the program.
- Test a function with one example
Run it with a value you can check by hand.
- Functions
The original idea, now as a lecture you can replay: name the work and return the result.
06. Lists and dictionaries
- A list of values
Several items in order, kept under one name.
- Index and length
The first item is zero, and length tells you when to stop.
- Add and remove an item
Change the list without rebuilding it by hand.
- Loop over a list
Visit each item once and do the same small job.
- Find an item
Look for a value and decide what to do if it is missing.
- A dictionary of named fields
A key you can look up, instead of remembering a position.
- A missing key
Check before you read, so a typo does not crash the program.
- A tiny address book in memory
Names and numbers stored together, then printed as a list.
07. A small program
- Describe the program before you code
Inputs, the rule, and the line you want to print.
- Split the work into functions
Read, calculate, and print as three names.
- Reject bad input
A blank line or a word where a number was required.
- The happy path
Valid input goes in, and a sentence comes out.
- A small complete program
Read input, process it, and print a clear result.
- Run it twice with different numbers
The same file should work for more than one example.
- What you would change next
One improvement you can name, even if you do not build it yet.
- Explain the file to someone else
Walk the functions in order without reading every line aloud.
Lecture videos stay with the course. Playback for enrolled students will open once payments are available. Video links are not published on this page.
