KABLE ACADEMY
PYTHON LAB · NETWORK TOOLKIT · BEGINNER

>>> python network lab

build a real IT toolkit · 15 missions · zero experience needed
0 / 15 missions complete
WELCOME TO PYTHON NETWORK LAB
What you'll build 🛠

Over 15 missions you'll write Python code that starts from scratch and grows into a full Network Toolkit — a real command-line IT tool with features used by network engineers every day. By the end you'll have a working program that can ping hosts, look up IP information, scan ports, and more.

You don't need ANY prior coding experience. Every mission teaches one concept, then immediately applies it to the toolkit.
🐍
Why Python?
Python is the #1 language for network engineers, IT admins, and security pros. NetworkChuck, the entire CCNA community, and most automation tools use it. It reads almost like English.
🌐
Why a Network Toolkit?
Instead of writing random exercises, every line of code you write goes into a real tool. When you're done, you'll have something you can actually show off and USE in a networking career.
📦
What you need
Just a web browser! We use an online Python IDE — no installation required. All built-in libraries are available, so you can start coding in seconds.
How it works
Each mission teaches a Python concept, shows you the code, explains it line by line, then gives you assignment steps to run yourself. Mark complete when done.
YOUR LEARNING ROADMAP
Phase 1 Python Fundamentals (Missions 1–4)
M1 · Hello Network M2 · Variables & Input M3 · If/Else Logic M4 · Loops
Phase 2 Functions & Data (Missions 5–8)
M5 · Functions M6 · Lists & Dictionaries M7 · File I/O M8 · Error Handling
Phase 3 Network Power (Missions 9–12)
M9 · Importing Modules M10 · Ping with subprocess M11 · IP & DNS Lookup M12 · Port Scanner
Phase 4 Final Toolkit (Missions 13–15)
M13 · Menu System M14 · Logging to File M15 · Full Toolkit Launch
GETTING STARTED

🌐 We use an Online Python IDE — no install needed!

For all 15 missions in this lab, we'll be coding right in your browser using Online Python. No downloads, no setup — just open the link and start writing code.

→ Open Online Python IDE
Tip: Bookmark that link! You'll return to it for every mission. The IDE lets you write and run Python instantly — just paste or type your code and hit Run.

1. Open the Online Python IDE

Go to online-python.com in your browser. You'll see a code editor on the left and an output panel on the right. That's your Python environment — ready to go, no account needed.

2. Create your project file

In the IDE, you'll build your code mission by mission. For each mission, copy the provided code into the editor and click Run ▶. Each mission builds on the last, growing your toolkit step by step.

3. Run your first line of Python

Try it right now! Open the IDE, type print("Hello, network engineer!"), and click Run. If you see the output — you're all set and ready for Mission 1.
💡 NetworkChuck connection: This lab follows the same progression as NetworkChuck's "You Need to Know Python" series. The concepts map directly — variables, loops, functions, then network libraries. If you're watching his videos alongside this lab, they'll reinforce each other perfectly.
WANT TO RUN PYTHON LOCALLY? (OPTIONAL)

Install Python 3 on your computer

You don't need this for the lab, but if you ever want to run Python scripts directly on your machine, here's how:

1. Install Python 3 — Go to python.org/downloads and install the latest Python 3. During install on Windows, check the box that says Add Python to PATH.

2. Install VS Code (recommended) — Download Visual Studio Code from code.visualstudio.com. Install the Python extension from the Extensions panel for syntax highlighting and an integrated terminal.

3. Verify Python works — Open your terminal and type python --version (Windows) or python3 --version (Mac/Linux). You should see something like Python 3.11.4.

⚠️ Note: Some missions that use subprocess (ping, system commands) may behave differently in the online IDE vs. a local terminal. For those missions, we'll call out any differences.
PYTHON CONCEPTS QUICK REFERENCE
This page is your cheat sheet. Every concept used in the missions is explained here. Bookmark it — come back whenever something in a mission is confusing.
CORE CONCEPTS

print() — Display output

Displays text or values to the screen. The most fundamental tool in Python.
print("Hello, network engineer!")
print("Your IP is:", ip_address) # print multiple things

Variables — Storing data

Variables are named containers. You create them by typing a name, an equals sign, and a value. No type declarations needed in Python.
hostname = "router-01" # string (text)
port = 22 # integer (whole number)
is_up = True # boolean (True/False)
latency = 4.7 # float (decimal)

input() — Get user input

Pauses the program and waits for the user to type something, then stores it as a string.
host = input("Enter hostname: ")
port = int(input("Enter port: ")) # convert to integer

if / elif / else — Decision making

Runs different code depending on whether a condition is True or False. Indentation (4 spaces) is required.
if port == 22:
print("SSH port")
elif port == 80:
print("HTTP port")
else:
print("Unknown port")

for loops — Repeat for each item

Runs a block of code once for every item in a list or range.
ports = [22, 80, 443, 3389]
for port in ports:
print("Scanning port:", port)

for i in range(1, 11): # 1 through 10
print(i)

functions — Reusable blocks of code

Define once with def, call many times. Functions keep your code organized and avoid repetition.
def scan_port(host, port):
# code goes here
return True # send a result back

result = scan_port("192.168.1.1", 22)

Lists — Ordered collections

Square brackets hold multiple values. You can add, remove, and loop through them.
hosts = ["192.168.1.1", "192.168.1.2", "8.8.8.8"]
hosts.append("10.0.0.1") # add item
print(hosts[0]) # first item: 192.168.1.1
print(len(hosts)) # count: 4

Dictionaries — Key-value pairs

