Various types of data types in python


🔢 Numeric Types

Used for storing numbers:

  • int: Integer values, e.g., 42, -7
  • float: Floating-point numbers (decimals), e.g., 3.14, -0.001
  • complex: Complex numbers, e.g., 2 + 3j

🔡 Text Type

Used for textual data:

  • str: A sequence of characters, e.g., "hello world"

📦 Sequence Types

Ordered collections:

  • list: Mutable, ordered, e.g., [1, 2, 3]
  • tuple: Immutable, ordered, e.g., (1, 2, 3)
  • range: Represents a range of values, e.g., range(0, 10)

🔑 Mapping Type

Used for key-value pairs:

  • dict: e.g., {"name": "Ramesh", "age": 30}

🧮 Set Types

Collections of unique elements:

  • set: Unordered, mutable, no duplicates, e.g., {1, 2, 3}
  • frozenset: Immutable version of a set

Boolean Type

  • bool: Logical values True or False

🪙 Binary Types

Used to handle binary data:

  • bytes: Immutable sequence of bytes
  • bytearray: Mutable version of bytes
  • memoryview: Access internal data of objects without copying

Want to explore examples of each, or dive deeper into when to use which type? I’d be happy to break it down even further.

Examples
🔢 Numeric Types

  • int:pythonage = 30
  • float:pythonpi = 3.14159
  • complex:pythonz = 2 + 5j

🔡 Text Type

  • str:pythongreeting = "Hello, Ramesh!"

📦 Sequence Types

  • list:pythonfruits = ["apple", "banana", "cherry"]
  • tuple:pythoncoordinates = (10.0, 20.0)
  • range:pythonnumbers = range(1, 6) # 1 to 5

🔑 Mapping Type

  • dict:pythonperson = {"name": "Ramesh", "city": "Hyderabad", "age": 30}

🧮 Set Types

  • set:pythonunique_numbers = {1, 2, 3, 2} # duplicates ignored
  • frozenset:pythonfrozen = frozenset(["python", "java", "python"])

Boolean Type

  • bool:pythonis_active = True

🪙 Binary Types

memoryview:pythonview = memoryview(b"example")

bytes:pythondata = b"hello"

bytearray:pythonmutable_data = bytearray([65, 66, 67])

Similar Posts

  • Top Python IDEs in 2025: Best Tools for Developers , Data Scientists, Beginners, Professionals

    Python developers have a wide range of Integrated Development Environments (IDEs) to choose from, depending on their needs, preferences, and the type of projects they are working on. Below is a list of popular IDEs for Python, along with their key features: 1. PyCharm 2. Visual Studio Code (VS Code) 3. Jupyter Notebook/JupyterLab 4. Spyder…

  • Number Manipulation and F-Strings in Python, with examples:

    Python, mathematical operators are symbols that perform arithmetic operations on numerical values. Here’s a breakdown of the key operators: Basic Arithmetic Operators: Other Important Operators: Operator Precedence: Python follows the standard mathematical order of operations (often remembered by the acronym PEMDAS or BODMAS): Understanding these operators and their precedence is essential for performing calculations in…

  • Unlock the Power of Python: What is Python, History, Uses, & 7 Amazing Applications

    What is Python and History of python, different sectors python used Python is one of the most popular programming languages worldwide, known for its versatility and beginner-friendliness . From web development to data science and machine learning, Python has become an indispensable tool for developers and tech professionals across various industries . This blog post…

  • Create lists

    In Python, there are multiple ways to create lists, depending on the use case. Below are the most common methods: 1. Direct Initialization (Using Square Brackets []) The simplest way to create a list is by enclosing elements in square brackets []. Example: python empty_list = [] numbers = [1, 2, 3, 4] mixed_list = [1, “hello”, 3.14,…

  • Programs

    Weekly Wages Removing Duplicates even ,odd Palindrome  Rotate list Shuffle a List Python random Module Explained with Examples The random module in Python provides functions for generating pseudo-random numbers and performing random operations. Here’s a detailed explanation with three examples for each important method: Basic Random Number Generation 1. random.random() Returns a random float between 0.0 and 1.0 python import…

  • re module

    The re module is Python’s built-in module for regular expressions (regex). It provides functions and methods to work with strings using pattern matching, allowing you to search, extract, replace, and split text based on complex patterns. Key Functions in the re Module 1. Searching and Matching python import re text = “The quick brown fox jumps over the lazy dog” # re.search()…

Leave a Reply

Your email address will not be published. Required fields are marked *