Select the true statements about the following invocation: (Select two answers.)
Correct Answer: A,D
Explanation It addresses a service deployed at localhost (the host where the code is run). This statement is true because localhost is a special hostname that refers to the local machine or the current host where the code is run. It is equivalent to using the IP address 127.0.0.1, which is the loopback address of the network interface. By using localhost as the hostname, the invocation addresses a service that is deployed on the same machine as the client. It addresses a service listening at port 3000. This statement is true because port 3000 is the part of the URL that follows the colon after the hostname. It specifies the port number where the service is listening for incoming requests. A port number is a 16-bit integer that identifies a specific process or application on a host. By using port 3000, the invocation addresses a service that is listening at that port. It addresses a service whose timeout is set to 3000 ms. This statement is false because timeout is not a part of the URL, but a parameter that can be passed to the requests.get () function in Python. Timeout specifies how long to wait for the server to send data before giving up. It is measured in seconds, not milliseconds. By using timeout=3, the invocation sets the timeout to 3 seconds, not 3000 ms. It addresses a service located at the following address local.host.com. This statement is false because local.host.com is not the same as localhost. Local.host.com is a fully qualified domain name (FQDN) that consists of three parts: local, host, and com. It requires DNS resolution to map it to an IP address. Localhost, on the other hand, is a special hostname that does not require DNS resolution and always maps to 127.0.0.1. By using localhost as the hostname, the invocation does not address a service located at local.host.com. References: https://docs.python.org/3/library/requests.html : https://en.wikipedia.org/wiki/Localhost : https://en.wikipedia.org/wiki/Port_(computer_networking) : https://en.wikipedia.org/wiki/Fully_qualified_domain_name
Question 12
Look at the following code snippets and decide which ones follow PEP 8 recommendations for whitespacesin expressions and statements(Select two answers.)
Correct Answer: A,C
Explanation Option A is true because PEP 8 recommends avoiding extraneous whitespace immediately inside parentheses, brackets or braces 1. Option C is true because PEP 8 recommends avoiding extraneous whitespace between a trailing comma and a following close parenthesis 1.
Question 13
Which sentence about the property decorator is false?
Correct Answer: A
Explanation The @property decorator should be defined after the method that is responsible for setting an encapsulated attribute is a false sentence. In fact, the @property decorator should be defined before the method that is used to set the attribute value. The @property decorator and the setter and deleter methods work together to create an encapsulated attribute, which is used to provide control over the attribute's value.
Question 14
Which of the following will set the button text's font to 12 point italics Anal? (Select two answers)
Correct Answer: B,C
Explanation Option B is correct because it sets the font option of the button to a tuple containing the font family ('Arial'), size (12), and style ('italic'). Option C is correct because it sets the font option of the button to a string containing the font family ('Arial'), size (12), and style ('italic') separated by spaces.
Question 15
Which of the following values can be returnedby the messagebox. askquestion () method?
Correct Answer: C
Explanation The messagebox.askquestion() method in Python's tkinter library displays a message box with a specified question and two response buttons labeled "Yes" and "No". It returns a string indicating which button was selected - either "yes" or "no". This function is used to ask questions to the user that have only two options: YES or NO. It can be used to ask the user if they want to continue or if they want to submit something 1.