Lab: Practice Problems I

Basic function definitions

Copy this into a Python file and add the specified code under each comment. For testing purposes, you can comment out working parts as you go (surround the lines with """).

"""
This is how you comment
out a whole block of stuff.
"""
# define a function that takes two numbers, adds them, and returns the sum

# call that function to add 7 and 8 and then print the result

# using the variables below, call that function to add x and y, multiply the 
#  result by z and then print that result
x = 17
y = 6
z = 8

# call that function to add the second and fourth numbers in the list below
#  and then print the result
nums = [16, 23, 41, 89]


# define a function that takes three numbers and returns the largest one,
#  without using the built-in max function

# use that function to print the larger of x and y


# define a function that takes an integer and calls the use "poopy" (print to the screen)
#  that many times

# call that function to call the user "poopy" 7 times


# define a function that takes a list of numbers and returns a new list containing the
#  same numbers in reverse order (without using the built-in list reverse method)

# call that function to reverse the nums list above, then print the result