Courseiva

CCNA Software Development and Design Questions

22 of 97 questions · Page 2/2 · Software Development and Design · Answers revealed

76
MCQeasy

A Python script uses the 'requests' library to make a POST request to create a new resource. Which HTTP status code indicates successful creation?

A.204 No Content
B.200 OK
C.301 Moved Permanently
D.201 Created
AnswerD

201 Created signals that the POST succeeded and a new resource now exists; the response typically includes a Location header pointing to its URL. This satisfies the stem's requirement for the status code indicating successful resource creation, unlike 200 or 204.

Why this answer

According to the REST API conventions, a successful POST request returns status code 201 Created.

77
Multi-Selecthard

Which THREE statements about RESTful APIs are true?

Select 3 answers
A.They require WebSockets for communication.
B.They use HTTP methods to perform CRUD operations.
C.They use SOAP as the message format.
D.They use stateless communication.
E.They expose resources via URLs.
AnswersB, D, E

REST maps CRUD semantics onto HTTP verbs: POST creates, GET reads, PUT or PATCH updates and DELETE removes. This satisfies the truth criterion because the uniform interface is a defining REST architectural constraint, not an implementation detail.

Why this answer

Option B is correct because RESTful APIs map CRUD operations to standard HTTP methods: POST for create, GET for read, PUT/PATCH for update, and DELETE for delete. Option D is correct because REST enforces stateless communication, meaning each request from client to server must contain all information needed to understand and process it, with no client session state stored on the server between requests. Option E is correct because REST exposes resources as identifiable URIs/URLs, and clients interact with those resources using the uniform HTTP interface.

Option A is not correct because REST does not require WebSockets; it typically uses HTTP request/response, and WebSockets are a separate full-duplex protocol used for different scenarios. Option C is not correct because REST is an architectural style that commonly uses JSON or XML over HTTP, not SOAP, which is a separate messaging protocol with its own envelope and WS-* standards.

Exam trap

Cisco often tests the misconception that REST requires WebSockets for real-time communication or that REST is tied to SOAP, when in fact REST is protocol-agnostic but typically uses HTTP, and SOAP is a distinct, heavier-weight alternative.

78
MCQmedium

A developer is designing a Python script that must authenticate to a Cisco Meraki API using an API key. The key should not be hardcoded in the script. Which method is most secure for managing the API key?

A.Prompt the user to enter the API key each time the script runs.
B.Hardcode the API key in the script but obfuscate it using Base64 encoding.
C.Use environment variables to pass the API key to the script.
D.Store the API key in a configuration file and read it at runtime.
AnswerC

Environment variables keep sensitive data out of the source code and configuration files, reducing the risk of accidental exposure. They can be set securely in the deployment environment and are easily managed by CI/CD systems. This is a widely recommended practice for secrets management in twelve-factor apps.

Why this answer

Using environment variables is a secure and standard way to manage secrets like API keys. It keeps them out of code and version control, and allows different environments to use different keys. The other options either store the key insecurely, use reversible obfuscation, or are impractical for automation.

Environment variables strike a balance between security and usability.

Exam trap

The trap here is thinking that obfuscation or config files are sufficient, but they can still leak secrets; environment variables are preferred for automation.

79
Multi-Selecthard

Which THREE of the following are benefits of using event-driven architecture in a distributed system? (Choose three.)

Select 3 answers
A.Loose coupling between services
B.Real-time data processing
C.Scalability through independent processing
D.Eliminates the need for message brokers
E.Simpler debugging due to synchronous communication
AnswersA, B, C

Event-driven architecture decouples producers from consumers through an asynchronous broker, so services publish events without knowing subscribers. This satisfies the loose coupling benefit: components interact via events rather than direct calls, allowing independent scaling, deployment and failure isolation without cascading dependencies across the distributed system.

Why this answer

Option A is correct because in event-driven architecture producers emit events without knowing which consumers will handle them, so services interact only through the event channel rather than direct API calls, achieving loose coupling. Option B is correct because events are published and consumed as they occur, enabling real-time data processing and immediate reaction to state changes rather than relying on periodic polling or batch jobs. Option C is correct because each consumer or event processor can be scaled independently and events can be distributed across multiple partitions or instances, providing scalability through independent processing.

