MyInternships.in

Python Basics

Python Data Types

Every value in Python has a data type, which tells Python what kind of data it is and what operations you can perform on it.


Why Data Types Matter

Data types determine how Python stores and processes a value. For example, you can do math with numbers but not directly with plain text, and knowing the type of your data helps you avoid errors.

Python's Built-in Data Types

TypeExampleDescription
int25Whole numbers, positive or negative
float3.14Decimal (floating-point) numbers
str"hello"Text, written inside quotes
boolTrue / FalseRepresents true or false values
list[1, 2, 3]Ordered, changeable collection
tuple(1, 2, 3)Ordered, unchangeable collection
set{1, 2, 3}Unordered collection of unique items
dict{"a": 1}Key-value pairs
NoneNoneRepresents "no value" or empty
Examples of each data type
Python
age = 25
price = 3.14
name = "Learning Python"
is_active = True
fruits = ["apple", "mango"]
coordinates = (10, 20)
unique_ids = {101, 102, 103}
student = {"name": "Neha", "age": 22}
result = None

Checking a Variable's Type

Python has a built-in function called type() that tells you the data type of any value or variable, which is very useful while debugging.

Python
print(type(age))
print(type(name))
print(type(fruits))
ℹ️

Lists, tuples, sets and dicts are called collection types because each can hold multiple values inside one variable.

You will explore numbers, strings, booleans and each collection type in much more depth in the upcoming lessons.

Related Python Topics

Keep learning with these closely related lessons.

Ready to use your Python skills?

Find Python, data science and software internships and fresher jobs across India.

Browse Python Internships