WGU E010 FOUNDATIONS OF
PROGRAMMING (PYTHON) ADVANCED
ASSESSMENT
1. What is the output of the following code snippet? x = [1, 2, 3]; y = x; y.append(4); print(x)
A. [1, 2, 3]
B. Error
C. [1, 2, 3, 4]
D. [4]
Answer: C
Conceptual Explanation: In Python, lists are mutable objects. When y = x is assigned, both
variables point to the same list object in memory. Therefore, appending to y also updates x.
2. Which operator has the highest precedence in Python?
A. not (Logical NOT)
B. * (Multiplication)
C. + (Addition)
,D. ** (Exponentiation)
Answer: D
Conceptual Explanation: According to Python’s order of operations, exponentiation (**) is
evaluated before multiplication, addition, and logical operators.
3. What will result from the expression 10 // 3?
A. 3.333
B. 3
C. 3.0
D. 1
Answer: B
Conceptual Explanation: The // operator performs floor division, which divides the
numbers and rounds down to the nearest whole integer.
4. Given the string s = ‘Python’, what does s[1:4] return?
A. ‘yth’
B. ‘Pyth’
C. ‘ytho’
D. ‘ythn’
Answer: A
, Conceptual Explanation: String slicing [start:stop] includes the start index but excludes
the stop index. Indices start at 0, so s[1] is ‘y’ and s[3] is ‘h’.
5. What is the correct way to handle multiple potential exceptions in a single try block?
A. except ValueError, TypeError:
B. except ValueError or TypeError:
C. except (ValueError, TypeError):
D. catch (ValueError, TypeError):
Answer: C
Conceptual Explanation: To catch multiple specific exceptions, they must be passed as a
tuple to the except statement.
6. Which of the following creates a dictionary?
A. d = {“a”: 1}
B. d = {“a”, 1}
C. d = [“a”: 1]
D. d = (“a”, 1)
Answer: A
Conceptual Explanation: Dictionaries are defined using curly braces with key-value pairs
separated by colons.
PROGRAMMING (PYTHON) ADVANCED
ASSESSMENT
1. What is the output of the following code snippet? x = [1, 2, 3]; y = x; y.append(4); print(x)
A. [1, 2, 3]
B. Error
C. [1, 2, 3, 4]
D. [4]
Answer: C
Conceptual Explanation: In Python, lists are mutable objects. When y = x is assigned, both
variables point to the same list object in memory. Therefore, appending to y also updates x.
2. Which operator has the highest precedence in Python?
A. not (Logical NOT)
B. * (Multiplication)
C. + (Addition)
,D. ** (Exponentiation)
Answer: D
Conceptual Explanation: According to Python’s order of operations, exponentiation (**) is
evaluated before multiplication, addition, and logical operators.
3. What will result from the expression 10 // 3?
A. 3.333
B. 3
C. 3.0
D. 1
Answer: B
Conceptual Explanation: The // operator performs floor division, which divides the
numbers and rounds down to the nearest whole integer.
4. Given the string s = ‘Python’, what does s[1:4] return?
A. ‘yth’
B. ‘Pyth’
C. ‘ytho’
D. ‘ythn’
Answer: A
, Conceptual Explanation: String slicing [start:stop] includes the start index but excludes
the stop index. Indices start at 0, so s[1] is ‘y’ and s[3] is ‘h’.
5. What is the correct way to handle multiple potential exceptions in a single try block?
A. except ValueError, TypeError:
B. except ValueError or TypeError:
C. except (ValueError, TypeError):
D. catch (ValueError, TypeError):
Answer: C
Conceptual Explanation: To catch multiple specific exceptions, they must be passed as a
tuple to the except statement.
6. Which of the following creates a dictionary?
A. d = {“a”: 1}
B. d = {“a”, 1}
C. d = [“a”: 1]
D. d = (“a”, 1)
Answer: A
Conceptual Explanation: Dictionaries are defined using curly braces with key-value pairs
separated by colons.