Name Teacher: SUBJECT: Programming Grade 11 Term III Summative Assessment Total: 20 marks Student Instructions: 1. You have 40 minutes to answer this assessment under examination conditions (no talking, no copying or asking for help from the teacher or other students). 2. If you need more space for any answer, use the pages provided at the back of this booklet and clearly number the question. 3. For all numerical answers, full working of solutions should be shown and the answer should be rounded to the correct number of significant figures and given with an SI unit. For all ‘describe’ or ‘explain’ questions, the answer should be in complete sentences with all logic fully explained. For compare and contrast both items in question should be fully explained Characteristics of tasks of summative assessment for term 3 Unit 1 Unit 11.3A: Data 11 structures (continued) Methods of lists and strings. 12 Nested lists. 13 Dictionaries apply functions and string processing methods apply functions and methods of processing lists solve applied problems of various subject areas create nested lists; enter elements of nested lists from the keyboard solve applied problems of various subject areas create a dictionary search for data in a dictionary for a given key determine the difference between different data structures solve applied problems of various subject areas 1. Create a nested list called "My_School". Fill in the list with names of your friends. My_School = [[‘Dastan’,”Zhangir”], [‘Nigger’, ‘Aset’]] My_Class = My_School[0] print(My_Class) [1] 2. Find out the difference between two methods of finding: name="Hello,world" print(name.count("h")) print(name.index("h")) Output 1 Not found 2. Not found [2] 3. Create a dictionaries called “Numbers” and fill it with integer keys. Sort the dictionaries first ascending, then descending. Numbers = {1: ‘one’, 2: ‘two’, 3: ‘three’} print(sorted(Numbers.items())) print(sorted(Numbers.items(), reverse = True)) [3] 4. Write a Python program to multiply all the items in a list List = (1,2,3,4,5,6,7) for i in List: total *= i print("multiply of all elements in given list: ", total) [4] 5. Write the definition of nested list and string. Nested lists in Python – a list that is element of other list String in Python – type of object, list of element bytes [2] 6. Create a dictionary with mixed key. Dict = {1: ‘one’, ‘two’:2} [1] 7. Write a Python program to add a set of values to a single key. d = {} set = {1,2,3,4,5,6,7} sum = 0 for I in set: sum += i d[‘sum’] = sum print(d) [1] 8. Write a Python program to sum all the items in a dictionary. my_dict = {'data1':100,'data2':-54,'data3':247} sum(my_dict.values()) [1] 9. Write a Python program to iterate over dictionaries using for loops Dict = {1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6: 36, 7: 49, 8: 64, 9: 81, 10: 100, 11: 121, 12: 144, 13: 169, 14: 196, 15: 225} for key in Dict: print( key + ‘ ’ Dict[key]) [2] 10. Write a Python script to print a dictionary where the keys are numbers between 1 and 15 (both included) and the values are square of keys. dict = dict() for i in range (1,16): dict[i] = i*i print(dict) [3] Output {1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6: 36, 7: 49, 8: 64, 9: 81, 10: 100, 11: 121, 12: 144, 13: 169, 14: 196, 15: 225}