PYTHON & LOGIC GATES
Lesson 1 of 5WARMUP: Binary & Logic Icebreaker
Before we write code, let's understand how computers think. Computers don't understand words — they understand 1s and 0s (binary). Every piece of data, every image, every game is built from millions of tiny on/off switches.
Discuss: What would happen if a single bit flipped in a bank transaction?
CORE CONCEPTS
Variables are like labeled boxes where you store data. Python makes this easy — just assign a value!
Logic Gates are the building blocks of computing. AND outputs 1 only if both inputs are 1. OR outputs 1 if at least one input is 1. NOT flips the input.
Conditions let your code make decisions. Loops let it repeat tasks — essential for security scanners!
Functions let you package code into reusable blocks — a key skill for any cyber tool builder.
MINI CHALLENGE: Fix the Bug
The following Python code should check if a user is old enough to access a system, but it has a bug. Can you spot and fix it?
input() return? How do we compare numbers?
MAIN PROJECT: Login Simulator
Write a Python login simulator that stores a username and password, asks the user for credentials, and grants access only if both match. Use functions, conditions, and a loop to allow up to 3 attempts.
Define a login() function with two parameters
Store a hardcoded username and password
Add a loop that gives 3 attempts maximum
Return "Access Granted" or "Locked Out"
QUIZ: Python Basics
Test your understanding of Python fundamentals.
1. What operator checks if two values are equal in Python?
2. Which data type represents a whole number?
3. What does for i in range(3): do?