A compact Python cheatsheet that revisits the fundamentals of the language in less than 20 lines of code.
It covers variables, data structures, conditionals, loops, functions, and classes — all in a minimal and beginner-friendly format.
# Variables and types
name, age, active = "Python", 30, True
# Structures
fruits = ["apple", "banana"]
user = {"name": "Ana", "age": 25}
# Conditional
print("Adult" if age >= 18 else "Minor")
# For loop
for f in fruits: print(f)
# While loop
c = 0
while c < 2: print("Loop", c); c += 1
# Function
def add(a, b=0): return a + b
print(add(5, 3))
# Class
class Person:
def __init__(self, name): self.name = name
def speak(self): print(f"I am {self.name}")
Person("John").speak()- Variables, strings, numbers, booleans
- Lists and dictionaries
- If/else conditionals
- For and while loops
- Functions with default arguments
- A simple class (OOP basics)
- Perfect for beginners as a quick overview
- Great for revision before interviews
- A fun challenge: learn Python’s core in 20 lines only
After mastering these basics, try exploring:
- File handling (
open,read,write) - Popular libraries like
pandas,numpy, andrequests - Best practices for writing clean and maintainable code
This project is licensed under the MIT License.