← Back to Python Course | Chapter 2: Input, Output & Operators | Lesson 6 of 16

Python Arithmetic Operators

Arithmetic operators किसी कैलकुलेटर के गणित वाले बटन हैं, जैसे जोड़, घटाव, गुणा और भाग। Python इनका उपयोग numbers के साथ हिसाब करने के लिए करता है।
Syntax
python
result = a + b  # also -, *, /, //, %, **

जोड़ और घटाव

जोड़ (+) और घटाव (-) संख्याओं पर ठीक वैसे काम करते हैं जैसी उम्मीद है, और जब दोनों operands strings या lists हों तो Python + को concatenation के अर्थ में भी बढ़ा देती है, जो उन्हें संख्यात्मक रूप से जोड़ने की बजाय सिरे से सिरे तक जोड़ता है।

उदाहरण: Addition and Subtraction

python
print(5 + 3)  # numeric addition
print(5 - 3)  # numeric subtraction
print("Hello" + " " + "World")  # + concatenates strings instead of adding

गुणा और भाग

गुणा (*) दो values को गुणा करता है, जबकि true division (/) Python 3 में हमेशा float लौटाता है, भले ही दो पूर्ण संख्याओं को बराबर-बराबर भाग दिया गया हो — 10 / 2 का नतीजा 5.0 है, 5 नहीं, जो दूसरी भाषाओं से आने वालों के लिए आम आश्चर्य है।

उदाहरण: Multiplication and Division

python
print(4 * 3)
print(10 / 2)

Floor Division

Floor division (//) भाग देकर नतीजे को सबसे नज़दीकी पूर्ण संख्या तक नीचे round करता है और शेषफल को छोड़ देता है — जब भी आपको पूर्ण-संख्या वाला नतीजा चाहिए, जैसे items को समान समूहों में बाँटना, तब उपयोगी।

उदाहरण: Floor Division

python
print(10 // 3)

Modulo Operator

Modulo operator (%) भागफल की बजाय भाग के बाद बचा हुआ हिस्सा (शेषफल) लौटाता है, इसीलिए number % 2 == 0 यह जाँचने का मानक तरीका है कि संख्या सम है या नहीं।

उदाहरण: Modulo Operator

python
number = 7
print(number % 2 == 0)

Exponentiation

Exponentiation operator (**) बाएँ operand को दाएँ operand की घात तक बढ़ाता है — 2 ** 10 का मान 1024 होता है — और यह अलग power function बुलाने की जगह Python का built-in विकल्प है।

उदाहरण: Exponentiation

python
print(2 ** 10)
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.