Option D is not correct because event-driven systems typically depend on message brokers or event streaming platforms such as Kafka, RabbitMQ, or Amazon SNS/SQS to route, buffer, and deliver events. Option E is not correct because event-driven communication is inherently asynchronous, and debugging is generally more complex due to distributed tracing, eventual consistency, and the need to correlate events across services.

80
Multi-Selectmedium

Which TWO HTTP status codes indicate client errors?

Select 2 answers
A.500 Internal Server Error
B.404 Not Found
C.400 Bad Request
D.200 OK
E.201 Created
AnswersB, C

404 Not Found is a 4xx status code, the class reserved for client errors, indicating the requested resource does not exist on the server. It therefore qualifies as one of the two client-error codes the question requires.

Why this answer

Option B, 404 Not Found, is correct because it is a 4xx-class status code signaling that the client requested a resource the server cannot locate, which is by definition a client-side error. Option C, 400 Bad Request, is also correct because it is a 4xx status returned when the server cannot process the request due to malformed syntax, invalid framing, or deceptive routing sent by the client. The unmarked options do not belong: 500 Internal Server Error (A) is a 5xx server error indicating the server failed unexpectedly, while 200 OK (D) and 201 Created (E) are 2xx success codes confirming the request was received, understood, and processed (with 201 specifically indicating a new resource was created).

Exam trap

The trap is mixing up 4xx client errors with 5xx server errors — candidates often misclassify 500 as a client issue or forget that 2xx codes like 200 and 201 are successes, not errors.

81
MCQmedium

A developer is creating a Python function that must parse a JSON response from a Cisco DNA Center API. The function should handle cases where a key may be missing without crashing. Which approach best achieves this?

A.Convert the JSON response to a string and use regular expressions to extract values.
B.Use a try/except block around each key access to catch KeyError and assign a default.
C.Use response.json() and access keys directly with square brackets, relying on exception handling.
D.Use response.json().get('key', default_value) to retrieve values with a fallback.
AnswerD

The get() method on a dictionary returns the value for the specified key if it exists, and otherwise returns a provided default value. This avoids KeyError exceptions and allows the function to continue gracefully. It is the idiomatic Python way to handle optional keys in JSON responses, making the code robust and readable.

Why this answer

The get() method on a dictionary provides a safe way to access keys that may be absent, returning a default value instead of raising an exception. This is particularly useful when parsing JSON from APIs where fields are optional. The other options either rely on error-prone exception handling, are overly complex, or use inappropriate parsing techniques.

Using get() results in clean, robust code.

Exam trap

The trap here is assuming that direct key access with exception handling is equivalent to using get(), but get() is simpler and more readable for optional keys.

82
Multi-Selecteasy

A developer needs to create a Python script that makes a GET request to a REST API to retrieve a list of network devices. The API uses query parameters to filter by device type and status. Which TWO code snippets correctly include query parameters using the requests library? (Choose two.)

Select 2 answers
A.requests.get('https://api.example.com/devices', params={'type': 'router', 'status': 'active'})
B.requests.get('https://api.example.com/devices', data={'type': 'router', 'status': 'active'})
C.requests.get('https://api.example.com/devices?type=router&status=active')
D.requests.get('https://api.example.com/devices', json={'type': 'router', 'status': 'active'})
E.requests.get('https://api.example.com/devices', headers={'type': 'router', 'status': 'active'})
AnswersA, C

Passing a dictionary to the `params` argument lets the requests library serialise the key-value pairs into a properly URL-encoded query string, appending `?type=router&status=active` to the endpoint. This satisfies the stem's requirement to filter by device type and status without manual string concatenation or encoding errors.

Why this answer

Option A is correct because requests.get() accepts a params dictionary, which the requests library automatically URL-encodes and appends to the URL as query parameters (e.g., ?type=router&status=active). Option C is correct because the query parameters are already embedded directly in the URL string after the ? character, separated by &, which is the standard HTTP way to pass query parameters on a GET request. Option B is incorrect because the data parameter sends a form-encoded body, which is not used for GET query parameters and would not appear in the URL.

