गणित#

परिचय#

मैथ मॉड्यूल में बिल्ट-इन पायथन फ़ंक्शन और पूरा math मॉड्यूल शामिल है, जो VEXcode GO में स्वचालित रूप से उपलब्ध है। इन टूल्स की मदद से आप बुनियादी अंकगणित से लेकर उन्नत त्रिकोणमिति, राउंडिंग और लॉगरिदमिक ऑपरेशन तक सब कुछ कर सकते हैं।

इन फ़ंक्शन और स्थिरांकों का उपयोग करके आप अपने रोबोट की स्थिति, कोण, दूरी और अन्य संख्यात्मक मानों की गणना कर सकते हैं। आप डिग्री और रेडियन के बीच रूपांतरण भी कर सकते हैं, व्यंजकों का मूल्यांकन कर सकते हैं और अनंत और NaN जैसे विशेष मानों के साथ काम कर सकते हैं।

नीचे उपलब्ध गणितीय कार्यों, स्थिरांकों और उपयोगिताओं की सूची दी गई है:

अंतर्निहित फ़ंक्शन – पायथन में शामिल सामान्य गणितीय उपकरण।

  • abs – एक संख्या का निरपेक्ष मान लौटाता है।

  • round – किसी संख्या को दशमलव स्थानों की निर्दिष्ट संख्या तक राउंड करता है।

  • min – इनपुट मानों में से सबसे छोटा लौटाता है।

  • max – इनपुट मानों में से सबसे बड़ा मान लौटाता है।

  • sum – एक पुनरावर्ती में सभी मानों को जोड़ता है।

  • divmod – भागफल और शेषफल को टपल के रूप में लौटाता है।

  • pow – एक संख्या को घात तक बढ़ाता है, वैकल्पिक रूप से मॉड्यूल्स के साथ।

  • int – एक मान को पूर्णांक में परिवर्तित करता है।

  • float – मान को फ्लोटिंग-पॉइंट संख्या में परिवर्तित करता है।

स्थिरांक – math मॉड्यूल से पूर्वनिर्धारित मान।

  • math.pi – स्थिरांक π (पाई).

  • math.tau – स्थिरांक ताऊ (2π).

  • math.e – यूलर की संख्या, प्राकृतिक लॉग का आधार।

त्रिकोणमिति – कोणों की गणना करना और भुजाओं के बीच संबंध ज्ञात करना।

  • math.sin – रेडियन में कोण का साइन।

  • math.cos – रेडियन में कोण का कोसाइन।

  • math.tan – रेडियन में कोण का टेंजेंट।

  • math.atan – रेडियन में मान का आर्कटेंजेंट।

  • math.atan2 – रेडियन में y/x का आर्कटेंजेंट, चतुर्थांश को ध्यान में रखते हुए।

  • math.asin – रेडियन में मान का आर्कसाइन।

  • math.acos – रेडियन में मान का आर्ककोसाइन।

  • math.degrees – रेडियन को डिग्री में परिवर्तित करता है।

  • math.radians – डिग्री को रेडियन में परिवर्तित करता है।

राउंडिंग और एब्सोल्यूट वैल्यू – परिशुद्धता या दिशा को समायोजित करें।

  • math.ceil – निकटतम पूर्णांक तक पूर्णांकित करता है।

  • math.floor – निकटतम पूर्णांक तक नीचे की ओर पूर्णांकित करता है।

  • math.trunc – दशमलव भाग हटाता है।

  • math.fabs – फ्लोट के रूप में निरपेक्ष मान लौटाता है।

घातांक और लघुगणक – घात, मूल और लघुगणक की गणना।

  • math.pow – एक संख्या को घात तक बढ़ाता है।

  • math.sqrt – वर्गमूल लौटाता है।

  • math.exp – e की घात x की गणना करता है।

  • math.log – x का लघुगणक ज्ञात कीजिए।

  • math.log10 – x का आधार-10 लघुगणक की गणना करता है।

