Forwarded from Programming Quiz Channel
What exception does Python raise when you divide by zero?
Anonymous Quiz
16%
ValueError
72%
ZeroDivisionError
10%
ArithmeticError
1%
TypeError
π§ Think Like Python
Suppose you want to know if a username exists.
π» Many beginners write:
π’ Python gives you a simpler solution.
Less code. More readable. Usually faster to understand.
Whenever Python has a built-in way to express an idea, prefer it.
Suppose you want to know if a username exists.
π» Many beginners write:
found = False
for user in users:
if user == "Alex":
found = True
break
π’ Python gives you a simpler solution.
found = "Alex" in users
Less code. More readable. Usually faster to understand.
Whenever Python has a built-in way to express an idea, prefer it.
β€3
Python & NumPy Review Slides.pdf
1.1 MB
Python Notes for AI was requested by one of you. And here it is...
You can drop any future resource requests here.
You can drop any future resource requests here.
β€4
Python Script to Retrieve Saved Wi-Fi Passwords (Windows)
Someone requested this⦠We thought it might help.
π» How to use the above code:
1. Open any text editor (Notepad, VS Code, etc.)
2. Copy and paste the code above
3. Save the file as
4. Open Command Prompt or PowerShell as Administrator
5. Navigate to the folder where you saved the file
6. Run the command:
β The script will list all the Wi-Fi networks that are saved on your computer along with their passwords.
β οΈ This only works for networks that are already saved on your Windows PC. It cannot crack or find passwords of networks you have never connected to.
Someone requested this⦠We thought it might help.
import subprocess
def get_wifi_passwords():
# To get list of all saved Wi-Fi profiles
profiles_data = subprocess.check_output(['netsh', 'wlan', 'show', 'profiles']).decode('utf-8', errors="ignore").split('\n')
profiles = [line.split(":")[1].strip() for line in profiles_data if "All User Profile" in line]
print("\nSaved Wi-Fi Networks & Passwords:\n" + "-"*40)
for profile in profiles:
try:
# To get password for each profile
profile_info = subprocess.check_output(
['netsh', 'wlan', 'show', 'profile', profile, 'key=clear']
).decode('utf-8', errors="ignore").split('\n')
password = [line.split(":")[1].strip() for line in profile_info if "Key Content" in line]
print(f"Network : {profile}")
print(f"Password: {password[0] if password else 'None / Open Network'}\n")
except:
print(f"Network : {profile}")
print("Password: Unable to retrieve\n")
if __name__ == "__main__":
get_wifi_passwords()
π» How to use the above code:
1. Open any text editor (Notepad, VS Code, etc.)
2. Copy and paste the code above
3. Save the file as
wifi_passwords.py4. Open Command Prompt or PowerShell as Administrator
5. Navigate to the folder where you saved the file
6. Run the command:
python wifi_passwords.py
β The script will list all the Wi-Fi networks that are saved on your computer along with their passwords.
β οΈ This only works for networks that are already saved on your Windows PC. It cannot crack or find passwords of networks you have never connected to.
β€3π₯2
π¦ What Should You Learn After Python Basics?
β Functions & Modules
β¬οΈ
β Object-Oriented Programming
β¬οΈ
β File Handling
β¬οΈ
β Exception Handling
β¬οΈ
β Virtual Environments
β¬οΈ
β Git & GitHub
β¬οΈ
β Choose a Path:
β’ Web Development
β’ Automation
β’ Data Science
β’ Machine Learning
β’ Cybersecurity
β’ Backend APIs
Python is just the language.
Your specialization is what turns it into a career.
β Functions & Modules
β¬οΈ
β Object-Oriented Programming
β¬οΈ
β File Handling
β¬οΈ
β Exception Handling
β¬οΈ
β Virtual Environments
β¬οΈ
β Git & GitHub
β¬οΈ
β Choose a Path:
β’ Web Development
β’ Automation
β’ Data Science
β’ Machine Learning
β’ Cybersecurity
β’ Backend APIs
Python is just the language.
Your specialization is what turns it into a career.
β€3π1
β‘οΈ append() vs extend()
These two methods look similar, but they do completely different things.
Output:
Now compare it with:
Output:
π
π
This small difference causes countless beginner bugs.
These two methods look similar, but they do completely different things.
numbers = [1, 2, 3]
numbers.append([4, 5])
print(numbers)
Output:
[1, 2, 3, [4, 5]]
Now compare it with:
numbers = [1, 2, 3]
numbers.extend([4, 5])
print(numbers)
Output:
[1, 2, 3, 4, 5]
π
append() adds one object.π
extend() adds every element.This small difference causes countless beginner bugs.
β€5
Forwarded from Programming Quiz Channel
What does the Python slice list[::-1] do?
Anonymous Quiz
22%
Removes the last element
56%
Reverses the list
16%
Sorts the list descending
5%
Returns an empty list
π 10 Python Modules You Probably Didn't Know Existed
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
1.
textwrap - Format long blocks of text.2.
difflib - Compare files or strings.3.
fractions - Work with exact fractions.4.
decimal - High precision decimal arithmetic.5.
calendar - Generate calendars programmatically.6.
uuid - Generate unique IDs.7.
secrets - Create cryptographically secure tokens.8.
pprint - Print nested data structures beautifully.9.
platform - Detect operating system information.10.
getpass - Securely read passwords from the terminal.β€5π1
π Reading Python Error Messages
Suppose you see this.
Instead of panicking, read it from left to right.
TypeError β The operation uses the wrong data type.
str β Python found a string.
int β It also found an integer.
π You're trying to combine two incompatible types.
Suppose you see this.
TypeError: can only concatenate str (not "int") to str
Instead of panicking, read it from left to right.
TypeError β The operation uses the wrong data type.
str β Python found a string.
int β It also found an integer.
π You're trying to combine two incompatible types.
β€3
β‘οΈ Why Is This Loop So Slow?
Imagine you're checking whether thousands of usernames exist.
If
For every lookup.
Now imagine
That's why changing this:
into this:
can dramatically speed up membership checks without changing the rest of your code.
Imagine you're checking whether thousands of usernames exist.
for username in usernames:
if username in banned_users:
...
If
banned_users is a list, Python checks one element at a time.Alice?
Bob?
Charlie?
David?
...
For every lookup.
Now imagine
banned_users is a set. Python doesn't search one by one. It uses a hash table to jump directly to where the value should be.That's why changing this:
banned_users = [...]
into this:
banned_users = {...}can dramatically speed up membership checks without changing the rest of your code.
β€3
π Python Type Checking
πΉ What is Type Checking?
Type checking is the process of checking the data type of a value or variable. Python provides several ways to do this.
πΉ Using
πΉ Type Hints
Python also supports type hints, which make your code easier to understand and allow tools such as IDEs and static type checkers to detect potential problems.
Here:
π Key takeaway:
Python is dynamically typed, but that doesn't mean you should ignore types. Using
πΉ What is Type Checking?
Type checking is the process of checking the data type of a value or variable. Python provides several ways to do this.
age = 17
name = "Ted"
skills = ["Python", "AI", "Data Science"]
print(type(age)) # <class 'int'>
print(type(name)) # <class 'str'>
print(type(skills)) # <class 'list'>
πΉ Using
isinstance()isinstance() is often more useful when you want to check whether a value belongs to a particular type.age = 17
if isinstance(age, int):
print("Age is an integer")
πΉ Type Hints
Python also supports type hints, which make your code easier to understand and allow tools such as IDEs and static type checkers to detect potential problems.
def calculate_total(price: float, quantity: int) -> float:
return price * quantity
Here:
price: float β expected to be a decimal numberquantity: int β expected to be an integer-> float β expected return typeπ Key takeaway:
Python is dynamically typed, but that doesn't mean you should ignore types. Using
type(), isinstance(), and type hints can make your Python code more reliable and easier to maintain.β€3
π§ dict.get() in Python
Suppose you have this dictionary.
Now you try to access a key that doesn't exist.
π»Python raises:
Sometimes that's exactly what you want. A missing key should crash the program.
But often, a missing value is perfectly normal.
Instead of checking manually:
π’ Python provides:
If the key exists, you get its value.
If it doesn't, you get
You can even choose a default value.
Suppose you have this dictionary.
user = {
"name": "Alice",
"age": 24
}Now you try to access a key that doesn't exist.
print(user["email"])
π»Python raises:
KeyError: 'email'
Sometimes that's exactly what you want. A missing key should crash the program.
But often, a missing value is perfectly normal.
Instead of checking manually:
if "email" in user:
email = user["email"]
else:
email = None
π’ Python provides:
email = user.get("email")If the key exists, you get its value.
If it doesn't, you get
None instead of a crash.You can even choose a default value.
email = user.get("email", "Not provided")
π get() isn't shorter just for the sake of being shorter. It expresses the idea that a missing key is expected.π2β€1
π 50 Python Project Ideas
Whether you're a beginner or an experienced Python developer, building projects is the fastest way to improve your skills. Here's a curated list of 50 Python project ideas!
π’ Beginner
1. Calculator
2. To-Do List App
3. Number Guessing Game
4. Password Generator
5. Dice Rolling Simulator
6. Rock Paper Scissors Game
7. Countdown Timer
8. Unit Converter
9. Digital Clock
10. Contact Book
11. Expense Tracker
12. BMI Calculator
13. QR Code Generator
14. Quiz Application
15. Hangman Game
π‘ Intermediate
16. Weather App (API)
17. Currency Converter
18. URL Shortener
19. File Organizer
20. PDF Merger & Splitter
21. Bulk Image Resizer
22. YouTube Video Downloader
23. Web Scraper
24. Email Automation Tool
25. News Aggregator
26. Markdown to HTML Converter
27. Flashcard Learning App
28. Voice Assistant
29. Chat Application
30. Music Player
π΄ Advanced
31. AI Chatbot
32. Face Recognition Attendance System
33. Object Detection with YOLO
34. Sentiment Analysis Tool
35. Fake News Detector
36. Stock Price Prediction
37. Recommendation System
38. Resume Screening System
39. AI Image Caption Generator
40. Handwritten Digit Recognition
β‘οΈ Automation & Dev Tools
41. Website Uptime Monitor
42. Automated Backup Tool
43. File Encryption Tool
44. Network Port Scanner
45. Password Manager
46. Typing Speed Tester
47. Clipboard Manager
48. WiFi Password Viewer (For Your Own Device)
49. API Testing Tool
50. Personal Finance Dashboard
π‘ Which project are you planning to build next? Let us know in the comments! π
Whether you're a beginner or an experienced Python developer, building projects is the fastest way to improve your skills. Here's a curated list of 50 Python project ideas!
π’ Beginner
1. Calculator
2. To-Do List App
3. Number Guessing Game
4. Password Generator
5. Dice Rolling Simulator
6. Rock Paper Scissors Game
7. Countdown Timer
8. Unit Converter
9. Digital Clock
10. Contact Book
11. Expense Tracker
12. BMI Calculator
13. QR Code Generator
14. Quiz Application
15. Hangman Game
π‘ Intermediate
16. Weather App (API)
17. Currency Converter
18. URL Shortener
19. File Organizer
20. PDF Merger & Splitter
21. Bulk Image Resizer
22. YouTube Video Downloader
23. Web Scraper
24. Email Automation Tool
25. News Aggregator
26. Markdown to HTML Converter
27. Flashcard Learning App
28. Voice Assistant
29. Chat Application
30. Music Player
π΄ Advanced
31. AI Chatbot
32. Face Recognition Attendance System
33. Object Detection with YOLO
34. Sentiment Analysis Tool
35. Fake News Detector
36. Stock Price Prediction
37. Recommendation System
38. Resume Screening System
39. AI Image Caption Generator
40. Handwritten Digit Recognition
β‘οΈ Automation & Dev Tools
41. Website Uptime Monitor
42. Automated Backup Tool
43. File Encryption Tool
44. Network Port Scanner
45. Password Manager
46. Typing Speed Tester
47. Clipboard Manager
48. WiFi Password Viewer (For Your Own Device)
49. API Testing Tool
50. Personal Finance Dashboard
π‘ Which project are you planning to build next? Let us know in the comments! π
β€4
π Pythonβs Secret Memory Saver:
π Most Python tutorials teach you Object-Oriented Programming (OOP) using
When you create thousands or millions of object instances, Pythonβs default behavior wastes a massive amount of memory. Here is how
ββββββββββ
πΉ 1. The Hidden Problem with Default Python Classes
By default, Python stores an object's attributes in a dynamic dictionary called
π Why this is a problem:
β Dictionaries are flexible, but extremely memory-heavy.
β Every single instance gets its own dictionary overhead.
β If you instantiate 100,000 objects, your applicationβs RAM usage skyrockets.
ββββββββββ
π₯ 2. The Solution:
ββββββββββ
πΉ 3. Standard Class vs. Slotted Class
β Standard Class (Uses Heavy
β Optimized Class with
ββββββββββ
π 4. The Real-World Impact
By adding that single line of code (
βοΈ ~60% to 70% reduction in memory usage across large object lists.
βοΈ Faster attribute access (up to 20% faster speed because Python skips dictionary lookups).
ββββββββββ
β οΈ 5. The Trade-Off (What You Must Know)
Because
β You cannot dynamically add new attributes at runtime (e.g.,
ββββββββββ
β 6. When Should You Use It?
βοΈ Working with huge datasets or simulation objects in memory.
βοΈ Building high-performance backend microservices.
βοΈ Designing lightweight data structures (like custom Nodes, Vectors, or Points).
__slots__ β‘οΈπ Most Python tutorials teach you Object-Oriented Programming (OOP) using
self.variable = value. But almost none mention what happens under the hood or how it can quietly eat up your RAM.When you create thousands or millions of object instances, Pythonβs default behavior wastes a massive amount of memory. Here is how
__slots__ fixes that.ββββββββββ
πΉ 1. The Hidden Problem with Default Python Classes
By default, Python stores an object's attributes in a dynamic dictionary called
__dict__. π Why this is a problem:
β Dictionaries are flexible, but extremely memory-heavy.
β Every single instance gets its own dictionary overhead.
β If you instantiate 100,000 objects, your applicationβs RAM usage skyrockets.
ββββββββββ
π₯ 2. The Solution:
__slots____slots__ tells Python: Do not create a dynamic
__dict__ for this class. Only allow these specific attribute names.
ββββββββββ
πΉ 3. Standard Class vs. Slotted Class
β Standard Class (Uses Heavy
__dict__):class DataPoint:
def __init__(self, x, y, z):
self.x = x
self.y = y
self.z = z
β Optimized Class with
__slots__:class DataPoint:
# Restrict attributes & eliminate __dict__
__slots__ = ("x", "y", "z")
def __init__(self, x, y, z):
self.x = x
self.y = y
self.z = z
ββββββββββ
π 4. The Real-World Impact
By adding that single line of code (
__slots__): βοΈ ~60% to 70% reduction in memory usage across large object lists.
βοΈ Faster attribute access (up to 20% faster speed because Python skips dictionary lookups).
ββββββββββ
β οΈ 5. The Trade-Off (What You Must Know)
Because
__slots__ locks down your object structure:β You cannot dynamically add new attributes at runtime (e.g.,
point.new_var = 10 will throw an AttributeError). ββββββββββ
β 6. When Should You Use It?
βοΈ Working with huge datasets or simulation objects in memory.
βοΈ Building high-performance backend microservices.
βοΈ Designing lightweight data structures (like custom Nodes, Vectors, or Points).
β€3