Getting Started6 lessons, and everything around them.
Watch each lesson, answer its quiz, then do its practice. After the last lesson: the module quiz, the project, and the interview questions.
The lessonsin the order to take them.
- 1.1Why Python?Say what Python is and why it is used for AI and machine learning, and know where Python code is written and run. Open
- 1.2Run Your First Python CodeRun Python in a notebook and know what happens when a cell executes. Open
- 1.3Variables, Keywords and IdentifiersBind names to objects, and name variables by Python's rules. Open
- 1.4Data TypesKnow the basic types and how they convert. Open
- 1.5Input, Output and FormattingRead input and print results readably. Open
- 1.6OperatorsCompute and compare with Python's operators, and know their precedence. Open
Glossaryevery term the module introduces.
Each with the lesson that introduces it.
- programming language
- precise rules for writing instructions a computer can carry out 1.1
- interpreted
- the interpreter executes code one statement at a time 1.1
- library
- published code your program can import and use 1.1
- notebook · cell
- a document made of cells; a code cell holds Python, a text cell holds notes 1.1
- function · argument
- a named piece of code that does one job · a value passed to it 1.2
- string
- text, written in quotes 1.2
- statement
- one instruction 1.2
- comment
- text after
#, skipped when the code runs 1.2 - kernel · execution count
- runs the cells and keeps their names · the order cells ran 1.2
- variable · assignment
- a name given to a value · the instruction that gives it 1.3
- object · namespace · bind
- a value in memory with its type · the table of names · add a name with a reference to an object 1.3
- identifier · keyword
- the name of a variable · a word Python reserves (35 in 3.12) 1.3
- int · float · complex · bool · str · None
- whole number · decimal number · complex number · True/False · text · no value 1.4
- type annotation
- the intended type,
age: int = 7; not checked by Python 1.4 - "f" string · format specifier
f"{price:.2f}"· after the colon, how a value is shown 1.5- operator · operand · expression
+· the values it works on · code that evaluates to a value 1.6- precedence
- the order operators run in:
**, unary-,* / // %,+ -, comparisons,not,and,or1.6
Module quiz15 questions across it all.
Take it after the last lesson. Write each answer down before you check it.
- 01
Python code is executed one statement at a time by which program?
- 02
What does a notebook cell show when its last line is
2.25 + 1.25 + 3.50, with noprint? - 03
After a restart, a cell containing
total = bread + milk + eggsis run before the cell that createsbread. What happens? - 04
After
a = 24.75andb = a, what isa is b? - 05
Then
a = 26.25. What isb? - 06
Is
2nd_itema valid identifier? Isitem_2? - 07
What is
bool("False")? - 08
What is
int(-7.9)? - 09
What does
int("3.0")give? - 10
A user types
3atpeople = input("People: "). What ispeople * 2? - 11
What does
print("Total: {x}")print, whenx = 5? - 12
What is
f"{1234.5:,.2f}"? - 13
What is
10 / 5? And-7 // 2? - 14
What is
70 / 1.75 ** 2, to one decimal place, and why is it not1600.0? - 15
What is
round(2.5)? And0.1 + 0.2 == 0.3?
Project: Bill Splitterbuild it without a template.
Stated as a problem, with no step-by-step instructions. Working out the steps is the point.
The task
Write a program, in one Colab notebook, that does the following.
04_module_project.ipynb checks the core of it (the total, the
shares, and how many people pay a cent more). Your program must:
- asks for the bill amount, the tip as a percentage, and the number of people;
- prints the tip, the total with tip, and each person's share, each to the cent
and with a
$sign; - prints the shares so that they add up to exactly the total, even when the total does not divide evenly;
- has a comment on every line that computes something.
Notebooksthat check your answers.
Open them in Google Colab. Each answer is checked as you go: correct, wrong with the expected value, or not answered yet.
- Notebook 1 · Getting StartedLessons 1.1 and 1.2 Sign in to download
- Notebook 2 · Variables and Data TypesLessons 1.3 and 1.4 Sign in to download
- Notebook 3 · Input, Output and OperatorsLessons 1.5 and 1.6 Sign in to download
- Notebook 4 · Project: Bill SplitterThe module project, with checks Sign in to download
Referencefor revising and for interviews.
The cheat sheet is one page of the module’s terms, rules and gotchas. The interview questions come with model answers.