Option D is incorrect because the json parameter serializes the dictionary into a JSON request body, not query parameters. Option E is incorrect because the headers parameter sets HTTP request headers, not URL query parameters.

83
MCQmedium

A network automation script uses the requests library to retrieve device information from a REST API. The API requires authentication via a bearer token. Which code example correctly sets the Authorization header?

A.headers = {'Authorization': 'Token ' + token}\nresponse = requests.get(url, headers=headers)
B.response = requests.get(url, headers={'Authorization': token})
C.headers = {'Authorization': 'Bearer ' + token}\nresponse = requests.get(url, headers=headers)
D.response = requests.get(url, auth=('Bearer', token))
AnswerC

The Authorization header must carry the literal scheme 'Bearer' followed by a space and the token value. Concatenating 'Bearer ' with the token and passing the dictionary via the headers parameter sets this correctly for the authenticated GET request.

Why this answer

It constructs the Authorization header using the 'Bearer' scheme, which is the standard method for passing OAuth 2.0 bearer tokens in HTTP requests. The requests library requires the header to be explicitly set as a dictionary, and the token must be prefixed with 'Bearer ' to comply with RFC 6750.

Exam trap

Cisco often tests the distinction between the 'Bearer' scheme and other authentication methods, and the trap here is that candidates confuse the auth parameter (which only supports Basic/Digest) with the need to manually set the Authorization header for bearer tokens.

How to eliminate wrong answers

Option A is wrong because it uses 'Token ' as the scheme prefix instead of 'Bearer ', which is the correct scheme for bearer tokens per OAuth 2.0 (RFC 6750). Option B is wrong because it passes only the token value without any scheme prefix, which will cause the API to reject the request as malformed. Option D is wrong because the requests library's auth parameter expects a tuple of (username, password) for Basic authentication, not a bearer token scheme.

84
MCQhard

A developer is writing a Python script that processes a large CSV file. The script uses 'with open(file, 'r') as f' to read the file. Why is this approach preferred over calling f = open(file) and then f.close()?

A.It automatically closes the file when the block exits, even if an exception is raised.
B.It allows the file to be opened in both read and write mode simultaneously.
C.It reduces memory usage by loading the file in chunks.
D.It increases the speed of file operations.
AnswerA

The with statement invokes the file object's context manager protocol, guaranteeing __exit__ runs and closes the file when the block exits, including when an exception propagates. This prevents file descriptor leaks that manual open and close calls risk if an error occurs before close executes.

Why this answer

The 'with' statement in Python implements a context manager that automatically calls the file object's __exit__ method when the block exits, ensuring the file is closed even if an exception occurs. This prevents resource leaks and is the recommended pattern for file I/O in Python, as explicitly calling f.close() may be skipped if an exception is raised before the close call.

Exam trap

Cisco often tests the distinction between a language feature (context managers) and unrelated performance or mode characteristics, so candidates may incorrectly associate 'with' with speed or chunking rather than its core purpose of guaranteed cleanup.

How to eliminate wrong answers

Option B is wrong because the 'with open(file, 'r')' opens the file in read-only mode, not both read and write simultaneously; to open in both modes you would use 'r+' or 'w+'. Option C is wrong because the 'with' statement does not inherently load the file in chunks; memory usage depends on how the file is read (e.g., using f.read() vs iterating line by line), not on the context manager itself. Option D is wrong because the 'with' statement does not increase the speed of file operations; it provides deterministic cleanup but does not affect I/O performance.

85
MCQhard

A developer is designing a Python class to model a network device. The class should prevent direct modification of the device's IP address after it is set, while still allowing the address to be read. Which implementation achieves this encapsulation requirement?

A.Define the IP address as a public attribute named ip_address.
B.Define the IP address as a private attribute named __ip_address and provide only a getter method.
C.Define the IP address as a protected attribute named _ip_address and document that it should not be changed.
D.Define the IP address as a class variable shared by all instances.
AnswerB

