Sovi.AI - AI Math Tutor

Scan to solve math questions

QUESTION IMAGE

question 24 in the following code, what would be a good post - conditio…

Question

question 24
in the following code, what would be a good post - condition to write?
/* precondition: karel is on a spot with a tennis ball facing east
postcondition: ...
*/
function getontop() {
turnleft();
move();
turnright();
}
karel is on a spot with a tennis ball facing north
karel ends one spot above a tennis ball facing east
karel is on the same position but on top of a ball
karel is facing east

Explanation:

Brief Explanations

The function getOnTop first turns left (from facing east to north), then moves forward one spot, and then turns right (back to facing east). So Karel ends one spot above the original position (where the tennis - ball was) and is still facing east.

Answer:

Karel ends one spot above a tennis ball facing East