Exam 2026/2027 – Verified Q&A – 100%
Correct – Detailed Rationales – Pass
Guaranteed – A+ Graded
Python Fundamentals & Data Types
Q1: You're writing a script to process user input from a web form. The input arrives as
the string "42.5" and you need to perform mathematical calculations on it. Which
conversion ensures you maintain decimal precision for accurate financial calculations?
A. int("42.5") to ensure whole number arithmetic
B. float("42.5") to preserve the decimal component [CORRECT]
C. str("42.5") to maintain the original formatting
D. bool("42.5") to validate the input exists
Correct Answer: B
Rationale: The float() function converts a string to a floating-point number, preserving
decimal precision needed for financial calculations. int() would truncate the decimal
and raise a ValueError if the string contains a decimal point, while str() and bool() don't
provide numeric types suitable for math operations.
Q2: A junior developer on your team asks why their variable name 2nd_user is
throwing a syntax error. Which explanation correctly identifies the Python naming rule
being violated?
A. Variable names cannot contain underscores
B. Variable names cannot begin with a number [CORRECT]
C. Variable names must be all uppercase
D. Variable names cannot contain the letter 'd'
Correct Answer: B
,Rationale: Python variable names must start with a letter or underscore, never a
number. While underscores are allowed and encouraged for readability (snake_case),
starting with a digit violates lexical rules and raises a SyntaxError immediately upon
parsing.
Q3: Examine this expression: result = 10 + 5 * 2 ** 2 - . What value
does result hold after evaluation?
A. 17.0
B. 26.0
C. 28.0 [CORRECT]
D. 12.0
Correct Answer: C
Rationale: Following PEMDAS (Python operator precedence), exponentiation happens
first (2**2=4), then multiplication/division left-to-right (5*4=20, 8/4=2.0), then
addition/subtraction left-to-right (10+20-2.0=28.0). The division operation promotes the
result to a float.
Q4: You're debugging a configuration script that unexpectedly modifies shared settings.
You suspect the issue relates to how Python handles data types. Which pair correctly
identifies a mutable type that might cause this unexpected behavior when passed
between functions, versus an immutable alternative?
A. tuple (mutable) and list (immutable)
B. list (mutable) and tuple (immutable) [CORRECT]
C. string (mutable) and dictionary (immutable)
D. integer (mutable) and float (immutable)
Correct Answer: B
Rationale: Lists are mutable objects that can be modified in-place after creation,
causing unintended side effects when passed to functions that modify them. Tuples are
immutable sequences that cannot be changed after creation, making them safer for
shared configuration data. Strings, integers, and floats are also immutable, while
dictionaries are mutable.
, Q5: A system monitor script needs to check if two conditions are met: disk_usage is
below 90% AND either cpu_load is below 80% OR memory_pressure is False. Given
disk_usage=85, cpu_load=85, memory_pressure=False, what does this evaluate to?
A. False because cpu_load exceeds 80%
B. True because disk_usage is below 90% and memory_pressure provides the necessary
True condition [CORRECT]
C. False because both cpu_load and memory_pressure must be favorable
D. True only if disk_usage is below 80%
Correct Answer: B
Rationale: The expression evaluates as: (disk_usage < 90) AND ((cpu_load < 80) OR (not
memory_pressure)). With the given values: True AND (False OR True) → True AND True
→ True. The OR operator only requires one true condition, so the favorable
memory_pressure saves the evaluation despite high CPU load.
Q6: Your automation script calculates monetary values and you're seeing unexpected
results when adding 0.1 + 0.2. Which statement best explains this common Python
behavior and the appropriate solution?
A. Python cannot perform decimal arithmetic without external libraries
B. Floats use binary representation causing precision errors; use the decimal module for
financial calculations [CORRECT]
C. The sum equals exactly 0.3 but print statements round it
D. Integers should be used by multiplying all values by 100
Correct Answer: B
Rationale: Floating-point numbers use binary fractions which cannot precisely represent
decimal values like 0.1 or 0.2, causing rounding errors (0.30000000000000004). For
financial calculations requiring exact decimal precision, Python's decimal module
provides Decimal objects that avoid these binary representation issues.
Q7: You need to determine if a user-provided year is a leap year using the standard
algorithm: divisible by 4, except if divisible by 100 unless also divisible by 400. Which
operator combination correctly implements this logic?
A. year / 4 == 0 and year / 100 != 0 or year / 400 == 0
B. year % 4 == 0 and year % 100 != 0 or year % 400 == 0 [CORRECT]
C. year // 4 == 0 and year // 100 != 0
D. year ** 4 == 0
Correct Answer: B