0% found this document useful (0 votes)
22 views4 pages

Python Programming CAT Questions Feb 2024

This document contains a Python programming exam with two questions. Question one has two parts that ask the student to print a substring from a string and create and print a list of car prices and totals. Question two has two parts that ask the student to combine two lists in different orders and print the results. The student is asked to write code to complete the tasks in 3 sentences or less for each part.

Uploaded by

victorndiritu9
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views4 pages

Python Programming CAT Questions Feb 2024

This document contains a Python programming exam with two questions. Question one has two parts that ask the student to print a substring from a string and create and print a list of car prices and totals. Question two has two parts that ask the student to combine two lists in different orders and print the results. The student is asked to write code to complete the tasks in 3 sentences or less for each part.

Uploaded by

victorndiritu9
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

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

You might also like