Prefixing the attribute with double underscores triggers name mangling, making it harder to access directly from outside the class. Providing only a getter method allows reading the address while omitting a setter prevents direct modification. This satisfies the encapsulation requirement of read-only access after initialization.

Why this answer

Using a double-underscore prefix triggers name mangling, which discourages direct external access, and exposing only a getter method allows reading the address without providing a way to change it. A public attribute, a single-underscore convention, or a class variable all permit modification or do not represent per-instance state, so they fail the encapsulation requirement.

Exam trap

The trap here is assuming that a single underscore provides real protection, when it is only a naming convention that Python does not enforce.

86
MCQmedium

A developer is writing a Python unit test for a function that parses interface status from a network device. The function raises a custom exception called InterfaceDownError when an interface is administratively down. Which unittest assertion correctly verifies that calling parse_interface('down') raises InterfaceDownError?

A.self.assertTrue(parse_interface('down') == InterfaceDownError)
B.self.assertEqual(parse_interface, 'down')
C.self.assertRaises(InterfaceDownError, parse_interface, 'down')
D.self.assertIsInstance(parse_interface, InterfaceDownError)
AnswerC

assertRaises accepts an exception class, a callable, and any arguments to pass to that callable. It invokes parse_interface('down') and passes the test only if InterfaceDownError is raised. This is the correct unittest idiom for verifying that a specific exception occurs under the given scenario.

Why this answer

The unittest framework provides assertRaises specifically for verifying that a callable raises a particular exception when invoked with given arguments. It calls parse_interface('down') and succeeds only if InterfaceDownError is raised. The other assertions either compare values, invoke the function outside an exception context, or check types incorrectly, so they do not validate the exception behavior.

Exam trap

The trap here is calling the function directly inside an assertion that is not designed to catch exceptions, which causes a test error instead of a clean pass or fail.

87
Multi-Selectmedium

Which TWO statements about the MVC pattern are correct? (Choose two.)

Select 2 answers
A.Model is dependent on the View.
B.Controller handles user input and updates the Model.
C.View displays data from the Model.
D.Model represents the user interface.
E.View directly modifies the Model.
AnswersB, C

In MVC, the controller receives user input, interprets it, and invokes the appropriate model operations, so the model's state changes accordingly. This directly satisfies the stem's requirement that the controller handles input and updates the model, distinguishing it from the view, which only renders output.

Why this answer

Option B is correct because in MVC the Controller is the component that receives and interprets user input (e.g., HTTP requests or UI events) and then invokes the appropriate operations on the Model to change application state. Option C is correct because the View is responsible for rendering/presenting the Model's data to the user, typically reading from the Model (or a ViewModel) without containing business logic. Option A is incorrect because the Model must not depend on the View; dependencies flow from View/Controller toward the Model, not the reverse.

Option D is incorrect because the Model represents application data and business rules, not the user interface. Option E is incorrect because the View should not directly modify the Model; modifications go through the Controller to preserve separation of concerns.

Exam trap

200-901 often tests the direction of dependencies in MVC — candidates frequently assume the Model depends on the View or that the View can modify the Model directly, which inverts the intended decoupling.

88
MCQeasy

Which data structure in Python would be most appropriate for storing a collection of unique items and performing fast membership tests?

A.Tuple
B.Set
C.List
D.Dictionary
AnswerB

A set stores only unique elements using hashing, giving average O(1) membership testing via the in operator and automatic duplicate elimination. Lists allow duplicates and require O(n) scans, making them unsuitable for fast uniqueness checks on large collections.

Why this answer

A set is the correct choice because it is implemented as a hash table in Python, which provides O(1) average-time complexity for membership tests using the `in` operator. Sets automatically enforce uniqueness, meaning duplicate items are not allowed, making them ideal for storing a collection of distinct elements. This directly matches the requirement for fast membership testing and uniqueness.

Exam trap

Cisco often tests the misconception that a dictionary is the best choice for fast membership tests because it also uses hashing, but the trap is that the question specifically asks for a collection of unique items, not key-value pairs, making a set the more precise and appropriate data structure.

