ExamGecko
Question list
Search
Search

List of questions

Search

Related questions











Question 386 - PT0-002 discussion

Report
Export

Which of the following would be the most efficient way to write a Python script that interacts with a web application?

A.
Create a class for requests.
Answers
A.
Create a class for requests.
B.
Write a function for requests.
Answers
B.
Write a function for requests.
C.
Import the requests library.
Answers
C.
Import the requests library.
D.
Use the cURL OS command.
Answers
D.
Use the cURL OS command.
Suggested answer: C

Explanation:

The most efficient way to write a Python script that interacts with web applications is to import the requests library. The requests library is a Python HTTP library that simplifies making HTTP requests to web servers, which is essential for interacting with web applications. It allows you to easily send HTTP/1.1 requests, without the need for manually adding query strings to your URLs, or form-encode your POST data. Options A and B involve creating a class or function for requests, which could be more time-consuming and less efficient than using a well-established library like requests. Option D, using the cURL OS command, is less efficient in a Python script since it involves calling an external command rather than using a native Python library.

asked 02/10/2024
Martin Ng
43 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first