




























































































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!





























































































Course: E010 – Foundations of Programming (Python) Institution: Western Governors University (WGU) Assessment: Objective Assessment (OA) – Final Exam Latest Update: 2025/ Format: 300 practice questions with verified answers and detailed rationales Source: Compiled from actual exam prep materials, practice test banks, and verified OA questions
| Section | Domain | Questions | |-||| | I | Variables, Data Types & Type Casting | 1–40 | | II | Operators & Expressions | 41–70 | | III | String Manipulation & Indexing | 71–100 | | IV | Control Flow – Conditionals (if/elif/else) | 101–125 | | V | Loops (for, while, break, continue) | 126–160 | | VI | Functions & Scope | 161–195 | | VII | Data Structures – Lists, Tuples, Dictionaries, Sets | 196–230 | | VIII | File Handling & Input/Output | 231–255 | | IX | Comprehensive Mixed Review | 256–300 |
SECTION I: VARIABLES, DATA TYPES & TYPE CASTING (Questions 1–40)
Question 1 What is the correct way to create a variable named age with the value 25 in Python?
Answer: C Rationale: Python uses the assignment operator = to assign values to variables. No type declaration is needed. == is a comparison operator, := is the walrus operator used in expressions, and int age = 25 is invalid Python syntax.
Question 2 Which of the following is a valid variable name in Python?
Answer: C Rationale: Python variable names cannot start with a digit (eliminating 2ndName), cannot contain hyphens (eliminating my-name), and cannot be reserved keywords like class (eliminating class). Underscores are allowed and commonly used, so my_name is valid.
Question 3 Which of the following is a valid Boolean value in Python?
Answer: C Rationale: Python's Boolean values are True and False (capitalized). "True" is a string, true is not a valid keyword (Python is case-sensitive), and 1 is an integer that evaluates to True in a Boolean context but is not itself a Boolean.
Question 4 What is the output of bool(0)?
Answer: C Rationale: int() cannot convert a string representing a floating-point number directly. It will raise a ValueError because the string contains a decimal point.
Question 8 What is the output of print(type(10 / 2))?
Answer: B Rationale: In Python, the division operator / always returns a float, even if the numbers divide evenly. 10 / 2 evaluates to 5.0, and type(5.0) returns ``. Python does not have a separate double type.
Question 9 What is the output of print(type(10 // 2))?
Answer: A Rationale: The floor division operator // returns an integer result (if both operands are integers) or a float if any operand is a float. 10 // 2 evaluates to 5, which is an int.
Question 10 Which data type is immutable in Python?
Answer: D
Rationale: Tuples cannot be changed after creation, making them immutable. Lists, dictionaries, and sets are all mutable data types that can be modified after creation.
Question 11 What is the output of print(type([]))?
Answer: B Rationale: [] creates an empty list, so type([]) returns ``.
Question 12 Which of the following creates a dictionary in Python?
Answer: B Rationale: {} creates an empty dictionary. [] creates a list, () creates a tuple, and set() creates an empty set.
Question 13 What is the output of print(type(()))?
Answer: A Rationale: () creates an empty tuple, so type(()) returns ``.
Answer: D Rationale: True is a Boolean value, so type(True) returns ``.
Question 18 Which of the following is NOT a valid data type in Python?
Answer: C Rationale: Python does not have a double data type. Floating-point numbers are represented by the float type.
Question 19 What is the output of print(type(None))?
Answer: D Rationale: None is a special constant in Python representing the absence of a value. Its type is ``.
Question 20 What is the result of int(3.14)?
Answer: A Rationale: The int() function truncates the decimal portion of a floating-point number, converting it to an integer. int(3.14) returns 3.
Question 21 What is the result of float(5)?
Answer: B Rationale: The float() function converts an integer to a floating-point number. float(5) returns 5.0.
Question 22 What is the result of str(100)?
Answer: B Rationale: The str() function converts a value to a string. str(100) returns the string "100".
Question 23 What is the output of print(bool(1))?
Answer: A
Question 27 What is the output of print(bool([]))?
Answer: B Rationale: An empty list evaluates to False in a Boolean context.
Question 28 What is the output of print(bool([1, 2, 3]))?
Answer: A Rationale: A non-empty list evaluates to True in a Boolean context.
Question 29 Which of the following is a valid way to create a variable with a floating-point value?
Answer: B Rationale: 5.0 is a floating-point literal. 5 is an integer, "5.0" is a string, and True is a Boolean.
Question 30 What is the output of print(type(5.0))?
Answer: B Rationale: 5.0 is a floating-point number, so type(5.0) returns ``.
Question 31 What is the output of print(int(True))?
Answer: A Rationale: In Python, True is represented internally as 1. int(True) returns 1.
Question 32 What is the output of print(int(False))?
Answer: B Rationale: In Python, False is represented internally as 0. int(False) returns 0.
Question 33 What is the output of print(bool(0.0))?
Question 37 What is the output of print(10 // 3)?
Answer: A Rationale: The // operator performs floor division, returning the largest integer less than or equal to the result. 10 // 3 returns 3.
Question 38 What is the output of print(10 % 3)?
Answer: B Rationale: The % operator returns the remainder of the division. 10 % 3 returns 1 because 3 goes into 10 three times with a remainder of 1.
Question 39 Which of the following correctly converts a string to a float?
Answer: A Rationale: The float() function can convert a string representing a floating-point number to a float. int("3.14") would raise an error because of the decimal point.
Question 40 What is the output of print(type(int("100")))?
Answer: A Rationale: int("100") converts the string "100" to the integer 100. type(100) returns ``.
SECTION II: OPERATORS & EXPRESSIONS (Questions 41–70)
Question 41 What is the output of print(5 + 10)?
Answer: B Rationale: The + operator performs arithmetic addition when both operands are integers. 5 + 10 equals 15.
Question 42 What is the output of print("5" + "10")?
Answer: C Rationale: When both operands are strings, the + operator performs concatenation. "5" + "10" results in the string "510".
Question 46 What is the output of print(10 // 4)?
Answer: A Rationale: The // operator performs floor division. 10 // 4 returns 2.
Question 47 What is the output of print(5 == 5)?
Answer: A Rationale: The == operator compares two values for equality. 5 == 5 returns True.
Question 48 What is the output of print(5 != 5)?
Answer: B Rationale: The != operator checks if two values are not equal. 5 != 5 returns False.
Question 49 What is the output of print(5 > 3)?
Answer: A Rationale: The > operator checks if the left value is greater than the right value. 5 > 3 returns True.
Question 50 What is the output of print(5 < 3)?
Answer: B Rationale: The < operator checks if the left value is less than the right value. 5 < 3 returns False.
Question 51 What is the output of print(5 >= 5)?
Answer: A Rationale: The >= operator checks if the left value is greater than or equal to the right value. 5 >= 5 returns True.
Question 52 What is the output of print(5 <= 3)?
Rationale: The not operator returns the opposite Boolean value. not True returns False.
Question 56 What is the output of print(3 + 4 * 2)?
Answer: B Rationale: Python follows operator precedence. Multiplication is performed before addition: 4 * 2 = 8, then 3 + 8 = 11.
Question 57 What is the output of print((3 + 4) * 2)?
Answer: A Rationale: Parentheses have the highest precedence. (3 + 4) = 7, then 7 * 2 = 14.
Question 58 What is the output of print(10 - 3 * 2)?
Answer: B Rationale: Multiplication is performed before subtraction: 3 * 2 = 6, then 10 - 6 = 4.
Question 59 What is the output of print(10 % 3 == 1)?
Answer: A Rationale: 10 % 3 returns 1. The expression 1 == 1 returns True.
Question 60 What is the output of print(2 * 3 2)?
Answer: B Rationale: Exponentiation has higher precedence than multiplication. 3 2 = 9, then 2 * 9 = 18.
Question 61 What is the output of print(2 3 2)?
Answer: B Rationale: Exponentiation is right-associative in Python. 3 2 = 9, then 2 9 = 512.
Question 62 What is the output of print(5 + "5")?