Computer Science

Ace your homework & exams now with Quizwiz!

Level 8 Level 9 Cannot go up. Level 9

A large office building has an elevator that carries occupants between any of the building's 10 floors. The basement is referred to as "Level 0" while the topmost floor is "Level 9." The software for the elevator uses a variable, called level, to track the floor number of the elevator's current position. When a person presses a button requesting the elevator to rise to a higher floor, the above code is executed. What is displayed if the elevator is currently on the 7th floor (level = 7) and the person on the elevator presses a button that says to go up 3 floors (floors = 3)?

Use 26 IF blocks formatted similarly to the one above (changing the letters of the alphabet and fruits). -This is correct. This is a simple solution, although not the most efficient: each IF statement will be checked in order and run if the letter matches and not run if it does not. This means only one out of the 26 statements will run. b)Use 25 nested IF/ELSE blocks where the IF portion is formatted like the code segment above (changing the letters of the alphabet and fruits) and the else simply holding the next IF portion until the last ELSE, which displays a fruit that begins with Z.

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

16

Assuming that before this code is run x= 1. What would be displayed at the end.

This is correct. The program starts with a REPEAT UNTIL block with the condition CAN_MOVE (right), containing one instruction, MOVE_FORWARD (). This means that when the code is run the robot will initially check if it can move right, and if not will move forward. It will repeat this procedure until the first time it can move right, at which point the loop will exit and the final two commands, ROTATE_RIGHT () and MOVE_FORWARD () will run, causing the robot to turn 90 degrees right and move forward one

Below is a block of code intended to navigate a robot through a grid of squares. For which of the following grids will the code correctly navigate the robot to a final destination of the grey square and then terminate?

Line 3,5

Below is a program that is supposed to be a "Guess a Number" game where you are trying to accurately guess a randomly generated number between 1 and 100. However, the program is not functioning as expected.

Debugging

Chad has written the majority of his code in Scratch and is now ready to start thinking of test causes to make that his program functions properly and then when issues arise, fix them. The process is known a what?

change in condition in the IF block to be : IF x>y and y£ 20, Swap the Two DISPLAY blocks(I.e. DISPLAY "yes", DISPLAY "no")

Consider the following code segment that is intended to accept two integers, x and y, as input, and then display "yes" if and only if x is greater than y and y is less than or equal to 20. Otherwise, it should display "no". x ← Input y ← Input If (x <= y) or (y>20) Display ("yes") Else Display ("no")

Both programs will work as intended but Program B is more readable

Consider the following code segments designed to find the area of a triangle using the formula A = ½ bh. Program A v1 ← Input v2 ← Input v3 ← v1 * v2 / 2 Display (v3) Program B base ← Input height ← Input

x must be 0 and y must be a positive number

For what values of x and y when inputted in the program below, will display Right Right?

Group 2

Given the following code segment, what would be displayed if age were initialzed with a value of 18?

Better late than never

If the variables onTime and absent both have the value false, what is displayed as a result of running the code segment?

The procedure makes that section more abstract, so she doesn't have to think through all 10 blocks each time she comes across them in her code, If there's an error in the procedure, she can fix the error in the procedure without having to search through her code for each place the procedure is used

Sally notices that she has the same set of 10 blocks in her code in multiple places. She decides to create a new block (procedure) in Scratch so that she can simply replace those 10 blocks with one. Why would this be beneficial to Sally later when she debugs and reasons through her program?

turn MOD 2 = 1

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

turn MOD 2 = 1

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.

(value MOD 5) = 0

The block of code below is supposed to display "Multiple of 5" if the positive number value is in fact a multiple of 5. If (missing condition) Display (multiple of 5) Else Display (Incorrect)

validate(127) validate(128) validate(2048) validate(32768) validate(32769)

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 sets of test cases would be the best choice to fully test this procedure and provide evidence that it executes as intended for all values of x?

The Arrow in the middle of the grids

