# 15110 Lab 5 debug_part_one.py ######################################################## # CLASS ACTIVITY ######################################################## # The following function will compute the sum from # 1 to n inclusively. # Place your responses to the Class Activity here: # 1. # 2. # 3. # 4. # 5. def class_activity(n): sumN = 0 for i in range(0,n): sumN = sumN + i return sumN ######################################################## # STUDENT ACTIVITY ######################################################## # Problem 1 #-------------------------------------------------------- # The following function returns a string that is the # concatonation of all the strings in a list # Place your responses to Problem 1 here: # 1. # 2. # 3. # 4. # 5. def f1(string_list): big_string = "" for string_elem in range(0,len(string_list)): big_string = big_string + string_elem return big_string # Problem 2 #-------------------------------------------------------- # The following function returns the number of iterations # it takes to divide floatA in half until it is less than # floatB. # Place your responses to Problem 2 here: # 1. # 2. # 3. # 4. # 5. def f2(floatA, floatB): count = 0 while(floatA < floatB): floatA = floatA / 2 count = count + 1 return count # Problem 3 #-------------------------------------------------------- # The following function return a list that contains all the # non-negative integers less than n that are a multiple of k # Place your responses to Problem 3 here: # 1. # 2. # 3. # 4. # 5. def f3(n, k): multiple_list = [] for i in range(0, n): if (i % k == 0): multiple_list.append(k) return multiple_list # Problem 4 #-------------------------------------------------------- # The following function take a list of integers as input # to the function, and will return a list that has all # the even elements removed. # Place your responses to Problem 4 here: # 1. # 2. # 3. # 4. # 5. def f4(integer_list): for element_index in range(0,len(integer_list)): if (integer_list[element_index] % 2 == 0): integer_list.pop(element_index) return integer_list