1. Given the function definition below, which of the following are NOT legal/appropriate
calls to the function. Explain.
def add_one(value):
return value+1
a. add_one(10)
b. add_one()
c. add_one
d. add_one(-1)
e. add_one(2, 3)
f. add_one(16.1)
g. add_one("cs150 is great")
2. The program below is supposed to calculate the length of the hypotenuse of a right
triangle with sides 3 and 4 and print out the answer. However, the program has three
errors in it: one syntax and two when it runs relating to type. What are the three
errors? Try and figure it out WITHOUT trying to run the program.
# take the sqrt of a number
def my_sqrt(x):
return x**(1//2)
# calculate the length of the hypotenuse of a right
# triangle
def hypotenuse_length(a, b)
sum = a**2 + b**2
return my_sqrt(sum)
print("If a is 3 and b is 4 then hypotenuse is " + hypotenuse_length(3,4))
3. What is wrong with the following function:
def triangle_area(base, height):
return base*height/2.0
print("Base is: " + str(base))