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)
    print "Today is a good day";
    while k < 10:
       wald = wald + k
       print "wald is " wald
    m == wald
    if m % 2 == 0:
       return "even"
    else:
       return odd

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)
    temp = 0
    while gaspode > 0
       temp = gavin + temp
    return temp

D.a. If the input to function ankh above is 8 and 3, what is returned by ankh?

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 is 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 characters in it? Either describe in words or write a few Python statements that would do the error check.

G. Give at least four values that should be used as input to test function uber? What useful information would you get from testing these values?