01 - Learn the Basics of Python


Introduction

Python is a beginner-friendly programming language known for its readability and simplicity. This step will help you set up Python, understand basic syntax, and write your first Python program.



1. Installing Python


Windows/macOS/Linux

  • Download Python from the official site: python.org
  • Install it and ensure pip (Python package manager) is included.
  • Verify installation:
    python --version
    
    or (on some systems)
    python3 --version
    


2. Running Python Code

You can run Python code using:

  • Interactive Mode (REPL): Open terminal and type python.
  • Script Mode: Create a .py file and execute it:
    python script.py
    


3. Writing Your First Python Program

Create a file hello.py and add:

print("Hello, Python!")

Run it:

python hello.py


4. Understanding Variables & Data Types


Variable Declaration

name = "Alice"
age = 25
is_python_learner = True

Data Types in Python

  • String (str): "Hello"
  • Integer (int): 25
  • Float (float): 3.14
  • Boolean (bool): True or False
  • List (list): [1, 2, 3]
  • Dictionary (dict): {"name": "Alice", "age": 25}

Check data types:

print(type(name))  # Output: <class 'str'>


5. Working with Input & Output


Printing Output

print("Welcome to Python!")

Taking User Input

name = input("Enter your name: ")
print("Hello, " + name + "!")


6. Operators in Python


Arithmetic Operators

x = 10
y = 5
print(x + y, x - y, x * y, x / y, x % y)

Comparison Operators

print(10 > 5)  # True
print(10 == "10")  # False


7. Writing Comments in Python

  • Single-line comment:
    # This is a comment
    print("Hello")
    
  • Multi-line comment:
    """
    This is a multi-line comment
    describing the code.
    """
    


8. Python Indentation

Python uses indentation instead of {}:

if 5 > 2:
    print("Five is greater than two!")


Exercises

  • Install Python and verify the version.
  • Run Python in interactive mode and try printing a message.
  • Create a Python script that asks for a user's name and prints a greeting.
  • Declare variables of different types and print their types.
  • Write a small script using arithmetic operators.


Conclusion

You have now set up Python, learned basic syntax, and written your first program. The next step is to dive deeper into control flow with loops and conditionals.


NoFuture - A new way to learn it stuff

Sn0wAlice

NoFuture Menthor - Cybersec Analyst

I'm Alice Snow, a cybersecurity professional with a passion for Blue Team operations, defensive security, and compliance. I focus on creating practical solutions to help organizations strengthen their security posture. I’m also involved in offensive CI/CD research and incident detection, always looking for ways to bridge the gap between security theory and real-world application.

Profile Profile