Reference no: EM132382483
Question
Complete the function asn2_1() so it prints the sum of its arguments
Complete the function asn2_2() so it calculates the average of its arguments and returns the average rounded to 2 decimal places.
Complete the function asn2_3() so it returns the area of a pizza, rounded to two decimal places. It will take one parameter -- the diameter of the pizza (assume the pizza is round).
Complete the function asn2_4() so it draws a rectangle. The function should take five parameters: a turtle, the length of the horizontal side, the length of the vertical side, the x location of the bottom left corner, and the y location of the bottom left corner.
Complete the statements in main() according to the directions in the code:
Add commands to the loop (for diameter in [10, 12, 16]) to calculate the areas of 10, 12, and 16 inch pizzas (using asn2_3()) and print those results.
Add commands to draw four rectangles using asn2_4()
The code is as follows:
import turtle
def asn2_1(num1, num2, num3):
'''Prints (does not return) the sum of three numbers'''
def asn2_2(??num1, num2, num3, num4, num5):
'''Returns (does not print) the average of five intergers'''
def asn2_3(d):
'''Returns the area of a pizza. The parameter is the pizza's diameter.'''
#Write function asn2_4() to draw rectangles
d?ef asn2_4(t, hlen, vlen, x, y):
'''asn2_4 takes the following parameters:
a turtle and 4 intergers; the integers are the length of the horizontal side, the length of the vertical side, x position of lower left corner, y position of lower left corner.'''
def main():
'''Change only the statements you are directed to change below'''
asn2_1(10, 12, 14) #Do not change this statement
average = asn2_2(10, 12, 14, 16, 18) ???#Do not change this statement
print("The average is", average) #Do not change this statement
for diamter in [10, 12, 16]:
#Add commands to call asn2_3() and print the areas of 10, 12, and 16 inch pizzas
wn = turtle.Screen() #Do not change this statement
jack = turtle.Turtle() #Do not change this statement
#Add commands to draw 4 rectangles using asn2_4() and turtle jack
wn.exitonclick() #Do not change this statement
main()