Topic 4 / 5📁 Unit Index
BP101T • Unit 1Topic 4 of 5⏱ 5 Min Read

4. Python Operators: Arithmetic, Relational, Logical & Assignment

💡 Core Concept & Clinical Context:

Operators are special symbols in Python that execute arithmetic calculations, comparisons, and logical evaluations on operands (variables and values). In pharmaceutical computing, arithmetic operators compute dilution factors and body surface areas; relational operators compare lab test values against pharmacopoeial monographs; logical operators combine multiple release criteria (e.g., hardness AND dissolution); and assignment operators update running batch totals.

Pharmaceutical Code & Calculation Examples:
1Comprehensive Batch Release Quality Check Script

Demonstrating arithmetic, relational, and logical operators in evaluating finished tablet batches.

example_1.py
# Batch quality parameters
tablet_hardness_kg = 5.8
disintegration_time_min = 11.5
friability_percent = 0.65

# Relational & Logical Operators for IP Tablet Release
# Standards: Hardness >= 4.5 kg, DT <= 15 min, Friability <= 1.0%
hardness_ok = tablet_hardness_kg >= 4.5
dt_ok = disintegration_time_min <= 15.0
friability_ok = friability_percent <= 1.0

# Logical AND operation: All 3 criteria must be True
batch_passed = hardness_ok and dt_ok and friability_ok

print(f"Hardness Test: {hardness_ok} | DT Test: {dt_ok} | Friability Test: {friability_ok}")
print(f"Final Batch Commercial Release: {batch_passed}")
📋Key Takeaways & Exam Highlights
  • Arithmetic Operators: `+` (add), `-` (subtract), `*` (multiply), `/` (float divide), `//` (floor/integer divide), `%` (modulus/remainder), `**` (exponentiation/power).
  • Relational Operators: `==` (equal), `!=` (not equal), `>`, `<`, `>=`, `<=` (return boolean True/False).
  • Logical Operators: `and` (True if both are true), `or` (True if at least one is true), `not` (inverts boolean value).
  • Compound Assignment: `+=`, `-=`, `*=`, `/=` modify variables in place efficiently.
🇮🇳 हिन्दी व्याख्या (4. Python Operators: Arithmetic, Relational, Logical & Assignment)

ऑपरेटर्स के ज़रिए जोड़-घटाव (Arithmetic), दो मानों की तुलना (Relational जैसे >=, <=), और कई शर्तों को एक साथ जोड़ना (Logical जैसे and, or) संभव होता है।

Need to see the complete unit overview, solved numericals, or exam checklist?Open Unit 1 Overview Hub →