▶️ आगे: 10 Practice Problems — Operators (with Hints & Solutions)

🏅 10 Practice Problems — Python Operators (in Hindi)

नीचे दिए गए प्रश्नों से python operators in hindi में आपकी पकड़ मजबूत होगी। हर प्रश्न के लिए Hint और Solution मौजूद है। कोड ब्लॉक्स कॉपी-बटन के साथ हैं।

Q1. Discount Price

MRP और discount% देकर final price निकालें (2 दशमलव तक)।

💡 Hint

price × (1 – d/100); round()

✅ Solution
mrp = 999
disc = 20
final_price = round(mrp * (1 - disc/100), 2)
print(final_price)  # 799.2

Q2. Operator Precedence

Expression 2 + 3 * 4 ** 2 का परिणाम बताएं।

💡 Hint

** > * > +

✅ Solution
print(2 + 3 * 4 ** 2)  # 2 + 3 * 16 = 50

Q3. Wallet Updates

wallet = 1000; ₹250 जोड़ें, फिर 10% tax घटाएँ (compound assignment से)।

💡 Hint

+= और -= के साथ 10% = ×0.10

✅ Solution
wallet = 1000
wallet += 250
wallet -= wallet * 0.10
print(round(wallet, 2))  # 1125.0

Q4. Comparison Chain

जांचें कि score 0 और 100 के बीच है (inclusive)।

💡 Hint

0 ≤ score ≤ 100 chaining

✅ Solution
score = 86
print(0 <= score <= 100)  # True

Q5. Login Check

email और password non-empty हों तो “OK” प्रिंट करें (short-circuit use)।

💡 Hint

if email and password:

✅ Solution
email, password = "a@b.com", "secret"
if email and password:
    print("OK")
else:
    print("Invalid")

Q6. Find Vowel

string में कोई vowel मौजूद है या नहीं?

💡 Hint

any(ch in 'aeiou')

✅ Solution
s = "Vista"
print(any(ch.lower() in "aeiou" for ch in s))  # True

Q7. Identity vs Equality

दो lists equal हों पर same object न हों — test करें।

💡 Hint

== vs is

✅ Solution
a = [1,2,3]
b = [1,2,3]
print(a == b)  # True (values equal)
print(a is b)  # False (different objects)

Q8. Even/Odd (Bitwise)

बिना % के जाँचें कि n even है या odd।

💡 Hint

n & 1

✅ Solution
n = 42
print("Even" if (n & 1) == 0 else "Odd")  # Even

Q9. Pagination Calc

items=73, per_page=10 → total pages? (floor/ceil logic)

💡 Hint

(n + k - 1)//k

✅ Solution
items, per_page = 73, 10
pages = (items + per_page - 1) // per_page
print(pages)  # 8

Q10. Filter Emails

list में से valid emails (जिनमें '@' और '.') हों।

💡 Hint

'@' in s and '.' in s

✅ Solution
emails = ["a@b.com", "foo", "x@y", "c@d.org"]
valid = [e for e in emails if ("@" in e and "." in e)]
print(valid)  # ['a@b.com', 'c@d.org']
```html
📋 Get Course Details
```