Complete Guide to Python
1. What is Python?
Python is a high-level, interpreted programming language created by Guido van Rossum and
released in 1991. It is popular for its readability and wide application in web development, data
science, automation, and more.
2. Python Basics
Variables store data.
Example:
name = 'Arjun'
age = 13
Data Types:
- int, float, str, bool, list, tuple, set, dict
Input/Output:
name = input('Enter your name: ')
print('Hello', name)
3. Control Structures
If-Else Example:
if age > 10:
print('Older than 10')
else:
Complete Guide to Python
print('10 or younger')
Loops:
- for i in range(5): print(i)
- while count < 5: count += 1
4. Functions
Functions allow code reuse.
Example:
def greet(name):
print('Hello', name)
greet('Arjun')
5. Data Structures
List: fruits = ['apple', 'banana']
Tuple: coordinates = (10, 20)
Set: {1, 2, 3}
Dict: {'name': 'Arjun'}
6. Object-Oriented Programming (OOP)
Classes define templates for objects.
Example:
class Student:
Complete Guide to Python
def __init__(self, name, age):
self.name = name
self.age = age
7. Advanced Topics
- Modules: import math
- File Handling: with open('file.txt') as f
- Error Handling: try/except
8. Libraries & Frameworks
Web: Flask, Django
Data Science: NumPy, pandas
ML: TensorFlow, scikit-learn
Automation: Selenium
9. Python Special Features
- List comprehensions: [x*x for x in range(10)]
- Lambda: lambda x, y: x + y
10. Real-World Usage
Used by NASA, Google, Instagram. Python powers AI, web apps, games, and automation tools.