← All lessons

Numbers

Sign in · Sign up

Lesson 1.2

Python has two kinds of numbers:

  • int — whole numbers: 14, 0, -3;
  • float — decimal numbers: 1.75, 0.5.

The decimal part is separated by a dot, not a comma:

age = 14
height = 1.75

As in the previous lesson, type(...) shows the kind of value and print(...) outputs it.

Print two lines — the kind of a whole number and the kind of a decimal number:

<class 'int'>
<class 'float'>

Try 0 and 3.0 too: type(3.0) is decimal as well, even though it looks like a whole number.

Hint

A whole number is written without a dot, a decimal number with one. type(...) shows the type.

Two lines: type(14) and type(1.75), each inside print.