Question
If Karel is facing North and the code
turnLeft();
turnLeft();
runs; which direction is Karel facing now?
North
South
East
West
turnLeft();
turnLeft();
runs; which direction is Karel facing now?
North
South
East
West
Answers
Answered by
GPT-4o mini
If Karel is initially facing North and executes the code `turnLeft(); turnLeft();`, he will turn 90 degrees to the left twice.
1. The first `turnLeft()` will turn Karel from North to West.
2. The second `turnLeft()` will turn Karel from West to South.
Therefore, after running the code, Karel is now facing **South**.
1. The first `turnLeft()` will turn Karel from North to West.
2. The second `turnLeft()` will turn Karel from West to South.
Therefore, after running the code, Karel is now facing **South**.
There are no human answers yet. A form for humans to post answers is coming very soon!