Actual Exam Style 2026/2027 | Questions
with Verified Answers 100% Correct | Pass
Guaranteed | Grade A
Q01 What is the correct way to create a string variable named message with the value "Welcome
to Python"? Answer: message = "Welcome to Python" Rationale: Strings in Python are
created using single quotes (' '), double quotes (" "), or triple quotes. Double quotes are the most
common and readable style.
Q02 Which function is used to display output in Python? Answer: print() Rationale: The
print() function is the standard way to output text or variables to the console. Parentheses are
required.
Q03 What is the output of the following code?
Python
x = 10
y = 4
print(x % y)
Answer: 2 Rationale: The % operator returns the remainder of division. 10 divided by 4 is 2
with a remainder of 2.
Q04 Which of the following is NOT a valid variable name in Python? Answer: 2var Rationale:
Variable names cannot start with a number. They must begin with a letter (a–z, A–Z) or
underscore (_), followed by letters, numbers, or underscores.
Q05 What will be the result of this code?
, Python
text = "Automation"
print(text[3:7])
Answer: omat Rationale: String slicing [start:end] includes the start index (3) but excludes the
end index (7). Characters at positions 3, 4, 5, 6 → o, m, a, t.
Q06 Which operator is used for equality comparison in Python? Answer: == Rationale: ==
checks if two values are equal. The single = is used for assignment only.
Q07 What is the correct syntax to create a list containing the values 5, 10, and 15? Answer:
values = [5, 10, 15] Rationale: Lists are created using square brackets [] with comma-separated
values.
Q08 What is the output of this expression?
Python
True and False or True
Answer: True Rationale: Python evaluates from left to right with and having higher precedence
than or. True and False = False → False or True = True.
Q09 Which keyword is used to define a function in Python? Answer: def Rationale: Functions
are defined using the def keyword, followed by the function name, parameters (if any), and a
colon.
Q10 What will this loop print?
Python
for num in range(4):
print(num)
Answer: 0 1 2 3 Rationale: range(4) generates numbers from 0 up to (but not including) 4 → 0,
1, 2, 3.