
Python Data Types
Python Data Types
Data types are used to define the type of the variable. We do not need to declare datatype in python as we do in other languages. We can assign values to a variable simply.
Basic Datatypes in Python
- Numeric
- String
- List
- Tuple
- Dictionary
Numeric Data Types
Variables with numeric datatypes hold numeric values.
Int – For non-limited length signed integers.
Long – For long integers
Float – For decimal numbers (accurate up to 15 decimals)
Complex – For complex numbers.
Variables with string datatypes hold a sequence of characters. In general, strings are represented by single or double quotes.
String Data Type:
Variables with string datatypes hold a sequence of characters. In general, strings are represented by single or double quotes.
List Data Types:
The list is an exclusive data type of Python. A list in python can hold a different type of data simultaneously.
Tuple Data Types:
A tuple is similar to a List where it can hold different data simultaneously. But the difference is the values in tuples cannot be modified. It is immutable. Tuples use parenthesis where List uses square braces.
Dictionary Data Types:
Dictionary in python is unordered, changeable and indexed collection.
Dictionary format: {Key:Value, Key:Value, …}