Monday 29 July 2024

Different data types in Python

Here are some of the most commonly used data types in Python:



  1. **Numeric Types**:

   - **int**: Integer values, e.g., `5`, `-3`

   - **float**: Floating-point numbers, e.g., `3.14`, `-0.001`

   - **complex**: Complex numbers, e.g., `1 + 2j`

  1. **Sequence Types**:

   - **list**: Ordered, mutable collections of items, e.g., `[1, 2, 3]`

   - **tuple**: Ordered, immutable collections of items, e.g., `(1, 2, 3)`

   - **range**: Represents an immutable sequence of numbers, e.g., `range(0, 10)`

 

  1. **Text Type**:

   - **str**: String literals, e.g., `"hello"`, `'world'`

 

  1. **Binary Types**:

   - **bytes**: Immutable sequences of bytes, e.g., `b'hello'`

   - **bytearray**: Mutable sequences of bytes, e.g., `bytearray(5)`

   - **memoryview**: Allows byte-level access to bytes-like objects without copying, e.g., `memoryview(b'abc')`

 

  1. **Set Types**:

   - **set**: Unordered collections of unique elements, e.g., `{1, 2, 3}`

   - **frozenset**: Immutable version of a set, e.g., `frozenset([1, 2, 3])`

 

  1. **Mapping Type**:

   - **dict**: Collections of key-value pairs, e.g., `{'a': 1, 'b': 2}`

 

  1. **Boolean Type**:

   - **bool**: Represents truth values, `True` or `False`

 

  1. **None Type**:

   - **NoneType**: Represents the absence of a value, `None`

 

These are the basic data types available in Python, each serving different purposes depending on the needs of the program.

TCCI Computer classes provide the best training in all computer courses online and offline through different learning methods/media located in Bopal Ahmedabad and ISCON Ambli Road in Ahmedabad.

For More Information:                   

Call us @ +91 98256 18292

Visit us @ http://tccicomputercoaching.com/

No comments:

Post a Comment