OpenViSTAI · Agents · Blockchain · Crypto
Menu

OPENVIST LEARN · FREE LESSONS

Numbers, types and conversion

Work with integers and decimals while recognising that text containing digits is still text.

Lesson 3 of 22 · About 20 minutes · Beginner · English

By the end of this lesson

Choose a numeric type and convert numeric text deliberately.

Before you start

  • Python 3.12 or a compatible newer Python 3 interpreter; no external packages.
  • Complete lesson 2 in this route, or be comfortable with its examples.

Three words to know

int
An integer, such as 12.
float
A floating-point approximation of a number with a fractional part.
Type
The kind of value that determines supported operations.

1. Calculate a small workload

Use +, -, * and / for arithmetic. Parentheses make grouping explicit. The / operator returns a float even when the result is mathematically an integer. // is floor division; with positive values it counts complete groups. % gives the remainder.

Pages in batchesPYTHON · save as lesson.py, then run with your interpreter
pages = 17
batch_size = 5
print(pages // batch_size)
print(pages % batch_size)
print(pages / batch_size)
What you should see · example output
3
2
3.4

2. Convert text explicitly

The text "12" and the number 12 have different types. int converts valid integer text. int("twelve") raises ValueError; later lessons handle this. Inspecting a value’s type helps explain a surprising result.

Digits are not automatically a numberPYTHON · save as lesson.py, then run with your interpreter
raw = "12"
print(raw + raw)
print(int(raw) + int(raw))
print(type(raw).__name__)
What you should see · example output
1212
24
str

3. Choose a suitable representation

A float is useful for approximate measurements but does not represent every decimal fraction exactly. For this practice price total, store whole cents as integers. This is a teaching convention, not a complete accounting system; rounding, currencies and tax rules need separate decisions.

Whole centsPYTHON · save as lesson.py, then run with your interpreter
unit_cents = 125
quantity = 3
total_cents = unit_cents * quantity
print(total_cents)
print(f"{total_cents / 100:.2f}")
What you should see · example output
375
3.75

YOUR TURN

A small check before you continue

With 23 pages and batches of 6, how many full batches and remaining pages are there?

Show a suggested answer

23 // 6 is 3 and 23 % 6 is 5. Four batches are required to include every page, because the last batch is partial.

Sources and scope

Documentation and examples reviewed 2026-10-18. Provider screens, package versions and output wording can differ. Examples show expected outcomes; they are not a claim that OpenViST connected to your server or verified your setup.