100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Exam (elaborations)

AP Computer Science Principles Programming (Khan Academy) UPDATED ACTUAL Questions and CORRECT Answers

Rating
-
Sold
-
Pages
53
Grade
A+
Uploaded on
25-10-2024
Written in
2024/2025

AP Computer Science Principles Programming (Khan Academy) UPDATED ACTUAL Questions and CORRECT Answers Which of the following is a benefit of procedures for programmers? - CORRECT ANSWER- Programmers can more easily understand programs with procedures, since procedures give names to complex pieces of code. Aarush is writing a program to help him calculate how 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)

Show more Read less
Institution
AP Computer Science Principles Programming
Course
AP Computer Science Principles Programming











Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Institution
AP Computer Science Principles Programming
Course
AP Computer Science Principles Programming

Document information

Uploaded on
October 25, 2024
Number of pages
53
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

Content preview

AP Computer Science Principles
Programming (Khan Academy) UPDATED
ACTUAL Questions and CORRECT
Answers
Which of the following is a benefit of procedures for programmers? - CORRECT
ANSWER✔✔- Programmers can more easily understand programs with procedures, since
procedures give names to complex pieces of code.


Aarush is writing a program to help him calculate how 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? - CORRECT ANSWER✔✔- 500


At that distance, the code should give the player a 30% chance of making the goal. -
CORRECT ANSWER✔✔- RANDOM(1, 100) <= 30


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? - CORRECT
ANSWER✔✔- ≥


IF (ironLevel < 10)
{
diagnosis ← "anemic"
}
ELSE
{
diagnosis ← "normal"
}
Which of these tables shows the expected values of diagnosis for the given values of
ironLevel?

Choose 1 answer: - CORRECT ANSWER✔✔- 4.5 "anemic"
8.2 "anemic"
9.9 "anemic"
10.0 "normal"
22.5 "normal"

,NOT ( calendar = "user" AND rsvp = "yes" ) - CORRECT ANSWER✔✔- calendar ≠ "user"
OR rsvp ≠ "yes"


This graph contains a line with unknown slope, going through the points [2, 1][2,1]open
bracket, 2, comma, 1, close bracket and [4, 3][4,3]open bracket, 4, comma, 3, close bracket: -
CORRECT ANSWER✔✔- (2, 1, 4, 3)


Program 1:
totalCalories ← 0
loggedMeals ← [700, 800, 600, 300]
FOR EACH loggedMeal IN loggedMeals
{
totalCalories ← totalCalories + loggedMeal
}
IF (totalCalories > 2000) {
excessCalories ← totalCalories - 2000
DISPLAY(excessCalories)
}
Program 2:
totalCalories ← 0
loggedMeals ← [700, 800, 600, 300]
FOR EACH loggedMeal IN loggedMeals
{
totalCalories ← totalCalories + loggedMeal
IF (totalCalories > 2000) {
excessCalories ← totalCalories - 2000
}
}

DISPLAY(excessCalories) - CORRECT ANSWER✔✔- Program 1 and Program 2 display
the same output, but Program 2 requires more computations.

, REPEAT UNTIL ( canTakeCheese() )
{
<MISSING CODE>
}
There are many ways for him to reach the cheese. Of the options below, which will require
the most repetitions of the loop? - CORRECT ANSWER✔✔- IF (facingWall())
{
turnRight()
}
ELSE
{
walkForward(2)
}


sentence ← ""
word1 ← "Hello"
firstLetter1 ← SUBSTRING(word1, 1, 1)
otherLetters1 ← SUBSTRING(word1, 2, LENGTH(word1) - 1)
pigLatin1 ← CONCAT(otherLetters1, firstLetter1, "ay")
sentence ← CONCAT(sentence, pigLatin1, " ")
word2 ← "Mister"
firstLetter2 ← SUBSTRING(word2, 1, 1)
otherLetters2 ← SUBSTRING(word2, 2, LENGTH(word2) - 1)
pigLatin2 ← CONCAT(otherLetters2, firstLetter2, "ay")
sentence ← CONCAT(sentence, pigLatin2, " ")
word3 ← "Rogers"
firstLetter3 ← SUBSTRING(word3, 1, 1)
otherLetters3 ← SUBSTRING(word3, 2, LENGTH(word3) - 1)
pigLatin3 ← CONCAT(otherLetters3, firstLetter3, "ay")
sentence ← CONCAT(sentence, pigLatin3, " ")

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
MGRADES Stanford University
View profile
Follow You need to be logged in order to follow users or courses
Sold
1069
Member since
1 year
Number of followers
102
Documents
68976
Last sold
1 hour ago
MGRADES (Stanford Top Brains)

Welcome to MGRADES Exams, practices and Study materials Just think of me as the plug you will refer to your friends Me and my team will always make sure you get the best value from the exams markets. I offer the best study and exam materials for a wide range of courses and units. Make your study sessions more efficient and effective. Dive in and discover all you need to excel in your academic journey!

3.8

169 reviews

5
73
4
30
3
44
2
8
1
14

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions