GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Python Tutorial
  • Data Types
  • Interview Questions
  • Examples
  • Quizzes
  • DSA Python
  • Data Science
  • NumPy
  • Pandas
  • Practice
  • Django
  • Flask
  • Introduction1 min read
  • Input & Output2 min read

This view

  • Original page
  • New address

GeezerVison is showing www.geeksforgeeks.org — Python Data Types - GeeksforGeeks

geeksforgeeks
search icon
  • Courses
  • Tutorials
  • Interview Prep
  • Python Tutorial
  • Data Types
  • Interview Questions
  • Examples
  • Quizzes
  • DSA Python
  • Data Science
  • NumPy
  • Pandas
  • Practice
  • Django
  • Flask

Python Data Types

Last Updated : 19 Sep, 2026

Data types in Python define the type of value stored in a variable and determine the operations that can be performed on that data. Since Python treats everything as an object, each value is associated with a specific data type.

  • Helps the interpreter understand how to store and process different kinds of data efficiently.
  • Enables correct operations by ensuring only valid actions are performed on compatible data types.
Python-Data-Types
Python DataTypes

Below code assigns different types of values to variable x. With each new assignment, the previous value is replaced and x changes to the new data type.

Python
x = 50
x = 60.5
x = "Hello World"
x = ["geeks", "for", "geeks"]
x = ("geeks", "for", "geeks")

Numeric Data Types

In, Python Numeric data types are used to store numeric values. It can be an integer, floating number or even a complex number. It supports three main numeric types:

  • Integers: value is represented by int class. It contains positive or negative whole numbers (without fractions or decimals).
  • Float: value is represented by float class. It is a real number with a floating-point representation. It is specified by a decimal point.
  • Complex: It is represented by a complex class. It stores numbers with real and imaginary parts. For example: 2+3j
Python
a = 5
b = 5.0
c = 2 + 4j

print(type(a))
print(type(b))
print(type(c))

Output
<class 'int'>
<class 'float'>
<class 'complex'>

Sequence Data Types

A sequence is an ordered collection of items, which can be of similar or different data types. Elements in a sequence can be accessed using indexing.

1. String

Strings are used to store text data. A string is represented using the str class and can be created using single, double or triple quotes.

Python
s = 'Welcome to the Geeks World'
print(s)
print(type(s))

# access string with index
print(s[1])
print(s[-1])

Output
Welcome to the Geeks World
<class 'str'>
e
d

2. List

Lists are ordered and mutable collections used to store multiple items in a single variable. Elements in a list can be of different data types and are accessed using indexing.

Python
a = [1, 2, 3]
print(a)

b = ["Geeks", "For", "Geeks", 4, 5]
print(b[3])
print(b[-3])

Output
[1, 2, 3]
4
Geeks

3. Tuple

Tuples are ordered and immutable collections used to store multiple items in a single variable. Once created, tuple elements cannot be modified and are accessed using indexing.

Note: A tuple with a single element must include a trailing comma, otherwise Python treats it as a normal value instead of a tuple.

Python
t1 = (1,)
print(type(t1))

t2 = ('Geeks', 'For', 'Geeks', 1, 2)
print(t2[3])
print(t2[-3])

Output
<class 'tuple'>
1
Geeks

Boolean Data Type

Boolean data type represents one of two values: True or False. It is mainly used in conditions and comparisons and is represented by the bool class.

Python
print(type(True))
print(type(False))

Output
<class 'bool'>
<class 'bool'>

Truthy and Falsy Values

truthy and falsy values are values that evaluate to True or False in a Boolean context. Truthy values behave like True, while falsy values behave like False when used in conditions.

Python
if 1:
    print("1 is truthy")

if not 0:
    print("0 is falsy")

Output
1 is truthy
0 is falsy

Set Data Type

Sets are unordered and mutable collections used to store unique elements. Since sets are unordered, elements cannot be accessed using indexing. Elements are usually accessed by iterating through the set using a loop.

Python
s1 = {"a", "a", "b", "c", "b"}
print(s1)

s2 = {"Geeks", "For", "Geeks"}
for i in s2:
    print(i)

Output
{'b', 'a', 'c'}
Geeks
For

Note: Sets in Python are unordered, so the order of elements when printed may vary each time the code is run.

Dictionary Data Type

Dictionaries are used to store data in key:value pairs. Each key in a dictionary must be unique and values are accessed using their keys with square brackets [] or get() method.

Note: Dictionary keys are case sensitive, the same name but different cases of Key will be treated distinctly.

Python
d = {1: 'Geeks', 2: 'For', 3: 'Geeks'}
print(d[1])    
print(d.get(2))

Output
Geeks
For
Comment

Explore

    Python Fundamentals
    • Introduction1 min read
    • Input & Output2 min read
    • Variables4 min read
    • Operators4 min read
    • Keywords2 min read
    • Data Types4 min read
    • Conditional Statements3 min read
    • Loops3 min read
    • Functions4 min read
    Python Data Structures
    • String4 min read
    • List3 min read
    • Tuples3 min read
    • Dictionary3 min read
    • Set2 min read
    • Arrays5 min read
    Advanced Python
    • OOP Concepts3 min read
    • Exception Handling5 min read
    • File Handling4 min read
    • Python Database2 min read
    • MongoDB3 min read
    • MySQL7 min read
    • Packages4 min read
    • Modules3 min read
    • DSA Libraries5 min read
    • Python GUI2 min read
    Data Science with Python
    • Numpy3 min read
    • Pandas4 min read
    • Matplotlib3 min read
    • Seaborn3 min read
    • StatsModel2 min read
    • Model Building6 min read
    • TensorFlow2 min read
    • PyTorch5 min read
    Web Development with Python
    • Flask3 min read
    • Django5 min read
    • Django ORM4 min read
    • Jinja2 Templating5 min read
    • Django Templates5 min read
    • REST API3 min read
    • Build API with DRF4 min read
    Python Practice
    • Quiz1 min read
    • Practice Problems2 min read
    • Interview Q & A15+ min read
    Courses
    • Placement 360 Course2 min read
    • Data Science 360 Course2 min read
    • AI Engg Course2 min read
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.