Numeric Functions in Python in Hindi – न्यूमेरिक फंक्शन्स क्या हैं?

Arpit Nageshwar
⏰ 4 min read

Table of Contents

Numeric Functions in Python in Hindi – न्यूमेरिक फंक्शन्स क्या हैं?

  • Numeric Functions Python के वे built-in functions होते हैं जिनका इस्तेमाल numbers पर अलग-अलग तरह के mathematical operations perform करने के लिए किया जाता है।

  • आसान भाषा में कहें तो, जब भी हमें किसी number का maximum, minimum, power, rounding या conversion निकालना हो, तो इसके लिए हमें बार-बार logic लिखने की जरूरत नहीं पड़ती, बल्कि Python के ready-made numeric functions काम आ जाते हैं।

  • ये functions Python में पहले से available होते हैं, इसलिए इन्हें इस्तेमाल करने के लिए किसी अलग library को import करने की जरूरत नहीं पड़ती।

  • Numeric functions integer, float और यहाँ तक कि complex numbers के साथ भी आसानी से काम करते हैं।

  • इन functions का इस्तेमाल mathematical calculations, data analysis, scientific programs और daily use वाले छोटे programs में बहुत ज्यादा किया जाता है।

  • Numeric functions को इस्तेमाल करने से code छोटा, साफ और ज्यादा readable बनता है, क्योंकि complex calculations एक ही line में हो जाती हैं।

  • Python में कुछ numeric functions built-in होते हैं (जैसे max, min, round), जबकि कुछ math module के through भी इस्तेमाल किए जाते हैं (जैसे sqrt, floor)।

  • Beginners के लिए numeric functions सीखना जरूरी है क्योंकि ये लगभग हर program में किसी न किसी रूप में इस्तेमाल होते ही हैं।

Example of Numeric Function – एक Simple शुरुआत

मान लो आपको दो numbers में से बड़ा number पता करना है। इसके लिए manually if-else लगाने की बजाय max() function का इस्तेमाल किया जा सकता है।

a = 25
b = 40
print(max(a, b))
# Output: 40

Commonly Used Numeric Functions in Hindi – eval(), max(), min(), pow(), round(), int()

1. eval() Function

eval() function किसी string के रूप में लिखी गई mathematical expression को execute करके उसका result return करता है। यह तब बहुत काम आता है जब कोई expression user से string के रूप में input ली गई हो।

expression = "5 + 3 * 2"
result = eval(expression)
print(result)
# Output: 11

2. max() Function

max() function दिए गए numbers, list या tuple में से सबसे बड़ी value return करता है। इसे दो या उससे ज्यादा values के साथ या फिर किसी iterable के साथ भी इस्तेमाल किया जा सकता है।

print(max(10, 25, 7))
# Output: 25

numbers = [4, 9, 2, 15, 6]
print(max(numbers))
# Output: 15

3. min() Function

min() function ठीक max() के उल्टा काम करता है, यानी यह दी गई values में से सबसे छोटी value return करता है।

print(min(10, 25, 7))
# Output: 7

numbers = [4, 9, 2, 15, 6]
print(min(numbers))
# Output: 2

4. pow() Function

pow() function किसी number की power (घात) निकालने के लिए इस्तेमाल होता है। इसमें दो values दी जाती हैं – base और exponent, और optional रूप से एक modulus value भी दी जा सकती है।

print(pow(2, 3))
# Output: 8

print(pow(2, 3, 5))
# Output: 3  (यानी 2 की power 3 = 8, फिर 8 mod 5 = 3)

5. round() Function

round() function किसी decimal number को उसके नजदीकी whole number या दिए गए decimal places तक round कर देता है।

print(round(7.6))
# Output: 8

print(round(3.14159, 2))
# Output: 3.14

6. int() Function

int() function किसी number (float या string के रूप में लिखा number) को integer में convert कर देता है। यह decimal part को round नहीं करता, बल्कि सीधे हटा (truncate कर) देता है।

print(int(7.9))
# Output: 7

print(int("15"))
# Output: 15

Commonly Used Numeric Functions eval() max() min() pow() round() int() ये सभी functions numbers पर अलग-अलग operations करते हैं

यह SVG Python के सबसे ज्यादा इस्तेमाल होने वाले numeric functions को एक साथ दिखा रहा है।

Numeric Functions को साथ में इस्तेमाल करना

Real programs में अक्सर एक से ज्यादा numeric functions को साथ में इस्तेमाल करना पड़ता है, जैसे नीचे दिए गए example में।

numbers = [12.5, 7.3, 19.8, 4.1]

print("Maximum:", max(numbers))
print("Minimum:", min(numbers))
print("Rounded Max:", round(max(numbers)))
print("Integer Min:", int(min(numbers)))

