1. Python
  2. Fundamentals
  3. Data Types

Python Data Types

Last updated:

Strings

Sequences of characters, such as words or sentences - can be enclosed in single quotes (‘ ‘) or double quotes (“ “):

name = 'John Doe'
message = "Welcome to Python!"

The type of the name and message variables is str.

String interpolation (f-strings):

name = "Python"
message = f"Welcome to {name}!"

Numbers

Integers

Represent whole numbers, both positive and negative.

age = 25
temperature = -10

Floats

Represent real numbers, including decimals and fractions.

pi = 3.14159
weight = 75.5

Booleans

Booleans represent the logical values of True or False and are commonly used in conditional expressions and control structures:

is_adult = True
is_raining = False