
Python Dictionary is a built-in data structure, and it is also used to store sequential data but in an unordered collection of key and value pairs.

Now let us check the type function with a tuple. Let’s see a example of tuple: tup = (24, "Hello", "World", 2021) We can add any value in the list, but if it is a string, it should be in a single quote (‘) or double quote (“).Ī tuple is similar to the list in many ways. Like lists, tuples also contain the collection of the items of different data types, and values are separated with a comma (,) but enclosed within parentheses ().Ī tuple is immutable, so it is a read-only data structure, and we can’t modify the size and value of the items of a tuple.

#BASIC DATA TYPES IN LISTS HOW TO#
How to Create a ListĪs a list is a collection of the items, we need to separate all the values with a comma (,), and it should be enclosed in square brackets. The list is mutable so that we can change the value in the list at any time. It is a very flexible data type in Python. The list is like an array from the other programming language. The list is used to store an ordered sequence of values in a single variable, or we can say the list is the collection of the items of different data types. This is the topic you will often use in your python journey. Sequential data types are the same as arrays in other programming languages but with advanced features. Sequential data types are a few of the built-in data structures. Suppose we take an example as 2 + 4j where 2 is a real part and j is the imaginary part. Unlike other programming languages such as Java or C++, Python can identify these complex numbers with values. This data type is used to store float values like a real number with floating-point representation-examples 1.2, 45.66, 30000.1.Īs the name suggests, a complex number with a real and an imaginary part like 1+A3 and 7+34i.

Print(type(X)) This is an example of a Type function. Let take another example by using the type() function along with the string data type.Įxample: X = "This is an example of a Type function." To implement string, we need to follow the same steps as assigning a variable.Įxample: X = "This is a String Data Type." and we can also use all the specials characters like *. Generally, strings are represented by either single or double quotes. Python Text or String Data typesĪ text or a string data type which can store a value like letters from a-z in the capital as well as in small, Integer values like 0-9 or a float value like 1.5, 3.7, 200.453, etc.

All nine data types have different purposes. As we can see in the above diagram, there are nine default python data types in python.
