3.12 Calling Procedures HW
MCQ:
- B
- B
- B
- B
- A
Code Runner Challenge
popcorn hack
View IPYNB Source
# CODE_RUNNER: popcorn hack
def report_status(location, status):
print(f"Location: {location} | Status: {status}")
# Calling report_status() two times with different locations and statuses
report_status("Server Room A", "Operational")
report_status("Database Hub", "Maintenance Required")
Lines: 1
Characters: 0
Output
Click "Run" in code control panel to see output ...
Code Runner Challenge
popcorn hack 2
View IPYNB Source
# CODE_RUNNER: popcorn hack 2
# Helper Procedure
def is_priority(incident_type):
# Return True when the incident is a "Medical Emergency"
return incident_type == "Medical Emergency"
# Outer Procedure
def process_report(location, incident_type):
# Call is_priority() using incident_type and store the returned value
is_crit = is_priority(incident_type)
# Use an if/else statement
if is_crit:
print(f"URGENT: High-priority incident at {location} — Medical Emergency!")
else:
print(f"Standard Report: Incident at {location} logged as '{incident_type}'.")
# Call process_report() two times with different incident types
process_report("Sector 7", "Medical Emergency")
process_report("Sector 4", "Maintenance Issue")
Lines: 1
Characters: 0
Output
Click "Run" in code control panel to see output ...
Code Runner Challenge
homework
View IPYNB Source
# CODE_RUNNER: homework
# Homework Hack
def check_priority(incident_type):
# Return True when the incident requires priority handling
priority_types = ["Fire", "Medical Emergency", "Hazard"]
return incident_type in priority_types
def dispatch_response(location, incident_type):
# Call check_priority() and store the returned value in a variable
is_urgent = check_priority(incident_type)
# Use an if/else statement to print the appropriate response
if is_urgent:
print(f"🚨 PRIORITY DISPATCH: Emergency response unit deployed to {location} for {incident_type}!")
else:
print(f"Standard response: Logging routine incident at {location} ({incident_type}).")
# Call dispatch_response() at least three times with different incident types/locations
dispatch_response("Sector 1", "Fire")
dispatch_response("Sector 2", "Routine Maintenance")
dispatch_response("Sector 1", "Medical Emergency")
Lines: 1
Characters: 0
Output
Click "Run" in code control panel to see output ...