VOOZH about

URL: https://www.analyticsvidhya.com/blog/2021/08/data-types-in-python-you-need-to-know-at-the-beginning-of-your-data-science-journey/

⇱ Data Types in Python | 6 Standard Data Types in Python


India's Most Futuristic AI Conference Is Back – Bigger, Sharper, Bolder

  • d
  • :
  • h
  • :
  • m
  • :
  • s

Beginner’s Guide to Standard Data Types in Python

Prashant Last Updated : 05 Feb, 2025
5 min read

Python is a language that needs no introduction. It’s incredibly powerful, versatile, fast, and easy to learn. It is one of the languages that’s witnessing incredible growth and recognition year by year. Being object-oriented, it is often a programmer’s first choice for general-purpose programming. In this article, we will learn about some of the different values and standard data types in the Python language.

Learning Objectives:

  • Understand what data types are.
  • Learn about the different data types in Python.
  • Know the applications of the various data types in Python programming and their syntax.

What Are Data Types?

Data types are the classification or categorization of knowledge items. It represents the useful type that tells what operations are often performed on specific data. Since everything is an object in Python programming, data types are classes, and variables are instances (objects) of those classes.

Data types are an important concept within the Python programing language. Every value has its own Python Data Type in the Python programming language. Data Type is the classification of knowledge items or placing the info value into some kind of data category.

Data Types in Python

Python has six standard or built-in data types:

  • Numeric
  • String
  • List
  • Tuple
  • Set
  • Dictionary
👁 Python has six standard Data Types
Source: educba.com

Now let’s discuss the above data types one by one.

Numeric Data Type

In Python, numeric data type represents the data that has a numeric value. The numeric value can be an integer, a floating number, or even a complex number. These values are defined as int, float, and complex classes in Python.

Integers: This data type is represented with the help of int class. It consists of positive or negative whole numbers (without fractions or decimals). In Python, there’s no limit to how long integer values are often.

Example:
Python Code:

a = 2
print(a, "is of type", type(a))

Float: The float class represents this type. It is a true number with a floating-point representation. It is specified by a decimal point. Optionally, the character e or E followed by a positive or negative integer could even be appended to specify scientific notation.

Example:

b = 1.5
print(b, "is of type", type(b))
Output: 1.5 is of type

Complex Numbers: Complex numbers are represented by complex classes. It is specified as (real part) + (imaginary part)j, For example – 4+5j.

Example:

c = 8+3j
print(c, "is a type", type(c))
Output: (8+3j) is a type

String Data Type

The string is a sequence of Unicode characters. A string may be a collection of 1 or more characters put during a quotation mark, double-quote, or triple-quote. It can be represented using an str class.

Example:

string1= “Hello World”
print(string1)
output: Hello World

We can perform several operations in strings like Concatenation, Slicing, and Repetition.

Concatenation: It includes the operation of joining two or more strings together.

Example:

String1 = "Hello"
String2 ="World"
print(String1+String2)
Output: Hello World

Slicing: Slicing is a technique for extracting different parts of a string.

Example:

String1 = "Hello"
print(String1[2:4])
Output: llo

Repetition: It means repeating a sequence of instructions a certain number of times.

Example:

Print(String1*5)
Output: HelloHelloHelloHelloHello

List Data Type

A list is formed (or created) by placing all the items (elements) inside square brackets [ ], separated by commas.

It can have any number of items that may or may not be of different types (integer, float, string, etc.).

A list is mutable, which suggests we will modify the list

Example:

List1 = [3,8,7.2,"Hello"]
print("List1[2] = ", List[2])
Output: List1[2] = 7.2
print("List1[1:3] = ", List[1:3])
Output: List1[1:3] = [8, 7.2]

Updating the list: we can update the list.

List1[3] = "World"
#If we print the whole list, we can see the updated list.
print(List1)
Output: [3, 8, 7.2, ‘World’]

Tuple Data Type

A tuple is defined as an ordered collection of Python objects. The only difference between a tuple and a list is that tuples are immutable, i.e., tuples can’t be modified once created. It is represented by a tuple class. We can represent tuples using parentheses ( ).

Example:

Tuple = (25,10,12.5,"Hello")
print("Tuple[1] = ", Tuple[1])
Output: Tuple[1] = 10
print("Tuple[0:3] =", Tuple[0:3])
Output: Tuple[0:3] = (25,10,12.5)

