Possible test question types Oct 4, 2011 CSE 1310-004 (Tiernan) Below are examples of the kinds of questions I might ask on an exam. Try to work through these and then we can discuss your answers on Thursday in class if desired. I will not do a review for the test so your questions on Thursday will be your opportunity to find out about the test or to explore what I am looking for in regard to these questions. A. Given the Python code below , indicate all syntax errors. Number each location that has an error. After the code, list your numbers and describe what the error is and what should be done. Def uber(wald) #no colon; should be "def" no 'D' print "Today is a good day"; # no ; while k < 10: # k is undefined at this point wald = wald + k print "wald is " wald # need comma before variable wald m == wald # m is undefined because there is no assignment # or comparison isn't saved or used if m % 2 == 0: return "even" else: return odd # odd is an undefined variable or # return "odd" to match other return B. Describe in your own words what indentation is used for in Python. C. Describe in your own words what a function is in Python, how it is different from a plain program, and why you would use functions. D. Given the code below describe in words what the function does in the simplest terms. def ankh( gaspode, gavin): # a(3,8) t=0 temp = 0 #test gs =3, gv =8, t while gaspode > 0 : # T 3 8 0 temp = gavin + temp # T 2 8 8 gaspode -= 1 # T 1 8 16 return temp # F 0 8 24 The function ankh returns the product of gaspode and gavin D.a. If the input to function ankh above is 8 and 3, what is returned by ankh? 24 E. Write a Python program to read in value from the user indicating the user's height and weight. Use the following algorithm to determine if the person is slender, average, or muscled and tell the user which applies to them. The algorithm is: BMI = weight in kg divided by the square of height in meters An average BMI is roughly 21 - 24. Less than this i s slender, greater than this is muscled for purposes of this question. F. What kind of error checking should be done if the input should be a word with only alphabetic characters in it? Either describe in words or write a few Python statements that would do the error check.