Python Basics Cheat Sheet

Python syntax at a glance – data types, loops, functions, lists, dictionaries and file handling.

Basics

name = "Skillkul"          # str
age = 21                   # int
price = 499.0              # float
is_active = True           # bool
print(f"{name} is {age}")  # f-string

Collections

skills = ["html", "css", "python"]       # list
skills.append("sql")
point = (10, 20)                          # tuple
student = {"name": "Asha", "score": 92}   # dict
student["city"] = "Jaipur"
unique = {1, 2, 3}                        # set

Conditions & loops

if score >= 90:
    grade = "A"
elif score >= 75:
    grade = "B"
else:
    grade = "C"

for skill in skills:
    print(skill)

squares = [n * n for n in range(1, 6)]   # list comprehension

Functions & files

def greet(name, greeting="Hello"):
    return f"{greeting}, {name}!"

with open("notes.txt", "w") as f:
    f.write("Learn. Build. Grow.")

More free resources