List DataType Python

aimtocode

DataType Definition

Data types are means to identify the type of data and associated operations for handling it. In python, we need not to define the type of the variable while declaring it. The interpreter implicitly binds the value with its type accordingly.

Data types represent a kind of value which determines what operations can be performed on that given data.


List DataType

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 in python.

The values stored in a list can be accessed using the slice operator ([ ] and [:]) with indexes starting at 0 in the beginning of the list and working their way to end -1.

The plus (+) sign is the list concatenation operator, and the asterisk (*) is the repetition operator.

For example −



Output:

 ['Hai', 123, 1.75, 'Prayag', 100.25]
 Hai
 100.25
 [123, 1.75]
 [1.75, 'Prayag', 100.25]
 [251, 'Verma', 251, 'Verma']
 ['Hai', 123, 1.75, 'Prayag', 100.25, 251, 'Verma']


Read Also:


aimtocode