🐍
Python For Starters
  • Overview
  • Python for starters
  • Content
  • Foreword
  • Introduction To Python
    • Python Installation
    • Variables
    • Python Data Types
    • Python Data Structures
    • Python numbers
    • Python strings
    • Python Boolean
    • Python constants
    • Python Comments
    • Type Conversion
    • Control flow in python
  • Python Functions
    • Function Definition
    • Function Parameter
    • Recursive Functions
    • Using Global Variables in Functions
    • Lambda Functions
  • What are Data Structures
    • Python Lists
    • Python Tuples
    • Python Dictionaries
    • Python Sets
    • Iterable in python
    • Python Map, Filter & Reduce Functions
  • Error handling in Python
  • Loop ... Else Clause, Partial Functions & Type Hints
    • Partial Functions
    • Type Hints
  • Python Modules
  • Python Libraries & Packages
    • Python Packages
  • Directory & IO
    • Python IO Module
  • Pyenv
  • Virtual Environments
    • Pipenv
    • Virtualenv
  • Object Oriented Programming in Python
    • Class
    • Class Methods
    • Python Class Inheritance
    • Python Class Polymorphism
    • Python special methods
  • Appendix
  • Contributing
Powered by GitBook
On this page
  1. Introduction To Python

Python Data Types

Data Types

For short, a data type describes a set of possible values and operations that can be performed on a variable

In Python, a data type is a category for values. Every value in Python has a data type, which determines the kind of operations that can be performed on that value and the way the value can be stored in memory.

There are several built-in data types in Python, including:

  • Numbers: Python has three types of numbers: integers (int), floating-point numbers (float), and complex numbers (complex). Integers are whole numbers, while floating-point numbers have decimal points. Complex numbers have a real and imaginary part.

  • Strings: A string is a sequence of characters, represented by either single quotes (') or double quotes ("). Strings can contain letters, numbers, and special characters.

  • Lists: A list is an ordered collection of values that can be of any data type. Lists are written as a series of values separated by commas and enclosed in square brackets.

  • Tuples: A tuple is similar to a list, but it is immutable, meaning that its values cannot be modified once it is created. Tuples are written as a series of values separated by commas and enclosed in parentheses.

  • Sets: A set is an unordered collection of unique values. Sets are written as a series of values separated by commas and enclosed in curly braces.

  • Dictionaries: A dictionary is a collection of key-value pairs. The keys must be unique and are used to retrieve the corresponding values. Dictionaries are written as a series of key-value pairs separated by commas and enclosed in curly braces.

In addition to these built-in data types, you can also define your own data types in Python using classes (more of this in an advanced topic)

PreviousVariablesNextPython Data Structures

Last updated 1 year ago