← All lessons

Data types

Sign in · Sign up

Lesson 1.1

Every value in Python has a type. These are the four main ones:

Type What it is Example
str text "Mia"
int whole number 14
float decimal number 1.75
bool true or false True

The new command type(value) tells you what type something is. print(...) shows the answer on screen.

Print four lines — the type of some text, of a whole number, of a decimal number and of a boolean:

<class 'str'>
<class 'int'>
<class 'float'>
<class 'bool'>

print(type("Mia")) is enough for the first line, and the same idea for the rest.

Hint

type(value) returns the type, and print shows it.

The value must go inside type(...): type first, then the value. Four lines — the four types from the task: text in quotes, a whole number, a decimal number with a dot, and True.