फ्लोटिंग पॉइंट ऑपरेशन्स – फ्लोट वैल्यूज का निरीक्षण या विश्लेषण करें।

  • math.modf – एक फ्लोट के भिन्नात्मक और पूर्णांक भाग लौटाता है।

  • math.frexp – एक संख्या को मंटिसा और घातांक में विघटित करता है।

  • math.fmod – भाज्य के चिह्न के साथ शेषफल।

  • math.copysign – दूसरे के चिह्न के साथ एक मान लौटाता है।

  • math.ldexp – x * (2 ** exp) की गणना करता है।

अंतर्निर्मित कार्य#

पायथन कई अंतर्निहित फ़ंक्शन प्रदान करता है जो आपको अपने प्रोजेक्ट के भीतर गणितीय संक्रियाएं करने की अनुमति देते हैं।

abs#

abs किसी संख्या का निरपेक्ष मान लौटाता है, जिसमें से कोई भी ऋणात्मक चिह्न हटा दिया जाता है।

Usage:
abs(x)

पैरामीटर

विवरण

x

एक पूर्णांक या फ्लोट।

def main():
    # Get the absolute value of -10
    abs_result = abs(-10)
    console.print(abs_result)

# abs_result = 10

# Start threads — Do not delete
start_thread(main)

round#

round किसी संख्या को निर्दिष्ट संख्या में दशमलव स्थानों तक पूर्णांकित करता है।

Usage:
round(x, ndigits)

पैरामीटर

विवरण

x

एक पूर्णांक या फ्लोट।

ndigits

यह वैकल्पिक है। दशमलव के कितने स्थानों तक पूर्णांकित करना है, यह निर्धारित किया जा सकता है। डिफ़ॉल्ट मान 0 है।

def main():
    # Round 5.7 to the nearest integer
    round_int_result = round(5.7)
    console.print(round_int_result)

# round_int_result = 6

# Start threads — Do not delete
start_thread(main)

def main():
    # Round 3.14159 to 2 decimal places
    round_result = round(3.14159, 2)
    console.print(round_result, precision=2)

# round_result = 3.14

# Start threads — Do not delete
start_thread(main)

min#

min एकाधिक तर्कों या एक पुनरावृत्ति से सबसे छोटा मान लौटाता है।

Usage:
min(arg1, arg2, …) or min(sequence)

पैरामीटर

विवरण

arg1, arg2, …

तुलना करने के लिए संख्याएँ।

sequence

संख्याओं वाली सूची, टपल या अन्य अनुक्रम।

def main():
    # Get the smallest number from 3, 7, and 1
    min_result = min(3, 7, 1)
    console.print(min_result)

# min_result = 1

# Start threads — Do not delete
start_thread(main)

def main():
    # Get the smallest value from a list
    min_list_result = min([10, 4, 25, 1])
    console.print(min_list_result)

# min_list_result = 1

# Start threads — Do not delete
start_thread(main)

max#

max एकाधिक तर्कों या एक पुनरावृत्ति से सबसे बड़ा मान लौटाता है।

Usage:
max(arg1, arg2, …) or max(sequence)

पैरामीटर

विवरण

arg1, arg2, …

तुलना करने के लिए संख्याएँ।

sequence

संख्याओं वाली सूची, टपल या अन्य अनुक्रम।

def main():
    # Get the largest number from 3, 7, and 1
    max_result = max(3, 7, 1)
    console.print(max_result)

# max_result = 7

# Start threads — Do not delete
start_thread(main)

def main():
    # Get the largest value from a list
    max_list_result = max([10, 4, 25, 1])
    console.print(max_list_result)

# max_list_result = 25

# Start threads — Do not delete
start_thread(main)

sum#

sum एक इटरेबल में सभी मानों को जोड़ता है, जिसमें एक वैकल्पिक प्रारंभिक मान शामिल होता है।

Usage:
sum(sequence, start)

पैरामीटर

विवरण

sequence

संख्याओं वाली सूची, टपल या अन्य अनुक्रम।

start

यह वैकल्पिक है। योग में जोड़ने के लिए एक मान। डिफ़ॉल्ट मान 0 है।

