CSC 110 Midterm: CSC 110 Midterm 3

57 views8 pages

Document Summary

Csc 110 midterm 2 sample exam #1: list mystery. Consider the following function: def list_mystery(list): x = 0 for i in range(len(list) - 1): if list[i] > list[i + 1]: x += 1 return x. In the left-hand column below are specific lists of integers. Indicate in the right-hand column what value would be returned by function list_mystery if the integer list in the left-hand column is passed as its parameter. Function call output mystery(5, 0) _______________________________ mystery(3, 2) _______________________________ mystery(16, 5) _______________________________ mystery(80, 9) _______________________________ mystery(1600, 40) _______________________________ For the following function, identify each of the three assertions in the table below as being either always true, Never true or sometimes true / sometimes false at each labeled point in the code. You may abbreviate these choices as a/n/s respectively. def mystery(): y = 0 z = 1 next = input() # point c z = y y += 1 next = input()