AP Computer Science Principles Flashcards: Using Programs With Data

Study Using Programs With Data in AP Computer Science Principles with focused flashcards that help you recognize the idea, recall the key rule, and apply it in practice-style prompts.

AP Computer Science Principles

Using Programs With Data

0 mastered0 still learning

0% Complete

QUESTION
1/ 55

What does 'break' do in a loop?

Tap card or press Space to flip

ANSWER

Exits the loop immediately. Break statement terminates loop execution completely.

How well did you know it?

Card 1 / 55

What this deck covers

This deck focuses on Using Programs With Data, giving you a quick way to review the definitions, rules, and examples that matter most for AP Computer Science Principles.

How to use these flashcards

Work through these flashcards in short sessions. Try to answer each prompt before flipping the card, then revisit any cards you miss until the explanation feels automatic.

All flashcards

Flashcard 1: What does 'break' do in a loop?

Answer: Exits the loop immediately. Break statement terminates loop execution completely.

Flashcard 2: Identify the error in 'for i in 5: print(i)'

Answer: 'range()' is needed to iterate through integers. Cannot iterate directly over integer; range creates sequence.

Flashcard 3: Which data structure uses key-value pairs?

Answer: Dictionary. Dictionaries map unique keys to corresponding values.

Flashcard 4: What does the 'append' method do to a list?

Answer: Adds an element to the end of the list. Append method inserts new item at list's final position.

Flashcard 5: What is a string in programming?

Answer: A sequence of characters. Text data type enclosed in quotes or apostrophes.

Flashcard 6: Identify the error: 'list.append(x)' when 'list' is not defined.

Answer: 'list' must be defined before use. Variable name must exist before calling methods on it.

Flashcard 7: Identify the correct syntax for a Python function call.

Answer: function_name(arguments). Parentheses after name pass values to function parameters.

Flashcard 8: What is the value of 232^3?

Answer:

  1. Two raised to the third power equals eight.

Flashcard 9: What is the result of 4×(3+2)4 \times (3 + 2)?

Answer:

  1. Order of operations: parentheses first, then multiplication.

Flashcard 10: Choose the correct syntax to declare an integer variable in Python.

Answer: variable_name = 0. Python uses assignment operator to create variables dynamically.

Flashcard 11: What does 'len()' function return?

Answer: The number of items in an object. Built-in function counts elements in sequences and collections.

Flashcard 12: What is the purpose of 'continue' in a loop?

Answer: Skips the current iteration and continues with the next. Continue jumps to next iteration without finishing current one.

Flashcard 13: Identify the error in 'for i in 5: print(i)'

Answer: 'range()' is needed to iterate through integers. Cannot iterate directly over integer; range creates sequence.

Flashcard 14: Choose the correct syntax to declare an integer variable in Python.

Answer: variable_name = 0. Python uses assignment operator to create variables dynamically.

Flashcard 15: Identify the error in the expression: 5+35 + '3'

Answer: Type error: mixing integer and string. Cannot add integer and string directly without type conversion.

Flashcard 16: Identify the error: 'if x = 10:'

Answer: Use '==' for comparison, not '='. Assignment operator should be comparison operator for conditions.

Flashcard 17: State the syntax to access the third element of a list in Python.

Answer: list_name[2]. List indexing starts at 0, so third element is index 2.

Flashcard 18: Which keyword defines a function in Python?

Answer: 'def'. Keyword that declares new function definitions in Python.

Flashcard 19: Identify the error in this function definition: 'def add(a, b): return a + b'

Answer: No error; the function is correct. This function definition follows proper Python syntax rules.

Flashcard 20: Identify the error in this loop: 'for i in range(5) print(i)'

Answer: Missing colon after range(5). Python requires colon after for statement header.

Flashcard 21: What is the purpose of the 'if' statement in programming?

Answer: To execute code conditionally based on a boolean expression. It evaluates the boolean and runs code only when true.

Flashcard 22: What is an 'else' clause used for?

Answer: To execute code when an 'if' condition is false. Else provides alternative code path for false conditions.

Flashcard 23: What is the result of 3//23 // 2 in Python?

Answer:

  1. Floor division operator returns integer quotient without remainder.

Flashcard 24: Which data type is used for true/false values?

