AP Computer Science Principles Exam

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson
Download our mobile app to listen on the go
Get App

Questions and Answers

Consider the pseudocode: x ← 2, REPEAT 4 TIMES {x ← x * 3}. What value is stored in x after execution?

  • 162 (correct)
  • 18
  • 24
  • 64

A wildlife research team is using 'citizen science' to analyze images from field cameras. What is a primary reason to use this approach?

  • A distributed group of individuals is faster and efficient at analysis. (correct)
  • Image analysis always requires inherently complex methods.
  • Citizens are always more accurate in species identification.
  • Individual citizens provide analysis that is always more consistent.

Which software abstraction represents the highest level of abstraction?

  • Boolean expression
  • Procedure
  • Software library (correct)
  • Selection statement

An algorithm aims to generate the output: red red blue red red blue red red blue. Which code segment achieves this?

<p><code>REPEAT 3 TIMES {REPEAT 2 TIMES {DISPLAY(&quot;red&quot;)} DISPLAY(&quot;blue&quot;)}</code> (D)</p> Signup and view all the answers

Consider the domain names example.com and cs.example.com. Which correctly describes their relationship?

<p><code>cs.example.com</code> is a subdomain of <code>example.com</code>, which is a subdomain of <code>.com</code>. (B)</p> Signup and view all the answers

A program adds two positive integers, resulting in an overflow error. Which statement best explains this?

<p>The sum exceeded the maximum integer representable. (C)</p> Signup and view all the answers

A logic circuit contains OR, AND gates. For which input will it output TRUE?

<p>A = FALSE, B = TRUE, C = TRUE, D = TRUE (B)</p> Signup and view all the answers

Two robot programs aim to move a robot to a gray square. Program II uses GoalReached() to check if the goal is achieved. Which statement best describes the programs?

<p>Both programs are correct. (B)</p> Signup and view all the answers

What is the least likely benefit of using flight simulation software for pilot training?

<p>Providing a more realistic experience than actual flights. (B)</p> Signup and view all the answers

Which set of actions are generally helpful in program development?

<p>Consulting users, testing code segments, and collaborating (C)</p> Signup and view all the answers

Which method provides the most security when transmitting private data over the Internet?

<p>Sending data using public-key encryption. (A)</p> Signup and view all the answers

Given ticket prices differing based on age and guided tour selection, which code segment correctly displays the ticket cost?

<p><code>cost ← 6; IF (age &gt; 12) { cost ← cost + 2 }; IF (includesTour) { cost ← cost + 2 }; DISPLAY(cost)</code> (D)</p> Signup and view all the answers

Given an RGB triplet table, what color does (11111111, 11111111, 11110000) represent?

<p>Ivory (C)</p> Signup and view all the answers

Based on the information provided, what is the binary RGB triplet for the color indigo?

<p>(01001011, 00000000, 10000010) (C)</p> Signup and view all the answers

A library database tracks book loans. What information cannot be determined from the data collected?

<p>Total books that were never borrowed. (C)</p> Signup and view all the answers

An algorithm takes a positive integer and displays its digits from right to left, but a step is missing. What is that step?

<p>Display the remainder and then store the integer quotient. (B)</p> Signup and view all the answers

Two programs display a sequence of numbers. What is the relationship in values they display?

<p>Identical values in the same order. (B)</p> Signup and view all the answers

Which of the following is not a way to enhance privacy while browsing the internet?

<p>Visiting only bookmarked websites (A)</p> Signup and view all the answers

A program aims to remove 'the' and 'a' from a wordList, but it loops infinitely. What fixes it?

<p>Inserting <code>index ← index - 1</code> between lines 6 and 7 (A)</p> Signup and view all the answers

Which data can be represented as a sequence of bits?

<p>An integer, alphanumeric character, and machine language instruction (A)</p> Signup and view all the answers

A robot must move to a gray square, avoiding black areas. Given procedure GoalReached(), what code drives the movement?

<p><code>REPEAT UNTIL (CAN_MOVE(forward) = false) { ROTATE_RIGHT(); MOVE_FORWARD() }</code> (D)</p> Signup and view all the answers

