PYTHON IT AUTOMATION EXAM STUDY
GUIDE | LATEST 2025/2026 GUIDE
Looping over a dictionary - Correct Answer - To access both keys and
values, use the .items() method.
Memory efficiency of range() - Correct Answer - In Python 3, range()
produces a range object that generates numbers on the fly.
Converting range to list - Correct Answer - You can convert a range
object to a list with list(range(n)), but it's rarely necessary for iteration.
Polling until something is true - Correct Answer - A scenario where a
while loop is useful, such as waiting for a certain state.
Updating router_id in a loop - Correct Answer - To avoid an infinite loop,
modify router_id in the loop or change the condition.
Printing count in a while loop - Correct Answer - A while loop can print
count from 0 to 4 using count += 1.
,Loop condition - Correct Answer - Always ensure your loop condition will
eventually become False to avoid infinite loops.
Order of items in a dict - Correct Answer - In Python 3.7+, the order of
items in a dictionary is preserved.
Skipping items in a loop - Correct Answer - Use continue to skip certain
items and move on to the next iteration.
Example of continue - Correct Answer - In a loop, if num == 3, continue
will skip printing 3.
Logic error causing infinite loop - Correct Answer - Typically involves
forgetting to update the loop condition variable.
Interrupting a Python script - Correct Answer - You can interrupt a
Python script using Ctrl+C in many environments.
Using .keys() in a dictionary - Correct Answer - To get only keys from a
dictionary, use for key in student: or .keys() explicitly.
Using .values() in a dictionary - Correct Answer - To get only values from
a dictionary, use .values().
,enumerate() - Correct Answer - A function in Python that generates pairs
of (index, value) for each element in a list.
Looping with enumerate - Correct Answer - Using the enumerate
function allows you to iterate over a list with both the index and value
simultaneously.
Example of enumerate - Correct Answer - For the list fruits = ["apple",
"banana", "cherry"], using enumerate gives: 0 : apple, 1 : banana, 2 :
cherry.
Starting index in enumerate - Correct Answer - You can give enumerate
a start value to begin counting from a number other than 0, e.g.,
enumerate(fruits, start=1) gives indices 1, 2, 3.
Python script for server status - Correct Answer - A script that checks a
list of server statuses in a dictionary and prints which ones are down.
Server status example - Correct Answer - Given servers =
{"192.168.1.1": "up", "192.168.1.2": "down", "192.168.1.3": "down",
"192.168.1.4": "up"}, the script prints messages for devices that are
down.
, Socket module - Correct Answer - The socket module provides access
to the BSD socket interface for creating network connections (both TCP
and UDP).
Creating a socket - Correct Answer - You can create a socket using
import socket; s = socket.socket(socket.AF_INET,
socket.SOCK_STREAM) for TCP connections.
Connecting with socket - Correct Answer - s.connect(("example.com",
80)) connects to example.com on port 80.
Script for find and replace - Correct Answer - To find and replace a
substring in all files in a directory, you would import necessary modules,
loop through files, read contents, search and replace, and write modified
content back.
File read and replace example - Correct Answer - Example snippet: text
= ""; with open("example.txt", "r") as f: text = f.read(); new_text =
text.replace("OLD_STRING", "NEW_STRING"); with open("example.txt",
"w") as f: f.write(new_text).
Importance of daily coding practice - Correct Answer - Daily practice is
crucial for learning Python as it reinforces syntax, improves problem-
solving skills, and makes debugging more comfortable.