Curly braces hold data as name:value pairs. Perfect for structured data like port names.
port_names = {
22: "SSH",
80: "HTTP",
443: "HTTPS",
3389: "RDP"
}
print(port_names[22]) # prints: SSH

try / except — Error handling

Catches errors so your program doesn't crash. Essential for network tools where things fail unpredictably.
try:
ip = socket.gethostbyname(hostname)
except socket.gaierror:
print("Could not resolve hostname")

import — Using built-in modules

Python comes with powerful libraries. Import them to access networking, OS, and system features.
import socket # networking
import subprocess # run system commands (ping)
import os # operating system info
import datetime # dates and times

f-strings — Clean string formatting

Put an f before a string and use {} to embed variables directly. Much cleaner than concatenation.
host = "google.com"
ip = "142.250.80.46"
print(f"Host: {host} → IP: {ip}")
# prints: Host: google.com → IP: 142.250.80.46

File I/O — Reading and writing files

Use open() to read from or write to files. The with statement closes the file automatically.
# Write to a file
with open("log.txt", "a") as f:
f.write("Scan complete\n")

# Read from a file
with open("log.txt", "r") as f:
print(f.read())
15 MISSIONS — BUILD THE NETWORK TOOLKIT
↑ Click a mission above to view the lesson and your assignment steps
THE COMPLETE NETWORK TOOLKIT
This is what your network_toolkit.py looks like when all 15 missions are complete. Every line of code you wrote across all missions comes together here. Study it, run it, and be proud — this is a real IT tool.

🛠 network_toolkit.py — Complete Program

~90 lines · 4 features · built across 15 missions
COMPLETE SOURCE CODE network_toolkit.py
# ═══════════════════════════════════════════════
# Kable Academy — Network Toolkit
# Built across Python Network Lab (15 missions)
# ═══════════════════════════════════════════════
import socket
import subprocess
import os
import datetime

# ── Port name dictionary (Mission 6) ────────────
PORT_NAMES = {
    21: "FTP", 22: "SSH", 23: "Telnet",
    25: "SMTP", 53: "DNS", 80: "HTTP",
    110: "POP3", 143: "IMAP", 443: "HTTPS",
    3389: "RDP", 8080: "HTTP-ALT"
}

# ── Logging (Mission 14) ────────────────────────
def log(message):
    timestamp = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
    with open("toolkit_log.txt", "a") as f:
        f.write(f"[{timestamp}] {message}\n")

# ── Ping a host (Mission 10) ────────────────────
def ping_host(host):
    print(f"\n[*] Pinging {host}...")
    param = "-n" if os.name == "nt" else "-c"
    result = subprocess.run(["ping", param, "4", host],
        capture_output=True, text=True)
    if result.returncode == 0:
        print(f"[+] {host} is REACHABLE")
        log(f"PING OK: {host}")
    else:
        print(f"[-] {host} is UNREACHABLE")
        log(f"PING FAIL: {host}")

# ── IP / DNS Lookup (Mission 11) ────────────────
def ip_lookup(host):
    print(f"\n[*] Looking up {host}...")
    try:
        ip = socket.gethostbyname(host)
        hostname = socket.getfqdn(ip)
        print(f"[+] IP Address : {ip}")
        print(f"[+] Hostname : {hostname}")
        log(f"LOOKUP: {host}{ip}")
    except socket.gaierror as e:
        print(f"[-] Error: {e}")

# ── Port Scanner (Mission 12) ───────────────────
def port_scan(host, ports):
    print(f"\n[*] Scanning {host}...")
    log(f"SCAN START: {host}")
    for port in ports:
        try:
            s = socket.socket()
            s.settimeout(0.5)
            result = s.connect_ex((host, port))
            name = PORT_NAMES.get(port, "Unknown")
            if result == 0:
                print(f" [OPEN] Port {port} ({name})")
                log(f"OPEN PORT: {host}:{port} ({name})")
            else:
                print(f" [closed] Port {port} ({name})")
            s.close()
        except:
            print(f" [error] Port {port}")

# ── Main Menu (Mission 13) ──────────────────────
def main():
    print("\n" + "="*45)
    print(" Kable Academy — Network Toolkit v1.0")
    print("="*45)
    while True:
        print("\n [1] Ping a host")
        print(" [2] IP / DNS Lookup")
        print(" [3] Port Scanner")
        print(" [4] View Log")
        print(" [5] Exit\n")
        choice = input("Select option: ")
        if choice == "1":
            h = input("Enter host/IP: ")
            ping_host(h)
        elif choice == "2":
            h = input("Enter hostname/IP: ")
            ip_lookup(h)
        elif choice == "3":
            h = input("Enter host/IP to scan: ")
            port_scan(h, list(PORT_NAMES.keys()))
        elif choice == "4":
            try:
                with open("toolkit_log.txt") as f:
                    print(f.read())
            except: print("No log yet.")
        elif choice == "5":
            print("Goodbye!"); break

if __name__ == "__main__":
    main()
🏓
Ping Tool
Tests if any host or IP is reachable on your network. Works on Windows, Mac, and Linux.
🔍
IP / DNS Lookup
Resolves a hostname to its IP address and performs a reverse DNS lookup.
🔭
Port Scanner
Checks 11 common ports (SSH, HTTP, HTTPS, RDP, FTP, DNS...) and reports open/closed.
📋
Activity Log
Every scan and lookup is timestamped and saved to toolkit_log.txt automatically.
🚀 Running your toolkit: Open your terminal in the folder containing network_toolkit.py and run python network_toolkit.py (Windows) or python3 network_toolkit.py (Mac/Linux). The menu will appear and you can use all four features!
Loading grade sheet...