Objective Assessment Exam Prep | 100+ Practice Questions & Answers
with Detailed Explanations | Python Fundamentals, Coding Concepts,
Variables, Loops, Functions, Lists & Dictionaries | Comprehensive D335
Review & Practice Test | High-Yield Study Material for Confident Exam
Preparation
Question 1: What is the correct way to print "Hello World" in Python?
• A) print("Hello World")
• B) printf("Hello World")
• C) System.out.println("Hello World")
• D) console.log("Hello World")
Answer: A) print("Hello World")
Rationale: Python uses the print() function to output text to the console. The text must be
enclosed in quotes (single or double). The other options are syntax from other
programming languages (C, Java, JavaScript respectively).
Question 2: Which of the following is NOT a valid Python comment?
• A) # This is a comment
• B) // This is a comment
• C) """ This is a multi-line comment """
• D) ''' This is also a multi-line comment '''
Answer: B) // This is a comment
Rationale: In Python, single-line comments start with #. Multi-line comments can use triple
quotes (""" or '''). // is used for comments in languages like C++, Java, and JavaScript,
but not in Python.
,Question 3: What is the output of print(type(3.14))?
• A) <class 'int'>
• B) <class 'float'>
• C) <class 'str'>
• D) <class 'bool'>
Answer: B) <class 'float'>
Rationale: 3.14 is a floating-point number. The type() function returns the data type of the
argument. Integers are whole numbers without a decimal point.
Question 4: Which of the following is a valid variable name in Python?
• A) 2nd_place
• B) my-variable
• C) _private
• D) class
Answer: C) _private
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 5: 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. Empty containers like [], (), {}, "" are
also False.
Question 6: What is the output of bool("Hello")?
• A) True
• B) False
• C) "Hello"
• D) Error
Answer: A) True
Rationale: Any non-empty string is considered True in a Boolean context. Only empty
strings ("") are considered False.
Question 7: What is the output of print("5" + "3")?
• A) 8
• B) 53
• C) Error
• D) "5 3"
Answer: B) 53
Rationale: The + operator concatenates strings. "5" + "3" results in "53". To perform
numeric addition, you would need to convert the strings to integers first.
Question 8: What is the output of print("Hello" * 3)?
• A) Hello Hello Hello
• B) Hello Hello Hello
• C) Hello3
, • D) Error
Answer: A) HelloHelloHello
Rationale: The * operator repeats strings. "Hello" * 3 repeats the string three times,
resulting in "HelloHelloHello".
Question 9: Which function is used to get user input in Python?
• A) input()
• B) get_input()
• C) scan()
• D) read()
Answer: A) input()
Rationale: The built-in input() function reads a line from standard input and returns it as
a string. It optionally accepts a prompt string as an argument.
Question 10: What does the input() function return?
• A) An integer
• B) A float
• C) A string
• D) A boolean
Answer: C) A string
Rationale: The input() function always returns a string. If you need a numeric value, you
must convert it using int() or float().
Question 11: What is the output of print()?