UPDATED OA | 150+ PRACTICE QUESTIONS & ANSWERS | ULTIMATE
EXAM PREP & STUDY GUIDE | PYTHON FUNDAMENTALS,
PROGRAMMING CONCEPTS, CODING PRACTICE & DETAILED
EXPLANATIONS | COMPREHENSIVE OBJECTIVE ASSESSMENT REVIEW |
HIGH-YIELD TOPICS, EXAM-STYLE QUESTIONS & ANSWER RATIONALES |
IN-DEPTH REVISION MATERIAL | BOOST YOUR CONFIDENCE & PREPARE
TO PASS!
Question 1: What is the correct way to create a variable named age with the value
25 in Python
A) age == 25
• B) age := 25
• C) age = 25
• D) int age = 25
Answer: C) age = 25
Rationale: Python uses the assignment operator = to assign values to variables. == 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?
• A) 2nd_place
• B) my-variable
• C) _private_var
• D) class
Answer: C) _private_var
,Rationale: Variable names can start with a letter or underscore ( _), followed by letters,
numbers, or underscores. They cannot start with a digit (eliminating A), cannot contain
hyphens (eliminating B), and cannot be reserved keywords like class (eliminating D) .
Question 3: What is the data type of the value 3.14 in Python?
• A) Integer
• B) Float
• C) String
• D) Boolean
Answer: B) Float
Rationale: Any number with a decimal point is a floating-point number (float) in Python.
Integers (int) are whole numbers without a decimal point .
Question 4: What is the output of type()?
• A) <class 'int'>
• B) <class 'float'>
• C) <class 'str'>
• D) <class 'bool'>
Answer: B) <class 'float'>
Rationale: In Python, the / operator always returns a float, even when the result is a
whole number. evaluates to 5.0, which is a float .
Question 5: Which function converts the string "123" to an integer?
• A) str("123")
• B) int("123")
• C) float("123")
, • D) bool("123")
Answer: B) int("123")
Rationale: The int() function converts a value to an integer. "123" is a string containing
digits, so it can be successfully converted to the integer 123 .
Question 6: What is the output of bool(0)?
• A) True
• B) False
• C) 0
• D) None
Answer: B) False
Rationale: In Python, 0 is considered False when converted to a Boolean. Any non-zero
number (positive or negative) is considered True .
Question 7: What is the output of bool("") (empty string)?
• A) True
• B) False
• C) ""
• D) Error
Answer: B) False
Rationale: An empty string is considered False in a Boolean context. Non-empty strings
are considered True .
Question 8: What happens when you run int("3.14")?
, • A) Returns 3
• B) Returns 3.14
• C) Returns "3.14"
• D) Raises a Value Error
Answer: D) Raises a ValueError
Rationale: int() can only convert strings that represent whole numbers. "3.14" contains a
decimal point, so Python raises a ValueError .
Question 9: What is the output of print(type("Hello"))?
• A) <class 'str'>
• B) <class 'int'>
• C) <class 'float'>
• D) <class 'bool'>
Answer: A) <class 'str'>
Rationale: The type() function returns the data type of the argument. "Hello" is a string
(str), which is a sequence of characters enclosed in quotes .
Question 10: What is the output of print("5" + "3")?
• A) 8
• B) 53
• C) Error
• D) 5 3
Answer: B) 53
Rationale: String concatenation joins strings. "5" + "3" results in "53" because both
operands are strings. If you wanted numeric addition, you would need to convert them to
integers first .