Python · live now

Basic data types

The types Python builds everything else from: integers, floats, booleans and strings, formatting with f-strings, arithmetic, and converting between types.

No account needed to read a lesson · 30-day money-back guarantee

See the full learning path

8

lessons

87

practice questions

7

prerequisite lessons

See it taught

1 of the 8 lessons here is free to preview - the whole explanation and worked example, with no account and no email.

The editor you get

A still of the editor, not a live one

Python Editor

1 2 3
value = "7" number = int(value) print(number + 1, type(number))

Editor Output

1

Output:

8 <class 'int'>

You write and run Python in the browser - nothing to install, no setup. Questions are marked on the values your code produces. The snippet here is an example of the kind of code you write.

The 8 lessons

The 8 lessons in this unit. Expand any one to see what it covers. Each unlocks when its own prerequisites are passed.

01

Integers

9 questions

Learn how to define integer values in Python by assigning whole numbers, including both positive and negative numbers, and use underscores to improve the readability of large integers.

Covers

Creating integers from literal values

Writing integers

02

Floats

12 questions

Learn how to define floating-point numbers in Python using decimal and scientific notation, understand why floats can be imprecise due to their binary representation, and use the round() function to control the number of decimal places displayed.

Covers

Creating floats from literal values

Imprecision of floats

Rounding floats

03

Booleans

12 questions

Understand how Python represents truth values with the boolean constants True and False, how to use the logical operators and, or and not to combine or negate boolean values, and how operator precedence affects the evaluation of complex boolean expressions.

Covers

True and False

Logical operators: and, not, or

Creating booleans from logical expressions

04

Strings

Preview

14 questions

Learn how to create strings using different types of quotes, combine and repeat strings with operators, and use basic string methods for transforming and searching text in Python.

Covers

Creating strings from literal values

Concatenating and repeating strings

Basic string methods

Preview this lesson - no account needed

05

f-strings

4 questions

Learn how to use Python f-strings to embed variables and expressions directly into strings for clear and concise output formatting.

Covers

What is an f-string?

06

Basic arithmetic

12 questions

Understand how to use Python's arithmetic operators to perform calculations, combine them following operator precedence, and compute integer quotients and remainders using floor division and modulus.

Covers

Arithmetic operators

Combining arithmetic operators

Floor division and modulus for positive numbers

07

Type conversions

20 questions

Understand how to convert between Python types using built-in functions, including how implicit and explicit conversions work and the rules for converting between strings, integers, floats, and booleans.

Covers

What is type conversion?

Explicit type conversion using int()

Explicit type conversion using float()

Explicit type conversion using bool()

Explicit type conversion using str()

08

Activity: user profiles

4 questions

Practise working with strings, integers, floats and booleans by writing four functions that fill in a customer's name, birth year, account balance and promotion eligibility.

Covers

Create the customer name

Calculate birth year

Calculate account balance

Determine eligibility

Create user profile

Where this unit sits in the curriculum

This unit is part of our Python Done Right learning path, which contains 100 lessons. Every one of them is drawn below.

The diagnostic test lets you skip any lesson you already know, including the ones in this unit.

Every dot is a lesson and every line a prerequisite. The 8 red dots are the lessons in Basic data types; the 7 blue dots feeding into them are the lessons Basic data types depends on; the 85 pale dots are the rest of the learning path, which come after Basic data types or alongside it.Basic data typesFirst lessons on the left100 lessons

Hover any dot to name its lesson.

8 lessons in this unit

7 prerequisite lessons across the unit, counting every step back to the start

85 other lessons in the learning path - after this unit, or alongside it

Every dot is a lesson, every line a prerequisite. You can only start a lesson once you have mastered all of its prerequisites, so you are always building on solid foundations.

Start Basic data types

One subscription covers every learning path, and you can test out of anything you already know.

One subscription covers every learning path · 30-day money-back guarantee

More in Introduction to Python: Python basics