Variables and data types

Numbers, strings, booleans, and converting between them.

A variable is a name for a value. You do not declare a type, because Python works it out from the value.

Expected output
str
int
float
bool

Converting types

input() always gives you text. Convert it before doing arithmetic.

Expected output
255
30
99%

Operators

Expected output
3.5
3
1
32

Those are true division, floor division, remainder and power. The remainder is the usual way to test for even numbers.

โ† Getting started with PythonStrings โ†’