Bird
0
0

Given this Python HTTP function code snippet, what will be the HTTP status code returned when a request is made?

medium📝 Predict Output Q4 of 15
GCP - Cloud Functions
Given this Python HTTP function code snippet, what will be the HTTP status code returned when a request is made?
def hello_world(request):
    return ('Hello, World!', 200)
A302
B200
C500
D404
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the return statement

    The function returns a tuple with a string and the status code 200.
  2. Step 2: Understand HTTP response format

    Returning ('Hello, World!', 200) sets the HTTP status code to 200.
  3. Final Answer:

    200 -> Option B
  4. Quick Check:

    Return tuple with 200 = HTTP status 200 [OK]
Quick Trick: Return tuple with status code sets HTTP response code [OK]
Common Mistakes:
  • Ignoring the status code in the return tuple
  • Assuming default status code 404
  • Confusing string return with status code

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GCP Quizzes