Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Cheat Sheet in AP Computer Science Reference Sheet, Cheat Sheet of Computer Science

AP Computer Science Principles Exam Reference Sheet includes Selection, Iteration, List Operations, Procedures

Typology: Cheat Sheet

2020/2021

Uploaded on 04/27/2021

brittani
brittani 🇺🇸

4.7

(30)

287 documents

1 / 6

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
AP® Computer Science Principles Exam
Reference Sheet
July 2015
This reference sheet provides instructions and explanations to help
students understand the format and meaning of the questions they will
see on the exam. The reference sheet includes two programming
formats, text-based and block-based.
Programming instructions use four data types: numbers, Booleans,
strings, and lists.
Instructions from any of the following categories may appear on the
exam:
Assignment, Display, and Input
Arithmetic Operators and Numeric Procedures
Relational and Boolean Operators
Selection
Iteration
List Operations
Procedures
Robot
pf3
pf4
pf5

Partial preview of the text

Download Cheat Sheet in AP Computer Science Reference Sheet and more Cheat Sheet Computer Science in PDF only on Docsity!

AP

®

Computer Science Principles Exam

Reference Sheet

July 2015

This reference sheet provides instructions and explanations to help

students understand the format and meaning of the questions they will

see on the exam. The reference sheet includes two programming

formats, text-based and block-based.

Programming instructions use four data types: numbers, Booleans,

strings, and lists.

Instructions from any of the following categories may appear on the

exam:

  • Assignment, Display, and Input
  • Arithmetic Operators and Numeric Procedures
  • Relational and Boolean Operators
  • Selection
  • Iteration
  • List Operations
  • Procedures
  • Robot

Assignment, Display, and Input Text: a ← expression

Block:

Evaluates expression and assigns the result to the variable a.

Text: DISPLAY (expression)

Block:

Displays the value of expression, followed by a space.

Text: INPUT ()

Block:

Accepts a value from the user and returns it.

Arithmetic Operators and Numeric Procedures Text and Block: a + b a - b a * b a / b

The arithmetic operators +, - , *, and / are used to perform arithmetic on a and b.

For example, 3 / 2 evaluates to 1.5.

Text and Block: a MOD b

Evaluates to the remainder when a is divided by b. Assume that a and b are positive integers.

For example, 17 MOD 5 evaluates to 2. Text: RANDOM (a, b)

Block:

Evaluates to a random integer from a to b, including a and b.

For example, RANDOM (1, 3) could evaluate to 1 , 2 , or 3. Relational and Boolean Operators Text and Block: a = b a π b a > b a < b a  b a  b

The relational operators =, π , >, <,  , and  are used to test the relationship between two variables, expressions, or values.

For example, a = b evaluates to true if a and b are equal; otherwise it evaluates to false.

Text: NOT condition

Block:

Evaluates to true if condition is false; otherwise evaluates to false.

Text: condition1 AND condition

Evaluates to true if both condition1 and condition2 are true; otherwise evaluates to false.

Iteration (continued) Text: REPEAT UNTIL (condition) { }

Block:

The code in block of statements is repeated until the Boolean expression condition evaluates to true.

List Operations For all list operations, if a list index is less than 1 or greater than the length of the list, an error message is produced and the program terminates. Text: list[i]

Block:

Refers to the element of list at index i. The first element of list is at index 1.

Text: list[i] ← list[j]

Block:

Assigns the value of list[j] to list[i].

Text: list ← [value1, value2, value3]

Block:

Assigns value1, value2, and value3 to list[1], list[2], and list[3], respectively.

Text: FOR EACH item IN list { }

The variable item is assigned the value of each element of list sequentially, in order from the first element to the last element. The code in block of statements is executed once for each assignment of item.

List Operations (continued) Text: INSERT (list, i, value)

Block:

Any values in list at indices greater than or equal to i are shifted to the right. The length of list is increased by 1, and value is placed at index i in list.

Text: APPEND (list, value)

Block:

The length of list is increased by 1, and value is placed at the end of list.

Text: REMOVE (list, i)

Block:

Removes the item at index i in list and shifts to the left any values at indices greater than i. The length of list is decreased by 1.

Text: LENGTH (list)

Block:

Evaluates to the number of elements in list.

Procedures Text: PROCEDURE name (parameter1, parameter2, ...) { }

Block:

A procedure, name, takes zero or more parameters. The procedure contains programming instructions.

Text: PROCEDURE name (parameter1, parameter2, ...) { RETURN (expression) }

A procedure, name, takes zero or more parameters. The procedure contains programming instructions and returns the value of expression. The RETURN statement may appear at any point inside the procedure and causes an immediate return from the procedure back to the calling program.