Answer: Boolean. Boolean data type represents logical values: True or False.

Flashcard 25: Which keyword defines a function in Python?

Answer: 'def'. Keyword that declares new function definitions in Python.

Flashcard 26: What does the 'return' statement do in a function?

Answer: It exits the function and optionally returns a value. Return sends a value back to the caller and stops execution.

Flashcard 27: Which data type would you use for a decimal number in Python?

Answer: Float. Float type handles numbers with decimal points.

Flashcard 28: What is the main difference between a list and a tuple?

Answer: Lists are mutable; tuples are immutable. Lists can be modified; tuples cannot be changed.

Flashcard 29: State the syntax to access the third element of a list in Python.

Answer: list_name[2]. List indexing starts at 0, so third element is index 2.

Flashcard 30: Identify the error: 'if x = 10:'

Answer: Use '==' for comparison, not '='. Assignment operator should be comparison operator for conditions.

Flashcard 31: What type is returned by 'input()' function in Python?

Answer: String. Input always returns text even for numeric entries.

Flashcard 32: What is the result of 3//23 // 2 in Python?

Answer:

  1. Floor division operator returns integer quotient without remainder.

Flashcard 33: What is the syntax for a for-each loop in Python?

Answer: for item in iterable:. Standard Python loop syntax for iterating collections.

Flashcard 34: What is the purpose of a function in programming?

Answer: To encapsulate code for reuse and organization. Functions group code into reusable blocks with optional parameters.

Flashcard 35: Which keyword is used to start a loop in Python?

Answer: 'for' or 'while'. Both keywords create repetitive execution structures in Python.

Flashcard 36: What function converts a string to an integer in Python?

Answer: 'int()'. Built-in function converts string numbers to integer type.

Flashcard 37: What is the purpose of a 'for' loop?

Answer: To iterate over a sequence of items. For loops process each item in collections automatically.

Flashcard 38: What does the 'append' method do to a list?

Answer: Adds an element to the end of the list. Append method inserts new item at list's final position.

Flashcard 39: Choose the correct way to start a multiline comment in Python.

Answer: Use triple quotes: '''comment'''. Triple quotes allow comments spanning multiple lines.

Flashcard 40: What is an 'else' clause used for?

Answer: To execute code when an 'if' condition is false. Else provides alternative code path for false conditions.

Flashcard 41: Which data structure uses key-value pairs?

Answer: Dictionary. Dictionaries map unique keys to corresponding values.

Flashcard 42: What is the value of 232^3?

Answer:

  1. Two raised to the third power equals eight.

Flashcard 43: What is the output of 'print("Hello, World!")'?

Answer: Hello, World. Print function displays text exactly as written inside quotes.

Flashcard 44: How is a comment started in Python?

Answer: Using '#'. Hash symbol creates single-line comments in Python code.

Flashcard 45: How is a comment started in Python?

Answer: Using '#'. Hash symbol creates single-line comments in Python code.

Flashcard 46: What is a 'while' loop used for?

Answer: To repeat code while a condition is true. While loops continue until condition becomes false.

Flashcard 47: Which operator is used for exponentiation in Python?

Answer: '**'. Double asterisk performs mathematical power operations.

Flashcard 48: Identify the error: 'list.append(x)' when 'list' is not defined.

Answer: 'list' must be defined before use. Variable name must exist before calling methods on it.

Flashcard 49: What is a variable in programming?

Answer: A named storage location for data. Variables hold values that can be accessed and modified by name.

Flashcard 50: What does the 'return' statement do in a function?

Answer: It exits the function and optionally returns a value. Return sends a value back to the caller and stops execution.

Flashcard 51: What does 'break' do in a loop?

Answer: Exits the loop immediately. Break statement terminates loop execution completely.

Flashcard 52: What is an array?

Answer: A collection of elements identified by index. Arrays store multiple values accessible by numeric position.

Flashcard 53: Identify the component of a loop that determines when it stops.

Answer: Loop condition or termination condition. This boolean expression controls when the loop continues or stops.

Flashcard 54: What is the result of 4×(3+2)4 \times (3 + 2)?

Answer:

  1. Order of operations: parentheses first, then multiplication.

Flashcard 55: What is a 'while' loop used for?

Answer: To repeat code while a condition is true. While loops continue until condition becomes false.