Professional Documents
Culture Documents
1. As we have seen in class, a list is a mutable object, meaning that we can change its elements and
even the number of elements in the list. A tuple is similar to a list, but it is immutable, meaning that
once it has been defined it cannot be changed. A tuple is defined with round brackets () instead of the
square brackets [] of the list. Can you think of a reason for why we want objects to be immutable?
Write a program which uses a 'tuple' to create a data base of your name, date of birth, and place of
birth, and then prints them one by one. (Feel free to make things up.)
2. Write a program which determines whether a string is shorter, longer or precisely 10 characters using
if statements. Let the program ask for user input for the string.
3. In the list [-1.0, 0.5, -0.5, 1.0] add 0.0 to the beginning and -2.0 to the end. Find the
index (i.e. its number in the list) of -0.5, reverse the list and remove all numbers which are less than
one. Hint: do dir(list) to find out about the functions available to list. The function comes after your
list: your_list.function(arguments). Also, have a look at this page:
https://www.tutorialspoint.com/python/python_lists.htm