Principles Programming
(Khan Academy) 2026 |
Study Guide, Practice
Questions, Answers,
Rationales & Exam Review
| Complete Ethics Study
Guide
Updated 2026 Questions and Answers
100% Verified Exam Prep and Comprehensive
Rationales
,Included
, Which of the following is a benefit of procedures for Programmers can more easily understand programs with procedures, since
programmers? procedures give names to complex pieces of code.
Aarush is writing a program to help him calculate how 500
much exercise he does at the gym.
The procedure calcSwimYards returns the number of yards
swum for a given number of laps in a pool of a given
length.
PROCEDURE calcSwimYards(poolLength, numLaps)
{
lapLength ← poolLength * 2
RETURN lapLength * numLaps
}
Aarush then runs this line of code:
yardsSwum ← calcSwimYards(25, 10)
What value is stored in yardsSwum?
At that distance, the code should give the player a 30% RANDOM(1, 100) <= 30
chance of making the goal.
RANDOM(1, 10) <= 3
discount ← 0 ≥
IF (quantity <?> 150)
{
discount ← 10
} ELSE
{
IF (quantity <?> 75)
{
discount ← 7
}
ELSE {
IF (quantity <?> 10)
{
discount ← 5
}
}
}
Which operator could replace <?> so that the code snippet
works as expected?
IF (ironLevel < 10) 4.5 "anemic"
{ 8.2 "anemic"
diagnosis ← "anemic" 9.9 "anemic"
} 10.0 "normal"
ELSE 22.5 "normal"
{
diagnosis ← "normal"
}
Which of these tables shows the expected values of
diagnosis for the given values of ironLevel?
Choose 1 answer: