Getting a Single Element of a List in Python
You can access the elements of a list in the same way as you access the characters of a string: the first element has the number 0, the second has the number 1, and so on. These numbers are called the indices of the elements of the list. Let's look at an example:
pythonlst = ['a', 'b', 'c', 'd', 'e']
print(lst[0]) # 'a'
print(lst[1]) # 'b'
print(lst[2]) # 'c'
Задание 1
Given a list:
pythonlst = [1, 2, 3, 4, 5]
Print the first element of this list.
Задание 2
Given a list:
pythonlst = [1, 2, 3, 4, 5]
Print the second element of this list.
Задание 3
The following code is given:
pythonlst = [1, 2, 3, 4, 5]
print(lst[-1])
Tell me what will be output to the console.
Задание 4
The following code is given:
pythonlst = [2, 4, 6, 8]
res = lst[3] - lst[0]
print(res)
Tell me what will be output to the console.