''' This is a small review of CSI 31. Omitted from the review, but to be covered: - Sets, Dictionaries - Classes ''' ################# ## Reading Code # ################# print("*****************\n\nREADING PROBLEM 1") k = -5 if k > 0: print(k) elif k < -5: print(k*2) elif k == -4.9: print(k+2) else: print(k - 1) print("*****************\n\nREADING PROBLEM 2") L = [2,9, 2,1] X = L X[2] = 0 print(L) print("*****************\n\nREADING PROBLEM 3") def F(y,L,x): L[2] = x L[3] = L[2] L[2] = 9 y = x + y return y x, z = 2, 70 myList = ['one', 8, 'two', 'three', 100] z = F(z, myList, x) print("x:",x) print("z:",z) print("myList:", myList) print("*****************\n\nREADING PROBLEM 4") for x in range(3): for y in range(2,4): print(x,y) # Modify the above code so that # it prints out # "point 1 is: (0,2)" # "point 2 is: ..." # ETC. ################ # Writing Code # ################ # 1 # Write a function that takes a list as input # and outputs the sum of the squares of the entries # in the list. # 2 # Write a program that takes input from the # user until "Enter" is hit with no number. # The program outputs the value of the # largest and smallest number inputed. # Do this program in two ways: # 1- First with lists, then # 2- Without lists. # After it works, add error checking: # For example, if the user inputs a string, inform them of # the error and ask them for a valid input. # 3 # Write a program (use for-loops) that creates a list # of tuples where each tuple is # the pair (i,j) where "i" can be any number between 1 and 5, # while "j" can be any letter between A and D, e.g. # the list starts like [(1,'A'), (1,'B'), ...] # 4 # Write a program that takes a sentence # as user input and then prints out the # number of 4-letter words in the sentence.