














Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!















This exam evaluates core competency in Python programming, covering syntax, data structures, functional paradigms, and error handling.
C. -- This is a comment D. # This is a comment Correct Choice: D Rationale: The hash symbol (#) tells the interpreter to ignore everything following it on that line. C-style comments like // are not valid in Python.
Correct Choice: D Rationale: range(5) starts at 0 and stops before 5, producing 0, 1, 2, 3, 4. It is a common mistake to think range(4) would include the number 4.
Correct Choice: C Rationale: Floor division // divides two numbers and truncates the result to the nearest lower integer. Students often confuse this with the modulo % operator.
C. is D. === Correct Choice: A Rationale: The == operator checks for value equality. The is operator checks for object identity (memory location), which is a common source of bugs.
Correct Choice: B Rationale: append() is the standard method for adding a single element to the end of a list. push() is a JavaScript array method often used incorrectly by beginners.
D. Error Correct Choice: A Rationale: Multiplying a string by an integer repeats the string. Students often expect a mathematical result of 6 if they forget the "3" is a string.
Correct Choice: A Rationale: Floor division // results in 3 (it drops the .75). Students frequently round up to 4 or keep the decimal.
B. len() C. size() D. length() Correct Choice: B Rationale: len() is the universal function for getting the size of any sequence, including strings.
B. round(5.9) C. integer(5.9) D. int(5.9) Correct Choice: D Rationale: The int() function truncates decimals toward zero. round() would return 6, and floor() requires importing the math module.
C. Curly braces D. Semicolons Correct Choice: A Rationale: Python uses whitespace indentation to mark the start and end of functions, loops, and classes.