Fundamentals 4 min read

Introduction to Python Data Types: int, float, str, list, tuple, and dict

This article introduces the six fundamental Python data types—integers, floats, strings, lists, tuples, and dictionaries—explaining their purpose, characteristics, and providing clear code examples to help beginners understand and apply them effectively in programming.

Test Development Learning Exchange
Test Development Learning Exchange
Test Development Learning Exchange
Introduction to Python Data Types: int, float, str, list, tuple, and dict

Welcome to the Python beginner village! In this tutorial we explore the core data types of Python, which are the building blocks of any program and essential for a solid start in coding.

Integer (int)

Integers store whole numbers without a decimal point.

age = 25  # define an integer variable
print(age)

Float (float)

Floats are used for numbers that contain a decimal point.

pi = 3.14159  # define a float variable
print(pi)

String (str)

Strings are sequences of characters enclosed in single or double quotes.

greeting = 'Hello, world!'  # single‑quoted string
print(greeting)
message = "I'm learning Python."  # double‑quoted string
print(message)

List (list)

Lists are mutable ordered collections that can hold items of any type.

fruits = ['apple', 'banana', 'cherry']  # define a list
print(fruits)
fruits.append('orange')  # add an element to the end
print(fruits)
print(fruits[0])  # access the first element

Tuple (tuple)

Tuples are similar to lists but immutable once created, useful for fixed sequences.

colors = ('red', 'green', 'blue')  # define a tuple
print(colors)
print(colors[1])  # access the second element

Dictionary (dict)

Dictionaries store key‑value pairs, ideal for data with unique identifiers.

person = {'name': 'Alice', 'age': 30, 'city': 'New York'}  # define a dict
print(person)
person['age'] = 31  # modify a value
print(person)
print(person['name'])  # access a value by key

These six data types each have unique strengths and uses; mastering them enables you to write more efficient, elegant, and powerful Python code.

PythonData Typestutorialbasics
Test Development Learning Exchange
Written by

Test Development Learning Exchange

Test Development Learning Exchange

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.