Flip cards to learn Python concepts with clear examples and simple explanations. Perfect for beginners!

All Concepts
Basics
Data Structures
Functions
Control Flow
File Handling
Your Learning Progress: 30% Complete

Variables

Storing and accessing data

Click to flip

Example

# Creating variables
name = "Alice"
age = 30
height = 5.8

# Using variables
print(f"Hello {name}!")
print(f"You are {age} years old")
print(f"Height: {height} feet")

Simple Explanation

Variables are like containers that store information
Use descriptive names (e.g. 'user_age' instead of 'a')
Python automatically detects the data type
Values can be changed at any time

Lists

Ordered collections of items

Click to flip

Example

# Create a list
fruits = ["apple", "banana", "cherry"]

# Access elements
print(fruits[0]) # First item: apple

# Modify list
fruits.append("orange")
fruits[1] = "blueberry"

# Loop through list
for fruit in fruits:
    print(fruit)

Simple Explanation

Lists store multiple items in a single variable
Items are ordered and can be changed
Access items using their index (position)
Useful for storing collections of related data

Loops

Repeating code blocks

Click to flip

Example

# For loop with range
for i in range(3):
    print(f"Count: {i}")

# While loop
count = 0
while count < 3:
    print(f"Number: {count}")
    count += 1

# Loop through list
colors = ["red", "green", "blue"]
for color in colors:
    print(color)

Simple Explanation

Loops repeat code multiple times
Use 'for' when you know how many times to repeat
Use 'while' to repeat until a condition changes
Essential for processing collections of data

Functions

Reusable code blocks

Click to flip

Example

# Define a function
def greet(name):
    return f"Hello, {name}!"

# Call the function
print(greet("Alice"))

# Function with default value
def power(base, exponent=2):
    return base ** exponent

print(power(3)) # 3^2 = 9
print(power(3, 3)) # 3^3 = 27

Simple Explanation

Functions group code into reusable blocks
Help avoid repeating the same code
Can accept inputs (parameters)
Can return results using the 'return' keyword

Dictionaries

Key-value pairs

Click to flip

Example

# Create dictionary
person = {
    "name": "Alice",
    "age": 30,
    "city": "New York"
}

# Access values
print(person["name"])

# Add new key-value
person["email"] = "alice@example.com"

# Loop through dictionary
for key, value in person.items():
    print(f"{key}: {value}")

Simple Explanation

Dictionaries store data as key-value pairs
Keys must be unique (like a word in a dictionary)
Access values using their key instead of position
Ideal for storing structured, labeled data

Conditionals

Making decisions in code

Click to flip

Example

# Simple if statement
age = 20
if age >= 18:
    print("You are an adult")

# If-else statement
temperature = 25
if temperature > 30:
    print("It's hot!")
else:
    print("It's pleasant")

# Multiple conditions
score = 85
if score >= 90:
    print("A")
elif score >= 80:
    print("B")
else:
    print("C")

Simple Explanation

Conditionals let your code make decisions
'if' runs code only when condition is true
'elif' checks another condition if first is false
'else' runs when all conditions are false