You are on page 1of 2

EXERCISES

• Create an empty list called aList. Print the list.

• Use append method to populate this list with the following items: 2.3,
“CMP 211”, False, 23, True, 6. Print the list after populating.

• Write a program to generate a sublist of the list [30, 60, 90, 120, 150, 180,
210], the sublist should be made up of the third item up to the fifth item
(inclusive) of the original list. Print the sublist.

Answer

x = [30, 60, 90, 120, 150, 180, 210]

sublist = x[:]

print(sublist)

sublist = x[3:6]

print(sublist)

• Change the fourth value in the list ['NG', 'US', 'IN', 'CH', 'GM', 'CA'] to 'GH'.

• Remove the first and last values in the above list.

• Find and print the length of the list in 4.


• Write a program to create and build a list called unis. It will collect 6
university names from the user and print the list of the universities.

• unis = ['AUL', 'UNN', 'NAU', 'UI', 'OAU', 'ABU', 'UNN']. Write a program to
loop through the list and print 'University of Nigeria Nsukka' when it is UNN.

You might also like