Questions | 100% Correct Answers with Detailed
Rationales (2026/2027 Edition)
Graduate IT Python for IT Automation Objective Assessment
==============================
SECTION 1: Python Fundamentals
==============================
Question 1
Which of the following is the correct way to create a single-line comment in Python?
A. // This is a comment
B. /* This is a comment */
C. # This is a comment
D. <!-- This is a comment -->
Correct Answer: C
Rationale: In Python, single-line comments are created using the hash symbol (#). Option A is used
in C/C++/Java, Option B is a multi-line comment in C/C++/Java, and Option D is an HTML comment
syntax. Python does not use these other comment styles.
------------------------------
Question 2
What is the output of the following Python code?
```python
x=5
y=2
print(x // y)
```
A. 2.5
B. 2
,C. 3
D. 2.0
Correct Answer: B
Rationale: The floor division operator (//) returns the largest integer less than or equal to the division
result. 5 // 2 equals 2 (not 2.5 or 2.0), as floor division discards the remainder and returns an integer
in Python 3.x.
------------------------------
Question 3
Which data type would be most appropriate for storing a collection of unique IP addresses in
Python?
A. List
B. Tuple
C. Set
D. Dictionary
Correct Answer: C
Rationale: A set is the most appropriate data type for storing unique IP addresses because sets
automatically eliminate duplicate values. Lists and tuples allow duplicates, and while dictionaries
can store unique keys, a set is the most direct and efficient choice for a collection of unique values
without associated data.
------------------------------
Question 4
What is the output of the following code?
```python
name = "IT Automation"
print(name[3:8])
```
A. "Auto"
B. "Autom"
C. "o Aut"
D. "Automat"
, Correct Answer: C
Rationale: String slicing in Python uses the syntax [start:stop], where the start index is inclusive and
the stop index is exclusive. name[3:8] starts at index 3 ("o") and stops before index 8 ("t"), resulting in
"o Aut" (indices 3,4,5,6,7: o, space, A, u, t).
------------------------------
Question 5
Which Python built-in function is used to determine the length of a sequence such as a list, string, or
tuple?
A. size()
B. length()
C. len()
D. count()
Correct Answer: C
Rationale: The len() function is the built-in Python function used to return the number of items in a
sequence or collection. size() is not a built-in Python function (it's used in other languages like Java),
length() is not a Python built-in, and count() returns the number of occurrences of a specific element.
------------------------------
Question 6
What will be the output of the following code?
```python
a = [1, 2, 3]
b=a
b.append(4)
print(a)
```
A. [1, 2, 3]
B. [1, 2, 3, 4]
C. [4]
D. Error
Correct Answer: B