Python Programming - Cheat Sheets

Cheat Sheets

Quick reference guides for Python Programming. Download them for offline access!

Python Basics Cheat Sheet
Quick reference for Python fundamentals

Python Basics Cheat Sheet

Variables and Data Types

python
# Numbers
x = 5          # int
y = 3.14       # float

# Strings
name = "Alice"
message = 'Hello'

# Booleans
is_valid = True
is_empty = False

# Type conversion
int("10")      # Convert to integer
str(42)        # Convert to string
float("3.14")  # Convert to float

Operators

python
# Arithmetic
+ - * / // % **

# Comparison
== != > < >= <=

# Logical
and or not

Control Flow

python
# If statement
if condition:
    # code
elif other_condition:
    # code
else:
    # code

# For loop
for item in sequence:
    # code

# While loop
while condition:
    # code

Functions

python
def function_name(param1, param2):
    # code
    return result

# Call function
result = function_name(arg1, arg2)

Lists

python
my_list = [1, 2, 3]
my_list.append(4)      # Add to end
my_list.insert(0, 0)   # Insert at position
my_list.remove(2)      # Remove value
my_list.pop()          # Remove last item
len(my_list)           # Get length

Dictionaries

python
my_dict = {"key": "value"}
my_dict["new_key"] = "new_value"
my_dict.get("key")
my_dict.keys()
my_dict.values()
my_dict.items()