Select Page

In this lab you will practice creating programs that use lists. Each question is worth 1 mark.In this assignment, initialize a list in the program by assigning values rather than using input to supply the values to a list. The program must still be general for any list that complies with the question specification.Note, the TAs may use list values that are different from the sample solutions below when they test your program. 1. Write a program that initializes a list of integers called sumList such as the one below. Your program will then print the sum of the numbers in that list. You should use a loop to traverse the list and the list size may vary when your code is being tested by the TAs.For example, the list of numbers can be initialized as follows:sumList = [2,-1,4,17] Sample run:The sum of your numbers is 22 2. Write a program that initializes a list of integers called numList such as the one below. Your program will then compute the square of each value in numList. The program will store each square in a new list and print out the new list of squares. For example, the list of numbers can be initialized as follows:numList = [2,3,4,5,6,7]Sample run:The squares of your numbers are: [4, 9, 16, 25, 36, 49] 3. Write a program that initializes a list of integers called modList. This program will print the number of zeroes in the original list and modify the list to replace all negative numbers with zeros. The final list should be printed.For example, if the list of integers was initialized as follows:modList = [0,4,2,-2,-8,0,5,19, 200, -3]Sample run:There were 2 zeroes in the original list The new list is [0,4,2,0,0,0,5,19,200,0] 4. In this question, the user of the program will input a string and initialize a list of positions. You can assume that the positions will either be 0 or positive integers. The program must output the characters of the string at the values (positions) in the list in the order of their occurrence. Note that the program should handle if a position goes beyond the end of the string by printing an error message.For exampleif the input string is “Computing”and the position list is initialized to [2,4,15,0, 7,4,3,5]Then the program should printm u position 15 is too large C n u p tComputer ScienceEngineering & TechnologyPython Programming CMPUT 101

Order your essay today and save 20% with the discount code ESSAYHELP