• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 4 out of 41 pages
Exam (elaborations)

Khan Academy Programming Study List

Document preview thumbnail
Preview 4 out of 41 pages

Khan Academy Programming Study List Khan Academy Programming Study List Khan Academy Programming Study List

Content preview

Khan Academy Programming Study List
Joo-won is writing code to calculate the volume of a cone based on this formula:



Volume=(Pi(r)^2)(h/3)



He's testing his code on this cone:

The code starts with these variables, where radius represents rrr and height represents hhh:

radius ← 2

height ← 5

The built-in constant PI stores an approximation of PI

Which expression correctly calculates the volume? - CORRECT ANS PI * (radius * radius) * (height / 3)



A local search website lets users create lists of their favorite restaurants.

When the user first starts, the website runs this code to create an empty list:

localFavs ← []

The user can then insert and remove items from the list.

Here's the code that was executed from one user's list making session:

APPEND(localFavs, "Udupi")

APPEND(localFavs, "The Flying Falafel")

APPEND(localFavs, "Rojbas Grill")

APPEND(localFavs, "Cha-Ya")

APPEND(localFavs, "Platano")

APPEND(localFavs, "Cafe Nostos")



INSERT(localFavs, 3, "Gaumenkitzel")

,REMOVE(localFavs, 5)

What does the localFavs variable store after that code runs? - CORRECT ANS "Udupi", "The Flying Falafel",
"Gaumenkitzel", "Rojbas Grill", "Platano", "Cafe Nostos"



Alissa is programming an app called ShirtItUp, where users can customize a t-shirt with their own phrase
on it.

Which variable would she most likely use a string data type for? - CORRECT ANS phrase: The custom
phrase entered by the user



This program uses a conditional to determine whether a child will have free or attached earlobes.

if (fatherAllele = "G" OR motherAllele = "G")

{

earlobeType ← "free"

}

ELSE

{

earlobeType ← "attached"

}

In which situations will earlobeType be "free"?

👁️Note that there may be multiple answers to this question. - CORRECT ANS When fatherAllele is "G"
and motherAllele is "G"



When fatherAllele is "G" and motherAllele is "g"



When fatherAllele is "g" and motherAllele is "G"



This short program displays the winning result in a ship naming contest:

,DISPLAY ("Schoolie")

DISPLAY ("McSchoolFace")

Part 1: How many statements are in the above program?



Part 2: What does the program output? - CORRECT ANS 2



Schoolie McSchoolFace



Emanuel is writing a program to decide which fairgoers can ride on the rollercoaster, based on their
height.

The rollercoaster has a sign posted that states: "RIDERS MUST BE AT LEAST 48" TALL TO RIDE"

The variable riderHeight represents a potential rider's height (in inches), and his program needs to set
canRide to either true or false.

Which of these code segments correctly sets the value of canRide?

👁️
Note that there are 2 answers to this question. - CORRECT ANS IF (riderHeight ≥ 48) {

canRide ← true

}

ELSE {

canRide ← false

}



IF (riderHeight < 48) {

canRide ← false

}

ELSE {

canRide ← true

, }



This program simulates a game where two players try to make basketball shots . Once either player
misses 5 shots, the game is over.

1: player1Misses ← 0

2: player2Misses ← 0

3: REPEAT UNTIL (player1Misses = 5 OR player2Misses = 5)

4: {

5: player1Shot ← RANDOM(1, 2)

6: player2Shot ← RANDOM(1, 2)

7: IF (player1Shot = 2)

8: {

9: DISPLAY("Player 1 missed! ☹")

10: }

11: IF (player2Shot = 2)

12: {

13: DISPLAY("Player 2 missed! ☹")

14: }

15: IF (player1Shot = 1 AND player2Shot = 1)

16: {

17: DISPLAY("No misses! ☺")

18: }

19: }

Unfortunately, this code is incorrect; the REPEAT UNTIL loop never stops repeating.

Where would you add code so that the game ends when expected?

👁️
Note that there are 2 answers to this question. - CORRECT ANS Between line 9 and 10

Document information

Uploaded on
December 10, 2024
Number of pages
41
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers
$15.99

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

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.
lectjoseph
3.5
(10)
Sold
81
Followers
23
Items
5455
Last sold
2 months ago



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

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions