AP Computer Science Principles Semester 1 Study Guide

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

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

"Better late than never"

In a certain science experiment, 75 percent of trials are expected to be successful and 25 percent of trials are expected to be unsuccessful. The program below is intended to simulate the results of repeated trials of the experiment. Which of the following can be used to replace <MISSING CODE> so that the simulation works as intended? Line1: successful !0 Line 2: unsuccessful!0 Line 3: REPEAT 1000 TIMES Line 4: { Line 5: IF (<MISSING CODE>) Line 6: { Line 7: successful !successful + 1 Line 8: } Line 9: ELSE Line 10: { Line 11: unsuccessful !unsuccessful + 1 Line 12: } Line 13: } Line 14: DISPLAY (successful) Line 15: DISPLAY ("trials were successful.") Line 16: DISPLAY (unsuccessful) Line 17: DISPLAY ("trials were unsuccessful.")

"successful"

An online store uses 6-bit binary sequences to identify each unique item for sale. The store plans to increase the number of items it sells and is considering using 7-bit binary sequences. Which of the following best describes the result of using 7-bit sequences instead of 6-bit sequences?

2 times as many items can be uniquely identified

Consider the following code segment, which uses the variables r, s, and t. What is displayed as a result of running the code segment? r ← 1 s ← 2 t ← 3 r ← s s ← t DISPLAY (r) DISPLAY (s)

2, 3

A video-streaming Web site uses 32-bit integers to count the number of times each video has been played. In anticipation of some videos being played more times than can be represented with 32 bits, the Web site is planning to change to 64-bit integers for the counter. Which of the following best describes the result of using 64-bit integers instead of 32-bit integers?

2^32 times as many

In the program below, y is a positive integer (e.g., 1, 2, 3, ...) What is the value of result after running the program?

3y

According to the domain name system (DNS), which of the following is a subdomain of the domain example.com?

About.example.com

There are 32 students standing in a classroom. Two different algorithms are given for finding the average height of the students. Which of the following statements is true? Algorithm A Step 1: All students stand. Step 2: A randomly selected student writes his or her height on a card and is seated. Step 3: A randomly selected standing student adds his or her height to the value on the card, records the new value on the card, and is seated. The previous value on the card is erased. Step 4: Repeat step 3 until no students remain standing. Step 5: The sum on the card is divided by 32. The result is given to the teacher. Algorithm B Step 1: All students stand. Step 2: Each student is given a card. Each student writes his or her height on the card. Step 3: Standing students form random pairs at the same time. Each pair adds the numbers written on their cards and writes the result on one student's card; the other student is seated. The previous value on the card is erased. Step 4: Repeat step 3 until one student remains standing. Step 5: The sum on the last student's card is divided by 32. The result is given to the teacher.

Both Algorithm A and Algorithm B always calculate the correct average.

The algorithm below is used to simulate the results of flipping a coin 4 times. Consider the goal of determining whether the simulation resulted in an equal number of heads and tails. Following execution of the algorithm, which of the following expressions indicates that the simulation resulted in an equal number of heads and tails? 1. Step 1: Initialize the variables heads_counter and flip_counter to 0. 2. Step 2: A variable coin_flip is randomly assigned a value of either 0 or 1. If coin_flip has the value 0, the coin flip result is heads, so heads_counter is incremented by 1. 3. Step 3: Increment the value of flip_counter by 1. 4. Step 4: Repeat steps 2 and 3 until flip_counter equals 4.

D heads_counter = 2

Which of the following best describes the role of the Internet Engineering Task Force (IETF)?

Developing standards and protocols for Internet communication

Which of the following allows users to refer to Web sites using names, such as example.com, rather than numbers such as 93.184.216.34?

Domain Name System (DNS)

A programmer completes the user manual for a video game she has developed and realizes she has reversed the roles of goats and sheep throughout the text. Consider the programmer's goal of changing all occurrences of "goats" to "sheep" and all occurrences of "sheep" to "goats." The programmer will use the fact that the word "foxes" does not appear anywhere in the original text. Which of the following algorithms can be used to accomplish the programmer's goal?