How to eliminate wrong answers

Option A is wrong because a tuple is an immutable ordered sequence that allows duplicates and requires O(n) linear search for membership tests, making it unsuitable for fast lookups. Option C is wrong because a list is an ordered mutable sequence that also allows duplicates and requires O(n) linear search for membership tests, failing both the uniqueness and speed requirements. Option D is wrong because while a dictionary provides O(1) membership tests on its keys, it stores key-value pairs rather than just unique items, making it overkill and semantically incorrect for a simple collection of unique items.

89
MCQhard

A developer is building a Python client that calls a REST API returning JSON. The client must detect authentication failures, rate limiting, and server errors so it can retry or alert appropriately. Which coding practice should be applied?

A.Call response.json() immediately after every request and catch only json.JSONDecodeError, since valid JSON indicates success.
B.Set a long socket timeout and retry indefinitely on any exception until the request succeeds.
C.Wrap every request in a bare try/except that logs the exception and returns an empty list so the caller never fails.
D.Inspect the response status code and branch on categories such as 401/403 for authentication, 429 for rate limiting, and 5xx for server errors before processing the body.
AnswerD

HTTP status codes are the contract for request outcomes, so checking them first lets the client distinguish an expired token from throttling from an upstream fault. The client can then retry 429 responses with backoff, alert on persistent 5xx errors, and refresh credentials on 401. Reading the body only after confirming success avoids misinterpreting error payloads as data.

Why this answer

HTTP status codes carry the outcome of each request, so a robust client branches on them: refresh credentials on 401, respect Retry-After and back off on 429, and alert on 5xx. Parsing the body is meaningful only after the status indicates success. This ordering lets the client retry the conditions that are transient and escalate the ones that are not.

Exam trap

The trap here is treating a successful JSON parse as proof of success, when error responses such as 401 or 429 often return well-formed JSON bodies too.

90
MCQeasy

A developer is reviewing a Python script that makes a REST API call using the requests library. The script must set a custom HTTP header 'X-Auth-Token' with a value from an environment variable. Which code snippet correctly adds this header to the request?

A.requests.get(url, auth=('X-Auth-Token', os.environ['TOKEN']))
B.requests.get(url, params={'X-Auth-Token': os.environ['TOKEN']})
C.requests.get(url, headers={'X-Auth-Token': os.environ['TOKEN']})
D.requests.get(url, data={'X-Auth-Token': os.environ['TOKEN']})
AnswerC

This snippet passes the headers parameter as a dictionary, which is the correct way to set custom HTTP headers in the requests library. It reads the token from the environment variable TOKEN, satisfying the requirement without hardcoding secrets, and uses the standard get method with the url.

Why this answer

The requests library accepts a headers parameter as a dictionary to set custom HTTP headers. Passing {'X-Auth-Token': os.environ['TOKEN']} correctly adds the token header while keeping the secret out of source code. The auth parameter is for basic authentication, params adds query strings, and data sets the request body, none of which fulfill the need for a custom header.

Exam trap

The trap here is confusing the auth parameter, which is for HTTP Basic Authentication, with the headers parameter, which is used for arbitrary custom headers like API tokens.

91
MCQeasy

A Python script uses a dictionary to store device configuration parameters. Which key, if any, will raise a KeyError if it does not exist in the dictionary?

A.config.setdefault('timeout', 30)
B.config['timeout']
C.config.get('timeout')
D.config.pop('timeout', None)
AnswerB

Subscript access on a dictionary raises KeyError when the requested key is absent; config['timeout'] therefore fails if 'timeout' was never inserted. The .get() method instead returns None, so bracket notation is the construct that satisfies the KeyError condition.

Why this answer

Using square bracket notation (config['timeout']) on a dictionary will raise a KeyError if the specified key does not exist. This is a fundamental behavior of Python dictionaries: direct key access without a fallback mechanism throws an exception when the key is missing.

Exam trap

Cisco often tests the distinction between direct dictionary access (which raises KeyError) and safe access methods like .get(), .setdefault(), and .pop() with defaults, trapping candidates who assume all dictionary access methods behave identically.

