AP Comp Sci | Unit 1

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

A graphic artist uses a program to draw geometric shapes in a given pattern. The program uses an algorithm that draws the shapes based on input from the artist. The table shows the approximate number of steps the algorithm takes to draw different numbers of shapes. Number of Shapes Drawn Number of Steps 417524635750 Based on the values in the table, which of the following best characterizes the algorithm for drawing n shapes, where n is a very large number?

The algorithm runs in a reasonable amount of time because it will use approximately n2 steps to draw n shapes.

Consider the following code segment. What is the value of r as a result of executing the code segment?

r = 20

A school library allows students to borrow laptops. A computer program is used to count the number of times a particular laptop has been borrowed from the library and the number of times the same laptop has been returned to the library . Which of the following indicate that a particular laptop is not currently borrowed? Select two answers.

(1) A The difference between borrows and returns and is zero. (2) The sum of borrows and returns is a positive even number.

Which of the following algorithms display all integers between 1 and 20, inclusive, that are not divisible by 3 ?

(1) Step 1: Set x to 0. Step 2: Increment x by 1. Step 3: If x is not divisible by 3, then display x. Step 4: Repeat steps 2 and 3 until x is 20. (2) Step 1:Set x to 1. Step 2: If x is divisible by 3, then do nothing; otherwise display x. Step 3:Increment x by 1. Step 4: Repeat steps 2 and 3 until x is greater than 20.

Which of the following are benefits of using well-named variables in a computer program? Select two answers.

(1) The program will be easier for people to read. (2) The program will be easier to modify in the future.

A teacher is writing a code segment that will use variables to represent a student's name and whether or not the student is currently absent. Which of the following variables are most appropriate for the code segment?

A string variable named studentName and a Boolean variable named isAbsent

The figure below shows four grids, each containing a robot represented as a triangle. The robot cannot move to a black square or move beyond the edge of the grid. Which of the following algorithms will allow the robot to make a single circuit around the rectangular region of black squares, finishing in the exact location and direction that it started in each of the four grids?

Keep moving forward, one square at a time, until the square to the right of the robot is no longer black. Step 2: Turn right and move one square forward. Step 3: Repeat steps 1 and 2 three more times.

Consider the following code segment, where exam and presentation are integer variables and grade is a string variable. IF((exam > 90) AND (presentation > 80)) { grade ← "A" } IF((exam > 80) OR (presentation > 75)) { grade ← "B" } ELSE { IF((exam > 70) OR (presentation > 60)) { grade ← "C" } ELSE { IF(exam > 60) { grade ← "D" } ELSE { grade ← "F" } } } Under which of the following conditions will the value "C" be assigned to the variable grade ?

When the value of exam is 80 and the value of presentation is 60

The variable age is to be used to represent a person's age, in years. Which of the following is the most appropriate data type for age ?

number


संबंधित स्टडी सेट्स

Advanced Biomechanics Practice exam questions

View Set

CH. 5 - Accounting for Merchandising Businesses

View Set

Supervised Machine Learning: Regression and Classification

View Set