def main():
    # Calculate the sum of a list of numbers
    sum_result = sum([1, 2, 3, 4, 5])
    console.print(sum_result)

# sum_result = 15

# Start threads — Do not delete
start_thread(main)

def main():
    # Calculate the sum of a list with a starting value of 10
    sum_with_start = sum([1, 2, 3], 10)
    console.print(sum_with_start)

# sum_with_start = 16

# Start threads — Do not delete
start_thread(main)

divmod#

divmod एक टपल लौटाता है जिसमें भागफल और शेषफल होता है।

Usage:
divmod(a, b)

पैरामीटर

विवरण

a

लाभांश।

b

भाजक।

def main():
    # Perform integer division and remainder of 10 / 3
    divmod_result = divmod(10, 3)
    console.print(divmod_result)

# divmod_result = (3, 1)

# Start threads — Do not delete
start_thread(main)

pow#

pow किसी संख्या को घात तक बढ़ाता है और वैकल्पिक रूप से एक मॉड्यूलो ऑपरेशन करता है।

Usage:
pow(x, y, mod)

पैरामीटर

विवरण

x

आधार संख्या।

y

घातांक।

mod

वैकल्पिक। एक मापांक मान। यदि प्रदान किया जाता है, तो (x ** y) % mod लौटाता है।

def main():
    # Calculate 2 raised to the power of 3
    pow_result = pow(2, 3)
    console.print(pow_result)

# pow_result = 8

# Start threads — Do not delete
start_thread(main)

int#

int फ़ंक्शन किसी संख्या या स्ट्रिंग को पूर्णांक में परिवर्तित करता है। यह स्ट्रिंग से पूर्णांक में परिवर्तित करते समय आधार रूपांतरण का भी समर्थन करता है।

Usage:
int(x, base)

पैरामीटर

विवरण

x

रूपांतरण के लिए एक संख्या, स्ट्रिंग या अन्य ऑब्जेक्ट।

base

यह वैकल्पिक है। रूपांतरण के लिए उपयोग किया जाने वाला संख्या आधार। डिफ़ॉल्ट मान 10 है।

def main():
    # Convert a float to an integer to get rid of decimals
    price = 19.99
    price_int = int(price)
    console.print("{} coins".format(price_int))

# Output: 19 coins

# Start threads — Do not delete
start_thread(main)

def main():
    # Convert a string into an integer to use in calculations
    user_input = "55"
    user_number = int(user_input)
    console.print(user_number * 2)

# Output: 110

# Start threads — Do not delete
start_thread(main)

float#

float किसी संख्या या स्ट्रिंग को फ्लोटिंग-पॉइंट संख्या में परिवर्तित करता है।

Usage:
float(x)

पैरामीटर

विवरण

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

def main():
    # Calculate the area of a circle with radius 5 using pi
    circle_area = math.pi * 5 * 5
    console.print(circle_area, precision=2)

# circle_area = 78.54

# Start threads — Do not delete
start_thread(main)

ताउ#

tau 2π का मान देता है।

Usage:
math.tau

def main():
    # Calculate the circumference of a circle with radius
    circumference = math.tau * 5
    console.print(circumference, precision=2)

# circumference = 31.42

# Start threads — Do not delete
start_thread(main)

ई#

e प्राकृतिक लघुगणक का आधार देता है।

Usage:
math.e

def main():
    # Calculate e raised to the power of 2
    e_power = math.pow(math.e, 2)
    console.print(e_power, precision=2)

# e_power = 7.39

# Start threads — Do not delete
start_thread(main)

Trigonometry#

पाप#

sin रेडियन में किसी कोण का साइन मान की गणना करता है और एक फ्लोट मान लौटाता है।

Usage:
math.sin(x)

पैरामीटर

विवरण

x

रेडियन में कोण को दर्शाने वाला एक फ्लोट या पूर्णांक मान।

def main():
    # Calculate the sine of 
    # 30 degrees in radians
    result = math.sin(math.radians(30))
    console.print(result, precision=2)

# result = 0.50

# Start threads — Do not delete
start_thread(main)

