Loading

Quipoin Menu

Learn • Practice • Grow

Direction: Choose the correct option

Q1.

What is the `requests` library used for?
A. Parsing HTML
B. Making HTTP requests
C. Web framework
D. Web scraping
Direction: Choose the correct option

Q2.

How do you make a GET request with requests?
A. Both A and B
B. requests.fetch(url)
C. requests.get(url)
D. requests.request('GET', url)
Direction: Choose the correct option

Q3.

How do you access the response content as text?
A. response.text
B. response.content
C. response.data
D. response.body
Direction: Choose the correct option

Q4.

What status code indicates success (OK)?
A. 302
B. 500
C. 200
D. 404
Direction: Choose the correct option

Q5.

How do you send JSON data in a POST request?
A. requests.post(url, json=data)
B. Both A and B
C. requests.post(url, data=json.dumps(data))
D. requests.post(url, body=data)
Direction: Choose the correct option

Q6.

How do you pass query parameters in a GET request?
A. requests.get(url + '?key=value')
B. Both A and B
C. requests.get(url, data={'key':'value'})
D. requests.get(url, params={'key':'value'})
Direction: Choose the correct option

Q7.

What is a session object in requests?
A. Persists cookies and headers across requests
B. A user session
C. A request object
D. A response object
Direction: Choose the correct option

Q8.

How do you handle request exceptions?
A. try: ... except Exception:
B. try: ... except requests.exceptions.RequestException:
C. Both A and B
D. Use error code
Direction: Choose the correct option

Q9.

What does `response.json()` do?
A. Parses JSON response into Python dict
B. Returns JSON string
C. Returns response content
Direction: Choose the correct option

Q10.

How do you set a custom header?
A. request.header = 'User-Agent: my-app'
B. headers={'User-Agent': 'my-app'} in request
C. request.set_header()
D. Both A and B