PYnative

Python Programming

  • Learn Python
    • Python Tutorials
    • Python Basics
    • Python Interview Q&As
  • Exercises
    • Python Exercises
    • C Programming Exercises
    • C++ Exercises
  • Quizzes
  • Code Editor
    • Online Python Code Editor
    • Online C Compiler
    • Online C++ Compiler
Home » Python » Python Data Types

Python Data Types

Updated on: September 26, 2022 | 8 Comments

Data types specify the different sizes and values that can be stored in the variable. For example, Python stores numbers, strings, and a list of values using different data types.

Table of contents

  • Str data type
    • Example
  • Int data type
    • Example
    • Example
  • Float data type
    • Example
  • Complex data type
    • Example
  • List data type
    • Example list creation and manipulation
  • Tuple data type
    • Example Tuple creation and manipulation
  • Dict data type
    • Example dictionary creation and manipulation
  • Set data type
    • Example Set creation and manipulation
    • Frozenset
  • Bool data type
  • Bytes data type
    • bytearray
  • Range data type
  • memoryview

Python is a dynamically typed language; therefore, we do not need to specify the variable’s type while declaring it. Whatever value we assign to the variable based on that data type will be automatically assigned. For example, name = 'Jessa' here Python will store the name variable as a str data type.

No matter what value is stored in a variable (object), a variable can be any type like int, float, str, list, set, tuple, dict, bool, etc.

Also, Solve:

  • Python variables and data type Quiz
  • Basic Python exercise for beginners

There are mainly four types of basic/primitive data types available in Python

  • Numeric: int, float, and complex
  • Sequence: String, list, and tuple
  • Set
  • Dictionary (dict)