KHAN ACADEMY PROGRAMMING STUDY LIST 2024 COMPLETE GUIDE SOLVED AND VERIFIED 100%
KHAN ACADEMY PROGRAMMING STUDY LIST 2024 COMPLETE GUIDE SOLVED AND VERIFIED 100% 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? 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? 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? 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. 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? 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. 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. Ans- Between line 9 and 10 Between line 13 and 14 Nikki read that it's healthy to take 10,000 steps every day. She's curious how many steps that'd be per minute, walking from 10AM to 10PM, and is writing a program to figure it out. The program starts with this code: stepsPerDay ← 10000 hoursAwake ← 12 Which lines of code successfully calculate and store the steps per minute? ️Note that there may be multiple answers to this question. Ans- stepsPerMin ← stepsPerDay / hoursAwake / 60 stepsPerMin ← (stepsPerDay / hoursAwake) / 60 A gardener is writing a program to detect whether the soils for their citrus trees are the optimal level of acidity. IF (measuredPH > 6.5) { soilState ← "high" } ELSE { IF (measuredPH < 5.5) { soilState ← "low" } ELSE { soilState ← "optimal" } } Which of these tables shows the expected values of soilState for the given values of measuredPH? Ans- measuredPH soilState 4.7 "low" 5.4 "low" 5.5 "optimal" 6.2 "optimal" 6.5 "optimal" 6.7 "high" 7.2 "high" Darian is making a program to track his grades. He made the mistake of using the same variable name to track 3 different test grades, though. Here's a snippet of his code: a ← 89 a ← 97 a ← 93 What will be the value of a after this code runs? Ans- 93 KittyBot is a programmable robot that obeys the following commands: Name Description walkForward() Walks forward one space in the grid. turnLeft() Rotates left 90 degrees (without moving forward). turnRight() Rotates right 90 degrees (without moving forward). KittyBot is currently positioned in the second row and third column of the grid, and is facing the bottom edge of the grid. We want to program KittyBot so that she pounces on both of the MouseyBots, walking exactly into the squares where they're hiding. Which of these code segments accomplishes that goal? Ans- REPEAT 2 TIMES { walkForward() turnRight() walkForward() turnLeft() turnLeft() } Nuru writes this code to calculate the final cost of an item with a discount applied: price ← 0.7 discount ← 0.2 final ← price - discount They're surprised to see that final stores the value 0. instead of 0.5. What is the best explanation for that result? Ans- The arithmetic operations on floating-point numbers resulted in a round-off error. The following code snippet processes a list of strings with a loop and conditionals: words ← ["cab", "lab", "cable", "cables", "bales", "bale"] wordScore ← 0 FOR EACH word IN words { IF (LEN(word) ≥ 5) { wordScore ← wordScore + 3 } ELSE { IF (LEN(word) ≥ 4) { wordScore ← wordScore + 2 } ELSE { IF (LEN(word) ≥ 3) { wordScore ← wordScore + 1 } } } } DISPLAY(wordScore) The code relies on one string procedure, LEN(string), which returns the number of characters in the string. What value will this program display? Ans- 13 A digital artist is writing a program to draw a landscape with a randomly generated mountain range. This code draws a single mountain: xPos ← RANDOM(4, 240) height ← RANDOM(70, 120) drawMountain(xPos, 80, height) The code relies on the drawMountain() procedure, which accepts three parameters for the mountain's x position, y position, and height. Here's what's drawn from one run of the program: Which of these describes mountains that might be drawn from this program? ️Note that there may be multiple answers to this question. Ans- A mountain at an x position of 4 and a height of 120 A mountain at an x position of 180 and a height of 110 Marius is writing a program that calculates physics formulas. His procedure calcGravForce should return the gravitational force between two objects at a certain radius from each other, based on this formula: F=G((m1m2)/r^2) 1 PROCEDURE calcGravForce (mass1, mass2, radius) 2 { 3 ,,,,space, space, space, spaceG ← 6.674 * POWER(10, −11) 4 ,,,,space, space, space, spacemasses ← mass1 * mass2 5 ,,,,space, space, space, spaceforce ← G * ( masses / POWER(radius, 2) ) 6 } The procedure is missing a return statement, however. Part 1: Which line of code should the return statement be placed after? Ans- After line 5 RETURN force The following procedure calculates the slope of a line and takes 4 numeric parameters: the x coordinate of the first point, the y coordinate of the first point, the x coordinate of the second point, and the y coordinate of the second point. PROCEDURE lineSlope (x1, y1, x2, y2) { result ← (y2 - y1) / (x2 - x1) DISPLAY (result) } This graph contains a line with unknown slope, going through the points [2, 1] and [4, 3]: Which of these lines of code correctly calls the procedure to calculate the slope of this line? Ans- lineSlope(2, 1, 4, 3) Jace is making a simulation of conversations with his 2-year-old son.
Escuela, estudio y materia
- Institución
- Khan
- Grado
- Khan
Información del documento
- Subido en
- 21 de abril de 2024
- Número de páginas
- 37
- Escrito en
- 2023/2024
- Tipo
- Examen
- Contiene
- Preguntas y respuestas
Temas
-
khan academy programming study list 2024 complete
-
joo won is writing code to calculate the volume of
-
when the user first starts the website runs this
-
khan academy programming study list 2024 complete
Documento también disponible en un lote