Docsity

LESSONS 1-20 -CODEHS KAREL PROGRAMMING EXAM, Exams of Computer Science

Toggle sidebar
bg1
Page 1 of 95
LESSONS 1-20 -CODEHS KAREL PROGRAMMING
EXAM QUESTIONS WITH DETAILED- VERIFIED
ANSWERS- ALREADY GRADED A+ || NEWLY
RELEASED
Computer science / programming language
Examination Summary:-
Section Topics Covered Questions
1 Karel Commands and Basic Syntax 1–25
2 Functions and Top-Down Design 26–50
3 For Loops 51–70
4 While Loops 71–85
5 If Statements and If/Else Statements 86–105
6 Control Structures and Problem-Solving 106–125
7 Debugging, Testing, and Good Programming Style
126–140
8 Advanced Karel Concepts and Challenges 141–150
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58
pf59
pf5a
pf5b
pf5c
pf5d
pf5e
pf5f

Partial preview of the text

Download LESSONS 1-20 -CODEHS KAREL PROGRAMMING EXAM and more Exams Computer Science in PDF only on Docsity!

LESSONS 1- 20 - CODEHS KAREL PROGRAMMING

EXAM QUESTIONS WITH DETAILED- VERIFIED

ANSWERS- ALREADY GRADED A+ || NEWLY

RELEASED

Computer science / programming language Examination Summary:- Section Topics Covered Questions 1 Karel Commands and Basic Syntax 1 – 25 2 Functions and Top-Down Design 26 – 50 3 For Loops 51 – 70 4 While Loops 71 – 85 5 If Statements and If/Else Statements 86 – 105 6 Control Structures and Problem-Solving 106 – 125 7 Debugging, Testing, and Good Programming Style 126 – 140 8 Advanced Karel Concepts and Challenges 141 – 150

Section 1: Karel Commands and Basic Syntax (Questions 1 –

  1. Which of the following is a valid Karel command? A. move; B. MOVE C. move(); D. move() CORRECT ANSWER : C. move(); ✅ RATIONALE : Karel commands are case‑sensitive and must end with parentheses (). The correct syntax is move();. Commands cannot have spaces, and capitalization must match exactly.
  2. Which command does Karel use to place a tennis ball at its current location? A. addBall(); B. placeBall(); C. putBall();

A. turn left(); B. turnLeft(); C. TurnLeft(); D. turnLeft(); CORRECT ANSWER : B. turnLeft(); ✅ RATIONALE : Karel commands are case‑sensitive and cannot contain spaces. turnLeft(); is the correct syntax.

  1. What command does Karel use to move forward one space? A. move(); B. Move(); C. forward(); D. go(); CORRECT ANSWER : A. move(); ✅ RATIONALE : move(); is the Karel command that moves Karel forward one space in the direction it is facing.
  1. By default, Karel knows how to turn right. A. True B. False CORRECT ANSWER : B. False ✅ RATIONALE : Karel does not know how to turn right by default. Programmers must teach Karel to turn right by defining a function or using three turnLeft(); commands.
  2. If Karel is currently facing North and the code turnLeft(); turnLeft(); runs, which direction is Karel facing now? A. North B. South C. East D. West CORRECT ANSWER : B. South ✅

CORRECT ANSWER : B. Functions ✅ RATIONALE : Functions allow programmers to teach Karel new commands, such as turnRight();, by combining existing commands.

  1. What is the name of the function that is automatically called when you click "Run" in a Karel program? A. main(); B. start(); C. run(); D. begin(); CORRECT ANSWER : B. start(); ✅ RATIONALE : The start(); function is automatically called when you click Run. It should be the first function defined in your program.
  2. How many times should the start() function be defined in a Karel program?

A. 0

B. 1

C. 2

D. However many you like CORRECT ANSWER : B. 1 ✅ RATIONALE : The start(); function should be defined exactly once in a program. It is the entry point for Karel's execution.

  1. How many times should the start() function be called in a Karel program? A. 0 B. 1 C. 2 D. However many times you like CORRECT ANSWER : A. 0 ✅

D. Corner CORRECT ANSWER : A. Row ✅ RATIONALE : In Karel's world, rows are called streets, and columns are called avenues.

  1. What is an avenue in a Karel world? A. Row B. Column C. Street D. Corner CORRECT ANSWER : B. Column ✅ RATIONALE : In Karel's world, columns are called avenues, and rows are called streets.
  2. Karel starts at Street 1, Avenue 1, facing East in a 5× world. What will happen after this code runs? move(); move(); turnLeft(); move();

A. Karel will be at Street 2, Avenue 3 B. Karel will be at Street 1, Avenue 3 C. Karel will crash into a wall D. Karel will turn around CORRECT ANSWER : C. Karel will crash into a wall ✅ RATIONALE : Starting at (1,1) facing East, Karel moves to (1,2), then (1,3), then turns left to face North, then attempts to move to Street 2, Avenue 3. In a 5×5 world, this is valid. However, if the world has a wall at the top, Karel may crash. The CORRECT ANSWER depends on the specific world setup.

  1. If Karel starts at Street 1, Avenue 3 facing East, what street and avenue will Karel be on after this code runs? move(); move(); move(); turnLeft(); move(); A. Street 1, Avenue 6 B. Street 2, Avenue 6 C. Street 2, Avenue 3 D. Street 1, Avenue 4
  1. Which of the following is NOT true about a Karel command? A. Command names can only be made up of one word B. Commands do not have any spaces C. Capitalization has to match exactly D. Every command ends in (); CORRECT ANSWER : A. Command names can only be made up of one word ✅ RATIONALE : Command names can be made up of multiple words (e.g., turnLeft(); has two words combined). However, they cannot have spaces.
  2. All commands must be inside of a function. A. True B. False CORRECT ANSWER : A. True ✅

RATIONALE : In Karel programming, all commands must be placed inside a function (such as start(); or a custom function). Commands cannot exist outside of functions.

  1. What happens when Karel executes putBall(); at a location that already has a ball? A. Karel places an additional ball B. Karel ignores the command C. Karel crashes D. Karel removes the ball CORRECT ANSWER : A. Karel places an additional ball ✅ RATIONALE : Karel can place multiple balls at the same location. putBall(); simply adds another ball.
  2. What is the correct syntax to call a custom function named buildTower();? A. buildTower; B. buildTower();
  1. What does Karel do when it executes turnLeft(); while facing East? A. Faces North B. Faces South C. Faces West D. Faces East CORRECT ANSWER : A. Faces North ✅ RATIONALE : Turning left from East rotates Karel 90 degrees counter‑clockwise to North.
  2. What does Karel do when it executes turnLeft(); while facing West? A. Faces North B. Faces South C. Faces East D. Faces West CORRECT ANSWER : B. Faces South ✅

RATIONALE : Turning left from West rotates Karel 90 degrees counter‑clockwise to South. Section 2: Functions and Top-Down Design (Questions 26 – 50)

  1. What is a function in Karel programming? A. A way to store data B. A way to teach Karel a new word C. A variable that stores a number D. A loop that repeats code CORRECT ANSWER : B. A way to teach Karel a new word ✅ RATIONALE : Functions allow programmers to teach Karel new commands by defining a sequence of existing commands.
  2. Why do we use functions in programming? A. Break down our program into smaller parts B. Avoid repeating code

RATIONALE : Top‑down design is a problem‑solving approach that breaks a large problem into smaller, manageable subproblems.

  1. What is a code comment? A. A way to teach Karel a new word B. A way to give notes to the reader to explain what your code is doing C. A message to your teacher in code D. A place to write whatever you want in your code CORRECT ANSWER : B. A way to give notes to the reader to explain what your code is doing ✅ RATIONALE : Comments are notes in the code that explain what the code does. They are ignored by the computer.
  2. What is the correct syntax for a single‑line comment in JavaScript? A. // This is a comment

B. /* This is a comment / C. # This is a comment D. CORRECT ANSWER : A. // This is a comment ✅ RATIONALE : In JavaScript, single‑line comments begin with //. Multi‑line comments use / */.

  1. Why should a programmer indent their code? A. Helps show the structure of the code B. Easier for other people to understand C. Indenting is a key part of good programming style D. All of the above CORRECT ANSWER : D. All of the above ✅ RATIONALE : Indentation improves code readability and shows the structure of functions, loops, and conditionals.