Skip to main content

Lessons and exercises

Variables, types, operators, and control flow. Python hides type declarations, which makes the language friendly to start and makes type errors appear later than they would elsewhere.

Lesson 1.1

Variables and Dynamic Typing

A Python variable is a name bound to an object, and the type belongs to the object rather than to the name. Rebinding a name to a different type is legal.

Lesson 1.2

Numeric Types and Division

The two division operators differ: one always produces a float, the other floors toward negative infinity. Mixing int and float promotes to float.

Lesson 1.3

Strings and Formatting

Strings are immutable sequences. Formatted string literals interpolate expressions directly and are the clearest way to build output.

Lesson 1.4

Conditionals and Loops

Indentation defines blocks, so structure is enforced by layout. A for loop iterates over a sequence directly rather than over indices.

Need help with this topic?

Work through questions with a tutor and get help with the steps you find difficult.

Get help with this topic