In: Computer Science
Design a system to automatically check temperature and facial mask use of a customer, dispense hand sanitiser and unlock the door if these conditions are satisfied, and sanitize the door handle after a customer enters or exits the building. Provide programming codes in a python language
Program written using Google Colab
Code:
import random # Imports random library
import time # Imports time library
for i in range(5): # Loop for 5 customers (Can be increased according to requirement)
  action = random.choice(('Enter', 'Exit')) # Randomly chooses if the customer is entering or exiting the door
  if action == 'Enter': # If the customer is trying to enter the door
    print("Customer approaching the door to enter...") # Prints the arrival of the customer
    time.sleep(3) # Sleep time to make it more realistic (Can be removed if not required)
    print("Checking Temperature...") # Prints that it is checking temperature
    temp = random.choices(range(95,104)) # Randomly chooses the temperature of the customer 
    time.sleep(3) # Sleep time to make it more realistic (Can be removed if not required)
    print("Checking if the customer has mask on...") # Prints that the system is checking if the customer has mask on
    mask = random.choices(('Yes', 'No'), (0.7, 0.3)) # Randomly chooses if the customer has mask on (Have inserted probability to make it more realistic)
    time.sleep(3) # Sleep time to make it more realistic (Can be removed if not required)
    if int(temp[0]) < 100 and mask == ['Yes']: # If the customers temperature is below 100 and has mask on
      print(f"Customer's temperature is Normal [{int(temp[0])}°F] and He/She is wearing a mask") # Prints that the customers temp is normal and has mask on
      print("Despensing Sanitizer and opening door...") # Prints that the system is now dispensing sanitizer and opening door
      time.sleep(5) # Sleep time to make it more realistic (Can be removed if not required)
      print("Customer has entered through the door. Doors locked...") # Prints that the customer has entered the door and the doors are now locking
      print("Santitizing door handles...") # Prints that the system is sanitizing the doors
    elif int(temp[0]) > 100 and mask == ['Yes']: # If the customers temperature is above 100 and has mask on
      print(f"Customer's Temperature is above Normal [{int(temp[0])}°F]. Customer not allowed to enter through the door") # Prints that the customers temp is above normal and has mask on
    elif int(temp[0]) > 100 and mask == ['No']: # If the customers temperature is above 100 and has no mask
      print(f"Customer's Temperature is above Normal [{int(temp[0])}°F]. Customer not allowed to enter through the door") # Prints that the customers temp is above normal and has no mask
    elif int(temp[0]) < 100 and mask == ['No']: # If the customers temperature is below 100 and has no mask
      print(f"Customer's temperature is Normal [{int(temp[0])}°F], but He/She is not wearing a mask. Customer not allowed to enter through the door") # Prints that the customers temp is normal and has no mask
  elif action == 'Exit': # If the customer is trying to exit the door
    print("Customer is approaching door to exit...") # Prints the departure of the customer
    time.sleep(3) # Sleep time to make it more realistic (Can be removed if not required)
    print("Opening door...") # Prints that the system is opening door
    time.sleep(3) # Sleep time to make it more realistic (Can be removed if not required)
    print("Santitizing door handles...") # Prints that the system is sanitizing the doors
  print("") # Blank line
  print("-----------------------------------------------------------------") # Customer sepeartor lines
  print("") # Blank line
Output:
