20/04749 kamau Dennis Ngugi
Python Programming CAT One Feb 2024
Question one
a) What will be the output of the code below 4 mks
word = ‘aeioubcdfg'
print word [:3] + word [3:]
b) Create a lists carprices comprising cars and their prices of 10 cars. 3mks
i) Print out the list
ii) Add the price of first and last car in your list print the total cost 5mks
Question two
a) If list =(abcd,786,john, 2.23, 70.2)and tinylist=(efg, 100) write code to print :
i) List (efg, 100, abcd, 786, john, 2.23, 70.2) 4 mks
(ii) The list (70.2, 2.23, john, 786, abcd,100, efgh) 4mks
b) If list =(abcd,786,john, 2.23, 70.2)and tinylist=(efg, 100) write code to print :
i) List (efg, 100, abcd, 786, john, 2.23, 70.2) 4 mks
(ii) The list (70.2, 2.23, john, 786, abcd,100, efgh) 3 mks