How to eliminate wrong answers

Option A is wrong because dict.setdefault('timeout', 30) does not raise a KeyError; if the key 'timeout' does not exist, it inserts the key with the default value 30 and returns that value. Option C is wrong because dict.get('timeout') returns None (or a user-specified default) if the key is missing, never raising a KeyError. Option D is wrong because dict.pop('timeout', None) removes the key if it exists and returns its value; if the key does not exist, it returns the default value None without raising an error.

92
MCQhard

In the MVC (Model-View-Controller) pattern, which component is responsible for handling user input and updating the model?

A.Controller
B.Model
C.Router
D.View
AnswerA

The Controller receives user input, translates it into operations, and invokes the Model to update state, satisfying the stem's requirement for input handling plus model updating. The View only renders output, and the Model holds data and business logic, so neither performs the input-driven update role.

Why this answer

In the MVC pattern, the Controller is the component that receives user input (e.g., HTTP requests, button clicks) and translates it into commands that update the Model. It acts as the intermediary between the View and the Model, ensuring that user actions trigger appropriate changes in the application's data layer.

Exam trap

Cisco often tests the misconception that the Router is part of the MVC pattern, but in reality, the Router is a separate component used for URL dispatch, not for handling user input or updating the Model.

How to eliminate wrong answers

Option B is wrong because the Model is responsible for managing the application's data, business logic, and rules, not for handling user input directly. Option C is wrong because the Router is a component used in web frameworks (e.g., Express.js, Django) to map URLs to controllers, but it is not part of the core MVC pattern and does not handle user input or update the Model. Option D is wrong because the View is responsible for presenting data to the user and rendering the UI, not for processing user input or modifying the Model.

93
Multi-Selecthard

A developer is writing unit tests for a Python module that parses show command output from network devices. The tests must be deterministic and must not depend on real devices or the network. Which TWO practices should the developer apply? (Choose two.)

Select 2 answers
A.Use unittest.mock to replace the function that opens an SSH connection to the device with a stub that returns captured output.
B.Run the test suite against a production router to confirm the parser handles real output.
C.Run tests only in a lab environment where devices are always powered on and reachable.
D.Store expected device output in fixture files and assert that the parser produces the expected structured result.
E.Add time.sleep calls between assertions to allow the device to respond before checking results.
AnswersA, D

Mocking the SSH connection function isolates the parser from the network and returns fixed captured output, making tests deterministic and fast. This directly satisfies the requirement that tests not depend on real devices, and it lets the developer assert parsing behavior against known input without any live infrastructure.

Why this answer

Deterministic, device-independent parsing tests come from replacing live I/O with controlled substitutes and asserting against known data. Mocking the SSH layer removes network dependency, while fixture files supply stable input and expected results. Together these practices make the unit tests repeatable and safe to run in CI without any real routers or switches.

Exam trap

The trap here is equating a reliable lab with isolation, when any real device still makes tests non-deterministic and network-dependent.

94
MCQmedium

A developer needs to create a Python function that accepts any number of keyword arguments and prints them. Which function definition correctly uses **kwargs?

A.def print_args(*args): print(args)
B.def print_args(kwargs): print(kwargs)
C.def print_args(**kwargs): print(kwargs)
D.def print_args(*kwargs): print(kwargs)
AnswerC

The **kwargs syntax collects arbitrary keyword arguments into a dictionary named kwargs, which print then outputs. This satisfies the requirement to accept any number of keyword arguments, unlike *args, which gathers positional arguments into a tuple instead.

Why this answer

The **kwargs syntax in a Python function definition collects any number of keyword arguments into a dictionary. The function then prints that dictionary, which matches the requirement to accept and print any number of keyword arguments.

Exam trap

Cisco often tests the distinction between *args (positional arguments) and **kwargs (keyword arguments), and the trap here is that candidates confuse the single asterisk (*) for collecting keyword arguments instead of the double asterisk (**).

How to eliminate wrong answers

