Welcome, young cyber hero! In this module, we will learn how to write scripts — special sets of instructions that help computers protect themselves from bad guys. Scripts are like recipes for your computer. Just like you follow a recipe to bake a cake, your computer follows a script to stay safe. We will use very simple words and lots of fun examples. Let’s start our cyber adventure!
By the end of this module, you will be able to:
Ada lives in Lagos, Nigeria. She loves playing with her robot, “Guardy”. Guardy is a smart robot that watches over her house. One day, Ada wanted Guardy to check every door at night and send her a message if any door was open. She wrote a script — a list of steps — for Guardy. The script said: “At 10pm, check each door. If a door is open, send a message to Ada.” Guardy followed the script perfectly and kept the house safe. Scripts are like that: they tell computers exactly what to do to keep us safe!
Definition: A script is a set of instructions written in a language that a computer understands.
Why important: Scripts help computers do jobs automatically, so we don’t have to do them by hand.
Simple explanation: Think of a script like a dance routine. Each step is an instruction. When you follow all steps, you complete the dance. Computers follow scripts step by step.
Real-life example: A morning alarm clock follows a script: “At 6am, ring loudly.”
School example: Your teacher might have a script for the day: “Morning prayer, then maths, then break.”
Home example: “After dinner, wash dishes, then watch TV.”
Nigerian example: A security guard at a bank has a script: “Every hour, walk around the building. If you see anything strange, call the manager.”
Script for Guardy (robot): -------------------------- 1. Wait until 10pm 2. Check front door 3. Check back door 4. If any door open -> send message 5. End
Mini summary: A script is a list of steps for a computer to follow.
Definition: Cyber security scripts are written to protect computers, networks, and data from attacks.
Why important: They work 24/7 to catch dangers, so we don’t have to watch the screen all the time.
Simple explanation: Imagine you have a pet fish. You use a timer to feed it automatically. A security script is like a timer that checks for bad guys.
Real-life example: A script can scan all files on a computer and delete any that look like a virus.
School example: A script can lock all school computers at 4pm so no one uses them after school.
Home example: A script can turn on the security camera when you leave home.
Nigerian example: In a Nigerian bank, scripts monitor every transaction. If someone tries to transfer money to a bad account, the script stops it.
Security Script Flow: Start → Check all files → Look for viruses → If virus found → Quarantine it → Alert admin
Mini summary: Cyber scripts watch over our digital world and act fast when something is wrong.
Definition: Scripting languages are special languages used to write scripts. We will focus on Python (easy to read) and Bash (used in terminals).
Why important: Knowing a scripting language lets you talk to the computer.
Simple explanation: Just like you speak English or Yoruba to talk to friends, you use Python or Bash to talk to a computer.
Real-life example: Python is used by Google and Netflix to keep systems safe.
School example: You can write a Python script to check if your homework folder is safe.
Home example: Bash scripts are used to clean up old files on your family PC.
Nigerian example: Many Nigerian tech companies use Python to build security tools.
| Language | Use | Difficulty for Kids |
|---|---|---|
| Python | General scripting, security tools | 😊 Easy |
| Bash | Command line, file management | 😐 Medium |
Mini summary: We will learn Python because it is friendly and powerful.
Definition: A Python script is a text file with instructions that end with .py.
Why important: Writing your first script is like writing your first sentence – it opens a new world.
Simple explanation: Open a notepad, type a few lines, save as .py, and run it.
Real-life example: A script that prints “Hello, World!” is the classic start.
School example: Print “Welcome to cyber class”.
Home example: Print “Don’t forget to lock the door”.
Nigerian example: Print “Aroko wa (our message) – stay safe online”.
# my_first_script.py
print("Hello, Cyber Heroes!")
print("This script keeps us safe.")
Mini summary: We type instructions in a file and run them.
Definition: A variable is like a box where you store a value (number, text, or list).
Why important: Variables help us remember things in our script.
Simple explanation: Like a jar with a label. You put candies in it and can take them out later.
Real-life example: Let age = 10. Then you can use age later to check if someone is old enough.
School example: score = 100. Use it to reward a student.
Home example: door_locked = True. Use it to decide if the alarm should be on.
Nigerian example: balance = 5000 (in Naira). Use it to check if you can buy data.
# variables example name = "Chidi" age = 10 is_secure = True print(name, "is", age, "years old.")
Mini summary: Variables store data for later use.
Definition: Conditions are like questions that have True or False answers. They help scripts decide what to do.
Why important: They allow scripts to react differently in different situations.
Simple explanation: If it rains, take an umbrella. Else, wear sunglasses. The script checks the condition.
Real-life example: If a login password is wrong, deny access.
School example: If homework is done, you can play.
Home example: If the window is open, close it.
Nigerian example: If NEPA (electricity) is on, charge your phone; else, use a power bank.
password = "secure123"
if password == "secure123":
print("Access granted!")
else:
print("Access denied.")
Mini summary: Conditions let scripts choose between actions.
Definition: A loop repeats a block of instructions several times.
Why important: They save us from writing the same instruction over and over.
Simple explanation: Like singing “Happy Birthday” three times. A loop does that for you.
Real-life example: A script that checks 1000 files one by one – it uses a loop.
School example: Count from 1 to 10 using a loop.
Home example: Repeat “check the door” 5 times.
Nigerian example: A loop can check all 50 students’ scores and find the highest.
for i in range(5):
print("Checking door", i+1)
Mini summary: Loops repeat tasks automatically.
Definition: A function is a named group of instructions that you can call (run) whenever you want.
Why important: Functions keep your script neat and reusable.
Simple explanation: Like a “make_jollof” recipe – you can use it anytime you want to cook.
Real-life example: A function “scan_for_virus” that you can call many times.
School example: A function “calculate_average” for grades.
Home example: A function “lock_doors” that locks all doors.
Nigerian example: A function “send_alert” that sends a message to the security team.
def lock_doors():
print("Locking front door")
print("Locking back door")
# call the function
lock_doors()
Mini summary: Functions are reusable blocks of code.
Definition: Scripts can read data from files and write data to files.
Why important: This helps scripts keep logs (records) of what they did.
Simple explanation: Like keeping a diary. The script writes what it checked.
Real-life example: A script reads a list of bad IP addresses and blocks them.
School example: Read a list of student names and print each one.
Home example: Write a shopping list to a file.
Nigerian example: A script reads a list of bank account numbers to monitor for fraud.
# write to file
with open("log.txt", "w") as f:
f.write("All doors checked at 10pm")
Mini summary: Files help scripts store and retrieve data.
Definition: Modules are like toolboxes full of extra functions that other people made.
Why important: They save time – we don’t have to invent everything ourselves.
Simple explanation: Like using a calculator instead of doing long addition by hand.
Real-life example: The “os” module helps interact with the computer’s operating system.
School example: The “math” module gives you sin, cos, and more.
Home example: The “datetime” module helps get the current time.
Nigerian example: Use the “requests” module to check if a website is up.
import datetime
now = datetime.datetime.now()
print("Current time:", now)
Mini summary: Modules add superpowers to your scripts.
Definition: Error handling is a way to catch mistakes (errors) without crashing the script.
Why important: It makes scripts strong and reliable.
Simple explanation: Like wearing a helmet when riding a bike – if you fall, you are safe.
Real-life example: If a file is missing, the script tells you, instead of breaking.
School example: If a student’s name is not found, print “Not found”.
Home example: If the light bulb is broken, try another one.
Nigerian example: If the network is slow, the script waits and retries.
try:
file = open("missing.txt")
except:
print("File not found, but script continues.")
Mini summary: Error handling keeps scripts from crashing.
Definition: Logging means writing down what the script did, with timestamps.
Why important: Logs help us see what happened if something goes wrong.
Simple explanation: Like a diary for the script.
Real-life example: A script logs “2026-06-27 10:00: Door checked – OK”.
School example: Log when each student finishes a test.
Home example: Log when the alarm is turned on/off.
Nigerian example: A bank script logs every ATM withdrawal.
import logging
logging.basicConfig(filename='security.log', level=logging.INFO)
logging.info('Security check completed.')
Mini summary: Logging keeps a history of actions.
Definition: Automation means letting scripts do the repetitive work for us.
Why important: Humans get tired; scripts don’t.
Simple explanation: Like a robot vacuum that cleans the floor while you play.
Real-life example: A script that automatically updates antivirus definitions.
School example: A script that backs up all homework files every Friday.
Home example: A script that turns off lights at 11pm.
Nigerian example: A script that checks the weather every morning and sends a WhatsApp message.
# pseudo-code for automation
while True:
check_for_updates()
sleep(3600) # wait 1 hour
Mini summary: Automation makes life easier and safer.
Definition: We must protect our scripts so bad guys can’t change them. Use passwords and keep them hidden.
Why important: If an evil hacker changes your script, it may help them instead.
Simple explanation: Like keeping your diary in a locked drawer.
Real-life example: Never put passwords directly in a script; use secret files.
School example: The teacher keeps the answer key in a safe.
Home example: Keep your Wi-Fi password in a secret place.
Nigerian example: Bank scripts use special “API keys” that are never shown to anyone.
# NEVER do this: password = "mysecret123" # INSTEAD, read from a secure file or environment variable.
Mini summary: Keep your scripts and secrets safe.
Definition: Testing means running your script to make sure it works as expected.
Why important: You don’t want a broken script when you need it most.
Simple explanation: Like checking your shoes before a race – make sure they are tied.
Real-life example: Run the script with test data to see if it catches a fake virus.
School example: Test a grading script with sample scores.
Home example: Test the “lock doors” script during the day.
Nigerian example: A fintech startup tests their fraud script with dummy transactions.
# simple test
assert(2 + 2 == 4)
print("Test passed!")
Mini summary: Always test your scripts before using them for real.
Step 1: Define the problem Step 2: Write pseudo‑code Step 3: Write actual code Step 4: Run and debug Step 5: Deploy
Encourage students to think of scripts as “recipes”. Use pair programming for activities. Relate every concept to a daily routine. Use the Nigerian context to make it relatable. Emphasise that making mistakes is part of learning – debugging is a superpower!
Help your child by setting up a safe computer environment where they can practice. Ask them to explain their script to you. Celebrate small wins. Remind them that cyber security is about staying safe, not just about coding.
Did you know that the first script ever written was for a computer called the “Z3” in 1941? It was used to calculate rocket trajectories!
password_attempt).
Script Execution Flow
----------------------
Start
|
V
Read input → Process → Decision?
| |
| V
| (If true) → Action A
| (If false)→ Action B
|
V
Output result
|
V
End
Loop Illustration (for 5 times) +---+ +---+ +---+ +---+ +---+ | 1 | → | 2 | → | 3 | → | 4 | → | 5 | +---+ +---+ +---+ +---+ +---+
| Feature | Python | Bash |
|---|---|---|
| Readability | Very easy | Moderate |
| Best for | General automation, security tools | File operations, system commands |
| Learning curve | Gentle | Steeper |
Congratulations! You have learned what scripts are, why they are used in cyber security, and how to write simple ones in Python. You can use variables, conditions, loops, functions, and modules. You know how to test and keep scripts safe. Remember, scripts are like your digital helpers – always there to protect you. Keep practicing and you will become a cyber hero!
python filename.py in the terminal.print() do? Match the term with its description:
| Term | Description |
|---|---|
| 1. Script | A. Repeats code |
| 2. Variable | B. Stores a value |
| 3. Loop | C. Group of instructions |
| 4. Function | D. True/False check |
| 5. Condition | E. Named reusable block |
Answers: 1-C, 2-B, 3-A, 4-E, 5-D
Scenario 1: You are a security guard at a school. You want a script that checks if the main gate is locked after 6pm. Write a simple Python script (pseudo-code) that does this.
Scenario 2: A bank wants a script that alerts the manager if a withdrawal is above ₦500,000. Write a condition that does this.
In groups of 3, brainstorm five ways a script could help a small business in Nigeria. Then, write one small script (on paper) that solves one of those problems. Present it to the class.
Write a Python script that prints your name, your age, and a message like “I love cyber security”. Then, add a condition that prints “I am a kid” if age < 18, else “I am an adult”. Run it on your computer.
Build a simple password checker! Write a script that asks the user for a password. If the password is “cyber2026”, print “Access granted”. Otherwise, print “Access denied”. Add a loop that gives the user 3 tries.
Download a text file with 10 common passwords. Write a script that reads the file and checks if any of them are “password123”. If yes, print “Weak password found!” Use a loop and a condition.
Write a script that simulates a simple alarm system. If the door is open and the time is after 8pm, print “ALARM! Door open”. Otherwise, print “All safe”. Use variables for door status and time.
All multiple-choice answers are indicated in the questions above (bold). Fill-in-the-blank answers: 1-script, 2-Variables, 3-decision/conditional, 4-loop, 5-Functions. True/False: 1-T, 2-F, 3-T, 4-F, 5-F.
In the next module, we will learn about networks and how scripts can protect them. We will explore IP addresses, firewalls, and more fun stuff. See you there, cyber heroes!
End of Module 2 · Fundamentals of Cyber Security Scripting