Bird
0
0
LLDsystem_design~10 mins

Emergency handling in LLD - 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 basic emergency handler function.

LLD
def handle_emergency(event):
    if event == [1]:
        print("Alert: Fire detected!")
Drag options to blanks, or click blank then click option'
A"flood"
B"fire"
C"earthquake"
D"power_outage"
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect event strings like 'Fire' (case sensitive)
Using unrelated events like 'flood' or 'earthquake'
2fill in blank
medium

Complete the code to raise an alert when an emergency is detected.

LLD
def raise_alert(level):
    if level >= [1]:
        print("Emergency alert raised!")
Drag options to blanks, or click blank then click option'
A3
B5
C10
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Setting the threshold too high like 10, missing moderate emergencies
Setting the threshold too low like 1, causing false alerts
3fill in blank
hard

Fix the error in the emergency response function to correctly handle unknown events.

LLD
def emergency_response(event):
    match event:
        case "fire":
            print("Activate sprinklers")
        case "flood":
            print("Evacuate area")
        case _:
            print([1])
Drag options to blanks, or click blank then click option'
A"Unknown emergency! Stay alert."
BUnknown emergency! Stay alert.
CUnknown emergency
DNone
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting quotes causing syntax errors
Using incomplete or incorrect messages
4fill in blank
hard

Fill both blanks to create a dictionary mapping emergency types to their response actions.

LLD
emergency_actions = {
    [1]: "Call fire department",
    [2]: "Shut off electricity"
}
Drag options to blanks, or click blank then click option'
A"fire"
B"flood"
C"power_outage"
D"earthquake"
Attempts:
3 left
💡 Hint
Common Mistakes
Using variable names instead of string keys
Mixing up emergency types and response actions
5fill in blank
hard

Fill all three blanks to implement a function that logs emergency events with their severity and timestamp.

LLD
def log_emergency(event, severity):
    from datetime import datetime
    log_entry = {
        [1]: event,
        [2]: severity,
        [3]: datetime.now().isoformat()
    }
    print(log_entry)
Drag options to blanks, or click blank then click option'
A"event_type"
B"severity_level"
C"timestamp"
D"date"
Attempts:
3 left
💡 Hint
Common Mistakes
Using inconsistent or unclear key names
Using variable names instead of string keys