100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Exam (elaborations)

2.1-2.10 AP-Style MC Practices & Quizzes Proctored Exam.

Rating
-
Sold
-
Pages
25
Grade
A+
Uploaded on
09-03-2024
Written in
2023/2024

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.

Show more Read less
Institution
MC.
Course
MC.










Whoops! We can’t load your doc right now. Try again or contact support.

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

Get to know the seller

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.
RealGrades Nursing
View profile
Follow You need to be logged in order to follow users or courses
Sold
170
Member since
2 year
Number of followers
52
Documents
11616
Last sold
2 weeks ago

4.0

26 reviews

5
12
4
5
3
7
2
1
1
1

Recently viewed by you

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

Frequently asked questions