Python for Absolute Begginers

TL;DR: A beginner-friendly introduction to Python fundamentals for aspiring security engineers and developers.

Introduction

So you want to learn Python. You’ve come to the right place.

Python is widely regarded as one of the most beginner-friendly programming languages in the world. A huge number of security tools, automation frameworks, and pentesting utilities are written in Python.

There are several reasons for this:

  • It’s readable
  • It’s concise
  • It’s powerful
  • It’s easy to automate with

And yes — you can learn it.


Setting Up

First, we need to make sure Python is installed.

Check Your Version

python3 --version

or

python --version

You should see something like:

Python 3.11.2

If not, install it.

To install on Debian/Ubuntu:

sudo apt update
sudo apt install python3 python3-pip

To install Python on Windows, visit this page and choose the 64-bit installer. Here is a direct link to the Windows installer: Windows

Hello World

Create a file called 'hello.py' and add the following:

print("Hello, World!")

To run your python file, simply enter:

python3 hello.py

You should see:

Hello, World!

Congratulations. You’ve just written your first Python program.

Variables

Variables store data.

name = "Alice"
age = 25
height = 5.7

Python automatically infers the type.

print(type(name))   # <class 'str'>
print(type(age))    # <class 'int'>
print(type(height)) # <class 'float'>

Data Types Common data types: · str – text · int – whole numbers · float – decimal numbers · bool – True / False Example: is_admin = True

Strings

Strings are sequences of characters.

message = "Hello, World!"
print(message)

String Methods text = " Hello, World! "

print(text.upper()) print(text.lower()) print(text.strip()) print(text.replace("World", "Python")) print(text.split(","))

Startswith / Endswith clean = text.strip() print(clean.startswith("H")) # True print(clean.endswith("!")) # True

Basic Operators x = 10 y = 3

print(x + y) print(x - y) print(x * y) print(x / y) print(x % y)

Comparison operators: print(x == y) print(x != y) print(x > y) print(x < y) print(x >= y) print(x <= y)

Conditional Logic age = 18

if age >= 18: print("You are an adult.") else: print("You are a minor.")

Indentation matters. Python typically uses 4 spaces.

Loops For Loop for i in range(5): print(i)

While Loop count = 0

while count < 5: print(count) count += 1

Functions Functions allow reuse. def greet(name): print(f"Hello, {name}!")

greet("Alice")

Lists Lists store multiple values. tools = ["nmap", "burp", "metasploit"]

for tool in tools: print(tool)

Dictionaries Dictionaries store key-value pairs. user = { "username": "admin", "role": "superuser" }

print(user["username"])

Final Thoughts Python is not about memorizing syntax. It’s about understanding patterns. If this feels like a lot, that’s normal. Nothing here needs to be memorized. The goal is familiarity. The more you practice, the more it sticks. And yes — you can absolutely learn this. Stay consistent.