Set Data Type

A set is an unordered collection of items. Every set element is exclusive (no duplicates) and must be immutable (cannot be changed).

Example:

Set = {4,3,6.6,"Hello"}
print(Set)
Output: {‘Hello’, 3, 4, 6.6}

As the set is an unordered collection, indexing will be meaningless. Hence the slicing operator [ ] doesn’t work.

Set[1] = 12
Output: TypeError

Dictionary Data Type

In Python, Dictionary is an unordered collection of data values that stores data values like a map. Unlike other Data Types with only a single value as an element, a Dictionary consists of a key-value pair. Key-value is provided within the dictionary to form it more optimized. A colon (:) separates each key-value pair during a Dictionary, in the representation of a dictionary data type. Meanwhile, a comma (,) separates each key.

Syntax:
Key:value

Example:

Dict1 = {1:'Hello',2:5.5, 3:'World'}
print(Dict1)
Output: {1: ‘Hello’, 2: 5.5, 3: ‘World’}

We can retrieve the value by using the following method:

Example:

print(Dict[2])
Output: 5.5

We can update the dictionary by following methods as well:

Example:

Dict[3] = 'World'
print(Dict)
Output:
{1: ‘Hello’, 2: 5.5, 3: ‘World’}

Conclusion

If you’re reading this text, you’re probably learning Python or trying to become a Python developer. Learning Python or other programming languages begins by understanding the basic concepts of its foundation. You’ve covered the most commonly used data types used in Python programming in this article. Keep learning, and good luck in your journey to mastering Python!

Key Takeaways:

  • Data types are the classification or categorization of knowledge items.
  • The 6 standard data types in Python are Numeric, String, List, Tuple, Set, and Dictionary.

Frequently Asked Questions

Q1. What are the supported data types in Python?

A. Python supports several standard data types, including:
1. Numeric Types:
int: Integers, e.g., 10, -3, 0.
float: Floating-point numbers, e.g., 3.14, -2.5, 0.0.
complex: Complex numbers, e.g., 2+3j, -1-4j.
2. Sequence Types:
str: Strings of characters, e.g., “Hello”, ‘World’, “123”.
list: Ordered, mutable sequences, e.g., [1, 2, 3], [‘a’, ‘b’, ‘c’].
tuple: Ordered, immutable sequences, e.g., (1, 2, 3), (‘a’, ‘b’, ‘c’).
3. Mapping Type:
dict: Key-value pairs, e.g., {‘name’: ‘John’, ‘age’: 25}.
4. Set Types:
set: Unordered, mutable collection of unique elements, e.g., {1, 2, 3}, {‘a’, ‘b’, ‘c’}.
frozenset: Immutable set, e.g., frozenset({1, 2, 3}).
5. Boolean Type:
bool: Represents the truth values True and False.
6. Binary Types:
bytes: Immutable sequence of bytes, e.g., b’hello’, bytes([65, 66, 67]).
bytearray: Mutable sequence of bytes, e.g., bytearray(b’hello’), bytearray(3).
7. None Type:
None: Represents the absence of a value or a null value.

These are the most common standard data types in Python. Additionally, Python allows defining and using custom data types using classes and objects.

Q2. What is double data type in Python?

A. Python does not have a specific “double” data type like some other programming languages. Instead, Python uses the built-in “float” data type to represent floating-point numbers, which provides double-precision floating-point values. The “float” data type in Python can represent decimal numbers with a high level of precision, similar to the “double” data type in other languages.

Q3. What is data type in Python?

A data type in Python defines the kind of value a variable can hold. Python has several built-in data types, including:
1. Numeric (int, float, complex)
2. String
3. List
4. Tuple
5. Set
6. Dictionary

The media shown in this article are not owned by Analytics Vidhya and are used at the Author’s discretion.

Hello, my name is Prashant, and I'm currently pursuing my Bachelor of Technology (B.Tech) degree. I'm in my 3rd year of study, specializing in machine learning, and attending VIT University.

In addition to my academic pursuits, I enjoy traveling, blogging, and sports. I'm also a member of the sports club. I'm constantly looking for opportunities to learn and grow both inside and outside the classroom, and I'm excited about the possibilities that my B.Tech degree can offer me in terms of future career prospects.

Thank you for taking the time to get to know me, and I look forward to engaging with you further!

