Python 2-Hour Crash Course
1. Introduction to Python (10 min)
• What is Python, Features, IDEs, Installing Python
Example:
print("Hello World")
2. Python Syntax & Variables (15 min)
• Variables, Data Types (int, float, str, bool), Type Conversion
Example:
x = 10
y = 5.5
name = "Alice"
print(x, y, name)
3. Operators (10 min)
• Arithmetic, Comparison, Logical, Assignment, Membership, Identity
Example:
print(2 + 3, 2 > 3, True and False)
4. Conditional Statements (15 min)
• if, elif, else
Example:
temp = 25
if temp > 30:
print("Hot")
elif temp > 20:
print("Warm")
else:
print("Cold")
5. Loops (20 min)
• for, while, break, continue, pass
Example:
for i in range(3):
print(i)
i=0
while i < 3:
print(i)
i += 1
6. Functions (15 min)
• Defining, Parameters, Return, Scope
Example:
def add(a, b):
return a + b
print(add(2, 3))
7. Data Structures (25 min)
• Lists, Tuples, Sets, Dictionaries
Example:
my_list = [1, 2]
my_tuple = (1, 2)
my_set = {1, 2}
my_dict = {'a': 1}
8. String Manipulation (10 min)
• Slicing, Methods, f-strings
Example:
name = 'Alice'
print(name[0], [Link](), f'Hello {name}')
9. File Handling (10 min)
• Open, Read, Write
Example:
with open('[Link]', 'w') as f:
[Link]('Hello')
10. OOP Basics (20 min)
• Class, Object, Method, Constructor
Example:
class Person:
def __init__(self, name):
[Link] = name
p = Person('John')
print([Link])