गणित#
परिचय#
मैथ मॉड्यूल में बिल्ट-इन पायथन फ़ंक्शन और पूरा math मॉड्यूल शामिल है, जो VEXcode AIM में स्वचालित रूप से उपलब्ध है। इन टूल्स की मदद से आप बुनियादी अंकगणित से लेकर उन्नत त्रिकोणमिति, राउंडिंग और लॉगरिदमिक ऑपरेशन तक सब कुछ कर सकते हैं।
इन फ़ंक्शन और स्थिरांकों का उपयोग करके आप अपने रोबोट की स्थिति, कोण, दूरी और अन्य संख्यात्मक मानों की गणना कर सकते हैं। आप डिग्री और रेडियन के बीच रूपांतरण भी कर सकते हैं, व्यंजकों का मूल्यांकन कर सकते हैं और अनंत और NaN जैसे विशेष मानों के साथ काम कर सकते हैं।
नीचे उपलब्ध गणितीय कार्यों, स्थिरांकों और उपयोगिताओं की सूची दी गई है:
अंतर्निहित फ़ंक्शन – पायथन में शामिल सामान्य गणितीय उपकरण।
abs– एक संख्या का निरपेक्ष मान लौटाता है।round– किसी संख्या को दशमलव स्थानों की निर्दिष्ट संख्या तक राउंड करता है।min– इनपुट मानों में से सबसे छोटा लौटाता है।max– इनपुट मानों में से सबसे बड़ा मान लौटाता है।sum– एक पुनरावर्ती में सभी मानों को जोड़ता है।divmod– भागफल और शेषफल को टपल के रूप में लौटाता है।pow– किसी संख्या को घात तक बढ़ाता है, वैकल्पिक रूप से मॉड्यूल्स के साथ।int– एक मान को पूर्णांक में परिवर्तित करता है।float– मान को फ्लोटिंग-पॉइंट संख्या में परिवर्तित करता है।
स्थिरांक – math मॉड्यूल से पूर्वनिर्धारित मान।
math.pi– स्थिरांक π (पाई).math.tau– स्थिरांक tau (2π).math.e– यूलर की संख्या, प्राकृतिक लॉग का आधार।math.inf– धनात्मक अनंत.math.nan- कोई संख्या नहीं (NaN)।
त्रिकोणमिति – कोणों की गणना करना और भुजाओं के बीच संबंध ज्ञात करना।
math.sin– रेडियन में कोण का साइन।math.cos– रेडियन में कोण का कोसाइन।math.tan– रेडियन में कोण का टेंजेंट।math.atan– रेडियन में मान का आर्कटेंजेंट।math.atan2– रेडियन में y/x का आर्कटेंजेंट, चतुर्थांश को ध्यान में रखते हुए।math.asin– रेडियन में मान का आर्कसाइन।math.acos– रेडियन में मान का आर्ककोसाइन।math.degrees– रेडियन को डिग्री में परिवर्तित करता है।math.radians– डिग्री को रेडियन में परिवर्तित करता है।
हाइपरबोलिक्स – उन्नत त्रिकोणमिति संबंधी कार्य।
math.sinh– एक मान का हाइपरबोलिक साइन।math.cosh– एक मान का हाइपरबोलिक कोसाइन।math.tanh– एक मान का अतिपरवलयिक स्पर्शरेखा।math.asinh– व्युत्क्रम अतिपरवलयिक साइन.math.acosh– व्युत्क्रम अतिपरवलयिक कोसाइन.math.atanh– व्युत्क्रम अतिपरवलयिक स्पर्शरेखा.
राउंडिंग और एब्सोल्यूट वैल्यू – परिशुद्धता या दिशा को समायोजित करें।
math.ceil– निकटतम पूर्णांक तक पूर्णांकित करता है।math.floor– निकटतम पूर्णांक तक नीचे की ओर पूर्णांकित करता है।math.trunc– दशमलव भाग हटाता है।math.fabs– फ्लोट के रूप में निरपेक्ष मान लौटाता है।
घातांक और लघुगणक – घात, मूल और लघुगणक की गणना।
math.pow– एक संख्या को घात तक बढ़ाता है।math.sqrt– वर्गमूल लौटाता है।math.exp– e की घात x की गणना करता है।math.log– प्राकृतिक लघुगणक (आधार e).math.log10– आधार-10 लघुगणक.math.log2– आधार-2 लघुगणक.math.factorial– एक पूर्णांक का फैक्टोरियल।math.expm1–e^x - 1के लिए अधिक सटीक परिणाम।
फ्लोटिंग पॉइंट ऑपरेशन्स – फ्लोट वैल्यूज का निरीक्षण या विश्लेषण करें।
math.modf– एक फ्लोट के भिन्नात्मक और पूर्णांक भाग लौटाता है।math.frexp– एक संख्या को मंटिसा और घातांक में विघटित करता है।math.fmod– भाज्य के चिह्न के साथ शेषफल।math.copysign– दूसरे के चिह्न के साथ एक मान लौटाता है।math.ldexp–x * (2 ** exp)की गणना करता है।
तुलना और अनुमान – सहनशीलता या श्रेणियों के साथ मानों की जाँच करें।
math.isclose– परीक्षण करता है कि क्या दो मान लगभग बराबर हैं।math.isfinite– जाँच करता है कि कोई संख्या परिमित है या नहीं।math.isinf– जाँच करता है कि कोई संख्या अनंत है या नहीं।math.isnan– जाँच करता है कि क्या कोई मान NaN है।
त्रुटि और गामा – विशेष गणितीय फलन।
math.gamma– गामा फ़ंक्शन (सामान्यीकृत फ़ैक्टोरियल).math.lgamma– लघुगणकीय गामा.math.erf– त्रुटि फ़ंक्शन.math.erfc– पूरक त्रुटि फ़ंक्शन.
अंतर्निर्मित कार्य#
पायथन कई अंतर्निहित फ़ंक्शन प्रदान करता है जो आपको अपने प्रोजेक्ट के भीतर गणितीय संक्रियाएं करने की अनुमति देते हैं।
abs#
abs किसी संख्या का निरपेक्ष मान लौटाता है, जिसमें से कोई भी ऋणात्मक चिह्न हटा दिया जाता है।
Usage:
abs(x)
पैरामीटर |
विवरण |
|---|---|
|
एक पूर्णांक या फ्लोट। |
# Get the absolute value of -10
abs_result = abs(-10)
robot.screen.print(abs_result)
# abs_result = 10
round#
round किसी संख्या को निर्दिष्ट संख्या में दशमलव स्थानों तक पूर्णांकित करता है।
Usage:
round(x, ndigits)
पैरामीटर |
विवरण |
|---|---|
|
एक पूर्णांक या फ्लोट। |
|
यह वैकल्पिक है। दशमलव के कितने स्थानों तक पूर्णांकित करना है, यह निर्धारित किया जा सकता है। डिफ़ॉल्ट मान 0 है। |
# Round 5.7 to the nearest integer
round_int_result = round(5.7)
robot.screen.print(round_int_result)
# round_int_result = 6
# Round 3.14159 to 2 decimal places
round_result = round(3.14159, 2)
robot.screen.print(round_result)
# round_result = 3.14
min#
min एकाधिक तर्कों या एक पुनरावृत्ति से सबसे छोटा मान लौटाता है।
Usage:
min(arg1, arg2, …) or min(sequence)
पैरामीटर |
विवरण |
|---|---|
|
तुलना करने के लिए संख्याएँ। |
|
संख्याओं वाली सूची, टपल या अन्य अनुक्रम। |
# Get the smallest number from 3, 7, and 1
min_result = min(3, 7, 1)
robot.screen.print(min_result)
# min_result = 1
# Get the smallest value from a list
min_list_result = min([10, 4, 25, 1])
robot.screen.print(min_list_result)
# min_list_result = 1
max#
max एकाधिक तर्कों या एक पुनरावृत्ति से सबसे बड़ा मान लौटाता है।
Usage:
max(arg1, arg2, …) or max(sequence)
पैरामीटर |
विवरण |
|---|---|
|
तुलना करने के लिए संख्याएँ। |
|
संख्याओं वाली सूची, टपल या अन्य अनुक्रम। |
# Get the largest number from 3, 7, and 1
max_result = max(3, 7, 1)
robot.screen.print(max_result)
# max_result = 7
# Get the largest value from a list
max_list_result = max([10, 4, 25, 1])
robot.screen.print(max_list_result)
# max_list_result = 25
sum#
sum एक इटरेबल में सभी मानों को जोड़ता है, जिसमें एक वैकल्पिक प्रारंभिक मान शामिल होता है।
Usage:
sum(sequence, start)
पैरामीटर |
विवरण |
|---|---|
|
संख्याओं वाली सूची, टपल या अन्य अनुक्रम। |
|
यह वैकल्पिक है। योग में जोड़ने के लिए एक मान। डिफ़ॉल्ट मान 0 है। |
# Calculate the sum of a list of numbers
sum_result = sum([1, 2, 3, 4, 5])
robot.screen.print(sum_result)
# sum_result = 15
# Calculate the sum of a list with a starting value of 10
sum_with_start = sum([1, 2, 3], 10)
robot.screen.print(sum_with_start)
# sum_with_start = 16
divmod#
divmod एक टपल लौटाता है जिसमें भागफल और शेषफल होता है।
Usage:
divmod(a, b)
पैरामीटर |
विवरण |
|---|---|
|
लाभांश। |
|
भाजक। |
# Perform integer division and remainder of 10 / 3
divmod_result = divmod(10, 3)
robot.screen.print(divmod_result)
# divmod_result = (3, 1)
pow#
pow किसी संख्या को घात तक बढ़ाता है और वैकल्पिक रूप से एक मॉड्यूलो ऑपरेशन करता है।
Usage:
pow(x, y, mod)
पैरामीटर |
विवरण |
|---|---|
|
आधार संख्या। |
|
घातांक। |
|
वैकल्पिक। एक मापांक मान। यदि प्रदान किया जाता है, तो |
# Calculate 2 raised to the power of 3
pow_result = pow(2, 3)
robot.screen.print(pow_result)
# pow_result = 8
# Calculate (5 ** 3) % 7
pow_mod_result = pow(5, 3, 7)
robot.screen.print(pow_mod_result)
# pow_mod_result = 6
int#
int फ़ंक्शन किसी संख्या या स्ट्रिंग को पूर्णांक में परिवर्तित करता है। यह स्ट्रिंग से पूर्णांक में परिवर्तित करते समय आधार रूपांतरण का भी समर्थन करता है।
Usage:
int(x, base)
पैरामीटर |
विवरण |
|---|---|
|
रूपांतरण के लिए एक संख्या, स्ट्रिंग या अन्य ऑब्जेक्ट। |
|
यह वैकल्पिक है। रूपांतरण के लिए उपयोग किया जाने वाला संख्या आधार। डिफ़ॉल्ट मान 10 है। |
# Convert a float to an integer to get rid of decimals
price = 19.99
price_int = int(price)
robot.screen.print(f"{price_int} coins")
# Output: 19 coins
# Convert a string into an integer to use in calculations
user_input = "55"
user_number = int(user_input)
robot.screen.print(user_number * 2)
# Output: 110
float#
float किसी संख्या या स्ट्रिंग को फ्लोटिंग-पॉइंट संख्या में परिवर्तित करता है।
Usage:
float(x)
पैरामीटर |
विवरण |
|---|---|
|
रूपांतरण के लिए एक संख्या, स्ट्रिंग या अन्य ऑब्जेक्ट। |
# Convert division result to a float
num_apples = 6
num_people = 2
apples_per_person = float(num_apples) / num_people
robot.screen.print(apples_per_person)
# Output: 3.00
# Convert a string into a float to use in calculations
user_input = "23.4"
user_number = float(user_input)
robot.screen.print(user_number * 3)
# Output: 70.20
गणित मॉड्यूल#
माइक्रो पायथन में मौजूद math मॉड्यूल सामान्य गणितीय गणनाओं को करने के लिए अतिरिक्त विधियाँ प्रदान करता है। इन विधियों में त्रिकोणमितीय, लघुगणकीय और अन्य संख्यात्मक संक्रियाएँ शामिल हैं।
VEXcode में math मॉड्यूल डिफ़ॉल्ट रूप से आयात किया जाता है।
Constants#
स्थिरांक पूर्वनिर्धारित मान होते हैं जो किसी परियोजना के दौरान स्थिर रहते हैं। इन्हें बिना किसी परिभाषा या असाइनमेंट की आवश्यकता के गणनाओं में उपयोग किया जा सकता है।
अनुकरणीय#
pi गणितीय स्थिरांक π देता है, जो एक वृत्त की परिधि और उसके व्यास का अनुपात है।
Usage:
math.pi
# Calculate the area of a circle with radius 5 using pi
circle_area = math.pi * 5 * 5
robot.screen.print(circle_area)
# circle_area = 78.54
ताउ#
tau 2π का मान देता है।
Usage:
math.tau
# Calculate the circumference of a circle with radius
circumference = math.tau * 5
robot.screen.print(circumference)
# circumference = 31.42
ई#
e प्राकृतिक लघुगणक का आधार देता है।
Usage:
math.e
# Calculate e raised to the power of 2
e_power = math.pow(math.e, 2)
robot.screen.print(e_power)
# e_power = 7.39
inf#
inf एक फ्लोट के रूप में धनात्मक अनंत देता है।
Usage:
math.inf
# Check if infinity is infinite
inf_value = math.inf
if math.isinf(inf_value):
robot.screen.print("Infinity")
# Prints "Infinity"
नेन#
nan “नॉट ए नंबर” (NaN) के लिए एक विशेष फ्लोट को दर्शाता है।
Usage:
math.nan
# Check if nan is Not a Number
nan_value = math.nan
if math.isnan(nan_value):
robot.screen.print("Not a Number")
# Prints "Not a Number"
Trigonometry#
पाप#
sin रेडियन में किसी कोण का साइन मान की गणना करता है और एक फ्लोट मान लौटाता है।
Usage:
math.sin(x)
पैरामीटर |
विवरण |
|---|---|
|
रेडियन में कोण को दर्शाने वाला एक फ्लोट या पूर्णांक मान। |
# Calculate the sine of 30 degrees in radians
sine_result = math.sin(math.radians(30))
robot.screen.print(sine_result)
# sine_result = 0.50
ओल#
cos रेडियन में एक कोण का कोसाइन की गणना करता है और एक फ्लोट मान लौटाता है।
Usage:
math.cos(x)
पैरामीटर |
विवरण |
|---|---|
|
रेडियन में कोण को दर्शाने वाला एक फ्लोट या पूर्णांक मान। |
# Calculate the cosine of 60 degrees in radians
cosine_result = math.cos(math.radians(60))
robot.screen.print(cosine_result)
# cosine_result = 0.50
टैन#
tan रेडियन में किसी कोण का टेंजेंट की गणना करता है और एक फ्लोट मान लौटाता है।
Usage:
math.tan(x)
पैरामीटर |
विवरण |
|---|---|
|
रेडियन में कोण को दर्शाने वाला एक फ्लोट या पूर्णांक मान। |
# Calculate the tangent of 45 degrees in radians
tangent_result = math.tan(math.radians(45))
robot.screen.print(tangent_result)
# tangent_result = 1.00
एक भूरा#
atan किसी संख्या का व्युत्क्रम स्पर्शरेखा (चाप स्पर्शरेखा) की गणना करता है और रेडियन में कोण को दर्शाने वाला एक फ्लोट लौटाता है।
Usage:
math.atan(x)
पैरामीटर |
विवरण |
|---|---|
|
एक फ्लोट या पूर्णांक। |
# Calculate the arc tangent of 1 in degrees
arc_tangent_result = math.degrees(math.atan(1.0))
robot.screen.print(arc_tangent_result)
# arc_tangent_result = 45.00
अतान2#
atan2 y/x के व्युत्क्रम टेंजेंट का मुख्य मान की गणना करता है और रेडियन में कोण का प्रतिनिधित्व करने वाला एक फ्लोट लौटाता है।
Usage:
math.atan2(y, x)
पैरामीटर |
विवरण |
|---|---|
|
y-निर्देशांक को दर्शाने वाला एक फ्लोट या पूर्णांक मान। |
|
x-निर्देशांक को दर्शाने वाला एक फ्लोट या पूर्णांक। |
# Calculate the inverse tangent of 1/1 in degrees
atan2_result = math.degrees(math.atan2(1.0, 1.0))
robot.screen.print(atan2_result)
# atan2_result = 45.00
के रूप में#
asin किसी संख्या का व्युत्क्रम साइन (आर्क साइन) की गणना करता है और रेडियन में कोण को दर्शाने वाला एक फ्लोट लौटाता है।
Usage:
math.asin(x)
पैरामीटर |
विवरण |
|---|---|
|
-1 और 1 के बीच का एक फ्लोट या पूर्णांक। |
# Calculate the arc sine of 0.5 in degrees
arc_sine_result = math.degrees(math.asin(0.5))
robot.screen.print(arc_sine_result)
# arc_sine_result = 30.00
एकोस#
acos किसी संख्या का व्युत्क्रम कोसाइन (आर्क कोसाइन) की गणना करता है और रेडियन में कोण को दर्शाने वाला एक फ्लोट मान लौटाता है।
Usage:
math.acos(x)
पैरामीटर |
विवरण |
|---|---|
|
-1 और 1 के बीच का एक फ्लोट या पूर्णांक। |
# Calculate the arc cosine of 0.5 in degrees
arc_cosine_result = math.degrees(math.acos(0.5))
robot.screen.print(arc_cosine_result)
# arc_cosine_result = 60.00
डिग्री#
degrees रेडियन से डिग्री में कोण को परिवर्तित करता है।
Usage:
math.degrees(x)
पैरामीटर |
विवरण |
|---|---|
|
रेडियन में कोण को दर्शाने वाला एक फ्लोट या पूर्णांक मान। |
# Convert pi radians to degrees
degrees_result = math.degrees(math.pi)
robot.screen.print(degrees_result)
# degrees_result = 180.00
रेडियंस#
radians डिग्री से रेडियन में कोण को परिवर्तित करता है।
Usage:
math.radians(x)
पैरामीटर |
विवरण |
|---|---|
|
एक फ्लोट या पूर्णांक जो डिग्री में कोण को दर्शाता है। |
# Convert 180 degrees to radians
radians_result = math.radians(180)
robot.screen.print(radians_result)
# radians_result = 3.14
Hyperbolics#
सिंह#
sinh x का हाइपरबोलिक साइन की गणना करता है।
Usage:
math.sinh(x)
पैरामीटर |
विवरण |
|---|---|
|
इनपुट मान को दर्शाने वाला एक फ्लोट या पूर्णांक। |
# Calculate the hyperbolic sine of 1
sinh_result = math.sinh(1)
robot.screen.print(sinh_result)
# sinh_result = 1.18
सोंटा#
cosh x का हाइपरबोलिक कोसाइन की गणना करता है।
Usage:
math.cosh(x)
पैरामीटर |
विवरण |
|---|---|
|
इनपुट मान को दर्शाने वाला एक फ्लोट या पूर्णांक। |
# Calculate the hyperbolic cosine of 1
cosh_result = math.cosh(1)
robot.screen.print(cosh_result)
# cosh_result = 1.54
तन#
tanh x का हाइपरबोलिक टेंजेंट की गणना करता है।
Usage:
math.tanh(x)
पैरामीटर |
विवरण |
|---|---|
|
इनपुट मान को दर्शाने वाला एक फ्लोट या पूर्णांक। |
# Calculate the hyperbolic tangent of 1
tanh_result = math.tanh(1)
robot.screen.print(tanh_result)
# tanh_result = 0.76
असिन्ह#
asinh x का व्युत्क्रम अतिपरवलयिक साइन की गणना करता है।
Usage:
math.asinh(x)
पैरामीटर |
विवरण |
|---|---|
|
इनपुट मान को दर्शाने वाला एक फ्लोट या पूर्णांक। |
# Calculate the inverse hyperbolic sine of 1
asinh_result = math.asinh(1)
robot.screen.print(asinh_result)
# asinh_result = 0.88
एकोश#
acosh x का व्युत्क्रम अतिपरवलयिक कोसाइन की गणना करता है।
Usage:
math.acosh(x)
पैरामीटर |
विवरण |
|---|---|
|
एक फ्लोट या पूर्णांक जो 1 के बराबर या उससे बड़ा हो। |
# Calculate the inverse hyperbolic cosine of 2
acosh_result = math.acosh(2)
robot.screen.print(acosh_result)
# acosh_result = 1.32
अतन्ह#
atanh x का व्युत्क्रम अतिपरवलयिक स्पर्शरेखा की गणना करता है।
Usage:
math.atanh(x)
पैरामीटर |
विवरण |
|---|---|
|
-1 और 1 के बीच का एक फ्लोट (अनन्य)। |
# Calculate the inverse hyperbolic tangent of 0.5
atanh_result = math.atanh(0.5)
robot.screen.print(atanh_result)
# atanh_result = 0.55
Rounding & Absolute Values#
प्लस्तर लगाना#
ceil किसी संख्या को निकटतम पूर्णांक तक पूर्णांकित करता है।
Usage:
math.ceil(x)
पैरामीटर |
विवरण |
|---|---|
|
एक फ्लोट या पूर्णांक जिसे राउंड अप किया जाना है। |
# Round 3.7 up to the nearest integer
ceil_result = math.ceil(3.7)
robot.screen.print(ceil_result)
# ceil_result = 4
ज़मीन#
floor किसी संख्या को निकटतम पूर्णांक तक नीचे की ओर राउंड करता है।
Usage:
math.floor(x)
पैरामीटर |
विवरण |
|---|---|
|
एक फ्लोट या पूर्णांक जिसे नीचे की ओर राउंड ऑफ किया जाना है। |
# Round 3.7 down to the nearest integer
floor_result = math.floor(3.7)
robot.screen.print(floor_result)
# floor_result = 3
ट्रंक#
trunc किसी संख्या के दशमलव भाग को बिना राउंड किए हटा देता है।
Usage:
math.trunc(x)
पैरामीटर |
विवरण |
|---|---|
|
एक फ्लोट जिसे छोटा किया जाना है। |
# Remove the decimal part of 3.7
trunc_result = math.trunc(3.7)
robot.screen.print(trunc_result)
# trunc_result = 3
फैब्स#
fabs किसी संख्या का निरपेक्ष मान फ्लोट के रूप में लौटाता है।
Usage:
math.fabs(x)
पैरामीटर |
विवरण |
|---|---|
|
एक फ्लोट या पूर्णांक। |
# Get the absolute value of -3.7
fabs_result = math.fabs(-3.7)
robot.screen.print(fabs_result)
# fabs_result = 3.70
Exponents & Logarithms#
पाउ#
pow x की घात y को बढ़ाता है और एक फ्लोट मान लौटाता है, भले ही दोनों इनपुट पूर्णांक हों।
Usage:
math.pow(x, y)
पैरामीटर |
विवरण |
|---|---|
|
एक फ्लोट या पूर्णांक आधार। |
|
एक फ्लोट या पूर्णांक घातांक। |
# Calculate 2 raised to the power of 3
power_result = math.pow(2, 3)
robot.screen.print(power_result)
# power_result = 8.00
वर्गमूल#
sqrt किसी संख्या का वर्गमूल निकालता है और एक फ्लोट मान लौटाता है, यहां तक कि पूर्ण वर्गों के लिए भी।
Usage:
math.sqrt(x)
पैरामीटर |
विवरण |
|---|---|
|
एक गैर-ऋणात्मक फ्लोट या पूर्णांक। |
# Calculate the square root of 16
sqrt_result = math.sqrt(16)
robot.screen.print(sqrt_result)
# sqrt_result = 4.00
ऍक्स्प#
exp किसी संख्या का घातांक ज्ञात करता है और एक फ्लोट मान लौटाता है।
Usage:
math.exp(x)
पैरामीटर |
विवरण |
|---|---|
|
एक फ्लोट या पूर्णांक। |
# Calculate e raised to the power of 1
exp_result = math.exp(1)
robot.screen.print(exp_result)
# exp_result = 2.72
लकड़ी का लट्ठा#
log किसी संख्या का प्राकृतिक लघुगणक निकालता है और एक फ्लोट मान लौटाता है।
Usage:
math.log(x)
पैरामीटर |
विवरण |
|---|---|
|
एक धनात्मक फ्लोट या पूर्णांक। |
# Calculate the natural logarithm (base e) of 7.389056
log_result = math.log(7.389056)
robot.screen.print(log_result)
# log_result = 2.00
लॉग10#
log10 किसी संख्या का आधार-10 लघुगणक की गणना करता है और एक फ्लोट मान लौटाता है।
Usage:
math.log10(x)
पैरामीटर |
विवरण |
|---|---|
|
एक धनात्मक फ्लोट या पूर्णांक। |
# Calculate the base-10 logarithm of 1000
log10_result = math.log10(1000)
robot.screen.print(log10_result)
# log10_result = 3.00
लॉग2#
log2 किसी संख्या का आधार-2 लघुगणक की गणना करता है और एक फ्लोट मान लौटाता है, भले ही x , 2 की घात हो।
Usage:
math.log2(x)
पैरामीटर |
विवरण |
|---|---|
|
एक धनात्मक फ्लोट या पूर्णांक। |
# Calculate the base-2 logarithm of 8
log2_result = math.log2(8)
robot.screen.print(log2_result)
# log2_result = 3.00
कारख़ाने का#
factorial पूर्णांक xका फैक्टोरियल लौटाता है, जो x तक के सभी धनात्मक पूर्णांकों का गुणनफल है।
Usage:
math.factorial(x)
पैरामीटर |
विवरण |
|---|---|
|
एक गैर-ऋणात्मक पूर्णांक। |
# Calculate 5 factorial (5!)
factorial_result = math.factorial(5)
robot.screen.print(factorial_result)
# factorial_result = 120
expm1#
expm1 ex - 1की गणना करता है, जो छोटे x के लिए अधिक सटीक है।
Usage:
math.expm1(x)
पैरामीटर |
विवरण |
|---|---|
|
घातांक का मान। |
# Compute expm1(1) (e^1 - 1)
expm1_result = math.expm1(1)
robot.screen.print(expm1_result)
# expm1_result = 1.72
Floating Point Operations#
मॉडफ#
modf एक संख्या को उसके भिन्नात्मक और पूर्णांक भागों में विघटित करता है और एक टपल (fractional part, integer part)लौटाता है, दोनों फ्लोट के रूप में।
Usage:
math.modf(x)
पैरामीटर |
विवरण |
|---|---|
|
विघटित करने के लिए एक फ्लोट या पूर्णांक। |
# Decompose 3.14159 into fractional and integer parts
fractional_part, integer_part = math.modf(3.14159)
robot.screen.print(fractional_part)
robot.screen.next_row()
robot.screen.print(integer_part)
# fractional_part = 0.14
# integer_part = 3.00
फ्रेक्सप#
frexp एक संख्या को उसके मंटिसा और घातांक में विघटित करता है और एक टपल (mantissa, exponent)लौटाता है, जहां मंटिसा एक फ्लोट है और घातांक एक पूर्णांक है।
Usage:
math.frexp(x)
पैरामीटर |
विवरण |
|---|---|
|
विघटित करने के लिए एक फ्लोट या पूर्णांक। |
# Decompose 16 into its mantissa and exponent
mantissa, exponent = math.frexp(16)
robot.screen.print(mantissa)
robot.screen.next_row()
robot.screen.print(exponent)
# mantissa = 0.50
# exponent = 5
एफएमओडी#
fmod भाज्य के चिह्न को बनाए रखते हुए विभाजन का शेषफल लौटाता है (x)।
Usage:
math.fmod(x, y)
पैरामीटर |
विवरण |
|---|---|
|
लाभांश। |
|
भाजक। |
# Calculate remainder of 10 / 3
# that preserves the sign of 10
fmod_result = math.fmod(10, 3)
robot.screen.print(fmod_result)
# fmod_result = 1.00
प्रतिलिपिहस्ताक्षर#
copysign x को y के चिह्न के साथ लौटाता है।
Usage:
math.copysign(x, y)
पैरामीटर |
विवरण |
|---|---|
|
संशोधित किया जाने वाला मान। |
|
वह मान जिसका चिह्न कॉपी किया जाएगा। |
# Return -10 with the sign of 3 (positive)
copysign_result = math.copysign(-10, 3)
robot.screen.print(copysign_result)
# copysign_result = 10.00
एलडीएक्सपी#
ldexp की गणना x * (2 ** exp), जो x * 2exp{code} के बराबर है।
Usage:
math.ldexp(x, exp)
पैरामीटर |
विवरण |
|---|---|
|
आधार मूल्य। |
|
घातांक। |
# Compute 3 * (2 ** 4)
ldexp_result = math.ldexp(3, 4)
robot.screen.print(ldexp_result)
# ldexp_result = 48.00
Comparison & Approximation#
बंद है#
isclose यह जांचता है कि क्या दो संख्याएँ एक निश्चित सीमा के भीतर लगभग बराबर हैं।
Usage:
math.isclose(a, b, rel_tol, abs_tol)
पैरामीटर |
विवरण |
|---|---|
|
तुलना करने के लिए पहली संख्या। |
|
तुलना करने के लिए दूसरी संख्या। |
|
यह वैकल्पिक है। a और b के आकार के सापेक्ष उनके बीच अधिकतम अनुमत अंतर। डिफ़ॉल्ट मान 1e-09 (बहुत छोटा) है। |
|
यह वैकल्पिक है। त्रुटि का एक निश्चित मार्जिन, शून्य के निकट की संख्याओं की तुलना करते समय उपयोगी होता है। डिफ़ॉल्ट मान 0.0 है। |
नोट: यदि rel_tol और abs_tol दोनों प्रदान किए जाते हैं, तो जो भी शर्त पहले पूरी होती है, वही परिणाम निर्धारित करती है।
# Check if 1.000000001 and 1.0 are close
# within the default tolerance
isclose_result = math.isclose(1.000000001, 1.0)
robot.screen.print(isclose_result)
# isclose_result = True
# Check if 0.0000001 and 0.0 are close
# using absolute tolerance
isclose_result = math.isclose(0.0000001, 0.0, abs_tol=1e-07)
robot.screen.print(isclose_result)
# isclose_result = True
# Check if 1000000.0 and 1000000.1 are close
# with a stricter tolerance
isclose_result = math.isclose(1000000.0, 1000000.1, rel_tol=1e-10)
robot.screen.print(isclose_result)
# isclose_result = False
अनंत है#
isfinite यह जाँचता है कि कोई संख्या परिमित है या नहीं। यह विधि एक बूलियन मान लौटाती है:
True– संख्या परिमित है।False– संख्या अनंत है।
Usage:
math.isfinite(x)
पैरामीटर |
विवरण |
|---|---|
|
जांच करने के लिए एक फ्लोट या पूर्णांक। |
# Check if 42 is a finite number (returns True)
is_finite_true = math.isfinite(42)
robot.screen.print(is_finite_true)
# is_finite_true = True
# Check if infinity is a finite number (returns False)
is_finite_false = math.isfinite(math.inf)
robot.screen.print(is_finite_false)
# is_finite_false = False
isinf#
isinf यह जांचता है कि कोई संख्या अनंत है या नहीं। यह विधि एक बूलियन मान लौटाती है:
True– संख्या अनंत है।False– संख्या परिमित है।
Usage:
math.isinf(x)
पैरामीटर |
विवरण |
|---|---|
|
जांच करने के लिए एक फ्लोट या पूर्णांक। |
# Check if infinity is an infinite number (returns True)
is_inf_true = math.isinf(math.inf)
robot.screen.print(is_inf_true)
# is_inf_true = True
# Check if 42 is an infinite number (returns False)
is_inf_false = math.isinf(42)
robot.screen.print(is_inf_false)
# is_inf_false = False
इस्नान#
isnan यह जांचता है कि कोई संख्या NaN (नॉट ए नंबर) है या नहीं। यह विधि एक बूलियन मान लौटाती है:
True– संख्या NaN है।False– यह संख्या एक वैध संख्या है।
Usage:
math.isnan(x)
पैरामीटर |
विवरण |
|---|---|
|
जांच करने के लिए एक फ्लोट या पूर्णांक। |
# Check if NaN (Not a Number) is NaN (returns True)
is_nan_true = math.isnan(math.nan)
robot.screen.print(is_nan_true)
# is_nan_true = True
# Check if 42 is NaN (returns False)
is_nan_false = math.isnan(42)
robot.screen.print(is_nan_false)
# is_nan_false = False
Error and Gamma Calculations#
गामा#
gamma xका गामा फ़ंक्शन की गणना करता है, जो वास्तविक और जटिल संख्याओं के लिए फ़ैक्टोरियल फ़ंक्शन को सामान्यीकृत करता है। एक पूर्णांक nके लिए, gamma(n) = (n-1)!।
Usage:
math.gamma(x)
पैरामीटर |
विवरण |
|---|---|
|
एक धनात्मक फ्लोट या पूर्णांक। |
# Calculate the gamma function of 5 (equivalent to 4!)
gamma_result = math.gamma(5)
robot.screen.print(gamma_result)
# gamma_result = 24.00
lgamma#
lgamma फ़ंक्शन gamma का प्राकृतिक लघुगणक की गणना करता है।
Usage:
math.lgamma(x)
पैरामीटर |
विवरण |
|---|---|
|
एक धनात्मक फ्लोट या पूर्णांक। |
# Calculate the natural logarithm of the
# gamma function of 5
lgamma_result = math.lgamma(5)
robot.screen.print(lgamma_result)
# lgamma_result = 3.18
एर्फ#
erf x के त्रुटि फ़ंक्शन की गणना करता है।
Usage:
math.erf(x)
पैरामीटर |
विवरण |
|---|---|
|
इनपुट मान को दर्शाने वाला एक फ्लोट या पूर्णांक। |
# Calculate the error function of 1
erf_result = math.erf(1)
robot.screen.print(erf_result)
# erf_result = 0.84
ईआरएफसी#
erfc xके पूरक त्रुटि फ़ंक्शन की गणना करता है, जिसे 1 - erf(x) के रूप में परिभाषित किया गया है।
Usage:
math.erfc(x)
पैरामीटर |
विवरण |
|---|---|
|
इनपुट मान को दर्शाने वाला एक फ्लोट या पूर्णांक। |
# Calculate the complementary error function of 1
erfc_result = math.erfc(1)
robot.screen.print(erfc_result)
# erfc_result = 0.16