← Back to Unit 1

Week 9 Lesson 1 Challenge

YEAR 9 DIGITAL TECHNOLOGIES • IMPORTS CHALLENGE

Airport Security Challenge

In this challenge, you will use imports to build a simple airport security system.

✈️ SCENARIO

Imagine you are writing a Python program for an airport security gate.

The airport security system must decide whether a passenger:

  • is blocked because the airport is closed
  • is sent to extra screening
  • or is allowed through

To do that, the program will use two imports: datetime and random.

🎯 YOUR GOAL

Build a program that follows these rules:

  1. Check the current hour.
  2. If the airport is closed, stop there.
  3. If the airport is open, generate a random number.
  4. If that number divides exactly by 7, send the passenger to extra screening.
  5. Otherwise, allow the passenger through.
Challenge Brief

Your airport security program should work like this:

Step 1: Check the time
The airport is only open between 6 and 22.
Step 2: If closed
Print a message saying the airport is closed.
Step 3: If open
Generate a random number.
Step 4: Screening check
If the random number divides exactly by 7, send the passenger to extra screening.

Important: Build the logic yourself first. Do not jump straight to the hint or example code.

💭 WHAT YOU SHOULD THINK ABOUT
  • What does an import do?
  • How do you get the current hour from Python?
  • How do you generate a random number?
  • Which check should happen first?
  • How will your program decide whether the passenger is blocked, screened, or allowed?
  • What messages should the program print so the user understands what happened?
📌 SUCCESS CRITERIA
  • Your program uses at least one import.
  • Your program checks whether the airport is open.
  • Your program generates a random number only when needed.
  • Your program checks whether the number works exactly with 7.
  • Your output is clear and readable.
  • Your code is organised enough that you could explain it out loud.
📚 Where to find what modules can do (and what modules exist)

When you use import, you are bringing in tools that already exist in Python.

There are hundreds of built-in modules — you are not expected to memorise them.

🔎 Where to find available modules
  • Python Standard Library (official list):
    https://docs.python.org/3/library/
  • Search online:
    Try Python modules list or Python library random
  • Ask Python itself what exists (advanced later)
🧠 How to find what a module can do
  • Search the module name (e.g. Python random)
  • Use the official documentation
  • Use help() inside Python
# ============================================================
# USING PYTHON TO EXPLORE MODULES
# ============================================================

# Import a module
import random

# Ask Python what this module can do
help(random)

# Look at a specific function inside the module
help(random.randint)

# This shows:
# - what the function does
# - what inputs it needs
# - what it returns

Key idea: Real programmers don’t memorise modules — they look them up, test them, and learn as they go.

Stage 1 Hint: Using datetime

First, your program needs to know the current time.

Use the datetime import to get the current hour.

Stage 2 Hint: Using random

If the airport is open, the program should generate a random number.

Use the random import to generate a whole number between 1 and 100.

Stage 3 Hint: Put the challenge together

Now combine the time check and the random check into one complete airport security system.

First
Check if the airport is open.
Second
If open, generate a random number.
Third
Check if the number works exactly with 7.
Finally
Print the result clearly.
Programming tips
Hint 1: Imports go near the top

Most Python programs put their imports near the beginning so it is easy to see which tools are being used.

Hint 2: Solve one part at a time

Get the time check working first. Only after that should you worry about the random number.

Hint 3: Think about exact division

You need to decide whether the security number can be divided by 7 exactly.

There is a neat operator in Python that helps with this. If you do not remember it yet, post your best attempt first.

Hint 4: Keep your output clear

Good programs tell the user what happened. Don’t just print a number. Print a message that explains the result.

💬 WHAT TO POST IN REPLY BELOW
  • Your code attached as a .py file
✅ REMEMBER

You do not need to get it perfect on the first go.

The goal is to think, test, improve, and explain your logic.