• Why should we use functions in our programs?
  • True or False, the function below is incorrect because the variable name used within the function is different than the variable name defined outside.
def launch(item):
  print("item launched: %s".format(item))

missile = 'warhead'
  • True or False, even functions with no return statement return a value?
  • Write a function that combines two strings and returns the result.
  • How could you rewrite the following code using a function?
hole = None
if peg_type == 'round':
  print('the type supplied is round')
  hole = 'round'
elif peg_type == 'square':
  print('the type supplied is square')
  hole = 'square'
  • True or False, when calling a function, the order in which you supply arguments (the values you are giving to the function in parentheses) is critical?
  • Give an example of overriding scope.
  • How can you recover from a fatal error on your program?
  • Give an example of handling an IndexError.
  • Why would we care to write our data to a file?
  • How can I open a file in read/write mode?
  • What would I do if I wanted to read a file one line at a time?

results matching ""

    No results matching ""