Getting Started with Python
Welcome to the beginner-friendly guide that will get you up and running with Python, one of the most popular programming languages today.
1. Install Python
Download the latest version from python.org and follow the installer prompts. Remember to check “Add Python to PATH” on Windows.
# Verify installation
python --version
# or on macOS/Linux
python3 --version
2. Your First Program
Create a file named hello.py
and add the following line:
print("Hello, World!")
Run it from the terminal:
python hello.py
3. Variables & Data Types
Python is dynamically typed. You can assign values without declaring the type:
# Integers
age = 30
# Floats
price = 19.99
# Strings
name = "Alice"
# Booleans
is_admin = False
# Lists
fruits = ["apple", "banana", "cherry"]
4. Control Flow
Conditional statements and loops let you direct the execution of your code.
# If-elif-else
if age >= 18:
print("Adult")
elif age >= 13:
print("Teen")
else:
print("Child")
# For loop
for fruit in fruits:
print(fruit)
# While loop
counter = 0
while counter < 5:
print(counter)
counter += 1
5. Functions
Encapsulate reusable logic with functions:
def greet(name):
return f"Hello, {name}!"
message = greet("Bob")
print(message)
6. Next Steps
- Explore the official tutorial.
- Check out Virtual Environments for project isolation.
- Start a small project: a command‑line todo list, a web scraper, or a Flask web app.