First 50 of 200 questions. Each one lists the choices, the correct answer, and an explanation. The checker at the top of this page saves progress in this browser when it is available.
Continue in the practice tool above to load more questions, 50 at a time.
Question 1Automation and DevOps Fundamentals
Which practice is the clearest example of continuous integration?
- Developers merge to a shared trunk at least daily and each merge triggers an automated build and test run Correct answer.
- A release manager manually packages artifacts once per month
- Operations staff rebuild production servers from scratch every quarter
- Testers run a full regression suite the week before a release
Explanation
Continuous integration means integrating work frequently into a shared mainline and validating each integration automatically. The defining signals are short-lived branches, frequent merges, and an automated build/test triggered on every change.
Question 2Automation and DevOps Fundamentals
In a continuous delivery pipeline, what distinguishes continuous delivery from continuous deployment?
- Continuous delivery produces artifacts; continuous deployment does not
- Continuous delivery runs tests; continuous deployment skips testing entirely
- Continuous delivery requires manual approval to release; continuous deployment releases automatically Correct answer.
- Continuous delivery uses containers; continuous deployment uses virtual machines
Explanation
Both models keep the mainline releasable at all times; the difference is the final step. Continuous delivery stops at a deployable artifact awaiting a human decision, while continuous deployment pushes every passing change to production automatically.
Question 3Automation and DevOps Fundamentals
A team wants pipeline stages to fail fast. Which ordering best supports that goal?
- Run fast static checks and unit tests first, then slower integration and end-to-end suites Correct answer.
- Run the slowest performance tests first, then unit tests
- Run the longest end-to-end UI suite first, then linting
- Run all stages in parallel regardless of duration or cost
Explanation
Fail-fast pipelines front-load the cheapest, fastest signals so defects are reported within seconds or minutes. Expensive suites run only after quick checks pass, conserving compute and developer wait time.
Question 4Automation and DevOps Fundamentals
What is the primary purpose of a version control branching strategy such as trunk-based development?
- To keep integration risk low by minimizing long-lived divergent branches Correct answer.
- To eliminate the need for automated tests
- To remove the need for code review
- To guarantee that no defects reach production
Explanation
Trunk-based development keeps branches very short-lived so integration conflicts and merge risk stay small. It complements, but never replaces, automated testing and review.
Question 5Automation and DevOps Fundamentals
Which statement best describes infrastructure as code?
- Infrastructure changes are approved only by the operations manager
- Servers are configured by hand and the steps recorded in a wiki
- Infrastructure definitions are stored in version-controlled files and applied by tooling Correct answer.
- Infrastructure is provisioned only through a graphical console
Explanation
Infrastructure as code treats environment definitions as source artifacts kept in version control and applied repeatably by automation. This makes environments reproducible, reviewable, and auditable.
Question 6Automation and DevOps Fundamentals
An engineer runs the same Terraform configuration twice against an unchanged environment and the second run reports no changes. Which property does this demonstrate?
- Serialization
- Idempotence Correct answer.
- Elasticity
- Federation
Explanation
Idempotence means applying the same desired state repeatedly converges to the same result without additional side effects. A no-op second run is the classic observable sign of an idempotent apply.
Question 7Automation and DevOps Fundamentals
Which configuration management concept describes a declarative file that states the desired end state of a machine rather than the commands to reach it?
- Imperative runbook
- Desired-state manifest Correct answer.
- Change advisory board
- Rollback script
Explanation
A desired-state manifest declares what the end result should be, and the tool computes the steps needed to converge. Imperative scripts instead specify each command in order.
Question 8Automation and DevOps Fundamentals
A deployment must update a web tier with zero downtime. Which technique best achieves this?
- Deploying directly to the production database first
- Deploying to a subset of instances behind a load balancer, verifying health, then rolling forward Correct answer.
- Increasing the deployment window to several hours
- Stopping all instances, deploying, then starting them again
Explanation
Rolling or canary-style replacement keeps healthy capacity serving traffic while new versions are validated. Traffic is only shifted once the updated instances pass health checks.
Question 9Automation and DevOps Fundamentals
What is the main benefit of an immutable infrastructure model?
- Instances are never replaced after provisioning
- Servers can be patched in place with minimal tooling
- Configuration files are edited directly on running hosts
- Every change produces a new image, so environments are reproducible and drift is avoided Correct answer.
Explanation
Immutable infrastructure replaces rather than mutates running instances, so each version is a known, reproducible artifact. This eliminates configuration drift caused by in-place edits.
Question 10Automation and DevOps Fundamentals
In a blue-green deployment, what is the role of the router or load balancer?
- It switches live traffic between the two environments after the new one passes validation Correct answer.
- It runs the database migrations
- It stores the deployment secrets
- It compiles the application artifacts
Explanation
Blue-green keeps two parallel environments and flips traffic from the old to the new one once validation succeeds. The cutover mechanism is the routing layer.
Question 11Automation and DevOps Fundamentals
Which metric is most directly associated with the DevOps practice of measuring delivery performance?
- Lead time for changes Correct answer.
- Number of office printers per floor
- Count of manual approvals per quarter
- Average meeting duration
Explanation
Delivery performance metrics such as lead time for changes, deployment frequency, change failure rate, and time to restore are the standard DevOps measures. Lead time captures how long a committed change takes to reach production.
Question 12Automation and DevOps Fundamentals
A team's change failure rate is high while deployment frequency is also high. What is the most reasonable interpretation?
- The team deploys often but lacks sufficient automated validation and observability Correct answer.
- Deployment frequency and failure rate are unrelated, so no action is needed
- The team has too many automated tests
- The team should stop deploying to reduce risk
Explanation
High frequency with high failure rate suggests changes are reaching production without adequate automated checks or fast detection. The response is stronger testing, progressive rollout, and better observability rather than abandoning frequent delivery.
Question 13Automation and DevOps Fundamentals
Which practice best supports a blameless post-incident review?
- Restricting the review to managers only
- Closing the review once service is restored
- Focusing on systemic causes and documenting contributing factors and follow-up actions Correct answer.
- Identifying the individual who made the error and recording it in their file
Explanation
Blameless reviews examine system conditions, process gaps, and tooling that allowed an incident, producing actionable improvements. The goal is learning rather than assigning fault to a person.
Question 14Automation and DevOps Fundamentals
What does a service level objective (SLO) express?
- A contractual penalty for outages
- A list of on-call engineers
- A budget for cloud spending
- A target level of reliability measured over a defined window Correct answer.
Explanation
An SLO states a measurable reliability target, such as 99.9 percent availability over 30 days, derived from a service level indicator. It guides operational priorities and error-budget decisions.
Question 15Automation and DevOps Fundamentals
A team has consumed most of its error budget for the month. What action is most consistent with error-budget policy?
- Freeze risky changes and prioritize reliability work until the budget recovers Correct answer.
- Increase feature release velocity to make up for lost time
- Ignore the budget because it is only informational
- Disable monitoring to stop consuming budget
Explanation
An error budget converts reliability targets into a release policy: when the budget is nearly exhausted, risky changes pause and reliability work takes priority. This balances innovation against user-facing stability.
Question 16Automation and DevOps Fundamentals
Which statement best describes the role of a container image registry in a CI/CD workflow?
- It executes unit tests during the build
- It provisions network load balancers
- It stores and distributes versioned container images produced by the build stage Correct answer.
- It replaces the need for a version control system
Explanation
A registry is the artifact repository where built images are pushed, versioned by tag or digest, and pulled by deployment targets. It is a distribution mechanism, not a build or test engine.
Question 17Automation and DevOps Fundamentals
A pipeline builds an image tagged only with 'latest' and deploys it. Why is this risky?
- Images cannot be pulled without a semantic version
- Registries reject the word latest
- The tag is mutable, so different environments may run different code under the same name Correct answer.
- The tag is too long for most registries
Explanation
The latest tag is overwritten on each push, so it does not identify a specific build. Deployments should reference an immutable identifier such as a content digest or unique build tag for traceability and reproducibility.
Question 18Automation and DevOps Fundamentals
Which of the following is an example of a configuration drift detection activity?
- Rebooting every server nightly
- Deleting unused user accounts manually
- Comparing a running host's settings against the declared desired state and reporting differences Correct answer.
- Adding more instances during peak load
Explanation
Drift detection compares actual state to declared state and flags divergence, often on a schedule. It lets teams remediate manual changes that bypassed automation.
Question 19Automation and DevOps Fundamentals
Which benefit most directly results from automating a manual release process?
- Complete removal of the need for monitoring
- Consistent, repeatable execution that reduces human error and shortens cycle time Correct answer.
- Guaranteed elimination of all production defects
- Permanent reduction in infrastructure cost
Explanation
Automation standardizes each step so releases run the same way every time, cutting variability and manual mistakes. It also shortens the time from commit to release by removing handoffs.
Question 20Automation and DevOps Fundamentals
A team uses feature flags to decouple deployment from release. What does this enable?
- Code can be deployed without any testing
- Rollbacks require redeploying the previous build
- Database migrations become unnecessary
- Code can be deployed to production while the feature stays hidden until it is enabled Correct answer.
Explanation
Feature flags let code ship to production dark and be turned on independently of the deploy event. This separates technical deployment from business release and supports gradual rollout or instant disable.
Question 21Python Programming for Network Automation
Which Python data type is immutable and can be used as a dictionary key?
- bytearray
- tuple Correct answer.
- set
- list
Explanation
Dictionary keys must be hashable, and hashability requires immutability. Tuples of immutable elements are hashable, while lists, sets, and bytearrays are mutable and therefore cannot serve as keys.
Question 22Python Programming for Network Automation
What does the expression `'10.0.0.1'.split('.')` return?
- An integer 10001
- A tuple ('10','0','0','1')
- The string '10.0.0.1'
- A list ['10','0','0','1'] Correct answer.
Explanation
str.split(sep) divides the string at each occurrence of the separator and returns a list of substrings. With '.' as the separator, the four octets become four list elements.
Question 23Python Programming for Network Automation
Which statement about Python function default arguments is correct?
- Default arguments must be mutable objects
- Default values are re-evaluated on every call
- Default arguments cannot be used with keyword arguments
- Default values are evaluated once when the function is defined Correct answer.
Explanation
Default argument expressions are evaluated a single time at function definition, and the same object is reused across calls. Using a mutable default such as a list therefore accumulates state between calls.
Question 24Python Programming for Network Automation
A script opens a file with `with open('cfg.txt') as f:` and never calls `f.close()`. What happens to the file handle?
- It is closed when f is garbage collected immediately
- It is closed only if an exception is raised
- It is closed automatically when the with block ends Correct answer.
- It stays open until the interpreter exits
Explanation
The with statement relies on the context manager protocol: the file's __exit__ method closes the handle when the block finishes, whether normally or via exception.
Question 25Python Programming for Network Automation
What is the output of `print(list(range(2, 10, 3)))`?
- [2, 3, 4, 5, 6, 7, 8, 9]
- [2, 4, 6, 8]
- [2, 5, 8] Correct answer.
- [3, 6, 9]
Explanation
range(start, stop, step) begins at start, increments by step, and stops before reaching stop. Starting at 2 with step 3 yields 2, 5, and 8 before 11 exceeds the stop value.
Question 26Python Programming for Network Automation
Which comprehension builds a dictionary mapping each device name to its IP address from two parallel lists `names` and `ips`?
- {n, i for n, i in zip(names, ips)}
- {n: i for n, i in zip(names, ips)} Correct answer.
- [n: i for n in names for i in ips]
- {n: i for n in names, i in ips}
Explanation
A dict comprehension uses the form {key: value for ...}, and zip pairs corresponding elements from the two lists. This yields one key-value pair per device.
Question 27Python Programming for Network Automation
Given `d = {'a': 1}` and then `d['b'] = 2`, which expression raises a KeyError?
- d.get('c')
- d['a']
- d['c'] Correct answer.
- d['b']
Explanation
Subscript access raises KeyError when the key is absent. The get method returns None instead of raising, and existing keys return their values normally.
Question 28Python Programming for Network Automation
What is the value of `result` after this code runs?
```
nums = [1, 2, 3, 4]
result = [x * 2 for x in nums if x % 2 == 0]
```
- [2, 4, 6, 8]
- [2, 6]
- [4, 8] Correct answer.
- [1, 3]
Explanation
The filter clause keeps only even values (2 and 4), and the expression doubles each kept element. The result is therefore [4, 8].
Question 29Python Programming for Network Automation
Which exception type is raised by `int('10.0.0.1')`?
- ValueError Correct answer.
- TypeError
- KeyError
- SyntaxError
Explanation
int() raises ValueError when the string is not a valid integer literal. The dotted string contains non-digit characters, so conversion fails with ValueError.
Question 30Python Programming for Network Automation
What does `json.dumps({'host': 'r1', 'up': True})` return?
- A JSON-formatted string Correct answer.
- A JSON-formatted bytes object
- A file object written to disk
- A Python dict with string keys
Explanation
json.dumps serializes a Python object into a JSON string. The Python boolean True becomes the JSON literal true in that string.
Question 31Python Programming for Network Automation
Which regular expression matches an IPv4 address string such as '192.168.1.1' but not '192.168.1' or '192.168.1.1.1'?
- r'\d+\.\d+\.\d+\.\d+'
- r'^\d+\.\d+$'
- r'\d{1,3}\.\d{1,3}'
- r'^\d+\.\d+\.\d+\.\d+$' Correct answer.
Explanation
Anchors ^ and $ force the match to cover the entire string, and the four dot-separated digit groups require exactly the dotted-quad shape. Without anchors, substrings of longer strings would also match.
Question 32Python Programming for Network Automation
What is printed by `print(type(3 / 2).__name__, 3 / 2)`?
- int 1.5
- float 1.5 Correct answer.
- int 1
- float 1.0
Explanation
The / operator performs true division and always returns a float in Python 3, so 3 / 2 yields 1.5. Floor division with // would return an integer when both operands are ints.
Question 33Python Programming for Network Automation
A loop reads device records and writes each to a log. Which construct guarantees the log file is flushed and closed even if an exception occurs mid-loop?
- Relying on the operating system to close the file
- Wrapping the loop in a try/except and calling close in except only
- Using a with block around the file open and the loop Correct answer.
- Calling flush() once before the loop
Explanation
A with block invokes the file's __exit__ on both normal and exceptional exit, closing the handle. Handling only exceptions would skip cleanup on success or other exit paths.
Question 34Python Programming for Network Automation
Which statement correctly defines a function that accepts any number of positional arguments?
- def f(args):
- def f(*args): Correct answer.
- def f(**kwargs):
- def f(&args):
Explanation
A single asterisk before a parameter name collects extra positional arguments into a tuple. The double asterisk form collects keyword arguments into a dict instead.
Question 35Python Programming for Network Automation
What does the expression `'a,b,c'.split(',', 1)` evaluate to?
- ['a', 'b,c'] Correct answer.
- ['a', 'b', 'c']
- ['a,b', 'c']
- ['a,b,c']
Explanation
The second argument to split is maxsplit, the maximum number of splits performed. With maxsplit=1, only the first comma is split, leaving the remainder intact.
Question 36Python Programming for Network Automation
A module defines `def send(cmd, host='10.0.0.1'):` and a caller invokes `send('show version')`. What is the value of `host` inside the function?
- An empty string
- None
- '10.0.0.1' Correct answer.
- A NameError is raised
Explanation
When the caller omits an argument that has a default, the default expression's value is used. The default string '10.0.0.1' is bound to host.
Question 37Python Programming for Network Automation
Which code correctly catches a connection timeout while allowing other exceptions to propagate?
- try:\n connect()\nexcept Exception:\n pass
- try:\n connect()\nexcept:\n log('timeout')
- try:\n connect()\nfinally:\n log('timeout')
- try:\n connect()\nexcept TimeoutError:\n log('timeout') Correct answer.
Explanation
Naming a specific exception class in the except clause catches only that type, letting all others propagate. A bare except or a broad Exception clause would swallow unrelated errors.
Question 38Python Programming for Network Automation
What is the result of `sorted(['10.0.0.10', '10.0.0.2', '10.0.0.1'])`?
- A TypeError is raised
- ['10.0.0.1', '10.0.0.10', '10.0.0.2'] Correct answer.
- ['10.0.0.1', '10.0.0.2', '10.0.0.10']
- ['10.0.0.10', '10.0.0.2', '10.0.0.1']
Explanation
Default string sorting compares characters lexicographically, so '10.0.0.10' precedes '10.0.0.2' because '1' sorts before '2' at the differing position. Numeric IP ordering requires a key function such as ipaddress.ip_address.
Question 39Python Programming for Network Automation
Which statement about Python's `ipaddress.ip_network('10.0.0.0/24')` object is correct?
- It contains 256 addresses, and the first is 10.0.0.0
- It rejects the string because it lacks a mask
- It returns a string rather than an object
- It contains 254 usable host addresses via the hosts() iterator Correct answer.
Explanation
A /24 network object has 256 total addresses, and its hosts() iterator yields the usable host addresses, which for IPv4 excludes the network and broadcast addresses (254). The object also exposes network and broadcast attributes.
Question 40Python Programming for Network Automation
What does the following print?
```
x = [1, 2, 3]
y = x
y.append(4)
print(len(x))
```
- 3
- A NameError is raised
- 4 Correct answer.
- 0
Explanation
Assignment y = x binds both names to the same list object, so mutating through y is visible through x. The list now has four elements.
Question 41Python Programming for Network Automation
Which expression safely reads an optional key from a dict and supplies a fallback without raising?
- d.pop('timeout')
- d.index('timeout')
- d['timeout']
- d.get('timeout', 30) Correct answer.
Explanation
dict.get returns the value for the key if present, otherwise the provided default, and never raises for a missing key. This is the idiomatic way to read optional configuration values.
Question 42Python Programming for Network Automation
A script needs to run `show version` on many devices concurrently. Which standard-library tool is designed for running blocking I/O tasks in parallel threads?
- the itertools.chain function
- the multiprocessing.Queue
- the asyncio event loop with await
- concurrent.futures.ThreadPoolExecutor Correct answer.
Explanation
ThreadPoolExecutor runs callables in a pool of threads, which suits blocking I/O such as network calls where the GIL is released during waits. It returns futures whose results can be collected as tasks complete.
Question 43Python Programming for Network Automation
What is the output of `print(bool('False'), bool(''), bool(0))`?
- True True False
- False True True
- True False False Correct answer.
- False False False
Explanation
Any non-empty string is truthy regardless of its content, so 'False' is True. The empty string and the integer zero are falsy.
Question 44Python Programming for Network Automation
Which code snippet reads a JSON configuration file and turns it into a Python dictionary?
- with open('c.json') as f:\n cfg = f.read().split(',')
- with open('c.json') as f:\n cfg = json.dump(f)
- with open('c.json') as f:\n cfg = json.load(f) Correct answer.
- with open('c.json') as f:\n cfg = json.loads(f)
Explanation
json.load reads from a file-like object and parses the JSON into Python objects. It is the file-oriented counterpart of json.loads, which parses a string.
Question 45Python Programming for Network Automation
A list `hosts` is modified while a `for host in hosts:` loop iterates over it. What is the safest way to iterate while removing items?
- Sort the list before iterating
- Iterate over the original list and call remove inside
- Iterate over a copy, such as `for host in list(hosts):` Correct answer.
- Call hosts.pop() inside the loop
Explanation
Iterating over a copy decouples the iteration from mutations to the original list, avoiding skipped or duplicated elements. Removing from a list while iterating over it shifts indices and produces incorrect traversal.
Question 46Python Programming for Network Automation
Which expression returns the number of key-value pairs in the dictionary `d`?
- len(d) Correct answer.
- count(d)
- d.size()
- d.length
Explanation
The built-in function `len()` returns the number of items in a container, including the number of key-value pairs in a dictionary. Dictionaries do not have a `size()` or `length` attribute, and `count()` is not a built-in for this purpose.
Question 47Python Programming for Network Automation
What is the result of `'router1'.startswith('route')`?
- An error is raised
- False
- None
- True Correct answer.
Explanation
The `startswith()` method returns `True` if the string begins with the specified prefix. Since `'router1'` begins with `'route'`, the result is `True`.
Question 48Python Programming for Network Automation
Which code correctly opens a file for reading and ensures it is closed even if an exception occurs during processing?
- try:
f = open('log.txt')
data = f.read()
except:
pass
- f = open('log.txt')
try:
data = f.read()
finally:
f.close()
- with open('log.txt') as f:
data = f.read() Correct answer.
- f = open('log.txt')
data = f.read()
f.close()
Explanation
The `with` statement (context manager) guarantees that the file is closed when the block exits, even if an exception is raised. While a `try/finally` can also ensure closure, the `with` statement is the idiomatic and concise way to achieve this.
Question 49Python Programming for Network Automation
Given `d = {'a': 1, 'b': 2}`, which expression returns the value for key `'c'` if it exists, otherwise returns `0` without raising an exception?
- d.get('c', 0) Correct answer.
- d['c'] or 0
- d.fetch('c', 0)
- d['c']
Explanation
The `get()` method returns the value for a key if it exists, otherwise returns a default value (here `0`) without raising a `KeyError`. Direct indexing with `d['c']` raises `KeyError` if the key is missing.
Question 50Python Programming for Network Automation
A function is defined as `def configure(host, *commands):`. Which call correctly passes multiple command strings to the function?
- configure(host='r1', commands=['cmd1', 'cmd2'])
- configure('r1', commands='cmd1', 'cmd2')
- configure('r1', 'cmd1', 'cmd2') Correct answer.
- configure('r1', ['cmd1', 'cmd2'])
Explanation
The `*commands` parameter collects any number of positional arguments into a tuple. Passing additional positional arguments after the host, such as `'cmd1', 'cmd2'`, correctly populates `commands` with `('cmd1', 'cmd2')`.