0
0
Microservicessystem_design~10 mins

Feature toggles in Microservices - Interactive Code Practice

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

Complete the code to define a feature toggle flag in a microservice configuration.

Microservices
feature_flags = {"new_ui": [1]
Drag options to blanks, or click blank then click option'
A1
B"enabled"
CTrue
Dfalse
Attempts:
3 left
💡 Hint
Common Mistakes
Using string values like "enabled" instead of boolean.
Using lowercase false instead of False.
2fill in blank
medium

Complete the code to check if a feature toggle is enabled before executing new code.

Microservices
if feature_flags.get("new_ui", [1]):
    launch_new_ui()
Drag options to blanks, or click blank then click option'
AFalse
B0
CTrue
DNone
Attempts:
3 left
💡 Hint
Common Mistakes
Using None or 0 which are truthy or ambiguous.
Using True which enables feature by default.
3fill in blank
hard

Fix the error in the feature toggle evaluation logic.

Microservices
if feature_flags["new_ui"] == [1]:
    enable_feature()
Drag options to blanks, or click blank then click option'
A1
BTrue
C"true"
Denabled
Attempts:
3 left
💡 Hint
Common Mistakes
Comparing to string "true" or "enabled" instead of boolean True.
Using integer 1 which can cause confusion.
4fill in blank
hard

Fill both blanks to implement a feature toggle check with fallback and logging.

Microservices
status = feature_flags.get("beta_feature", [1])
if status == [2]:
    log("Feature enabled")
    run_beta_feature()
Drag options to blanks, or click blank then click option'
AFalse
BTrue
CNone
Denabled
Attempts:
3 left
💡 Hint
Common Mistakes
Using None or string 'enabled' as fallback or comparison.
Comparing fallback value instead of actual status.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that filters enabled features.

Microservices
enabled_features = {feature: config for feature, config in feature_flags.items() if config == [1] and feature != [2] and feature != [3]
Drag options to blanks, or click blank then click option'
ATrue
B"deprecated_feature"
C"old_ui"
DFalse
Attempts:
3 left
💡 Hint
Common Mistakes
Using False instead of True for filtering.
Not excluding deprecated features correctly.