ubuntu2004
Exercise 11.1
Create a list with the following items: 1, 1, 2, 3, 5, 8.
Assign it to the variable called
fib
.And print it.
Exercise 11.2
Print the length of the list fib
.
Exercise 11.3
Create an empty list called
eggs_laid
.Add the following two items to the list: 10, 11.
And print it.
Exercise 11.4
Sort the following list in place.
Print it.
Note: As this is a list of strings, the list will be sorted alphabetically.
Exercise 11.5
Sort the following list and assign it to a new variable called
sorted_eggs_laid
.Print
sorted_eggs_laid
.
Exercise 11.6
Access and print items from the second to the sixth positions inclusive from sorted_eggs_laid
.
Hint: Remember that the first item of a list has index 0.
Exercise 11.7
Print the reverse of the list sorted_eggs_laid
.
Exercise 11.8
Get and print the index of the first item with value 14 from sorted_eggs_laid
.
Exercise 11.9
A single nighttime survey of bats in the Forest of Dean produced a list of the species of all individual bats caught.
Test if the bat species Myotis alcathoe is in the following list bat_list
and print whether it is or not.
Exercise 11.10
Test if the bat species Rhinolophus hipposideros is in the above list bat_list
. If it is, print its index in the list otherwise print that it is not in the list.