0
0
Rest APIprogramming~10 mins

Query parameter versioning in Rest API - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to extract the API version from the query parameter.

Rest API
version = request.args.get('[1]')
Drag options to blanks, or click blank then click option'
Aversion
Bapi_version
Cv
Dver
Attempts:
3 left
💡 Hint
Common Mistakes
Using a key that is not present in the query parameters.
Using a key that is too long or uncommon.
2fill in blank
medium

Complete the code to check if the version parameter equals '1'.

Rest API
if version [1] '1':
Drag options to blanks, or click blank then click option'
A<
B==
C>
D!=
Attempts:
3 left
💡 Hint
Common Mistakes
Using assignment operator = instead of comparison.
Using inequality operator != by mistake.
3fill in blank
hard

Fix the error in the code to return a JSON response with the version.

Rest API
return jsonify({'version': [1])
Drag options to blanks, or click blank then click option'
Arequest.args.get('version')
Bversion()
Cversion
D'version'
Attempts:
3 left
💡 Hint
Common Mistakes
Using version() which causes an error because version is not a function.
Using a string literal 'version' instead of the variable.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps endpoints to their versions if version is greater than '1'.

Rest API
versions = {endpoint: [1] for endpoint, [2] in endpoints.items() if version > '1'}
Drag options to blanks, or click blank then click option'
Aversion
Bver
Attempts:
3 left
💡 Hint
Common Mistakes
Using inconsistent variable names for the value in the comprehension.
Using a variable name not defined in the loop.
5fill in blank
hard

Fill both blanks to filter endpoints with version '2' and create a dictionary with uppercase keys.

Rest API
filtered = {endpoint.[1](): version for endpoint, version in endpoints.items() if version [2] '2'}
Drag options to blanks, or click blank then click option'
A{
Bupper
C==
D[
Attempts:
3 left
💡 Hint
Common Mistakes
Starting comprehension with square brackets instead of curly braces.
Using wrong comparison operator for filtering.