Complete the code to check if the HTTP request method is GET.
if request.method == '[1]': print("This is a GET request")
The HTTP method to retrieve data is GET. Checking if request.method equals 'GET' confirms the request type.
Complete the code to assert the HTTP response status code is 404 (Not Found).
assert response.status_code == [1]The status code 404 means the requested resource was not found. The assertion checks if the response matches this expected status.
Fix the error in the code that checks if the request method is POST.
if request.method == '[1]': process_post_request()
The HTTP method names are case-sensitive and must be uppercase. Using 'POST' ensures the condition works correctly.
Fill both blanks to create a dictionary comprehension that maps status codes to their meaning for codes greater than 399.
error_codes = {code: messages[code] for code in codes if code [1] 399 and code [2] 600}The comprehension filters codes greater than 399 and less than 600, which are client and server error codes.
Fill both blanks to create a dictionary comprehension that maps uppercase HTTP methods to their success status codes greater or equal to 200.
success_status = {method: code for method, code in method_codes.items() if code [1] 200 and method[2].isupper()}The comprehension keeps methods as keys (no change), filters codes >= 200, and checks if method names are uppercase using .upper().