Python Membership & Bitwise Operators Explained | [DAY-11]–Python Basic to Advanced (AI/ML) in Hindi
Автор: Info Tech
Загружено: 2025-12-20
Просмотров: 50
In Day 11, we cover two extremely important (and often ignored) topics in Python:
Membership operators and Bitwise operators.
What you’ll learn in this lesson:
Membership Operators
Using in and not in
Checking items in lists and tuples
Real example: filtering a bulk list into:
invited users
non-invited users
Practical use cases like validation, filtering, access control
Bitwise Operators (with binary logic)
& Bitwise AND
| Bitwise OR
^ Bitwise XOR
~ Bitwise NOT
Left Shift
Right Shift
Understanding binary representation
Why ~5 becomes -6 (two’s complement explained)
Real-world permission system using bit flags:
READ
WRITE
DELETE
Checking permissions using bitwise AND
Converting numbers to binary using format()
This is not just Python — this is how systems, permissions, and performance logic work.
==== HOMEWORK [DAY - 11] =====
1. Membership Warm-up
Create a list:
items = ["pen", "book", "laptop", 100]
Write conditions to check:
if "laptop" is in the list
if "phone" is not in the list
Print meaningful messages, not just True/False.
2. Guest List Filter (Core Task 🔥)
Create:
friends = ["Aman", "Rohit", "Neha"]
guests = ["Rohit", "Kunal", "Aman", "Priya"]
Using a loop and membership operators:
create allowed_list
create blocked_list
Print both lists clearly.
3. Remove Duplicates Logic (Think Mode)
Given:
bulk_names = ["A", "B", "A", "C", "B"]
Create a new list that stores only unique names
(use in, not in, loops — no new concepts).
4. Bitwise Playground
Given:
a = 5
b = 6
Print results of:
a & b
a | b
a ^ b
~a
a shift left 1
b shift right 1
Also print their binary form using format(num, "08b").
5. Mini Project: Permission System 🛡️
Define:
READ = 0b001
WRITE = 0b010
DELETE = 0b100
Create a variable user_perm that has:
READ + WRITE access
Check using bitwise AND:
Can user read?
Can user write?
Can user delete?
Print permissions clearly.
_______________________________________
Send the homework directly in my email:
lichavi5260@gmail.com
and inform the name in comment.
_______________________________________
#PythonInHindi
#PythonBasics
#LearnPython
#ProgrammingInHindi
Доступные форматы для скачивания:
Скачать видео mp4
-
Информация по загрузке: