Posts

Showing posts from August, 2024

PYTHON PART - 2

Image
Python Lists Lists are ordered collection of data items. They store multiple items in a single variable. List items are separated by commas and enclosed within square brackets []. Lists are changeable meaning we can alter them after creation. Example 1: Explain lst1 = [ 1 , 2 , 2 , 3 , 5 , 4 , 6 ] lst2 = [ "Red" , "Green" , "Blue" ] print ( lst1 ) print ( lst2 ) Copy Output: [1, 2, 2, 3, 5, 4, 6] ['Red', 'Green', 'Blue'] Copy   Example 2: details = [ "Abhijeet" , 18 , "FYBScIT" , 9.8 ] print ( details ) Copy Output: ['Abhijeet', 18, 'FYBScIT', 9.8] Copy As we can see, a single list can contain items of different datatypes.   List Indexes Each item/element in a list has its own unique index. This index can be used to access any particular item from the list. The first item has index [0], second item has index [1], third item has index [2] and so on. Example: colors = [ "Red" ...