Login to continue reading and enjoy expert-curated content.

Free Courses

Generative AI - A Way of Life

Explore Generative AI for beginners: create text and images, use top AI tools, learn practical skills, and ethics.

Getting Started with Large Language Models

Master Large Language Models (LLMs) with this course, offering clear guidance in NLP and model training made simple.

Building LLM Applications using Prompt Engineering

This free course guides you on building LLM apps, mastering prompt engineering, and developing chatbots with enterprise data.

Improving Real World RAG Systems: Key Challenges & Practical Solutions

Explore practical solutions, advanced retrieval strategies, and agentic RAG systems to improve context, relevance, and accuracy in AI-driven applications.

Microsoft Excel: Formulas & Functions

Master MS Excel for data analysis with key formulas, functions, and LookUp tools in this comprehensive course.

Responses From Readers

DebrajCode

Hello Bro Nice Information

Programmer

Good morning, As i was reading this article i found an error for the following example output: String1 = "Hello" print(String1[2:4]) Output: llo The output should be: ll Best regards, Anonymous programmer

Flagship Programs

GenAI Pinnacle Program| GenAI Pinnacle Plus Program| AI/ML BlackBelt Program| Agentic AI Pioneer Program

Free Courses

Generative AI| DeepSeek| OpenAI Agent SDK| LLM Applications using Prompt Engineering| DeepSeek from Scratch| Stability.AI| SSM & MAMBA| RAG Systems using LlamaIndex| Building LLMs for Code| Python| Microsoft Excel| Machine Learning| Deep Learning| Mastering Multimodal RAG| Introduction to Transformer Model| Bagging & Boosting| Loan Prediction| Time Series Forecasting| Tableau| Business Analytics| Vibe Coding in Windsurf| Model Deployment using FastAPI| Building Data Analyst AI Agent| Getting started with OpenAI o3-mini| Introduction to Transformers and Attention Mechanisms

Popular Categories

AI Agents| Generative AI| Prompt Engineering| Generative AI Application| News| Technical Guides| AI Tools| Interview Preparation| Research Papers| Success Stories| Quiz| Use Cases| Listicles

Generative AI Tools and Techniques

GANs| VAEs| Transformers| StyleGAN| Pix2Pix| Autoencoders| GPT| BERT| Word2Vec| LSTM| Attention Mechanisms| Diffusion Models| LLMs| SLMs| Encoder Decoder Models| Prompt Engineering| LangChain| LlamaIndex| RAG| Fine-tuning| LangChain AI Agent| Multimodal Models| RNNs| DCGAN| ProGAN| Text-to-Image Models| DDPM| Document Question Answering| Imagen| T5 (Text-to-Text Transfer Transformer)| Seq2seq Models| WaveNet| Attention Is All You Need (Transformer Architecture) | WindSurf| Cursor

Popular GenAI Models

Llama 4| Llama 3.1| GPT 4.5| GPT 4.1| GPT 4o| o3-mini| Sora| DeepSeek R1| DeepSeek V3| Janus Pro| Veo 2| Gemini 2.5 Pro| Gemini 2.0| Gemma 3| Claude Sonnet 3.7| Claude 3.5 Sonnet| Phi 4| Phi 3.5| Mistral Small 3.1| Mistral NeMo| Mistral-7b| Bedrock| Vertex AI| Qwen QwQ 32B| Qwen 2| Qwen 2.5 VL| Qwen Chat| Grok 3

AI Development Frameworks

n8n| LangChain| Agent SDK| A2A by Google| SmolAgents| LangGraph| CrewAI| Agno| LangFlow| AutoGen| LlamaIndex| Swarm| AutoGPT

Data Science Tools and Techniques

Python| R| SQL| Jupyter Notebooks| TensorFlow| Scikit-learn| PyTorch| Tableau| Apache Spark| Matplotlib| Seaborn| Pandas| Hadoop| Docker| Git| Keras| Apache Kafka| AWS| NLP| Random Forest| Computer Vision| Data Visualization| Data Exploration| Big Data| Common Machine Learning Algorithms| Machine Learning| Google Data Science Agent
👁 Av Logo White

Continue your learning for FREE

Forgot your password?
👁 Av Logo White

Enter OTP sent to

Edit

Wrong OTP.

Enter the OTP

Resend OTP

Resend OTP in 45s

👁 Popup Banner
👁 AI Popup Banner