Python for Beginners — Essential Cheatsheet
A concise reference for the most important Python concepts and syntax.
Variables and Data Types
Python supports several built-in data types. You declare a variable simply by assigning a value —
no keyword needed.
name = 'Alice' # string
age = 30 # integer
height = 1.75 # float
is_student = True # boolean
Control Flow
Use if / elif / else to make decisions in your code:
if age >= 18:
print('Adult')
elif age >= 13:
print('Teenager')
else:
print('Child')
Loops
for i in range(5): # prints 0 to 4
print(i)
while count > 0: # loop while condition is true
count -= 1
Functions
Define reusable blocks of code with the def keyword:
def greet(name):
return f'Hello, {name}!'
print(greet('Alice')) # Hello, Alice!
Lists and Dictionaries
fruits = ['apple', 'banana', 'cherry'] # list
[Link]('date') # add item
print(fruits[0]) # apple
person = {'name': 'Bob', 'age': 25} # dictionary
print(person['name']) # Bob
Useful Built-In Functions
len(fruits) — number of items
type(age) — data type of a variable
range(start, stop, step) — generate number sequences
input('Enter: ') — read user input
int(), float(), str() — type conversion
Tip: Practice every concept by typing it yourself. Reading code alone is not enough — writing and
running it is how real learning happens.