DEV Community

SATHISHKUMAR R
SATHISHKUMAR R

Posted on

What are Data Types in Python?

Data Types in Python define what type of value a variable can store.

For example:
A variable can store numbers, text, decimal values, or multiple values.
name = "Sathish"
age = 22
height = 5.7

Here:

  • name → String
  • age → Integer
  • height → Float

Types of Data Types in Python:

Python has 8 main built-in data types, grouped into categories.

  1. Numeric Data Types:

Used to store numbers.
Data Type Meaning Example
int Whole numbers age = 22
float Decimal numbers price = 99.5
complex Complex numbers x = 2 + 3j

  1. String (str): Used to store text.

name = "Sathish"
print(name)

Output:
Sathish

  1. List (list):

Used to store multiple values. Lists are changeable.

fruits = ["Apple", "Banana", "Mango"]
print(fruits)

  1. Tuple (tuple):

Used to store multiple values. Tuples cannot be changed after creation.

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

  1. Set (set):

Used to store unique values (no duplicates).

numbers = {10, 20, 10, 30}
print(numbers)

Output:
{10, 20, 30}

  1. Dictionary (dict):

Used to store data in key-value pairs.

student = { "name": "Sathish", "age": 22}
print(student["name"])

Output:
Sathish

  1. Boolean (bool):

Stores only two values: True or False.

is_student = True
print(is_student)

  1. None (NoneType):

Represents no value or an empty value.

result = None
print(result)

Top comments (0)