EICTA, IIT Kanpur

Python Data Types Explained: A Complete Beginner's Guide

EICTA Content Team6 April 2026

In Python, every value has a data type that tells the program what it can do with that value-whether it can be added, compared, joined, or stored in a collection.

As a beginner, understanding Python data types is one of the most important first steps because almost every bug you face early on will be related to using the wrong type or mixing incompatible types.

What Are Data Types in Python and Why Do They Matter?

A data type is like a form field type in a bank: some fields accept text, some accept numbers, and some accept dates.

Python works the same way-when it knows a variable’s type, it knows which operations make sense and which should raise an error.

age = 21
message = "My age is " + age  # TypeError
message = "My age is " + str(age)  # "My age is 21"

Python is dynamically typed, which means you don’t have to declare types; they are inferred from the value you assign, but you must still stay aware of what type each variable holds.

Best AI ML Courses Online: Enroll Today!

Built-in Python Data Types (Overview)

  • Numeric types: int, float, complex.
  • Sequence types: str, list, tuple, range.
  • Mapping type: dict (key-value pairs).
  • Set types: set, frozenset (unique values).
  • Boolean type: bool (True or False).
  • None type: NoneType (no value).
print(type(42))        # <class 'int'>
print(type(3.14))      # <class 'float'>
print(type("Hello"))   # <class 'str'>
print(type([1, 2, 3])) # <class 'list'>
print(type(True))      # <class 'bool'>
print(type(None))      # <class 'NoneType'>

Numeric Data Types in Python

Integer (int)

Integers are whole numbers-positive, negative, or zero-with no decimal point.

students_in_class = 45
temperature_delhi = -2
floors_in_building = 0
print(type(students_in_class))  # <class 'int'>

Use ints for counts, scores, indices, or anything that must always be a whole number.

marks = 95
# print("Your marks are: " + marks)  # TypeError
print("Your marks are: " + str(marks))  # "Your marks are: 95"

Enroll Now: Python for Data Science

Float (float)

Floats are numbers with a decimal point, used for prices, percentages, and measurements.

