







Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!








Pages Total Marks Section Questions
Section 1 Multiple^ Choice Section 2 Short^ Answer Section 3 Long^ Answer 20 questions 6 questions 3 questions 40 total marks 30 total marks 30 total marks Name Student ID Date Signature
with detailed explanations.
AI to create targeted study materials like quizzes, summaries, and study guides.
Section 1 / 3 40 total^ marks Multiple Choice Select the most appropriate answer for each question. Each question is worth 2 marks.
An administrator is storing a status message in a variable named status. If the code is status = "System Online", which Python data type is being used? A int B bool C float D str
A script receives a numeric input from a user as a string: value = "10". Which code snippet correctly converts this to an integer and adds 5 to it? A result = str(value) + 5 B result = value + 5 C result = float(value) + "5" D result = int(value) + 5
You have a list of server names: servers = ["srv1", "srv2"]. Which method should be used to add "srv3" to the end of the existing list? A servers.remove("srv3") B servers.pop("srv3") C servers.insert(0, "srv3") D servers.append("srv3")
Consider the following function definition: def welcome_user(name="Guest"): What happens if the function is called as welcome_user() without any arguments? A The function prompts the user for input. B The function returns None. C The function uses "Guest" as the default value for name. D The function returns a SyntaxError.
Which built-in Python function is used to determine the number of items in a list or characters in a string? A len() B dir() C sum() D max()
A network administrator wants to add new log entries to the end of an existing text file without deleting the current content. Which file mode should be used in the open() function? A 'r' B 'w' C 'a' D 'x' 4 / 13
An automation script needs to store a fixed sequence of configuration values that should never be changed during the script's execution. Which data structure is most appropriate? A List B Set C Tuple D Dictionary
Which block in Python is used to catch and handle errors so that a script does not crash unexpectedly? A try/except B if/else C def/return D for/while
In basic socket programming, which socket method is used by a client to initiate a connection to a remote server and port? A s.bind() B s.accept() C s.connect() D s.listen()
What will be the value of result after executing: result = 10 % 3? A 3 B 0 C 1 D 3. 5 / 13
When working with csv.DictReader, how is each row in the CSV file represented? A As a dictionary where column headers are keys. B As a list of strings. C As a tuple. D As a single long string.
In Python, which Boolean value is returned by the expression bool(0)? A False B Error C True D None
A script needs to create a unique collection of IP addresses from a long list that contains many duplicates. Which data structure should be used to automatically remove duplicates? A Dictionary B Tuple C Set D List 7 / 13
Section 2 / 3 30 total^ marks Short Answer Provide short, technical answers or code snippets as requested. Each question is worth 5 marks.
Write a Python code snippet that performs the following tasks:
You have a dictionary representing a network device: device = {"id": "R1", "ip": "192.168.1.1", "status": "up"}. Write a for loop that iterates through the dictionary using the .items() method and prints each pair in the format: Key: Value.
Explain the difference between file.read() and file.readlines() when performing file operations in Python. 8 / 13
Section 3 / 3 30 total^ marks Long Answer Provide detailed code solutions and explanations for the following automation scenarios. Each question is worth 10 marks.
System Log Data You are tasked with auditing a list of system events. The event logs are stored in a Python list of strings, where each string represents an event and its status (either 'SUCCESS' or 'FAIL'). Example data: logs = ["Login SUCCESS", "Update FAIL", "Backup SUCCESS", "Login FAIL"] A Write a complete Python script to process the logs list from the provided scenario. Your script must:
Network Connectivity Tool You are building a tool to check if a specific management port (Port 80) is open on a target server (IP: 10.0.0.50). You must use the socket module and ensure the script doesn't crash if the connection fails. A Write a Python script to perform the connectivity check described in the scenario. Your script should: