Python Basics · Beginner Friendly
Python Basics Explained in Simple Language
Quick summary — Python basics in plain English
Python is one of the easiest languages to learn — but only if it's explained simply. This guide covers variables, lists, dictionaries, loops, functions, and OOP — with the smallest possible jargon.
In this guide you will learn:
- Variables — how to store values.
- Data types & structures — numbers, strings, lists, dicts.
- Control flow — if, for, while.
- Functions — reusable blocks of code.
- OOP basics — classes and objects.
SECTION 01Variables & data types
A variable is a name for a value. Python figures out the type automatically — you don't declare it.
# Numbers
age = 25
price = 199.99
# Strings
name = "Ankit"
greeting = 'Hello!'
# Booleans
is_active = True
has_paid = False
# Print them
print(name, age)
# → Ankit 25
# String operations
first = "Ankit"
last = "Kaushik"
# Concatenation
full = first + " " + last
# → "Ankit Kaushik"
# f-strings (modern way)
msg = f"Hello, {first}!"
# → "Hello, Ankit!"
# Methods
print(first.lower()) # → ankit
print(first.upper()) # → ANKIT
print(len(first)) # → 5
int age = 25. Just age = 25.
This is why Python is beginner-friendly.
SECTION 02Lists, tuples & dictionaries
These are the three most-used data structures in Python. Learn them and 80% of Python code becomes readable.
| Structure | Use it when… | Example |
|---|---|---|
List [] | You need an ordered, changeable collection | names = ["Ankit", "Priya"] |
Tuple () | You need an ordered, immutable collection | coords = (28.6, 77.2) |
Dictionary {} | You need key-value pairs | user = {"name": "Ankit", "age": 25} |
Set {} | You need unique values only | tags = {"python", "data"} |
# Lists — ordered, changeable
names = ["Ankit", "Priya", "Rahul"]
# Access by index
print(names[0]) # → Ankit
# Add
names.append("Sara")
# Remove
names.remove("Rahul")
# Loop over
for name in names:
print(f"Hello, {name}")
# Dicts — key-value pairs
user = {
"name": "Ankit",
"age": 25,
"skills": ["Python", "SQL", "pandas"],
}
# Access by key
print(user["name"]) # → Ankit
print(user.get("email")) # → None (safe)
# Add / update
user["email"] = "a@x.com"
# Loop over
for key, value in user.items():
print(f"{key}: {value}")
SECTION 03If, for, while — control flow
Control flow is how you tell Python "do this only if…" or "do this repeatedly." These three keywords cover 90% of logic.
# if / elif / else
score = 82
if score >= 90:
print("A")
elif score >= 80:
print("B") # ← this runs
elif score >= 70:
print("C")
else:
print("F")
# for loop — iterate over a collection
fruits = ["apple", "banana", "cherry"]
for fruit in fruits:
print(fruit)
# range for counting
for i in range(5):
print(i) # 0, 1, 2, 3, 4
# while loop — repeat until condition is false
count = 0
while count < 3:
print(count)
count += 1
# Loop control
for n in range(10):
if n == 3:
continue # skip this one
if n == 7:
break # stop the loop
print(n)
for when you know how many
times to repeat. Use while when you repeat until a
condition changes. If you're unsure — for is safer.
SECTION 04Functions
A function is a reusable block of code. Give it a name, feed it inputs, get outputs. That's it.
def greet(name):
return f"Hello, {name}!"
# Call it
message = greet("Ankit")
print(message) # → Hello, Ankit!
# A function that does more
def is_adult(age):
return age >= 18
print(is_adult(25)) # → True
print(is_adult(15)) # → False
# Default arguments
def greet(name, greeting="Hello"):
return f"{greeting}, {name}!"
print(greet("Ankit")) # → Hello, Ankit!
print(greet("Priya", "Namaste")) # → Namaste, Priya!
# Multiple return values
def min_max(numbers):
return min(numbers), max(numbers)
lo, hi = min_max([3, 7, 1, 9])
print(lo, hi) # → 1 9
# *args — accept any number of positional arguments
def total(*numbers):
return sum(numbers)
print(total(1, 2, 3)) # → 6
print(total(10, 20)) # → 30
SECTION 05OOP basics
OOP lets you bundle data and behaviour into "objects." Think of a class as a blueprint, and an object as an instance of that blueprint.
class User:
def __init__(self, name, email):
self.name = name
self.email = email
def greet(self):
return f"Hi, I'm {self.name}"
def is_valid(self):
return "@" in self.email
# Create objects
u1 = User("Ankit", "ankit@example.com")
u2 = User("Priya", "priya@example.com")
print(u1.greet()) # → Hi, I'm Ankit
print(u2.is_valid()) # → True
# Invalid user
u3 = User("Test", "not-an-email")
print(u3.is_valid()) # → False
self
— that's Python's way of saying "this object." Once that clicks,
OOP becomes straightforward.
SECTION 06Interview Q&A — Python basics
Q1What's the difference between a list and a tuple?
Lists are mutable (you can change them) and use square brackets
[]. Tuples are immutable (can't be changed) and use
parentheses (). Use tuples for fixed data like
coordinates; use lists for collections that change.
Q2When do you use a dictionary over a list?
Use a dict when you need to look things up by key — like a user's details by ID. Use a list when you need an ordered collection and don't need key-based access. Dicts are O(1) for lookups; lists are O(n).
Q3What is a function? Why do we use them?
A function is a reusable block of code with a name. We use them to avoid repetition, make code readable, and break complex logic into small, testable pieces. A good function does one thing and has a clear name.
Q4What does self mean in Python?
self refers to the instance of the class. When you
write def greet(self) inside a class, Python passes
the object itself as the first argument. It's how methods
access and modify the instance's data.
Q5Explain the difference between for and while.
for is used when you know the number of iterations
or are iterating over a collection. while is used
when you repeat until a condition changes — like waiting for
user input. If you're unsure, for is safer because
it has less risk of infinite loops.
SECTION 07Test yourself — Python basics quiz
Five questions. No sign-up.
0 / 5Pick an answer to see why it is right or wrong.
SECTION 08Frequently asked questions
Do I need to learn all Python basics before projects?
No — start building small projects as soon as you know variables, lists, loops, and functions. The rest (OOP, decorators, etc.) comes faster when you're building real things and hit real problems.
How long does it take to learn Python basics?
4–6 weeks with 1–2 hours/day. You'll cover variables, data structures, control flow, functions, and basic OOP. Another 4–6 weeks of practice gets you to comfort-level where you can build small scripts without help.
Should I learn OOP early?
Not necessarily. Start with functions and data structures first — you can write most Python without classes. Learn OOP when you encounter a problem that needs it — like a class hierarchy for a real project or framework.
What's the best way to practice Python basics?
Small projects that solve real problems: expense tracker, to-do list, temperature converter, quiz game. Each project forces you to combine variables, lists, loops, and functions. Kaggle's Python course and HackerRank practice also help.
Do I need to memorise syntax?
No — every Python developer looks things up. What matters is understanding concepts (when to use a list vs dict, how functions work) not memorizing syntax. Keep Google and Python docs open — everyone does.
SECTION 09Related reads
Classroom & online · Noida
Learn Python from scratch
Our Python Programming Course covers everything in this guide — plus real projects, debugging, and interview prep. Perfect for complete beginners.
₹15,500 · full programme- Beginner-friendly faculty
- Real projects + portfolio
- Interview prep
- Weekday & weekend batches