First, change all occurrences of "goats" to "foxes." Then, change all occurrences of "sheep" to "goats." Last, change all occurrences of "foxes" to "sheep."

Which of the following statements are true about using a high-level programming language instead of a lower-level language?

I. Programs written in a high-level language are generally easier for people to read than programs written ina low-level language. II. A high-level language provides programmers with more abstractions than a low-level language. III. Programs written in a high-level language are generally easier to debug than programs written in alow-level language.

The figure below represents a network of physically linked computers labeled A through G. A line between two computers indicates that the computers can communicate directly with each other. Any information sent between two computers that are not directly connected must go through at least one other computer. For example, information can be sent directly between computers A and B, but information sent between computers A and C must go through other computers. Which of the following statements about security in the network is true? I. Computers A and D need to communicate with at least two additional computers in the network in order to communicate with each other. II. Computers B and C can communicate with each other without additional computers being aware of the communication.

II.

ASCII is a character-encoding scheme that uses 7 bits to represent each character. The decimal (base 10) values 65 through 90 represent the capital letters A through Z, as shown in the table below. What ASCII character is represented by the binary (base 2) number 1001010 ?

J

Consider the following program code. Which of the following best describes the result of running the program code?

Nothing, the program runs infinitely

In the program below, the initial value of x is 5 and the initial value of y is 10. What is displayed as a result of running the program?

November

Which of the following is a true statement about program documentation?

Program documentation is useful during initial program development and also when modifications are made to existing programs

Two computers are built by different manufacturers. One is running a Web server and the other is running a Web browser. Which of the following best describes the ability of the two computers to communicate with each other across the Internet?

The computers can communicate directly because Internet communication uses standard protocols.

The procedure Draw (length, direction) is used to draw a line segment length units long in a given direction (left, right, up, or down), starting at the current cursor position. The cursor is then repositioned at the end of the line segment that was drawn. Consider the following program, where the cursor starts in the upper left corner of a grid of dots. The dots are spaced one unit apart. Draw (1, right) Draw (2, down) Draw (1, left) Draw (1, right) Draw (1, up) Draw (1, left) Which of the following represents the figure that is drawn by the program?

The cursor draws a shape that looks like the number "3"

A user enters a Web address in a browser, and a request for a file is sent to a Web server. Which of the following best describes how the file is sent to the user?

The file is broken into packets for transmission. The packets must be reassembled upon delivery

In the procedure Mystery below, the parameter number is a positive integer. Which of the following best describes the result of running the procedure Mystery?

The procedure returns true when the initial value of number is even, and it otherwise returns false.

A program is expressed in a programming language. Which of the following is true of the program?

The program can also be expressed as binary code, but will be more easily understood by humans when expressed in a higher-level programming language.

Consider the following program, which is intended to display the number of times a number target appears in a list. Which of the following best describes the behavior of the program?

The program correctly displays the number of times target appears in the list.

A student is recording a song on her computer. When the recording is finished, she saves a copy on her computer. The student notices that the saved copy is of lower sound quality than the original recording. Which of the following could be a possible explanation for the difference in sound quality?

The song was saved using fewer bits than the original song

ASCII is a character-encoding scheme that uses a numeric value to represent each character. For example, the uppercase letter "G" is represented by the decimal (base 10) value 71. A partial list of characters and their corresponding ASCII values are shown in the table below. ASCII characters can also be represented by hexadecimal numbers. According to ASCII character encoding, which of the following letters is represented by the hexadecimal (base 16) number 56?

V

Consider the following code segment. Which of the following replacements for <MISSING CONDITION> will result in an infinite loop?

j=0

A code segment will be used to swap the values of the variables a and b using the temporary variable temp. Which of the following code segments correctly swaps the values of a and b ?

temp=a a=b b=temp


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

Microbiology Chapter 8: Microbial Metabolism

View Set

B2-CLOSE UP unit 9-And What Do You Do?

View Set

Prep U Practice Questions (Tissue Integrity)

View Set

Vocabulary Workshop Level D Unit 5

View Set

Acct 3220 - Taxation Midterm Ch2

View Set

Christian Theology Exam 1 Whitlock

View Set

GI disorders of the adult client

View Set