Python Concepts: Beginner to Advanced (Explained Simply)
1. Printing Something
This is how Python talks to us:
print("Hello, world!")
Whatever is inside print() is printed.
2. Variables
Variables are like boxes that store stuff:
name = "Arinjay"
age = 13
Now name holds "Arinjay" and age holds 13.
3. Data Types
Python understands different types of data:
text = "Hello" (string)
number = 25 (integer)
height = 5.6 (float)
is_smart = True (boolean)
4. Math Operations
Python Concepts: Beginner to Advanced (Explained Simply)
Python can do math easily:
a=5
b=2
print(a + b) # 7
print(a / b) # 2.5
print(a ** b) # 25
5. Taking Input
You can ask the user to type something:
name = input("What is your name? ")
print("Hello", name)
6. If...Else (Decisions)
Let Python make choices:
age = int(input("Enter age: "))
if age >= 18:
print("Adult")
else:
print("Child")
7. Loops
Python Concepts: Beginner to Advanced (Explained Simply)
Do things again and again:
# while loop
i=1
while i <= 5:
print(i)
i += 1
# for loop
for i in range(5):
print("Hi", i)
8. Functions
Functions help reuse code:
def greet(name):
print("Hello", name)
greet("Arinjay")
9. Lists
Store many items:
fruits = ["apple", "banana", "mango"]
Python Concepts: Beginner to Advanced (Explained Simply)
print(fruits[0])
10. Loops with Lists
Use for loop to print each item:
for fruit in fruits:
print(fruit)
11. Dictionaries
Store info in key-value pairs:
student = {"name": "Arinjay", "age": 13}
print(student["name"])
12. Tuples
Fixed lists (can't change):
colors = ("red", "green", "blue")
13. Sets
Only unique values:
numbers = {1, 2, 3, 3}
Python Concepts: Beginner to Advanced (Explained Simply)
print(numbers) # {1, 2, 3}
14. File Handling
# Write to a file
with open("file.txt", "w") as f:
f.write("Hello")
# Read from file
with open("file.txt", "r") as f:
print(f.read())
15. Try and Except
Catch errors:
try:
num = int(input("Enter number: "))
print(100 / num)
except:
print("Error!")
16. Classes and Objects
Like blueprints:
class Dog:
Python Concepts: Beginner to Advanced (Explained Simply)
def __init__(self, name):
self.name = name
def bark(self):
print(self.name, "says Woof!")
d = Dog("Tommy")
d.bark()
17. Modules and Libraries
Use built-in power:
import math
print(math.sqrt(25))
18. Lambda Function
Mini function:
square = lambda x: x * x
print(square(4)) # 16
19. List Comprehension
Short loop:
squares = [x*x for x in range(5)]
Python Concepts: Beginner to Advanced (Explained Simply)
print(squares)
20. Advanced Topics Coming Soon
We'll cover decorators, generators, iterators with simple examples next!