Tuesday, 3 November 2026

Python Data Types Explained with Examples

 

What Is Python Data Types? A Complete Beginner's Guide with Examples

Introduction

Python is one of the most popular programming languages. It is easy to learn and useful for students, teachers, and beginners.

When we write a Python program, we use different types of data. These are called Python Data Types.

In this article, we will learn about Python data types with simple explanations and practical examples.

1. What Are Python Data Types?

A data type tells Python what kind of value we are storing in a variable.

For example:

  • Name is stored as text.

  • Age is stored as an integer.

  • Percentage can be stored as a decimal number.

2. Main Python Data Types

A. Integer (int)

An integer is a whole number without a decimal point.

Example:

age = 25
marks = 90

print(age)
print(marks)

Output:

25
90

B. Float (float)

A float is a number that contains a decimal point.

Example:

price = 99.50
percentage = 85.5

print(price)
print(percentage)

Output:

99.5
85.5

C. String (str)

A string is a collection of characters written inside quotation marks.

Example:

student_name = "Rekha"
subject = "Computer Science"

print(student_name)
print(subject)

Output:

Rekha
Computer Science

D. Boolean (bool)

Boolean data has only two possible values: True or False.

Example:

is_student = True
is_teacher = False

print(is_student)
print(is_teacher)

Output:

True
False

E. List

A list stores multiple values in one variable. Lists are written inside square brackets.

Example:

fruits = ["Apple", "Mango", "Banana"]

print(fruits)
print(fruits[0])

Output:

['Apple', 'Mango', 'Banana']
Apple

F. Tuple

A tuple stores multiple values and is written inside round brackets. It cannot be changed after creation.

Example:

colors = ("Red", "Green", "Blue")

print(colors)

G. Dictionary

A dictionary stores data in key-value pairs.

Example:

student = {
    "name": "Aman",
    "age": 15,
    "class": 10
}

print(student["name"])
print(student["age"])

Output:

Aman
15

H. Set

A set stores unique values. Duplicate values are automatically removed.

Example:

numbers = {10, 20, 30, 20}

print(numbers)

Output:

{10, 20, 30}

3. How to Check Data Types in Python

Python provides the type() function to check the data type of a value.

Example:

name = "Rekha"
age = 40
marks = 85.5

print(type(name))
print(type(age))
print(type(marks))

Output:

<class 'str'>
<class 'int'>
<class 'float'>

4. Why Are Python Data Types Important?

Python data types help programmers:

  1. Store different kinds of information.

  2. Perform mathematical calculations.

  3. Manage student records.

  4. Create useful applications.

  5. Write clear and organised programs.

5. Practice Questions

Try answering these questions:

  1. What is an integer in Python?

  2. What is the difference between int and float?

  3. Which data type stores text?

  4. What are Boolean values?

  5. Which data type stores key-value pairs?

Conclusion

Python data types are an important part of programming. Understanding integers, floats, strings, Booleans, lists, tuples, dictionaries, and sets makes it easier to write Python programs.

Students and beginners should practise these examples to improve their programming skills.

Thank you for visiting Digital Data Com! Keep learning and keep practising.

No comments:

Post a Comment