Python First Steps
Write real code from the first minute, in the editor built into this page. Variables, decisions and loops: the three ideas that every program, including every AI system, is made of.
Start this course →Lessons
What you will learn
- A variable is a name for a stored value.
- The = sign means "store", not "is equal to".
- A string is text in quotes. Numbers need no quotes.
- A condition is either True or False.
- An if statement runs its indented lines only when the condition is True.
- Indentation tells Python which lines belong to the if.
- A list keeps many values under one name.
- A for loop runs its indented lines once for each item.
- A running total, updated inside a loop, is the pattern behind sums, averages and the loss of a model.
Terms explained in this course
- statement
- One complete line of instruction in a program.
- string
- A piece of text in a program, written between quotes, such as "hello".
- integer
- A whole number, such as 7 or −3.
- float
- A number with a decimal point, such as 3.14.
- variable
- A name that refers to a stored value, so that the value can be used and changed later.
- assignment
- Storing a value under a name with the = sign. age = 20 means "let age now refer to 20".
- expression
- A piece of code that works out to a value, such as 2 + 3 or price * 2.
- comment
- A note for human readers that Python ignores. It starts with the # sign.
- boolean
- A value that is either True or False.
- condition
- An expression that is either True or False, used to make a decision.
- comparison operator
- A symbol that compares two values, such as > (greater than), < (less than), == (equal to) and != (not equal to).
- if statement
- Code that runs only when a condition is True. An optional else part runs when it is False.
- indentation
- The spaces at the start of a line. Python uses them to know which lines belong inside an if or a loop.
- list
- An ordered collection of values kept under one name, written in square brackets, such as [3, 8, 5].
- loop
- Code that repeats. A for loop runs once for each item in a collection.
- bug
- A mistake in a program that makes it behave wrongly.