How did registered users change over eight years since file storage application launched?

<p>Doubled yearly, then increased a constant rate. (A)</p> Signup and view all the answers

What best describes the average amount of data stored per user over the first eight years?

<p>Increased by about 10 GB each year. (D)</p> Signup and view all the answers

Referring to the provided circle graph, what observations are supported?

<p>Over 75% are under 10 MB. (B)</p> Signup and view all the answers

A spinner’s regions are six times one region, and move the space one. Move two and loop see turn; which simulated segment has a result that matches?

<p><code>spin ← RANDOM(1,8); IF spin = 1 DISPLAY(Move 1 Space); ELSE IF spin = 2 DISPLAY(Move 2 Space); ELSE DISPLAY(Lose a Turn)</code> (D)</p> Signup and view all the answers

Regarding cloud vs. local data storage, which statement is most likely true?

<p>The Cloud solution allows data access by multiple computers at one once (B)</p> Signup and view all the answers

A flowchart is used with conditional step-step where action happens from label else where happens variables set.

<p>All is in with and or by miles &lt; with (B)</p> Signup and view all the answers

To be having set having number binary having number to hexadecimal

<p>Binary be be smaller having number of number to hex (C)</p> Signup and view all the answers

Code loops, how to fix loop?

<p>1-20 has only number not be get correct (C)</p> Signup and view all the answers

What do bits explain?

<p>Have in to number 2 (D)</p> Signup and view all the answers

Robot test needs it or in set step.

<p>For word test has from on can (B)</p> Signup and view all the answers

Application year where do test all it test have go correct?

<p>That test only over from 1 to there was for new from from (A)</p> Signup and view all the answers

Why test it all

<p>Is new test to then to it 10 to test one time only it there from start (C)</p> Signup and view all the answers

Test what now at

<p>Has low under1 for about to (D)</p> Signup and view all the answers

How we will test code

<p>To the all new line from is line test that all be (A)</p> Signup and view all the answers

We for new line is a

<p>Is a test 1 that new what from bit that is go test (D)</p> Signup and view all the answers

Flashcards

Software library

A software abstraction considered the highest level. It is a collection of pre-written code and resources that perform common tasks, offering reusable functionality.

Citizen Science Approach

A method involving distributed individuals to analyze images.

Overflow Error

A programming error that occurs when the result of an arithmetic operation exceeds the maximum value that a variable can hold.

Public-key encryption

A digital method that scrambles data using public-key encryption to ensure it is only readable for those with the corresponding private key.

Signup and view all the flashcards

Domain Name System (DNS)

It allow users to refer to Web sites using names (such as example.com) rather than IP addresses (such as 156.33.241.5)

Signup and view all the flashcards

Lossy Compression

A method of data compression that reduces file size by removing some data.

Signup and view all the flashcards

Sharing copyrighted application

Legal permission from the copyright owner of the application to allow a student to share it.

Signup and view all the flashcards

Open-source software

A type of software licensing that grants users the rights to use, modify, and distribute the software.

Signup and view all the flashcards

Certificate authority

A method that verifies the authenticity of encryption keys used in secured communications.

Signup and view all the flashcards

Redundant Routing

Uses more than one path to transfer data across a network .

Signup and view all the flashcards

Crowdsourcing

A method to get contribution from a large number of internet users, especially from users online.

Signup and view all the flashcards

Abstraction

The process of creating simplified models of complex systems to analyze system behavior without the computational expense of detailed models.

Signup and view all the flashcards

Distributed Denial-of-Service (DDoS)

Cyberattack which make a service unavailable by overwhelming it with a flood of traffic from multiple sources.

Signup and view all the flashcards

Phishing

A technique used to obtain sensitive information by disguising as a trustworthy entity.

Signup and view all the flashcards

Study Notes

  • The 2020 AP Computer Science Principles Exam is 2 hours long with 74 multiple-choice questions.
  • Programming reference materials are provided.
  • The exam uses two programming formats, text-based and block-based.
  • Programming instructions use numbers, Booleans, strings, and lists data types.
  • Exam instructions might include assignment, display, and input, arithmetic operators, relational operators, selection, iteration, list operations, procedures and robots.

