Complete Beginner's Python Crash Course - 1 Hour
What is Python? (2 minutes)
Python is a programming language - a way to give instructions to a computer. Think of it like writing a
recipe, but for computers.
Part 1: The Very Basics (15 minutes)
What is Code?
Code is just text that tells a computer what to do. Like:
python
print("Hello")
This tells the computer to display "Hello" on screen.
Variables - Storing Information
A variable is like a box with a label where you store information:
python
name = "John" # Put "John" in a box labeled "name"
age = 25 # Put 25 in a box labeled "age"
height = 5.8 # Put 5.8 in a box labeled "height"
Rules for Variable Names (VERY IMPORTANT for exam!)
✅ GOOD names: name , age , my_car , student1 , _secret ❌ BAD names: 1name , 2cool , my-car
(can't start with numbers or use dashes)
Memory trick: Variable names are like people's names - they can't start with numbers!
Part 2: Types of Information (15 minutes)
Python stores different types of information:
Numbers
python
age = 25 # Integer (whole number)
price = 15.99 # Float (decimal number)
big_num = 2.3e2 # Scientific notation = 230.0
Text (Strings)
python
name = "Alice" # Text in quotes
city = 'London' # Single or double quotes both work
number_as_text = "123" # This is TEXT, not a number!
Key Point: Anything in quotes is text, even if it looks like a number!
True/False (Boolean)
python
is_student = True # Must be capital T
is_working = False # Must be capital F
Lists - Multiple Items in Order
python
fruits = ["apple", "banana", "orange"]
numbers = [1, 2, 3, 4, 5]
mixed = [1, "hello", 3.14] # Can mix types
Think of a list like a shopping list - items in a specific order.
Tuples - Like Lists but Can't Change
python
coordinates = (10, 20) # Parentheses instead of brackets
person = ("Alice", 25, 5.6) # Name, age, height
Dictionaries - Information with Labels
python
student = {"name": "John", "age": 20, "grade": "A"}
Like a real dictionary - you look up a word (key) to find its meaning (value).
Part 3: Basic Math (10 minutes)
Simple Operations
python
5+3 # Addition = 8
10 - 4 # Subtraction = 6
6*2 # Multiplication = 12
15 / 3 # Division = 5.0
10 % 3 # Remainder = 1 (what's left after division)
Order of Operations (CRUCIAL for exam!)
Python follows math rules: Multiply/Divide before Add/Subtract
python
10 - 3 * 2 # = 10 - 6 = 4 (NOT 14!)
(10 - 3) * 2 # = 7 * 2 = 14 (parentheses first)
Memory trick: Please Excuse My Dear Aunt Sally (Parentheses, Exponents, Multiply/Divide, Add/Subtract)
Part 4: Comparisons and Logic (8 minutes)
Comparing Things
python
5 == 5 # Equal to? True
5 != 3 # Not equal to? True
5>3 # Greater than? True
5 < 10 # Less than? True
Combining Comparisons
python
True and True # = True (both must be true)
True and False # = False
True or False # = True (at least one must be true)
False or False # = False
Important: and happens before or
python
True or False and False # = True or False = True
Part 5: Working with Lists (8 minutes)
Getting Items from Lists
python
fruits = ["apple", "banana", "orange"]
fruits[0] # First item = "apple" (counting starts at 0!)
fruits[1] # Second item = "banana"
fruits[2] # Third item = "orange"
List Slicing - Getting Multiple Items
Format: [start:stop:step]
python
numbers = [1, 2, 3, 4, 5, 6]
numbers[2:5] # Items 2,3,4 = [3, 4, 5]
numbers[:3] # First 3 items = [1, 2, 3]
numbers[2:] # From item 2 to end = [3, 4, 5, 6]
numbers[::2] # Every 2nd item = [1, 3, 5]
Memory trick: Think of it like "from here to there, taking every X steps"
Joining Lists
python
list1 = [1, 2]
list2 = [3, 4]
combined = list1 + list2 # = [1, 2, 3, 4]
Part 6: Making Decisions and Loops (10 minutes)
If Statements - Making Decisions
python
age = 18
if age >= 18:
print("You can vote")
else:
print("Too young to vote")
Important: The colon : is required!
For Loops - Repeating Actions
python
# Count from 1 to 5
for i in range(1, 6):
print(i)
# Go through a list
fruits = ["apple", "banana", "orange"]
for fruit in fruits:
print(fruit)
While Loops - Repeat Until Condition Changes
python
count = 1
while count <= 5:
print(count)
count = count + 1 # Don't forget to change the condition!
Part 7: Functions (5 minutes)
Functions are like recipes - you give them ingredients (inputs) and get a result (output).
python
def greet(name): # Define a function
return "Hello " + name # Give back a result
message = greet("Alice") # Use the function
print(message) # Prints: Hello Alice
Function Rules:
Must start with def
Must have parentheses ()
Must have a colon :
Code inside must be indented
Part 8: Common Mistakes to Avoid (5 minutes)
Syntax Errors (Grammar mistakes)
❌ Wrong: if x = 5 (use == for comparison)
✅ Right: if x == 5:
❌ Wrong: for i in range(5) (missing colon)
✅ Right: for i in range(5):
❌ Wrong: def myfunction() (missing colon)
✅ Right: def myfunction():
Data Type Confusion
python
"123" + "456" = "123456" # Text joining
123 + 456 = 579 # Number addition
Part 9: File Operations (2 minutes)
python
# Reading a file
file = open("data.txt", "r")
# Writing a file (replaces everything)
file = open("data.txt", "w")
# Adding to end of file (keeps existing content)
file = open("data.txt", "a")
Exam Strategy - Pattern Recognition
Your exam questions follow these patterns:
1. "What is the output?" → Trace through code step by step
2. "Which is syntactically correct?" → Look for missing colons, wrong brackets
3. "What is the data type?" → Check for quotes (string) vs no quotes (number)
4. "What does this expression equal?" → Follow order of operations
5. "Which is a valid identifier?" → Can't start with numbers
Quick Practice - Try These!
1. 10 % 3 = ? Answer: 1
2. "123" is what type? Answer: string
3. [1,2,3,4][::2] = ? Answer: [1, 3]
4. Is 2name a valid variable? Answer: No
5. True or False and False = ? Answer: True
Final Memory Aids
Quotes = Text: "123" is text, 123 is a number
Colons Required: After if , for , while , def
Math Order: Multiply/Divide before Add/Subtract
Lists Start at 0: First item is [0] , not [1]
Variables: Can't start with numbers
Boolean: Must be True / False with capital letters
You're ready! Remember: read each question carefully and trace through step by step. 🚀