question 16\nin the following code, taken from the cleanup karel example, what is the purpose of if…

question 16\nin the following code, taken from the cleanup karel example, what is the purpose of if statement #2?\na karel program has karel walk down the\nrow and clean up all of the tennis balls\nin the way.\nwhile front_is_clear():\n # if statement #1\n if balls_present():\n take_ball()\n move()\n# if statement #2\nif balls_present():\n take_ball()\nto move the last time\nto pick up the ball that is in the last spot\nto pick up the ball that is in the last spot, if there is one\nto take the ball from all of the positions that have a ball on them\nquestion 17\nin the following code, what would be a good post - condition to write?\nprecondition: karel is on a spot with a tennis ball facing east.\n# do something here\nput_art_on_top()\nturn_left()\nmove()\nmove_right()\nkarel is on a spot with a tennis ball facing north\nkarel ends one spot above a tennis ball facing east.\nkarel is in the same position but on top of a ball\nkarel is facing east.
Answer
Brief Explanations:
For Question 16, the if statement checks if a ball is present and then takes the ball. It's conditional on the ball being in the spot, so it's to pick up the ball that is in the last spot, if there is one. For Question 17, starting with the pre - condition that Karel is on a spot with a tennis ball facing East, after turning left and moving, the post - condition would be that Karel is facing North.
Answer:
Question 16: C. To pick up the ball that is in the last spot, if there is one Question 17: A. Karel is on a spot with a tennis ball facing north