price = 299.99
pi = 3.14159
average_score = 87.5
print(type(price))  # <class 'float'>
print(10 / 2)   # 5.0  (float)
print(10 // 2)  # 5    (int, floor division)
print(0.1 + 0.2)  # 0.30000000000000004

That tiny rounding difference is normal in floating-point math; for money calculations, you can use the decimal module instead.

Complex (complex)

Complex numbers have a real and an imaginary part and are written using j.

z = 3 + 5j
print(type(z))   # <class 'complex'>
print(z.real)    # 3.0
print(z.imag)    # 5.0

These are more common in scientific and engineering applications than in everyday beginner code.

Also Read: 25 Most Important Libraries in Python for Data Science in 2026

String Data Type (str)

Strings store text, such as names, messages, and user input.

name = "Priya"
city = 'Lucknow'
message = "Welcome to EICTA, IIT Kanpur"
paragraph = """This is a
multi-line string."""
print(type(name))  # <class 'str'>
course = "digital marketing"
print(course.upper())            # DIGITAL MARKETING
print(course.capitalize())       # Digital marketing
print(course.replace("digital", "advanced"))  # advanced marketing
print(len(course))               # 18
print(course.split(" "))         # ['digital', 'marketing']
student = "Rahul"
score = 92
print(f"Student: {student}, Score: {score}")

When joining text with numbers, always convert the number to a string first using str().

Boolean Data Type (bool)

A Boolean can be only True or False and is used for all decisions in your program.

is_enrolled = True
has_paid_fees = False
age = 20
print(age >= 18)  # True
print(age == 25)  # False
marks = 85
if marks >= 60:
    print("Pass")
else:
    print("Fail")
print(bool(0))       # False
print(bool(1))       # True
print(bool(""))      # False
print(bool("hello")) # True
print(bool([]))      # False

Zero, empty strings, empty lists, and None are treated as False, while most other values are treated as True.

NoneType (None)

None represents “no value” or “nothing” and has its own type, NoneType.

result = None
print(type(result))  # <class 'NoneType'>
user_input = None  # to be assigned later

if result is None:
    print("No result found")

Always use is None rather than == None when checking for this special value.

Also Read: How to learn Python for Finance 2026

Collections: List, Tuple, Set, Dictionary

List (list)

A list is an ordered, changeable collection that can hold multiple values of different types.

subjects = ["Python", "Data Science", "Machine Learning"]
scores = [85, 92, 78, 95]
mixed = ["Arjun", 21, True, 9.5]
fruits = ["mango", "banana", "apple"]
print(fruits[0])   # mango
print(fruits[-1])  # apple
fruits.append("grapes")
fruits.remove("banana")
fruits[0] = "papaya"
print(len(fruits))

Use a list when order matters and you expect to add, remove, or update items.

Tuple (tuple)

A tuple is like a list but immutable, meaning you cannot change its values after creation.

coordinates = (28.61, 77.21)
birthday = (15, "August", 2001)
rgb_color = (255, 128, 0)
name, age, city = ("Neha", 22, "Mumbai")
point = (10, 20)
# point[0] = 99  # TypeError

Tuples are perfect for fixed data such as coordinates, dates, or any record that should not change.

Set (set)

A set stores unique values with no guaranteed order.

enrolled_students = {"Amit", "Priya", "Rahul", "Priya"}
print(enrolled_students)  # {'Amit', 'Priya', 'Rahul'}
batch_a = {1, 2, 3, 4, 5}
batch_b = {4, 5, 6, 7, 8}
print(batch_a | batch_b)  # union
print(batch_a & batch_b)  # intersection
print(batch_a - batch_b)  # difference

Sets are excellent for removing duplicates and performing mathematical set operations, but you cannot access items by index.

Dictionary (dict)

A dictionary stores key–value pairs, like labeled form fields or JSON objects.

student = {
    "name": "Vikram",
    "age": 20,
    "city": "Bengaluru",
    "enrolled": True
}
print(student["name"])  # Vikram
student["course"] = "Data Science"
student["age"] = 21
del student["city"]
for key, value in student.items():
    print(f"{key}: {value}")

Dictionaries are used everywhere in Python-APIs, configuration, JSON data, and more.

Type Conversion (Casting)

Type conversion is changing a value from one type to another using built-in functions like int(), float(), str(), list(), bool(), and tuple().

# String to int
age_string = "25"
age_int = int(age_string)
# Int to string
roll = 1042
roll_string = str(roll)
# Int to float
marks = 85
marks_float = float(marks)

# Float to int (truncates, does not round)
price = 299.99
price_int = int(price)

# String to list
sentence = "Python is powerful"
words = sentence.split(" ")

When you see a TypeError about mixing types, a correct conversion is almost always the fix.

Quick Comparison of Python Data Types

Data Type Class Name Mutable Ordered Allows Duplicates Example
Integer int No N/A N/A 25
Float float No N/A N/A 99.9
String str No Yes Yes "Hello"
Boolean bool No N/A N/A True
List list Yes Yes Yes [1, 2, 3]
Tuple tuple No Yes Yes (1, 2, 3)
Set set Yes No No {1, 2, 3}
Dictionary dict Yes Yes Unique keys {"a": 1}
None NoneType No N/A N/A None

How to Choose the Right Data Type

  • Use int for counts, IDs, and whole-number scores.
  • Use float for prices, percentages, and measurements.
  • Use str for any text data.
  • Use bool for conditions, flags, and toggles.
  • Use list when you need an ordered, changeable collection.
  • Use tuple for ordered data that must not change.
  • Use set for unique values or when doing union/intersection operations.
  • Use dict for labeled or structured data.
  • Use None when there is no value yet or to indicate “not found.”

Common Beginner Mistakes with Data Types

  • Forgetting that indexing starts at 0, not 1.
  • Trying to modify a tuple instead of using a list.
  • Adding numbers directly to strings without using str().
  • Assuming sets keep order-sets are unordered.
  • Not using type() to debug unexpected behaviour.
  • Confusing None with 0, "", or False; None means “no value at all.”

Frequently Asked Questions

What are the main data types in Python?

The key types are int, float, str, bool, list, tuple, set, dict, and NoneType.

What is the difference between a list and a tuple?

Both are ordered collections, but lists are mutable and tuples are immutable.

What happens if you try to modify a tuple?

Python raises a TypeError because tuples are designed to be unchangeable.

What is a Boolean and why is it important?

A Boolean holds True or False and powers all decisions in if statements, loops, and comparisons.

What is None in Python?

None represents the complete absence of a value and is commonly used as a default or “not found” indicator.

What is dynamic typing in Python?

Dynamic typing means Python figures out a variable’s type from its value at runtime instead of requiring explicit type declarations.

Customer Support

Subscribe for expert insights and updates on the latest in emerging tech, directly from the thought leaders at EICTA consortium.