Quiz: IT Fundamentals Module 04: APIs and Programming Basics (Module 04 of 06)
Test your understanding of the concepts covered in this module.
50 questions
- 1
Which of the following best describes what an API (Application Programming Interface) is?
- 2
True or False: REST APIs use standard HTTP methods such as GET, POST, PUT, and DELETE to perform actions on resources.
- 3
Which HTTP method is used to retrieve data from a REST API without modifying anything on the server?
- 4
In your own words, explain what a REST API endpoint is and give an example of what one might look like.
This is a free-response question. Write your answer, then click “Show Answer” to compare.
- 5
A developer sends a request to `https://api.example.com/products/42`. In REST API terminology, what does `/products/42` represent?
- 6
Which HTTP method would you use to create a new user account through a REST API?
- 7
True or False: The HTTP PUT method is typically used to update an existing resource on the server.
- 8
Which of the following is valid JSON?
- 9
In JSON, which of the following are valid value types? (Select THREE.)Select multiple
- 10
What is wrong with the following JSON? ```json { "name": "Bob", "age": 30, "active": true, } ```
- 11
Which of the following correctly represents a JSON array?
- 12
True or False: In JSON, keys must always be strings enclosed in double quotes.
- 13
Given the following JSON, what is the value of `"city"`? ```json { "name": "Alice", "address": { "city": "Seattle", "state": "WA" } } ```
- 14
What is the purpose of an API key?
- 15
True or False: An API key should be kept secret and never shared publicly in your code or version control.
- 16
Which of the following best describes an authentication token (such as a bearer token) in the context of APIs?
- 17
A developer receives an HTTP `401 Unauthorized` response from an API. What is the most likely cause?
- 18
Which HTTP status code range indicates that the request was successful?
- 19
A REST API returns a `404 Not Found` status code. What does this mean?
- 20
In your own words, explain the difference between an API key and an authentication token.
This is a free-response question. Write your answer, then click “Show Answer” to compare.
- 21
What is a variable in programming?
- 22
Which of the following Python code correctly assigns the string `"hello"` to a variable named `greeting`?
- 23
Match each value to its data type: | Value | Data Type | |-------|-----------| | `"Seattle"` | _______ | | `42` | _______ | | `3.14` | _______ | | `True` | _______ | | `["a", "b", "c"]` | _______ | Choose from: String, Integer, Float, Boolean, List/Array
This is a free-response question. Write your answer, then click “Show Answer” to compare.
- 24
True or False: In Python, the boolean value `True` must be capitalized (uppercase T), while in JavaScript it is written as `true` (lowercase t).
- 25
Which of the following is a dictionary (key-value pair collection) in Python?
- 26
What is a function in programming?
- 27
What will the following Python function return when called with `calculate_total(5, 3)`? ```python def calculate_total(price, quantity): return price * quantity ```
- 28
True or False: A function can accept inputs (called parameters or arguments) and return an output value.
- 29
Which of the following correctly defines a function in Python that takes two parameters?
- 30
In JavaScript, which of the following correctly defines a function?
- 31
What does the following Python code print? ```python temperature = 75 if temperature > 80: print("Hot") elif temperature > 60: print("Warm") else: print("Cool") ```
- 32
True or False: In an if/elif/else chain, only the first branch whose condition is true will execute; the remaining branches are skipped.
- 33
What will the following JavaScript code output? ```javascript let score = 85; if (score >= 90) { console.log("A"); } else if (score >= 80) { console.log("B"); } else { console.log("C"); } ```
- 34
Which of the following best describes the purpose of an `else` block in a conditional statement?
- 35
How many times will the following Python loop print a message? ```python fruits = ["apple", "banana", "cherry"] for fruit in fruits: print(fruit) ```
- 36
What is the key difference between a `for` loop and a `while` loop?
- 37
What will the following Python code print? ```python count = 0 while count < 3: print(count) count = count + 1 ```
- 38
True or False: If the condition in a `while` loop never becomes false, the loop will run indefinitely (an infinite loop).
- 39
What will the following JavaScript code output? ```javascript for (let i = 0; i < 4; i++) { console.log(i); } ```
- 40
In Python, what does the `len()` function do when called on a list?
- 41
Which of the following Python code snippets correctly loops through a dictionary and prints each key?
- 42
A developer is reading API documentation and sees the following endpoint description: ``` GET /api/v1/users/{id} ``` What does `{id}` represent?
- 43
True or False: Good API documentation typically includes the available endpoints, required parameters, expected response format, and authentication requirements.
- 44
A REST API documentation page shows the following: ``` POST /api/v1/orders Content-Type: application/json Authorization: Bearer <token> { "product_id": 101, "quantity": 2 } ``` Which of the following statements are true about this request? (Select TWO.)Select multiple
- 45
What does the `Content-Type: application/json` header tell the server?
- 46
In your own words, describe what happens when a program makes a REST API call and receives a JSON response. Include the role of the HTTP method, the endpoint, and the response format.
This is a free-response question. Write your answer, then click “Show Answer” to compare.
- 47
What will the following Python code print? ```python data = {"name": "Alice", "scores": [90, 85, 92]} print(data["scores"][1]) ```
- 48
Which of the following is NOT a common HTTP method used in REST APIs?
- 49
A developer writes the following Python code. What will it print? ```python numbers = [10, 20, 30, 40, 50] total = 0 for num in numbers: total = total + num print(total) ```
- 50
True or False: JSON and Python dictionaries look similar, but JSON is a text-based data format used for exchanging data between systems, while a Python dictionary is a data structure that exists in memory during program execution.