Python Professional Course Chapter Two

Python Data Types:
In Python, data types represent the type or category of data that can be stored and manipulated
within a program. Python supports several built-in data types, each serving a different purpose. Here
are the main data types in Python:
Numeric Types:

  • int: Integer data type represents whole numbers, positive or negative, without any decimal
    point.
  • float: Float data type represents floating-point numbers, which include decimal points.
  • complex: Complex data type represents complex numbers in the form a + bj, where a and b are real numbers, and j is the imaginary unit.

Sequence Types:

  • str: String data type represents sequences of characters enclosed within single quotes (‘) or
    double quotes (“).
  • list: List data type represents ordered collections of items enclosed within square brackets ([]). Lists can contain elements of different data types.
  • tuple: Tuple data type represents immutable ordered collections of items enclosed within parentheses (()). Tuples can contain elements of different data types.
  • range: Range data type represents a sequence of numbers generated by the range() function.

Mapping Type:

  • dict: Dictionary data type represents unordered collections of key-value pairs enclosed
    within curly braces ({}). Each key-value pair in a dictionary maps the key to its corresponding
    value.

Set Types:

  • set: Set data type represents unordered collections of unique elements enclosed within curly
    braces ({}). Sets do not allow duplicate elements.
  • frozenset: Frozenset data type represents immutable sets, similar to sets but cannot be modified after creation

Download Chapter Two PDF

Leave a Reply

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