AP Computer Science Principles Flashcards: Identifying And Correcting Errors

Study Identifying And Correcting Errors 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

Identifying And Correcting Errors

0 mastered0 still learning

0% Complete

QUESTION
1/ 44

What is the output of 'print(2 ** 3)' in Python?

Tap card or press Space to flip

ANSWER

Output: 8. Double asterisk is the exponentiation operator in Python.

How well did you know it?

Card 1 / 44

What this deck covers

This deck focuses on Identifying And Correcting Errors, 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 is the output of 'print(2 ** 3)' in Python?

Answer: Output: 8. Double asterisk is the exponentiation operator in Python.

Flashcard 2: What is the output of '10 / 3' in Python 3?

Answer: Output: 3.3333... Python 3 performs true division by default.

Flashcard 3: What is the result of '3 ** 2' in Python?

Answer: Result: 9. Double asterisk performs exponentiation in Python.

Flashcard 4: What is the binary representation of the decimal number 10?

Answer: Binary: 1010. Convert decimal to binary using powers of 2.

Flashcard 5: What is the correct syntax for defining a function in Python?

Answer: def function_name(parameters):. Standard function definition syntax in Python.

Flashcard 6: What is the ASCII value for the character 'A'?

Answer: ASCII: 65. Standard ASCII value for uppercase A character.

Flashcard 7: Which Python keyword is used to handle exceptions?

Answer: try. Used with except to catch and handle errors.

Flashcard 8: What is the correct method to add an element to a list in Python?

Answer: list.append(element). Standard method to add elements to Python lists.

Flashcard 9: What is the purpose of 'break' in a loop?

Answer: Exits the loop prematurely. Immediately terminates loop execution and continues after loop.

Flashcard 10: What is the binary representation of the decimal number 10?

Answer: Binary: 1010. Convert decimal to binary using powers of 2.

Flashcard 11: Identify the error in 'if x > 5 then y = 10;' in Python.

Answer: Remove 'then': 'if x > 5: y = 10'. Python doesn't use 'then' keyword in if statements.

Flashcard 12: What is the purpose of the 'return' statement in a function?

Answer: Returns a value from a function. Exits function and sends value back to caller.

Flashcard 13: What is the error in 'if (x > y) print('x is greater');' in Python?

Answer: Use a colon: 'if (x > y): print('x is greater');'. Python if statements require colon after condition.

Flashcard 14: What is the correct syntax for a for-loop in Python?

Answer: for i in range(n):. Standard Python loop syntax iterating from 0 to n-1.

Flashcard 15: Find the error in 'print 5 + 5' in Python 3.

Answer: Use parentheses: 'print(5 + 5)'. Python 3 requires parentheses for print function calls.

Flashcard 16: What is the error in 'if (x > y) print('x is greater');' in Python?

Answer: Use a colon: 'if (x > y): print('x is greater');'. Python if statements require colon after condition.

Flashcard 17: What operator is used to check equality in Python?

Answer: ==. Double equals tests equality, single equals assigns values.

Flashcard 18: What is the correct way to start a comment in Python?

Answer: #. Hash symbol starts single-line comments in Python.

Flashcard 19: What operator is used to check equality in Python?

Answer: ==. Double equals tests equality, single equals assigns values.

Flashcard 20: What is the hexadecimal representation of the decimal number 15?

Answer: Hexadecimal: F. 15 in decimal equals F in hexadecimal (base 16).

Flashcard 21: What is the result of '7 % 2' in Python?

Answer: Result: 1. Modulo operator returns remainder of division operation.

Flashcard 22: What is the value of 10 mod 3?

Answer: Value: 1. Modulo operation returns remainder after division.

Flashcard 23: What is the decimal equivalent of the binary number 1101?

Answer: Decimal: 13. Binary 1101 = 8+4+1=138 + 4 + 1 = 13 in decimal.

Flashcard 24: What is the correct method to add an element to a list in Python?

Answer: list.append(element). Standard method to add elements to Python lists.

Flashcard 25: What is the correct syntax for a for-loop in Python?

Answer: for i in range(n):. Standard Python loop syntax iterating from 0 to n-1.

Flashcard 26: What is the result of '7 % 2' in Python?

Answer: Result: 1. Modulo operator returns remainder of division operation.

Flashcard 27: What is the value of 10 mod 3?

Answer: Value: 1. Modulo operation returns remainder after division.

Flashcard 28: Identify the error in 'if x > 5 then y = 10;' in Python.

Answer: Remove 'then': 'if x > 5: y = 10'. Python doesn't use 'then' keyword in if statements.

Flashcard 29: What is the output of 'print(2 ** 3)' in Python?

Answer: Output: 8. Double asterisk is the exponentiation operator in Python.

Flashcard 30: What is the result of '3 ** 2' in Python?

Answer: Result: 9. Double asterisk performs exponentiation in Python.

Flashcard 31: What is the hexadecimal representation of the decimal number 15?

Answer: Hexadecimal: F. 15 in decimal equals F in hexadecimal (base 16).

Flashcard 32: What is the ASCII value for the character 'A'?

Answer: ASCII: 65. Standard ASCII value for uppercase A character.

Flashcard 33: Find the error in 'while x = 5: pass' in Python.

Answer: Correct: 'while x == 5: pass'. Single equals is assignment, double equals is comparison.

Flashcard 34: Which Python keyword is used to handle exceptions?

Answer: try. Used with except to catch and handle errors.

Flashcard 35: What is the decimal equivalent of the binary number 1101?

Answer: Decimal: 13. Binary 1101 = 8+4+1=138 + 4 + 1 = 13 in decimal.

Flashcard 36: What is the purpose of the 'return' statement in a function?

Answer: Returns a value from a function. Exits function and sends value back to caller.

Flashcard 37: Find the error in 'while (x = 10): pass' in Python.

Answer: Use '==' for comparison: 'while (x == 10): pass'. Assignment operator used instead of equality comparison.

Flashcard 38: Find the error in 'while (x = 10): pass' in Python.

Answer: Use '==' for comparison: 'while (x == 10): pass'. Assignment operator used instead of equality comparison.

Flashcard 39: What is the purpose of 'break' in a loop?

Answer: Exits the loop prematurely. Immediately terminates loop execution and continues after loop.

Flashcard 40: What is the correct syntax for defining a function in Python?

Answer: def function_name(parameters):. Standard function definition syntax in Python.

Flashcard 41: Find the error in 'print 5 + 5' in Python 3.

Answer: Use parentheses: 'print(5 + 5)'. Python 3 requires parentheses for print function calls.

Flashcard 42: What is the output of '10 / 3' in Python 3?

Answer: Output: 3.3333... Python 3 performs true division by default.

Flashcard 43: Find the error in 'while x = 5: pass' in Python.

Answer: Correct: 'while x == 5: pass'. Single equals is assignment, double equals is comparison.

Flashcard 44: What is the correct way to start a comment in Python?

Answer: #. Hash symbol starts single-line comments in Python.