martes, 13 de octubre de 2026

CLASS ACTIVITY 2 WEEK 7

 

🐰 Python Exercise: Rabbit Monitoring System (Dictionaries)

🎯 Objective:

Learn how to create and structure nested dictionaries in Python by recording monitoring data for rabbits. Please complete the Bunny 2-3-4

1. Example Code (Teacher's Template)

Copy and paste this starter code into Spyder and run it:

# ======================================================

# RABBIT MONITORING SYSTEM

# ======================================================


# Step 1: Create the main dictionary with 1 example rabbit

rabbit_database = {

    "Bunny1": {

        "weight_g": 1850,

        "temperature_c": 38.5,

        "motion_status": "Active"

    }

}


# Step 2: Print the data for the first rabbit

print("=== RABBIT MONITORING DATA ===")

print("Bunny1 Data:")

print("• Weight:", rabbit_database["Bunny1"]["weight_g"], "g")

print("• Temperature:", rabbit_database["Bunny1"]["temperature_c"], "°C")

print("• Motion Status:", rabbit_database["Bunny1"]["motion_status"])

No hay comentarios:

Publicar un comentario