Introduction to Python Programming
Core Syntax & Data Structures Quick Reference Guide
1. Variables and Core Data Types
Python is dynamically typed, meaning you do not need to explicitly declare a variable's type before
initializing it.
# Variable Assignments
username = "Alice" # String (str)
account_id = 1024 # Integer (int)
account_balance = 250.75 # Float (float)
is_active = True # Boolean (bool)
2. Control Flow: Conditionals and Loops
Python uses clean indentation instead of curly braces to define scope blocks.
if account_balance > 100:
print("Premium Status Approved")
else:
print("Standard Account")
# Iterating through arrays/lists
items = ["server_1", "server_2", "server_3"]
for item in items:
print(f"Checking status of: {item}")
3. Native Data Structures
Lists are ordered and mutable, while dictionaries store key-value mappings for rapid lookups.
# Python Lists
tools = ["Git", "Docker", "Kubernetes"]
[Link]("Ansible")
# Python Dictionaries
config = {
"host": "localhost",
"port": 8080,
"ssl": True
}
1
4. Writing Functional Blocks
Functions maximize code reusability and enhance long-term project maintainability.
def calculate_tax(amount, rate=0.15):
return amount * rate
total_tax = calculate_tax(500)
print(f"Calculated Tax: {total_tax}")