The following question uses a robot and a grid of squares. The robot is represented as triangle, which is initially in the bottom left square of the grid and facing right.

1 * w * h

The volume of a rectangular prism is calculated by multiplying the length, width and height all together. What could we substitute into the section of the code marked < missing code > that would accurately calculate the volume based on the user input of l, w and h?

MOVE_FORWARD ( ) ROTATE _LEFT MOVE_ FORWARD ROTATE_ RIGHT ROTATE_ LEFT MOVE_FORWARD ROTATE_ RIGHT MOVE_ FORWARD (REPEAT 4 Times)

What blocks of code will properly navigate the robot to the final destination of the grey square in the bottom right corner of the grid

Y^3 8

What condition will make the following an infinite loop

short coffee

What is displayed if user enters 16 ounces and coffee as their preferred beverage?

12,14

What is value are more likely to be displayed using the following block of code

Missing out 1: Value does equal 4 Missing output 2: value is equal to 4

What outputs should be subsited for missing output 2" based on condition?

2

What starting value of n would make this portion of the program repeat the block of code below the most amount of times.

A=-5 B=0 C=0

What values, when inputted by the user, of the user of A, B, C will display Invalid input

AND

What would be the most appropriate to substitute for the missing Boolean Operator if this was supposed to display "True" for only values of x between, but not equal to values of 0 and 10?

Click on the GREEN flag. Once the game starts, use the arrow keys to navigate your way through the maze. In your travels, collect the "hearts" for more lives and avoid being eaten by zombies.

Which of the below options would options would be the best set of

It is useful to other programmers that view your code, so that they can understand what different parts of the code will do. It allows the programmer an opportunity to attribute help, work and code fromothers.

Which of the following are true about programming documentation?

The word HI could be displayed 1, 2, 3, 4, 5, 6, 7, 8, 9, or 10 times

Which of the following best describes the output of the following code segment? Repeat (random 1,10) times { Display "Hi" }

Nothing is displayed; the program results is an infinite loop.

Which of the following best describes the result of running the program code

userpassword= "swordfish"

Which of the following can replace the missing statement in the Repeat unit block so that the user will required to enter the correct password of swordfish before they can continue on the rest of the program.

The value of a sprite variable

Which of the following could be considered part of the "state" of one our sprites(objects) in our Scratch program?

All of these

Which of the following could be considered part of the state of our Scratch program

6

Which of the following values is displayed if the user inputs the following list of each prompt

Time_ Left

Which of the following would be the most appropriate name for variable

You may only reuse elements for which the original owner has granted a license to reuse

While developing a program, you find a similar project that someone has created and posted online. It contains a number of elements (e.g., images, music, code segments, etc.) that you would like to integrate into your own project. Under what conditions may you reuse these elements in your work

You may only reuse elements for which the original owner has granted a license to reuse, such as The Creative Commons Share Alike license

While developing a program, you find a similar project that someone has created and posted online. It contains a number of elements (e.g., images, music, code segments, etc.) that you would like to integrate into your own project. Under what conditions may you reuse these elements in your work?

After each calculation within your program, insert a temporary statement that displays the most recently calculated value. When running your program, compare the displayed values with the expected values to identify where in the program the error is being introduced

While writing a program to regulate the speed of a self-driving car, you find that your software sometimes miscalculates the ideal car speed for city streets to be over 1500 MPH (nearly twice the speed of sound), when it should be 30 MPH. Which of the following strategies would be best to employ in debugging your program


Related study sets

Chapter 50: Assessment and Management of Patients With Biliary Disorders NCLEX

View Set

Chapter 5 Test: Art Appreciation

View Set

Lewis Chapter 56 Skull Fracture Qs

View Set

Chapter 48: Drug Therapy for Parkinson's Disease, Urinary Spasticity, and Disorders Requiring Anticholinergic Drug Therapy

View Set

MCN - Unit 1 - Chapter 4: Common Reproductive Issues

View Set