Difference Between round() and int() in Hindi – राउंड और इंट में फर्क

Point round() Function int() Function
Kaam (Function) Number को उसकी नजदीकी value तक round करता है Decimal part को हटाकर सीधे integer part return करता है
Decimal Handling Value को ऊपर या नीचे, जो भी नजदीक हो, उस तरफ round करता है Decimal part को हमेशा truncate (काट) कर देता है, round नहीं करता
Example round(7.8) → 8 int(7.8) → 7
Decimal Places Control round(value, digits) से decimal places की संख्या control की जा सकती है int() में decimal places control करने का कोई option नहीं होता
Negative Numbers पर Effect round(-7.6) → -8 (नजदीकी value की तरफ round करता है) int(-7.6) → -7 (सीधे decimal part हटा देता है)
Use Case जब accurate rounding चाहिए हो, जैसे price या percentage में जब सिर्फ integer value चाहिए हो, बिना rounding के

round() और int() को Example से समझें

value = 7.8

print(round(value))
# Output: 8   (नजदीकी whole number की तरफ round हुआ)

print(int(value))
# Output: 7   (सिर्फ decimal part हटा दिया गया)

इसी तरह negative numbers में भी दोनों functions अलग-अलग behave करते हैं, जो अक्सर beginners को confuse करता है।

value = -7.6

print(round(value))
# Output: -8

print(int(value))
# Output: -7

round() vs int() round(7.8) नजदीकी value तक round करता है Output: 8 int(7.8) Decimal part सीधे हटा देता है Output: 7

यह SVG round() और int() के काम करने के तरीके में मौजूद मुख्य फर्क को दिखा रहा है।

Importance of Numeric Functions in Hindi

1. Quick Calculations में मदद

Numeric functions की मदद से complex calculations भी सिर्फ एक line के code में हो जाती हैं, जिससे programmer का समय बचता है।

2. Data Analysis में उपयोग

Data की values में से maximum, minimum या average निकालने के लिए numeric functions data analysis programs में बहुत इस्तेमाल होते हैं।

3. Error-Free और Reliable Code

चूंकि ये functions Python के built-in और well-tested होते हैं, इसलिए manually logic लिखने के मुकाबले इनका इस्तेमाल करना ज्यादा reliable होता है।

4. Real-World Applications में जरूरी

Billing systems, banking calculations, scientific programs और games जैसी जगहों पर numeric functions लगातार इस्तेमाल होते हैं।

Advantages of Numeric Functions in Hindi – फायदे

  • Code छोटा और readable बनता है।

  • Manual calculations की जरूरत नहीं पड़ती, समय बचता है।

  • ये functions Python में built-in होते हैं, इसलिए किसी extra import की जरूरत नहीं।

  • Integer और float दोनों तरह की values पर आसानी से काम करते हैं।

  • Data analysis और mathematical programs में बहुत उपयोगी साबित होते हैं।

Disadvantages of Numeric Functions in Hindi – सीमाएं

  • eval() function का गलत इस्तेमाल security issues पैदा कर सकता है, खासकर जब user input सीधे eval() में दिया जाए।

  • round() और int() के behaviour में फर्क को न समझने पर calculations गलत हो सकती हैं।

  • कुछ advanced mathematical operations के लिए अलग से math module import करना पड़ता है।

  • Beginners अक्सर round() की rounding logic (जैसे .5 वाले cases) को लेकर confuse हो जाते हैं।

FAQs

Numeric Functions Python के built-in functions होते हैं जिनका इस्तेमाल numbers पर mathematical operations जैसे maximum, minimum, power, rounding और conversion करने के लिए किया जाता है।
eval() function किसी string के रूप में लिखी गई mathematical expression को execute करके उसका result return करता है, जैसे eval("5 + 3") से 8 मिलेगा।
round() function number को उसकी नजदीकी value तक round करता है, जबकि int() function सीधे decimal part को हटाकर सिर्फ integer part return कर देता है, बिना किसी rounding के।
max() और min() functions कई values, list या tuple के साथ इस्तेमाल किए जा सकते हैं, जो दी गई सभी values में से क्रमशः सबसे बड़ी और सबसे छोटी value return करते हैं।
pow() function में तीसरा argument modulus value होती है, जो पहले base की power निकालकर फिर उस result को दिए गए modulus से divide करके remainder return कर देती है।
Students के लिए numeric functions जरूरी हैं क्योंकि ये daily programming, data analysis और mathematical calculations की base हैं, और Python के लगभग हर exam में इनसे जुड़े questions पूछे जाते हैं।
Arpit Nageshwar

✍️ Arpit Nageshwar

Post-graduated | Web Developer | +3 yr Experience | IIT Kharagpur Certified