100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
AP Computer Science Principles Programming (Khan Academy) UPDATED ACTUAL Questions and CORRECT Answers $11.99   Add to cart

Exam (elaborations)

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

 0 view  0 purchase
  • Course
  • AP Computer Science Principles Programming
  • Institution
  • AP Computer Science Principles Programming

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 comp...

[Show more]

Preview 4 out of 53  pages

  • October 25, 2024
  • 53
  • 2024/2025
  • Exam (elaborations)
  • Questions & answers
  • ap computer science
  • ap computer
  • AP Computer Science Principles Programming
  • AP Computer Science Principles Programming
avatar-seller
MGRADES
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, " ")

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller MGRADES. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $11.99. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

76799 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$11.99
  • (0)
  Add to cart