Assignment

  • The instruction a ← expression evaluates the expression and assigns the result to variable a.

Display

  • The instruction DISPLAY (expression) displays the value of the expression, followed by a space.

Input

  • The instruction INPUT () accepts a value from the user and returns it.

Arithmetic Operations

  • +, -, *, and / are used to perform arithmetic on a and b.
  • 3 / 2 evaluates to 1.5.

Modulo Operator

  • The modulo operator gets the remainder when a is divided by b.
  • Assumes that a and b are positive integers.
  • 17 MOD 5 evaluates to 2.

Random Numbers

  • RANDOM (a, b) can be used to generate random integers
  • Evaluates to a random integer from a to b, including a and b.
  • RANDOM (1, 3) could yields 1, 2, or 3.

Relational and Boolean Operators

  • Comparison operators =, ≠, >, <, , and  evaluate the relationship between two variables, expressions, or values.
  • a = b evaluates to true if a and b are equal; otherwise it evaluates to false.

NOT operator

  • NOT condition will evaluate to true if the condition is false, and vice versa

AND operator

  • condition1 AND condition2 will evaluate to true if both conditions are true, else to false.

OR operator

  • condition1 OR condition2 evaluates to true if condition1 is true or if condition2 is true or if both condition1 and condition2 are true, evaluates to false otherwise.

Selection Instructions

  • IF (condition) { <block of statements> } executes the code in block of statements if the Boolean expression condition evaluates to true; otherwise it will take no action.
  • IF (condition) { <first block of statements> } ELSE { <second block of statements> } executes the code in first block of statements if the Boolean expression condition evaluates to true; otherwise the code in second block of statements is executed.

Iteration Instructions

  • REPEAT n TIMES { <block of statements> } executes the code in block of statements n times.
  • REPEAT UNTIL (condition) { <block of statements> } executes the code in block of statements is repeated until the Boolean expression condition evaluates to true.

List Operations

  • If a list index is less than 1 or greater than the length of the list, an error message is thrown
  • list[i] refers to the element of list at index i. The first element of list is at index 1.
  • list[i] ← list[j] assigns the value of list[j] to list[i].
  • list ← [value1, value2, value3] will assign value1, value2, and value3 to list[1], list[2],and list[3],respectively.
  • FOR EACH item IN list { <block of statements> } assigns the value of each element of list to the variable item sequentially, in order from the first element to the last, and th code in block of statements is executed once for each assignment of item.
  • INSERT (list, i, value) shifts values in list at indices equal or greater than i to the right. The length of list is increased by 1, and value is placed at index i in list.
  • APPEND (list, value) increases the length of list by 1, and value is placed at the end of list.
  • REMOVE (list, i) removes the item at index i in list and shifts to the left any values at indices greater than i. Length of list is decreased by 1.
  • LENGTH (list) will find the number of elements in list.

Procedures

  • PROCEDURE name (parameter1, parameter2, ...){ <instructions> } A procedure, name, takes zero or more parameters and and contains programming instructions.
  • PROCEDURE name (parameter1, parameter2, ...) { <instructions> RETURN (expression) } contains programming insructions and returns the value of expression, and the RETURN statement will cause an return back to the calling program.

Robot instructions

  • MOVE_FORWARD () will move the robot one square forward in the direction it is facing and if it attempts to move to a square will stay if it is beyond the edge of the grid and the program will terminate.
  • ROTATE_LEFT () will rotate the robot 90 degrees counterclockwise (i.e., makes an in-place left turn) and if it attempts to move to a square will stay if it is beyond the edge of the grid and the program will terminate.
  • ROTATE_RIGHT () will rotate the robot 90 degrees clockwise (i.e., makes an in-place right turn) and if it attempts to move to a square will stay if it is beyond the edge of the grid and the program will terminate.
  • CAN_MOVE (direction) evaluates to true if there is an open square one square in the direction relative to where the robot is facing; otherwise evaluates to false, with direction can be left, right, forward, or backward and it attempts to move to a square will stay if it is beyond the edge of the grid and the program will terminate.

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

Related Documents

More Like This

Use Quizgecko on...
Browser
Browser