Option A is wrong because *args collects positional arguments into a tuple, not keyword arguments. Option B is wrong because it defines a single parameter named 'kwargs' that expects a single positional argument, not any number of keyword arguments. Option D is wrong because *kwargs uses the single-asterisk syntax, which collects positional arguments into a tuple, not keyword arguments into a dictionary.

95
MCQhard

In a microservices architecture, which of the following is a primary advantage over a monolithic architecture?

A.Easier end-to-end testing
B.Lower operational overhead
C.Simpler inter-service communication
D.Independent deployability and scaling of services
AnswerD

Microservices communicate through versioned APIs, so each service can be built, deployed and scaled on its own hardware footprint without redeploying the whole application. This satisfies the stem's advantage criterion, unlike a monolith, where any change requires rebuilding and redeploying one coupled artefact.

Why this answer

Microservices decompose an application into independently deployable services, each owning its own lifecycle. This enables teams to deploy, scale, and update services independently without redeploying the entire application, which is the primary advantage over a monolith. Independent deployability and scaling directly improve agility and fault isolation.

Exam trap

The trap is assuming microservices simplify operations and testing; in reality they trade monolithic simplicity for independent deployability and scaling, at the cost of added operational complexity.

How to eliminate wrong answers

Option A is wrong because end-to-end testing is generally harder in microservices — you must coordinate multiple services, contracts, and network calls, unlike a monolith where everything runs in one process. Option B is wrong because operational overhead typically increases with microservices due to more services, containers, orchestration, monitoring, and networking complexity. Option C is wrong because inter-service communication becomes more complex, requiring APIs, service discovery, retries, and handling partial failures — not simpler than in-process calls in a monolith.

96
MCQeasy

A developer is using Git to manage a project. They need to temporarily save changes that are not ready to be committed so they can switch to another branch. Which Git command should they use?

A.git commit -m 'WIP'
B.git reset --hard
C.git stash
D.git branch new-branch
AnswerC

git stash temporarily shelves changes in the working directory, allowing the developer to switch branches without committing incomplete work. It saves both staged and unstaged changes, and they can be reapplied later with git stash pop or git stash apply. This is ideal for quickly switching context without losing progress.

Why this answer

git stash is designed to temporarily save uncommitted changes, allowing a clean working directory to switch branches or perform other operations. It preserves the changes for later retrieval. The other commands either discard changes, create permanent commits, or do not save changes at all, making them unsuitable for this scenario.

Exam trap

The trap here is confusing temporary storage with committing or discarding changes; git stash is specifically for shelving work-in-progress.

97
MCQhard

Given the Python list comprehension: result = [x*2 for x in range(10) if x > 5] What is the value of result?

A.[12, 14, 16, 18]
B.[0, 2, 4, 6, 8, 10, 12, 14, 16, 18]
C.[10, 12, 14, 16, 18]
D.[6, 7, 8, 9]
AnswerA

The filter x > 5 restricts iteration to 6, 7, 8 and 9, since range(10) stops before 10. Doubling each yields 12, 14, 16 and 18, so the comprehension produces exactly that four-element list in ascending order.

Why this answer

The list comprehension `[x*2 for x in range(10) if x > 5]` iterates over `x` from 0 to 9, filters to only include `x` values greater than 5 (i.e., 6, 7, 8, 9), and multiplies each by 2, producing `[12, 14, 16, 18]`. This is a standard Python comprehension with a conditional filter.

Exam trap

The trap here is that candidates often forget the filter condition and include all values, or they mistakenly apply the multiplication to the filtered indices rather than the values, leading to options like C or D.

How to eliminate wrong answers

Option B is wrong because it includes all numbers from 0 to 9 multiplied by 2, which would result from omitting the `if x > 5` filter. Option C is wrong because it incorrectly includes 10 (from x=5), but the condition `x > 5` excludes 5, so 5*2=10 should not be present. Option D is wrong because it lists the unfiltered x values (6,7,8,9) instead of the doubled results, confusing the iteration variable with the output expression.

← PreviousPage 2 of 2 · 97 questions total

Ready to test yourself?

Try a timed practice session using only Software Development and Design questions.