Identifying and Correcting Errors - AP Computer Science Principles
Card 1 of 30
Which Python keyword is used to handle exceptions?
Which Python keyword is used to handle exceptions?
Tap to reveal answer
try. Used with except to catch and handle errors.
try. Used with except to catch and handle errors.
← Didn't Know|Knew It →
What is the purpose of 'break' in a loop?
What is the purpose of 'break' in a loop?
Tap to reveal answer
Exits the loop prematurely. Immediately terminates loop execution and continues after loop.
Exits the loop prematurely. Immediately terminates loop execution and continues after loop.
← Didn't Know|Knew It →
What is the result of '3 ** 2' in Python?
What is the result of '3 ** 2' in Python?
Tap to reveal answer
Result: 9. Double asterisk performs exponentiation in Python.
Result: 9. Double asterisk performs exponentiation in Python.
← Didn't Know|Knew It →
Find the error in 'while (x = 10): pass' in Python.
Find the error in 'while (x = 10): pass' in Python.
Tap to reveal answer
Use '==' for comparison: 'while (x == 10): pass'. Assignment operator used instead of equality comparison.
Use '==' for comparison: 'while (x == 10): pass'. Assignment operator used instead of equality comparison.
← Didn't Know|Knew It →
What is the output of '10 / 3' in Python 3?
What is the output of '10 / 3' in Python 3?
Tap to reveal answer
Output: 3.3333... Python 3 performs true division by default.
Output: 3.3333... Python 3 performs true division by default.
← Didn't Know|Knew It →
What is the correct method to add an element to a list in Python?
What is the correct method to add an element to a list in Python?
Tap to reveal answer
list.append(element). Standard method to add elements to Python lists.
list.append(element). Standard method to add elements to Python lists.
← Didn't Know|Knew It →
What operator is used to check equality in Python?
What operator is used to check equality in Python?
Tap to reveal answer
==. Double equals tests equality, single equals assigns values.
==. Double equals tests equality, single equals assigns values.
← Didn't Know|Knew It →
What is the result of '7 % 2' in Python?
What is the result of '7 % 2' in Python?
Tap to reveal answer
Result: 1. Modulo operator returns remainder of division operation.
Result: 1. Modulo operator returns remainder of division operation.
← Didn't Know|Knew It →
Identify the error in 'if x > 5 then y = 10;' in Python.
Identify the error in 'if x > 5 then y = 10;' in Python.
Tap to reveal answer
Remove 'then': 'if x > 5: y = 10'. Python doesn't use 'then' keyword in if statements.
Remove 'then': 'if x > 5: y = 10'. Python doesn't use 'then' keyword in if statements.
← Didn't Know|Knew It →
What is the correct way to start a comment in Python?
What is the correct way to start a comment in Python?
Tap to reveal answer
#. Hash symbol starts single-line comments in Python.
#. Hash symbol starts single-line comments in Python.
← Didn't Know|Knew It →
Find the error in 'print 5 + 5' in Python 3.
Find the error in 'print 5 + 5' in Python 3.
Tap to reveal answer
Use parentheses: 'print(5 + 5)'. Python 3 requires parentheses for print function calls.
Use parentheses: 'print(5 + 5)'. Python 3 requires parentheses for print function calls.
← Didn't Know|Knew It →
What is the value of $10 mod 3$?
What is the value of $10 mod 3$?
Tap to reveal answer
Value: 1. Modulo operation returns remainder after division.
Value: 1. Modulo operation returns remainder after division.
← Didn't Know|Knew It →
What is the error in 'if (x > y) print('x is greater');' in Python?
What is the error in 'if (x > y) print('x is greater');' in Python?
Tap to reveal answer
Use a colon: 'if (x > y): print('x is greater');'. Python if statements require colon after condition.
Use a colon: 'if (x > y): print('x is greater');'. Python if statements require colon after condition.
← Didn't Know|Knew It →
What is the hexadecimal representation of the decimal number 15?
What is the hexadecimal representation of the decimal number 15?
Tap to reveal answer
Hexadecimal: F. 15 in decimal equals F in hexadecimal (base 16).
Hexadecimal: F. 15 in decimal equals F in hexadecimal (base 16).
← Didn't Know|Knew It →
What is the output of 'print(2 ** 3)' in Python?
What is the output of 'print(2 ** 3)' in Python?
Tap to reveal answer
Output: 8. Double asterisk is the exponentiation operator in Python.
Output: 8. Double asterisk is the exponentiation operator in Python.
← Didn't Know|Knew It →
What is the purpose of the 'return' statement in a function?
What is the purpose of the 'return' statement in a function?
Tap to reveal answer
Returns a value from a function. Exits function and sends value back to caller.
Returns a value from a function. Exits function and sends value back to caller.
← Didn't Know|Knew It →
Find the error in 'print 5 + 5' in Python 3.
Find the error in 'print 5 + 5' in Python 3.
Tap to reveal answer
Use parentheses: 'print(5 + 5)'. Python 3 requires parentheses for print function calls.
Use parentheses: 'print(5 + 5)'. Python 3 requires parentheses for print function calls.
← Didn't Know|Knew It →
What is the hexadecimal representation of the decimal number 15?
What is the hexadecimal representation of the decimal number 15?
Tap to reveal answer
Hexadecimal: F. 15 in decimal equals F in hexadecimal (base 16).
Hexadecimal: F. 15 in decimal equals F in hexadecimal (base 16).
← Didn't Know|Knew It →
What is the binary representation of the decimal number 10?
What is the binary representation of the decimal number 10?
Tap to reveal answer
Binary: 1010. Convert decimal to binary using powers of 2.
Binary: 1010. Convert decimal to binary using powers of 2.
← Didn't Know|Knew It →
What is the output of 'print(2 ** 3)' in Python?
What is the output of 'print(2 ** 3)' in Python?
Tap to reveal answer
Output: 8. Double asterisk is the exponentiation operator in Python.
Output: 8. Double asterisk is the exponentiation operator in Python.
← Didn't Know|Knew It →
What is the error in 'if (x > y) print('x is greater');' in Python?
What is the error in 'if (x > y) print('x is greater');' in Python?
Tap to reveal answer
Use a colon: 'if (x > y): print('x is greater');'. Python if statements require colon after condition.
Use a colon: 'if (x > y): print('x is greater');'. Python if statements require colon after condition.
← Didn't Know|Knew It →
What is the value of $10 mod 3$?
What is the value of $10 mod 3$?
Tap to reveal answer
Value: 1. Modulo operation returns remainder after division.
Value: 1. Modulo operation returns remainder after division.
← Didn't Know|Knew It →
What is the ASCII value for the character 'A'?
What is the ASCII value for the character 'A'?
Tap to reveal answer
ASCII: 65. Standard ASCII value for uppercase A character.
ASCII: 65. Standard ASCII value for uppercase A character.
← Didn't Know|Knew It →
What is the correct method to add an element to a list in Python?
What is the correct method to add an element to a list in Python?
Tap to reveal answer
list.append(element). Standard method to add elements to Python lists.
list.append(element). Standard method to add elements to Python lists.
← Didn't Know|Knew It →
What is the result of '3 ** 2' in Python?
What is the result of '3 ** 2' in Python?
Tap to reveal answer
Result: 9. Double asterisk performs exponentiation in Python.
Result: 9. Double asterisk performs exponentiation in Python.
← Didn't Know|Knew It →
What is the correct syntax for a for-loop in Python?
What is the correct syntax for a for-loop in Python?
Tap to reveal answer
for i in range(n):. Standard Python loop syntax iterating from 0 to n-1.
for i in range(n):. Standard Python loop syntax iterating from 0 to n-1.
← Didn't Know|Knew It →
What is the purpose of the 'return' statement in a function?
What is the purpose of the 'return' statement in a function?
Tap to reveal answer
Returns a value from a function. Exits function and sends value back to caller.
Returns a value from a function. Exits function and sends value back to caller.
← Didn't Know|Knew It →
Find the error in 'while x = 5: pass' in Python.
Find the error in 'while x = 5: pass' in Python.
Tap to reveal answer
Correct: 'while x == 5: pass'. Single equals is assignment, double equals is comparison.
Correct: 'while x == 5: pass'. Single equals is assignment, double equals is comparison.
← Didn't Know|Knew It →
What is the result of '7 % 2' in Python?
What is the result of '7 % 2' in Python?
Tap to reveal answer
Result: 1. Modulo operator returns remainder of division operation.
Result: 1. Modulo operator returns remainder of division operation.
← Didn't Know|Knew It →
What is the decimal equivalent of the binary number 1101?
What is the decimal equivalent of the binary number 1101?
Tap to reveal answer
Decimal: 13. Binary 1101 = $8 + 4 + 1 = 13$ in decimal.
Decimal: 13. Binary 1101 = $8 + 4 + 1 = 13$ in decimal.
← Didn't Know|Knew It →