Iot Ca4
Iot Ca4
oriented programming?
4
[Module 3/CO3/Understand-LOCQ]
Suppose you are a data scientist working on a project to classify customer churn. You have
a dataset of customer data, including their demographics, purchase history, and support
tickets. You want to build a model to predict which customers are most likely to churn.
One way to do this would be to use a Python dictionary to store the customer data. The keys
of the dictionary would be the customer IDs, and the values would be the customer data.
You could then use the dictionary to look up the data for each customer and use that data to
train your model.
customers = {
"12345": {
"name": "John Doe",
"age": 30,
"purchase_history": [
{"item": "iPhone", "price": 1000},
{"item": "iPad", "price": 500},
],
"support_tickets": [
{"issue": "Problem with iPhone", "status": "resolved"},
{"issue": "Problem with iPad", "status": "open"},
],
},
"67890": {
"name": "Jane Doe",
"age": 25,
"purchase_history": [
{"item": "MacBook", "price": 2000},
{"item": "AirPods", "price": 150},
],
"support_tickets": [
{"issue": "Problem with MacBook", "status": "resolved"},
],
},
}
# Create instances
animal = Animal()
dog = Dog()
return output_datetime
# Example usage
input_datetime = "2024-05-04 12:30:45"
input_format = "%Y-%m-%d %H:%M:%S"
output_format = "%A, %B %d, %Y - %I:%M %p"
# Set up GPIO
LED_PIN = 18
SWITCH_PIN = 17
GPIO.setmode(GPIO.BCM)
GPIO.setup(LED_PIN, GPIO.OUT)
GPIO.setup(SWITCH_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP)
try:
while True:
# Read switch state
switch_state = GPIO.input(SWITCH_PIN)
# If switch is pressed (LOW), turn LED on
if switch_state == GPIO.LOW:
print("Switch pressed - LED ON")
GPIO.output(LED_PIN, GPIO.HIGH)
else:
print("Switch released - LED OFF")
GPIO.output(LED_PIN, GPIO.LOW)
except KeyboardInterrupt:
# Clean up GPIO
GPIO.cleanup()
20) Describe the basic building block of an IoT Device. 5
[Module 4/CO4/Analyze-IOCQ]
The basic building blocks of an IoT device include a microcontroller/microprocessor,
sensors, communication modules, actuators, power supply, memory/storage, and
application software.