Unit 4 AP CPS

Ace your homework & exams now with Quizwiz!

The procedure trace(x, y, a, b) is used to describe how a computer should create lines on a grid. The x and y represent the horizontal and vertical positions, respectively, of the start of the line and the a and b represent the horizontal and vertical positions, respectively, of the end of the line. The upper-left corner of the grid is represented as the horizontal and vertical position of 0 and 0 and the bottom right-hand corner of the grid is represented by 400 and 400. Grid lines are pre-drawn every 100 units. Consider the following code. Which of the following figures below best represents the figure being drawn in the program?

Side ways A

The procedure prime returns a value of "PRIME" if number is prime (divisible by only 1 and itself) and returns "NOT PRIME" otherwise. Assuming number must be larger than 1, what must go in the <MISSING CODE> section to make this procedure work as expected?

count = 2

In order to program a robot to move around within a two-dimensional space, a programmer considers four different designs for defining the robot's behavior. Which of the following sets of procedures would be the best design in terms of the readability, efficiency and flexibility of the resulting program?

move(dir, dist): Moves the robot dist spaces in the dir direction, where distis a number and dir is NORTH, SOUTH, EAST or WEST

The following procedure check is called in a program when a user answers a True or False question, with the answer typed by the user being assigned to the answer parameter. If the user types in True True False True as their answers for four questions on a quiz, how many times will the procedure check display Correct?

3

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 approximately 30 MPH. Which of the following strategies would be most efficient to employ in debugging your program?

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.

The image below shows a figure drawn by a program on a grid of dots. The program uses a cursor which starts in the upper left corner of the grid, and makes use of the procedure Draw (length, direction), which draws a line segment length units long from the current position of the cursor in a given direction (left, right, up or down). The cursor is then repositioned at the end of the line segment that was drawn. Which of the following programs could have produced the figure above?

Draw (2, right) Draw (1, down) Draw (2, left) Draw (1, down) Draw (1, right) Draw (1, up) Draw (2, right) Draw (1, down) Draw (1, left) Draw (1, down) Draw (1, left) Draw (1, up)Draw (1, right)

Procedures in programming are often defined with parameters - variables that are used in the procedure for which a value needs to be specified each time the procedure is called. Which of the following give a variable that would be useful to have as a parameter for the specified method? The value of 𝜋 (pi) in a procedure to find the area of a circle The name of an author in a procedure to search a library catalog for books The side length of a cube in a procedure to find the surface area of a cube

II and III only

A Hollywood sound designer has recorded a lion's roar that she plans to digitally alter and use as the voice of a small alien creature in an upcoming movie. Which of the following techniques would allow her to raise the pitch of the lion's roar so that it sounds like it comes from a much smaller fierce creature?

Increase the frequency of the digitized sound wave so that the samples play at twice the speed.

Which of the following describes a lossy transformation of a digital image composed of pixels which have red, green and blue components stored using values from 0-255?

Replace the green component of each pixel with the average value of the red and blue components of the pixel.

The following question uses a robot in a grid of squares. The robot is represented as a triangle which is initially in the bottom left square of the grid and facing right. Consider the following code segment which moves the robot in the grid. n ← 3 REPEAT 3 TIMES { REPEAT n TIMES { MOVE_FORWARD () } ROTATE_LEFT () n ← n - 1 }

Middle-Middle Facing Down

A graphic designer is hired to create a new logo for their client. This client gave them the following as a guide for what they wanted and is in order of precedence: The logo needs to have clean lines, even when scaled to different sizes The logo must use only a few colors The final logo size must not be large Which of the following types of images should the graphic designer create based on the Guidelines?

SVG

A musician has recorded some initial ideas for new songs which she wishes to share with her bandmates. As these are initial ideas she is not too concerned about the quality of the audio files she will send, but does wish the size of the files to be as small as possible so they can be easily downloaded by her bandmates, including using mobile data. Which of the following should she do to meet these requirements?

Save the audio using a low sampling rate. Save the audio using a low bit depth.

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.

Which of the following sorts software from the lowest level of abstraction to the highest?

Statement, code segment, program

The following images show the same image, but one of them is compressed and the other is not. Which of the following statements is true.

The image on the left is the original image and the image on the right is compressed.

Consider the following algorithm for manipulating the individual pixels of a digital RGB image of a panda bear surrounded by dense green jungle foliage. Algorithm:For each pixel, swap the values in the green and blue channels, leaving the red channel alone. Which of the following best describes the resulting image?

The panda's fur will appear black and white, but the foliage will appear to be tinted blue.

After conducting an online search for photos that you might use for your band's website, you find a particular photo of a funny-looking dog that you like. The photo appears on a professional photographer's website that he uses to display samples of his work. Along with the photo, the photographer has posted the following, "Attribution-No Derivatives Creative Commons License" for the work. This license is also represented by the figure below. Which of the following actions does this license allow you to do with this photo?

You may print the photo on t-shirts that your band wears while performing on stage. You may use the original photo as the background image for your band's promotional website.

What are the values of the variables a and b after the Python program below has been executed? a = 5 b = 10 temp = a a = b b = temp print(a)print(b)

a = 10 and b = 5

Consider the following procedure called square that is meant to multiply a number by itself and return the value. What should go in place of Missing Instructions in order to make this procedure work as intended?

squared ← number * number

Which of the following Python code segments best matches this Scratch block?

x = 0 if x > 0: x = x - 1 else: x = x + 10


Related study sets

Training and Development Test Two

View Set

HW1.3: Homework - Ch. 4: Equilibrium: How Supply and Demand Determine Prices

View Set

HomeostasisAssignment zoology connecte ed mcgraw hill

View Set