ओल#

cos रेडियन में एक कोण का कोसाइन की गणना करता है और एक फ्लोट मान लौटाता है।

Usage:
math.cos(x)

पैरामीटर

विवरण

x

रेडियन में कोण को दर्शाने वाला एक फ्लोट या पूर्णांक मान।

def main():
    # Calculate the cosine of 
    # 60 degrees in radians
    result = math.cos(math.radians(60))
    console.print(result, precision=2)

# result = 0.50

# Start threads — Do not delete
start_thread(main)

टैन#

tan रेडियन में किसी कोण का टेंजेंट की गणना करता है और एक पूर्णांक लौटाता है।

Usage:
math.tan(x)

पैरामीटर

विवरण

x

रेडियन में कोण को दर्शाने वाला एक फ्लोट या पूर्णांक मान।

def main():
    # Calculate the tangent of 
    # 45 degrees in radians
    result = math.tan(math.radians(45))
    console.print(result)

# result = 1

# Start threads — Do not delete
start_thread(main)

के रूप में#

asin किसी संख्या का व्युत्क्रम साइन (आर्क साइन) की गणना करता है और रेडियन में कोण को दर्शाने वाला एक पूर्णांक लौटाता है।

Usage:
math.asin(x)

पैरामीटर

विवरण

x

-1 और 1 के बीच का एक फ्लोट या पूर्णांक।

def main():
    # Calculate the arc sine 
    # of 0.5 in degrees
    result = math.degrees(math.asin(0.5))
    console.print(result)

# result = 30

# Start threads — Do not delete
start_thread(main)

एकोस#

acos किसी संख्या का व्युत्क्रम कोसाइन (आर्क कोसाइन) की गणना करता है और रेडियन में कोण को दर्शाने वाला एक पूर्णांक लौटाता है।

Usage:
math.acos(x)

पैरामीटर

विवरण

x

-1 और 1 के बीच का एक फ्लोट या पूर्णांक।

def main():
    # Calculate the arc cosine 
    # of 0.5 in degrees
    result = math.degrees(math.acos(0.5))
    console.print(result)

# result = 60

# Start threads — Do not delete
start_thread(main)

एक भूरा#

atan किसी संख्या का व्युत्क्रम स्पर्शरेखा (चाप स्पर्शरेखा) की गणना करता है और रेडियन में कोण का प्रतिनिधित्व करने वाला एक पूर्णांक लौटाता है।

Usage:
math.atan(x)

पैरामीटर

विवरण

x

एक फ्लोट या पूर्णांक।

def main():
    # Calculate the arc tangent 
    # of 1 in degrees
    arc_tan = math.atan(1.0)
    result = math.degrees(arc_tan)
    console.print(result)

# result = 45

# Start threads — Do not delete
start_thread(main)

अतान2#

atan2 y/x के व्युत्क्रम टेंजेंट का मुख्य मान की गणना करता है और रेडियन में कोण का प्रतिनिधित्व करने वाला एक फ्लोट लौटाता है।

Usage:
math.atan2(y, x)

पैरामीटर

विवरण

y

y-निर्देशांक को दर्शाने वाला एक फ्लोट या पूर्णांक मान।

x

x-निर्देशांक को दर्शाने वाला एक फ्लोट या पूर्णांक।

def main():
    # Calculate the inverse tangent 
    # of 1/1 in degrees
    atan2 = math.atan2(1.0, 1.0)
    result = math.degrees(atan2)
    console.print(result)

# result = 45

# Start threads — Do not delete
start_thread(main)

डिग्री#

degrees एक कोण को रेडियन से डिग्री में परिवर्तित करता है और एक पूर्णांक लौटाता है।

Usage:
math.degrees(x)

पैरामीटर

विवरण

x

रेडियन में कोण को दर्शाने वाला एक फ्लोट या पूर्णांक मान।

def main():
    # Convert pi radians to degrees
    degrees_result = math.degrees(math.pi)
    console.print(degrees_result)

# degrees_result = 180

# Start threads — Do not delete
start_thread(main)

रेडियंस#

