- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Standard Data Types in Python
The data stored in memory can be of many types. For example, a person's age is stored as a numeric value and his or her address is stored as alphanumeric characters. Python has various standard data types that are used to define the operations possible on them and the storage method for each of them.
Python has five standard data types −
Number data types store numeric values. Number objects are created when you assign a value to them. For example −
var1 = 1
var2 = 10
Strings in Python are identified as a contiguous set of characters represented in the quotation marks. Python allows for either pairs of single or double quotes. Subsets of strings can be taken using the slice operator ([ ] and [:] ) with indexes starting at 0 in the beginning of the string and working their way from -1 at the end.
Lists are the most versatile of Python's compound data types. A list contains items separated by commas and enclosed within square brackets (). To some extent, lists are similar to arrays in C. One difference between them is that all the items belonging to a list can be of different data type.
A tuple is another sequence data type that is similar to the list. A tuple consists of a number of values separated by commas. Unlike lists, however, tuples are enclosed within parentheses.
Python's dictionaries are kind of hash table type. They work like associative arrays or hashes found in Perl and consist of key-value pairs. A dictionary key can be almost any Python type, but are usually numbers or strings. Values, on the other hand, can be any arbitrary Python object.
- What are Standard Data Types in Python 3?
- Which data types are immutable in Python?
- Get tuple element data types in Python
- Data types in Java
- Data Types in C
- Difference between fundamental data types and derived data types
- Difference between fundamental data types and derived data types in C++
- What are various Text data types in Python pandas?
- Python – Extract rows with Complex data types
- What is the Simplified Data Encryption Standard?
- Java primitive data types
- What are the data types, value types and reference types in C#?
- Inplace vs Standard Operators in Python
- Standard errno system symbols in Python
- Python Standard operators as functions