List indexing¶
Analyse which of these assignment statements are correct and which are not. Why ?. Manually obtain the values of each variable. Then check them using a Python shell.
a = ['a', 5, 3.2, [4, 'bc']] b = a[0] c = a[-1] d = c[1] e = a[-5] f = a[4] g = a[1.0] h = a[[]] h = a['x'] i = a[-2] j = a[-1][1][0]
Which of these lists are homogeneous and which are heterogeneous ?
[3, 1, 5, 8] [3, 1, 5.0, 8] [3, 1, [5, 8]] ['3', 1, '5', 8] ['3', '1', '5', '8'] [3.0, 1.0, 5.0, 8.0] [[3], [1], [5, 8], []]