2.1-2.10 AP-Style MC Practices & Quizzes Proctored Exam.
Using the flowchart below, what value when entered for Y will generate a mathematical error and prevent our flowchart from being completely executed? -y=y x 5 -y=y-15 -y/15 >- 2 / yes no y+2 y-4 a)0 b)None of these values will produce a mathematical error c)3 d)1 - correct answer b)None of these values will produce a mathematical error 0This is correct. None of the operations in this flowchart have the potential to cause a mathematical error. Multiplication, addition and subtraction cannot by themselves cause mathematical errors, and the only division is by 15: only division by 0 causes a mathematical error. In a flowchart, a typical decision symbol has what type of output? a)boolean (true/false) b)None of these c)numerical d)text - correct answer a)boolean (true/false) -This is correct. A decision block allows one of two paths to be followed. To determine which path is followed, a boolean statement is usually written on the block, and one path is followed if this is true, another if it is false. Which is NOT true about comments in programs? a)Commenting about program components helps in developing and maintaining programs. b)All published programs have their comments available. c)Commenting helps programmers develop and maintain programs to efficiently solve problems. d)Commenting helps while working collaboratively in programming environments. - correct answer b)All published programs have their comments available. -This is correct. This is a false statement, as the comments and program documentation for many programs may not be available if the program uses closed source code (i.e. the source code is not released for public consumption). You will learn more about open and closed code in unit 6. Which of the following best describes the type of language used in the below algorithm? -Prompt user for number if number is greater than or equal to 0 Output "Positive" else Output "Negative" Repeat 4 times a)High-level language b)Pseudocode c)Natural language d)Low-level language - correct answer b)Pseudocode -This is correct. This language has a grammatical structure (syntax) which is not like that of a natural language such as written or spoken English. It is more precise and unambiguous than this. However there is no known computer programming language which is written in this way. This language is therefore best described as pseudocode. Consider the given code using variables a, b, and c. What will be the output of this code? a ← 2 b ← 6 c ← 12 a ← b b ← c DISPLAY(a) DISPLAY(c) a)2 12 b)2 6 c)12 12 d)6 12 - correct answer d)6 12 -This is correct. When the code is run, the initial value of a is set to 2, the initial value of b is set to 6, and the initial value of c is set to 12. The value of a is then set to the current value of b, which is 6, then the value of b is set to the current value of c, which is 12. At this point the value of a is now 6, and the value of both b and c is 12. The final two lines display the value of a, followed by the value of c. This results in the number 6, followed by the number 12 being displayed. Consider the following code: n ← 4 x ← -2.5 IF(n < 3) { DISPLAY("Team A") } ELSE { IF(n < 2) { DISPLAY("Team B") } ELSE { IF(x > -2) { DISPLAY("Team C") } ELSE { DISPLAY("Team D") } } } Which of the following is the output of the code? a)Team C b)Team B c)Team D d)Team A - correct answer c)Team D -This is correct. When the code is run, the value of n is set to 4, and the value of x is set to -2.5. The condition for the first IF statement is then checked (n < 3), and as this is not true (since n = 4), the code in the IF block is not run. As the code for this IF block did not run, instead the code in the corresponding ELSE block is run. Immediately a second IF statement with condition n < 2, is checked, and as the condition is once again not satisfied the code in the IF block is not run and the corresponding ELSE block is run instead. A final IF statement with condition x > -2, is checked, and as x = -2.5 the condition is once again not satisfied. The code in the IF block is not run and the corresponding ELSE block is run containing the statement DISPLAY("Team D"). Therefore the result of running the code is that "Team D" is displayed. Sam and Emma are creating a multiplayer tic-tac-toe game. Below is a segment of their code that is used so that the Sprite on screen can tell the user whose turn it is. turn ← turn + 1 -If (condition 1) Display player 1's turn else Display player 2's turn Before each user's turn, this set of code is run. What would condition 1 need to be so that this part of the program runs correctly? The variable turn is initialized as 0 at the start and player 1 always goes first. a)turn MOD 2 = 1 b)turn > 0 c)turn = 1 d)turn MOD 2 =0 - correct answer a)turn MOD 2 = 1 -This is correct. The variable turn is initialized as 0. When this block of code first runs, the first command increases the value of turn by 1. Therefore when the IF/ELSE block is first run the value of turn is 1. As this code is run before each users turn, when it is player 2's first turn the value of turn will again be increased by 1 to give a value of 2. Each subsequent turn the value is increased by 1, meaning that each time it is player 1's turn the value of turn is an odd number, and each time it is player 2's turn the value of turn is an even number. As the value of turn MOD 2 will be 1 whenever turn is odd, this condition should be in the place of condition 1 so that "Player 1's turn" is displayed whenever turn is odd. A student developed a program that outputs the name of a fruit that begins with a letter, dependent upon the variable keyPressed, which stores the letter (from A to Z only) a user types on the keyboard. Below is a section of code from her program: -If ("key pressed" = A) Display apple Which of the following descriptions below would be a way that this student might have written the rest of her code so that it executes as intended? Select two answers.
Written for
- Institution
- MC.
- Course
- MC.
Document information
- Uploaded on
- March 9, 2024
- Number of pages
- 25
- Written in
- 2023/2024
- Type
- Exam (elaborations)
- Contains
- Questions & answers
Subjects
-
21 210 ap style mc practices quizzes
Also available in package deal