Pythona
Pythona
Python Basics
• Object Oriented Programming Language
• Everything is object except control flow
• Installation
Python Basics
Python List
• List is an ordered sequence of items.
• All the items in a list do not need to be of the same type.
• [ ]
• a = [1, 2.2, 'python’]
a = [5,10,15,20,25,30,35,40]
# a[2] = 15
print("a[2] = ", a[2])
Output
a[2] = 15
a[0:3] = [5, 10, 15]
a[5:] = [30, 35, 40]
Lists are mutable, meaning, the value of elements of a list can be altered.
a = [1, 2, 3]
a[2] = 4
print(a)
Output
[1, 2, 4]
-1 refers to the last item, -2 refers to the second last item etc.
Example