Sitemap
Naga Durga Bhavani. Kokkira

Naga Durga Bhavani. Kokkira

Data Types

3 min readOct 11, 2023

Data types are the classification or categorization of knowledge items. The 6 standard data types in Python are Numeric, String, List, Tuple, Set, and Dictionary.

Numerical Data Types :

The numeric data type in Python represents the data that has a numeric value. A numeric value can be an integer, a floating number, or even a complex number. These values are defined as Python int, Python float, and Python complex classes in Python.

Integers : This value is represented by int class. It contains positive or negative whole numbers (without fractions or decimals). In Python, there is no limit to how long an integer value can be.

Float Values : This value is Represented by float(value). When called, float() returns a floating point number or a decimal point for a provided number or string.

Complex : The Complex Data Type in Python is the data type that is used for representing complex numbers. As mentioned above a complex number is represented in the form of “a + bi’. In Python, we use the j or J suffix instead of i, for denoting the imaginary part of the complex number. For example, 3 + 3j

String Data Types : In Python, a string is a sequence of characters enclosed within either single quotes (‘ ‘) or double quotes (“ “) or triple quotes (‘“ “‘). It is an immutable data type, which means once a string is created, it cannot be modified. However, it is possible to create a new string by concatenating two or more strings.

Get Naga Durga Bhavani. Kokkira’s stories in your inbox

Join Medium for free to get updates from this writer.

List : A list is a data structure in Python that is a mutable, or changeable, ordered sequence of elements. Each element or value that is inside of a list is called an item. Just as strings are defined as characters between quotes, lists are defined by having values between square brackets [ ] .

Tuple : Tuples are used to store multiple items in a single variable. Tuple is a collection which is ordered and unchangeable or immutable. Tuples are defined by having values between parenthesis ( ).

Sets : Sets are used to store multiple items in a single variable. A set is a collection which is unordered, unchangeable, and unindexed. Sets are defined by having values between curly brackets { }.

Dictionary : Dictionaries are used to store data values in key : value pairs. A dictionary is a collection which is ordered, changeable and do not allow duplicates.

Sequence : Arranging in a ordered manner is called a sequence. Sequences allow you to store multiple values in an organized and efficient fashion. Here Strings, list and tuple are comes under sequence data type.

Mutable : If an object can be modified after it is created is called as a mutable. This means that you can alter its internal data or attributes without creating a new object. Examples of mutable objects in Python include lists, dictionaries, and sets.

Immutable : Immutable in Python is when you cannot change the object type over time. If it is not possible to alter the value of an object in Python, it is known as an immutable object. Once an immutable object is created, its value remains permanent and unchangeable.

--

--