Computer Science  >  QUESTIONS & ANSWERS  >  AP Computer Science Unit 2 Review (Edhesive) (All)

AP Computer Science Unit 2 Review (Edhesive)

Document Content and Description Below

AP Computer Science Unit 2 Review (Edhesive) What will be the output of the following program if the user input number is -5? - ✔✔-15 A travel organization organizes a trip to London. The price ... changes based on the number of applicants. The following program is used to display the price of the trip, and uses the variable Applicants which is set to the number of applicants for the trip. If the number of applicants is 60, what will be displayed? - ✔✔The price of the trip is $250! Consider the following code: IF (n > 0) { DISPLAY ("The number is positive.") } ELSE { DISPLAY ("The number is not positive.") } What will be output by this code if the number n is zero? - ✔✔The number is not positive Which of the following blocks will display even if the positive number num is even? Select two answers. - ✔✔IF ((num MOD 2) = 0) {DISPLAY ["even"]} AND IF ((num MOD 2) = 1) {DISPLAY ["odd"]} ELSE {DISPLAY ["even"]} Below is a program that is supposed to be a "Guess a Number" game, wherein the user is trying to accurately guess a randomly generated number between 1 and 100. However, the program is not functioning as intended. Which two lines in the program need swapped in order for this program to work correctly? Select two answers. - ✔✔LINE 3 AND LINE 5 The following uses a robot in a grid of squares. The robot is represented by a triangle and is in the upper left corner facing toward the bottom of the grid. Which blocks of code will properly navigate the robot to the final destination of the grey square in the bottom right corner of the grid? Select two answers. - ✔✔Both of the boxes that state "Repeat 4 Times" Which of the following best describes the result of running the program below? number ← RANDOM (1, 6) REPEAT UNTIL number > 100 { number ← number * 2 } IF (number = 128) { DISPLAY (true) } ELSE { DISPLAY (false) } - ✔✔If number is a 1, 2 or 4, then the program will display true. Consider the following equivalent code segments that each display the first 12 positive and even integers. Which of the following is NOT an advantage of Segment B over Segment A? - ✔✔Segment B will execute in less time than Segment A. A program has been developed to compute the sum of all elements with a value greater than 10 in a list of integers. Which of the following statements best describes how iteration may be used to in the program in this example? - ✔✔The program will repeat the execution of a block of commands which test the value of an item and add it to a running total (if it is greater than 10) for each value in the list. The program below calculates and displays the sum of the integers from m to n inclusive, where m < n. Line 1 i ← m Line 2 r ← n-m+1 Line 3 sum ← 0 Line 4 REPEAT r TIMES Line 5 { Line 6 sum ← sum+i Line 7 i ← i+1 Line 8 } Line 9 DISPLAY sum If Line 1 is changed to read i ← n, which of the following changes will ensure that the program continues to calculates and displays the sum of the integers from m to n inclusive? - ✔✔Change line 7 to read i ← i-1 A study of beech trees shows that around 40% of these trees may be susceptible to a newly discovered disease. The computer program below is intended to determine the number of trees which may be susceptible to the disease in a forest containing k beech trees: Line 1: total ← 1 Line 2: repeat k times Line 3: { Line 4: IF () Line 5: { Line 6: total ← total + 1 Line 7: } Line 8: } Line 9: DISPLAY (total) Which of the following could be used to replace <MISSING CONDITION> to ensure the program works as intended? Select two answers. - ✔✔RANDOM (1, 5) < 3 AND RANDOM (1, 5) ≤ 2 Which of these statements will move the sprite 100 steps? - ✔✔{repeat (10) {move (10) steps { ->} What would a Sprite say as a result of executing this script? - ✔✔13 A standard deck of playing cards contains 52 cards, with each card being one of four suits: SPADES, HEARTS, CLUBS, and DIAMONDS. Each suit is represented by 13 cards whose values include ACE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, JACK, QUEEN, and KING. Consider the following two algorithms that are intended to find the card representing the "TEN of HEARTS" in a randomly shuffled deck and separate it from the other 51 cards in the deck. Algorithm A Step 1: Pick up the shuffled deck of cards. Step 2: Look at the topmost card in your hands. Step 3: If the card's suit is a HEART, place the card on top of the pile to your left. Step 4: Otherwise, place the card on top of the pile to your right. Step 5: Repeat steps 2 through 4 until you are no longer holding any cards. Step 6: Pick up the cards in the pile to your left. Step 7: Look at the topmost card in your hands. Step 8: If the card's value is a TEN, place all other cards in your hands on top of the pile to your right. Step 9: Otherwise, place the card on top of the pile to your right. Step 10: Repeat steps 7 through 9 until you are holding only one card. Step 11: The only card in your hand is the TEN of HEARTS. Algorithm B Step 1: Pick up the shuffled deck of cards. Step 2: Look at the topmost card in your hands. Step 3: If the card's suit is a HEART or the card's value is a TEN, place all other cards in your hands on top of the pile to your right. Step 4: Otherwise, place the card on top of the pile to your right. Step 5: Repeat steps 2 through 4 until you are holding only one card. Step 6: The only card in your hand is the TEN of HEARTS. - ✔✔Only Algorithm A will always work as intended. The following procedure, validate (x), is intended to display "PASS" if an integer, x, is within the range of 128 through 32768, inclusive. Values of x that are not within the range should display "FAIL". Which of the following s [Show More]

Last updated: 3 years ago

Preview 1 out of 8 pages

Buy Now

Instant download

We Accept:

Payment methods accepted on Scholarfriends (We Accept)
Preview image of AP Computer Science Unit 2 Review (Edhesive) document

Buy this document to get the full access instantly

Instant Download Access after purchase

Buy Now

Instant download

We Accept:

Payment methods accepted on Scholarfriends (We Accept)

Reviews( 0 )

$10.00

Buy Now

We Accept:

Payment methods accepted on Scholarfriends (We Accept)

Instant download

Can't find what you want? Try our AI powered Search

130
0

Document information


Connected school, study & course


About the document


Uploaded On

Dec 15, 2022

Number of pages

8

Written in

All

Seller


Profile illustration for Nutmegs
Nutmegs

Member since 4 years

607 Documents Sold

Reviews Received
77
14
8
2
21
Additional information

This document has been written for:

Uploaded

Dec 15, 2022

Downloads

 0

Views

 130

Document Keyword Tags


$10.00
What is Scholarfriends

Scholarfriends.com Online Platform by Browsegrades Inc. 651N South Broad St, Middletown DE. United States.

We are here to help

We're available through e-mail, Twitter, Facebook, and live chat.
 FAQ
 Questions? Leave a message!

Follow us on
 Twitter

Copyright © Scholarfriends · High quality services·