Skip to main content

Data Types

We can identify the type of data/variable based on value. It indicates which type of data that you are using like string, integer, float or other.

Data types are classifications of data items, indicating the kind of values they can hold and the operations that can be performed on them. In programming and computer science, data types are crucial because they determine the structure of data and the ways in which it can be manipulated.

In Python, data types are dynamically inferred, meaning you don't need to explicitly declare the type of a variable. Python automatically determines the data type based on the value assigned to it.

List of Data Types:

Name Keyword Example
Integer int a = 2
Float float b = 1.2
String str name = "John"
Boolean bool is_valid = True
List list numList = [10,20,30,40, 50]
Tuple tuple numTuple = (10,20,30,40, 50)
Dictionary dict nameDict = {"name": "John", "age": 25, "city": "New York"}
Set set numSet = {10, 20, 30, 40, 50}
NoneType None res = None

Get more information about all data types.

  • Integer (int): Represents whole numbers without any decimal points.
  • Float (float): Represents numbers with decimal points.
  • String (str): Represents sequences of characters enclosed within single, double, or triple quotes.
  • Boolean (bool): Represents truth values, either True or False.
  • List (list): Represents an ordered collection of elements. Lists can contain elements of different data types.
  • Tuple (tuple): Similar to lists but immutable (cannot be modified after creation).
  • Dictionary (dict): Represents a collection of key-value pairs. Keys must be immutable.
  • Set (set): Represents an unordered collection of unique elements.
  • NoneType (None): Represents the absence of a value. Often used to indicate that a variable has no value.

Comments