radians डिग्री से रेडियन में कोण को परिवर्तित करता है।

Usage:
math.radians(x)

पैरामीटर

विवरण

x

एक फ्लोट या पूर्णांक जो डिग्री में कोण को दर्शाता है।

def main():
    # Convert 180 degrees to radians
    radians_result = math.radians(180)
    console.print(radians_result, precision=2)

# radians_result = 3.14

# Start threads — Do not delete
start_thread(main)

Rounding & Absolute Values#

प्लस्तर लगाना#

ceil किसी संख्या को निकटतम पूर्णांक तक पूर्णांकित करता है।

Usage:
math.ceil(x)

पैरामीटर

विवरण

x

एक फ्लोट या पूर्णांक जिसे राउंड अप किया जाना है।

def main():
    # Round 3.7 up to the nearest integer
    ceil_result = math.ceil(3.7)
    console.print(ceil_result)

# ceil_result = 4

# Start threads — Do not delete
start_thread(main)

ज़मीन#

floor किसी संख्या को निकटतम पूर्णांक तक नीचे की ओर राउंड करता है।

Usage:
math.floor(x)

पैरामीटर

विवरण

x

एक फ्लोट या पूर्णांक जिसे नीचे की ओर राउंड ऑफ किया जाना है।

def main():
    # Round 3.7 down to the nearest integer
    floor_result = math.floor(3.7)
    console.print(floor_result)

# floor_result = 3

# Start threads — Do not delete
start_thread(main)

ट्रंक#

trunc किसी संख्या के दशमलव भाग को बिना राउंड किए हटा देता है।

Usage:
math.trunc(x)

पैरामीटर

विवरण

x

एक फ्लोट जिसे छोटा किया जाना है।

def main():
    # Remove the decimal part of 3.7
    trunc_result = math.trunc(3.7)
    console.print(trunc_result)

# trunc_result = 3

# Start threads — Do not delete
start_thread(main)

फैब्स#

fabs किसी संख्या का निरपेक्ष मान फ्लोट के रूप में लौटाता है।

Usage:
math.fabs(x)

पैरामीटर

विवरण

x

एक फ्लोट या पूर्णांक।

def main():
    # Get the absolute value of -3.7
    fabs_result = math.fabs(-3.7)
    console.print(fabs_result, precision=1)

# fabs_result = 3.7

# Start threads — Do not delete
start_thread(main)

Exponents & Logarithms#

लकड़ी का लट्ठा#

log किसी संख्या का लघुगणक निकालता है और एक फ्लोट मान लौटाता है।

Usage:
math.log(x, base)

पैरामीटर

विवरण

x

एक धनात्मक फ्लोट या पूर्णांक।

base

यह वैकल्पिक है। लघुगणक का आधार। डिफ़ॉल्ट रूप से यह प्राकृतिक लघुगणक होता है।

def main():
    # Calculate the natural logarithm
    # (base e) of 7.389056
    log_result = math.log(7.389056)
    console.print(log_result)

# log_result = 2

# Start threads — Do not delete
start_thread(main)

def main():
    # Calculate the log base 2 of 8
    log_result = math.log(8, 2)
    console.print(log_result)

# log_result = 3

# Start threads — Do not delete
start_thread(main)

लॉग10#

log10 किसी संख्या का आधार-10 लघुगणक की गणना करता है और एक फ्लोट लौटाता है।

Usage:
math.log10(x)

पैरामीटर

विवरण

x

एक धनात्मक फ्लोट या पूर्णांक।

def main():
    # Calculate the base-10 logarithm of 100
    log10_result = math.log10(100)
    console.print(log10_result)

# log10_result = 2

# Start threads — Do not delete
start_thread(main)

पाउ#

pow x की घात y को बढ़ाता है और एक फ्लोट मान लौटाता है, भले ही दोनों इनपुट पूर्णांक हों।

Usage:
math.pow(x, y)

पैरामीटर

विवरण

x

एक फ्लोट या पूर्णांक आधार।

y

एक फ्लोट या पूर्णांक घातांक।

def main():
    # Calculate 2 raised to the power of 3
    power_result = math.pow(2, 3)
    console.print(power_result)

    # power_result = 8

# Start threads — Do not delete
start_thread(main)

वर्गमूल#

sqrt किसी संख्या का वर्गमूल निकालता है और एक फ्लोट मान लौटाता है, यहां तक ​​कि पूर्ण वर्गों के लिए भी।

Usage:
math.sqrt(x)

पैरामीटर

विवरण

x

एक गैर-ऋणात्मक फ्लोट या पूर्णांक।

def main():
    # Calculate 2 raised to the power of 3
    power_result = math.pow(2, 3)
    console.print(power_result)

# power_result = 8

# Start threads — Do not delete
start_thread(main)

ऍक्स्प#

exp किसी संख्या का घातांक ज्ञात करता है और एक फ्लोट मान लौटाता है।

Usage:
math.exp(x)

पैरामीटर

विवरण

x

एक फ्लोट या पूर्णांक।

def main():
    # Calculate e raised to the power of 1
    exp_result = math.exp(1)
    console.print(exp_result, precision=2)

# exp_result = 2.72

# Start threads — Do not delete
start_thread(main)

Floating Point Operations#

मॉडफ#

modf एक संख्या को उसके भिन्नात्मक और पूर्णांक भागों में विघटित करता है और एक टपल (fractional part, integer part)लौटाता है, दोनों फ्लोट के रूप में।

Usage:
math.modf(x)

पैरामीटर

विवरण

x

विघटित करने के लिए एक फ्लोट या पूर्णांक।

def main():
    # Decompose 3.14159 into fractional and integer parts
    fractional_part, integer_part = math.modf(3.14159)
    console.print(fractional_part, precision=2)
    console.new_line()
    console.print(integer_part)

# fractional_part = 0.14
# integer_part = 3

# Start threads — Do not delete
start_thread(main)

फ्रेक्सप#

frexp एक संख्या को उसके मंटिसा और घातांक में विघटित करता है और एक टपल (mantissa, exponent)लौटाता है, जहां मंटिसा एक फ्लोट है और घातांक एक पूर्णांक है।

Usage:
math.frexp(x)

पैरामीटर

विवरण

x

विघटित करने के लिए एक फ्लोट या पूर्णांक।

def main():
    # Decompose 16 into its mantissa and exponent
    mantissa, exponent = math.frexp(16)
    console.print(mantissa, precision=2)
    console.new_line()
    console.print(exponent)

# mantissa = 0.50
# exponent = 5

# Start threads — Do not delete
start_thread(main)

एफएमओडी#

fmod भाज्य के चिह्न को बनाए रखते हुए विभाजन का शेषफल लौटाता है (x)।

Usage:
math.fmod(x, y)

पैरामीटर

विवरण

x

लाभांश।

y

भाजक।

def main():
    # Calculate remainder of 10 / 3
    # that preserves the sign of 10
    fmod_result = math.fmod(10, 3)
    console.print(fmod_result)

# fmod_result = 1

# Start threads — Do not delete
start_thread(main)

प्रतिलिपिहस्ताक्षर#

copysign x को y के चिह्न के साथ लौटाता है।

Usage:
math.copysign(x, y)

पैरामीटर

विवरण

x

संशोधित किया जाने वाला मान।

y

वह मान जिसका चिह्न कॉपी किया जाएगा।

def main():
    # Return -10 with the sign of 3 (positive)
    copysign_result = math.copysign(-10, 3)
    console.print(copysign_result)

# copysign_result = 10

# Start threads — Do not delete
start_thread(main)

एलडीएक्सपी#

ldexp की गणना x * (2 ** exp), जो x * 2exp के बराबर है।

Usage:
math.ldexp(x, exp)

पैरामीटर

विवरण

x

आधार मूल्य।

exp

घातांक।

def main():
    # Compute 3 * (2 ** 4)
    ldexp_result = math.ldexp(3, 4)
    console.print(ldexp_result)

# ldexp_result = 48

# Start threads — Do not delete
start_thread(main)