ഗണിതം#
ആമുഖം#
മാത്തിൽ ബിൽറ്റ്-ഇൻ പൈത്തൺ ഫംഗ്ഷനുകളും പൂർണ്ണമായ math മൊഡ്യൂളും ഉൾപ്പെടുന്നു, ഇത് VEXcode EXP-യിൽ യാന്ത്രികമായി ലഭ്യമാണ്. അടിസ്ഥാന ഗണിതം മുതൽ വിപുലമായ ത്രികോണമിതി, റൗണ്ടിംഗ്, ലോഗരിഥമിക് പ്രവർത്തനങ്ങൾ വരെ എല്ലാം ചെയ്യാൻ ഈ ഉപകരണങ്ങൾ നിങ്ങളെ അനുവദിക്കുന്നു.
നിങ്ങളുടെ റോബോട്ടിന്റെ സ്ഥാനങ്ങൾ, കോണുകൾ, ദൂരങ്ങൾ, മറ്റ് സംഖ്യാ മൂല്യങ്ങൾ എന്നിവ കണക്കാക്കാൻ ഈ ഫംഗ്ഷനുകളും സ്ഥിരാങ്കങ്ങളും ഉപയോഗിക്കുക. നിങ്ങൾക്ക് ഡിഗ്രികൾക്കും റേഡിയനുമിടയിൽ പരിവർത്തനം ചെയ്യാനും എക്സ്പ്രഷനുകൾ വിലയിരുത്താനും ഇൻഫിനിറ്റി, NaN പോലുള്ള പ്രത്യേക മൂല്യങ്ങളുമായി പ്രവർത്തിക്കാനും കഴിയും.
ലഭ്യമായ ഗണിത ഫംഗ്ഷനുകൾ, സ്ഥിരാങ്കങ്ങൾ, യൂട്ടിലിറ്റികൾ എന്നിവയുടെ ഒരു ലിസ്റ്റ് താഴെ കൊടുക്കുന്നു:
ബിൽറ്റ്-ഇൻ ഫംഗ്ഷനുകൾ - പൈത്തണിൽ ഉൾപ്പെടുത്തിയിരിക്കുന്ന സാധാരണ ഗണിത ഉപകരണങ്ങൾ.
abs– ഒരു സംഖ്യയുടെ കേവല മൂല്യം നൽകുന്നു.round– ഒരു സംഖ്യയെ നിശ്ചിത ദശാംശ സ്ഥാനങ്ങളിലേക്ക് റൗണ്ട് ചെയ്യുന്നു.min– ഇൻപുട്ട് മൂല്യങ്ങളിൽ ഏറ്റവും ചെറിയത് നൽകുന്നു.max– ഇൻപുട്ട് മൂല്യങ്ങളിൽ ഏറ്റവും വലുത് നൽകുന്നു.sum– ഒരു ഇറ്ററബിളിലെ എല്ലാ മൂല്യങ്ങളും ചേർക്കുന്നു.divmod– ഘടകാംശവും ശിഷ്ടവും ഒരു ട്യൂപ്പിളായി നൽകുന്നു.pow– ഒരു സംഖ്യയെ ഒരു പവറിലേക്ക് ഉയർത്തുന്നു, ഓപ്ഷണലായി ഒരു മോഡുലസ് ഉപയോഗിച്ച്.int– ഒരു മൂല്യത്തെ ഒരു പൂർണ്ണസംഖ്യയിലേക്ക് പരിവർത്തനം ചെയ്യുന്നു.float– ഒരു മൂല്യത്തെ ഒരു ഫ്ലോട്ടിംഗ്-പോയിന്റ് സംഖ്യയിലേക്ക് പരിവർത്തനം ചെയ്യുന്നു.
സ്ഥിരാങ്കങ്ങൾ - math മൊഡ്യൂളിൽ നിന്നുള്ള മുൻനിശ്ചയിച്ച മൂല്യങ്ങൾ.
ത്രികോണമിതി - വശങ്ങൾ തമ്മിലുള്ള കോണുകളും ബന്ധങ്ങളും കണക്കാക്കുക.
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– x ന്റെ ശക്തിയിലേക്ക് e കണക്കാക്കുന്നു.math.log– x ന്റെ ലോഗരിതം കണക്കാക്കുക.
ഫ്ലോട്ടിംഗ് പോയിന്റ് പ്രവർത്തനങ്ങൾ - ഫ്ലോട്ട് മൂല്യങ്ങൾ പരിശോധിക്കുക അല്ലെങ്കിൽ വിഘടിപ്പിക്കുക.
math.modf– ഒരു ഫ്ലോട്ടിന്റെ ഫ്രാക്ഷണൽ, ഇൻറിജർ ഭാഗങ്ങൾ തിരികെ നൽകുന്നു.math.frexp– ഒരു സംഖ്യയെ മാന്റിസ്സയായും ഘാതാംഗമായും വിഘടിപ്പിക്കുന്നു.math.fmod– ഡിവിഡന്റിന്റെ ചിഹ്നമുള്ള ശിഷ്ടം.math.copysign– മറ്റൊന്നിന്റെ ചിഹ്നമുള്ള ഒരു മൂല്യം നൽകുന്നു.math.ldexp–x * (2 ** exp)കണക്കാക്കുന്നു.
ബിൽറ്റ്-ഇൻ ഫംഗ്ഷനുകൾ#
നിങ്ങളുടെ പ്രോജക്റ്റിനുള്ളിൽ ഗണിത പ്രവർത്തനങ്ങൾ നടത്താൻ നിങ്ങളെ അനുവദിക്കുന്ന നിരവധി ബിൽറ്റ്-ഇൻ ഫംഗ്ഷനുകൾ പൈത്തൺ നൽകുന്നു.
abs#
abs ഒരു സംഖ്യയുടെ കേവല മൂല്യം നൽകുന്നു, ഏതെങ്കിലും നെഗറ്റീവ് ചിഹ്നം നീക്കം ചെയ്യുന്നു.
Usage:
abs(x)
പാരാമീറ്റർ |
വിവരണം |
|---|---|
|
ഒരു പൂർണ്ണസംഖ്യ അല്ലെങ്കിൽ ഫ്ലോട്ട്. |
# Get the absolute value of -10
abs_result = abs(-10)
brain.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)
brain.screen.print(round_int_result)
# round_int_result = 6
# Round 3.14159 to 2 decimal places
round_result = round(3.14159, 2)
brain.screen.print(round_result, precision=2)
# 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)
brain.screen.print(min_result)
# min_result = 1
# Get the smallest value from a list
min_list_result = min([10, 4, 25, 1])
brain.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)
brain.screen.print(max_result)
# max_result = 7
# Get the largest value from a list
max_list_result = max([10, 4, 25, 1])
brain.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])
brain.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)
brain.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)
brain.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)
brain.screen.print(pow_result)
# pow_result = 8
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)
brain.screen.print("{} coins".format(price_int))
# Output: 19 coins
# Convert a string into an integer to use in calculations
user_input = "55"
user_number = int(user_input)
brain.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 മൊഡ്യൂൾ സാധാരണ ഗണിത കണക്കുകൂട്ടലുകൾ നടത്തുന്നതിനുള്ള അധിക രീതികൾ നൽകുന്നു. ഈ രീതികളിൽ ത്രികോണമിതി, ലോഗരിഥമിക്, മറ്റ് സംഖ്യാ പ്രവർത്തനങ്ങൾ എന്നിവ ഉൾപ്പെടുന്നു.
math മൊഡ്യൂൾ VEXcode-ൽ ഡിഫോൾട്ടായി ഇറക്കുമതി ചെയ്യപ്പെടുന്നു.
Constants#
ഒരു പ്രോജക്റ്റ് സമയത്ത് സ്ഥിരമായി നിലനിൽക്കുന്ന മുൻകൂട്ടി നിശ്ചയിച്ച മൂല്യങ്ങളാണ് സ്ഥിരാങ്കങ്ങൾ. നിർവചനമോ അസൈൻമെന്റോ ആവശ്യമില്ലാതെ തന്നെ കണക്കുകൂട്ടലുകളിൽ അവ ഉപയോഗിക്കാൻ കഴിയും.
പൈ#
pi എന്നത് ഗണിത സ്ഥിരാങ്കം π നൽകുന്നു, ഇത് ഒരു വൃത്തത്തിന്റെ ചുറ്റളവും വ്യാസവും തമ്മിലുള്ള അനുപാതമാണ്.
Usage:
math.pi
# Calculate the area of a circle with radius 5 using pi
circle_area = math.pi * 5 * 5
brain.screen.print(circle_area, precision=2)
# circle_area = 78.54
ഇ#
e സ്വാഭാവിക ലോഗരിതത്തിന്റെ അടിസ്ഥാനം നൽകുന്നു.
Usage:
math.e
# Calculate e raised to the power of 2
e_power = math.pow(math.e, 2)
brain.screen.print(e_power, precision=2)
# e_power = 7.39
Trigonometry#
പാപം#
sin ഒരു കോണിന്റെ സൈൻ റേഡിയൻസിൽ കണക്കാക്കി ഒരു ഫ്ലോട്ട് തിരികെ നൽകുന്നു.
Usage:
math.sin(x)
പാരാമീറ്റർ |
വിവരണം |
|---|---|
|
റേഡിയനുകളിൽ ഒരു കോണിനെ പ്രതിനിധീകരിക്കുന്ന ഒരു ഫ്ലോട്ട് അല്ലെങ്കിൽ പൂർണ്ണസംഖ്യ. |
# Calculate the sine of
# 30 degrees in radians
result = math.sin(math.radians(30))
brain.screen.print(result, precision=2)
# result = 0.50
കാരണം#
cos റേഡിയൻസിൽ ഒരു കോണിന്റെ കോസൈൻ കണക്കാക്കുകയും ഒരു ഫ്ലോട്ട് തിരികെ നൽകുകയും ചെയ്യുന്നു.
Usage:
math.cos(x)
പാരാമീറ്റർ |
വിവരണം |
|---|---|
|
റേഡിയനുകളിൽ ഒരു കോണിനെ പ്രതിനിധീകരിക്കുന്ന ഒരു ഫ്ലോട്ട് അല്ലെങ്കിൽ പൂർണ്ണസംഖ്യ. |
# Calculate the cosine of
# 60 degrees in radians
result = math.cos(math.radians(60))
brain.screen.print(result, precision=2)
# result = 0.50
ടാൻ#
tan റേഡിയൻസിൽ ഒരു കോണിന്റെ ടാൻജെന്റ് കണക്കാക്കുകയും ഒരു ഫ്ലോട്ട് തിരികെ നൽകുകയും ചെയ്യുന്നു.
Usage:
math.tan(x)
പാരാമീറ്റർ |
വിവരണം |
|---|---|
|
റേഡിയനുകളിൽ ഒരു കോണിനെ പ്രതിനിധീകരിക്കുന്ന ഒരു ഫ്ലോട്ട് അല്ലെങ്കിൽ പൂർണ്ണസംഖ്യ. |
# Calculate the tangent of
# 45 degrees in radians
result = math.tan(math.radians(45))
brain.screen.print(result)
# result = 1.00
അസിൻ#
asin ഒരു സംഖ്യയുടെ വിപരീത സൈൻ (ആർക്ക് സൈൻ) കണക്കാക്കുകയും റേഡിയനുകളിൽ കോണിനെ പ്രതിനിധീകരിക്കുന്ന ഒരു ഫ്ലോട്ട് തിരികെ നൽകുകയും ചെയ്യുന്നു.
Usage:
math.asin(x)
പാരാമീറ്റർ |
വിവരണം |
|---|---|
|
-1 നും 1 നും ഇടയിലുള്ള ഒരു ഫ്ലോട്ട് അല്ലെങ്കിൽ പൂർണ്ണസംഖ്യ. |
# Calculate the arc sine
# of 0.5 in degrees
result = math.degrees(math.asin(0.5))
brain.screen.print(result)
# result = 30.00
അക്കോസ്#
acos ഒരു സംഖ്യയുടെ വിപരീത കോസൈൻ (ആർക്ക് കോസൈൻ) കണക്കാക്കുകയും റേഡിയനുകളിൽ കോണിനെ പ്രതിനിധീകരിക്കുന്ന ഒരു ഫ്ലോട്ട് തിരികെ നൽകുകയും ചെയ്യുന്നു.
Usage:
math.acos(x)
പാരാമീറ്റർ |
വിവരണം |
|---|---|
|
-1 നും 1 നും ഇടയിലുള്ള ഒരു ഫ്ലോട്ട് അല്ലെങ്കിൽ പൂർണ്ണസംഖ്യ. |
# Calculate the arc cosine
# of 0.5 in degrees
result = math.degrees(math.acos(0.5))
brain.screen.print(result)
# result = 60.00
ആതൻ#
atan ഒരു സംഖ്യയുടെ വിപരീത ടാൻജെന്റ് (ആർക്ക് ടാൻജെന്റ്) കണക്കാക്കുകയും റേഡിയനുകളിൽ കോണിനെ പ്രതിനിധീകരിക്കുന്ന ഒരു ഫ്ലോട്ട് തിരികെ നൽകുകയും ചെയ്യുന്നു.
Usage:
math.atan(x)
പാരാമീറ്റർ |
വിവരണം |
|---|---|
|
ഒരു ഫ്ലോട്ട് അല്ലെങ്കിൽ പൂർണ്ണസംഖ്യ. |
# Calculate the arc tangent
# of 1 in degrees
arc_tan = math.atan(1.0)
result = math.degrees(arc_tan)
brain.screen.print(result)
# result = 45.00
അറ്റൻ2#
atan2 y/x ന്റെ വിപരീത ടാൻജെന്റിന്റെ പ്രിൻസിപ്പൽ മൂല്യം കണക്കാക്കുകയും റേഡിയനുകളിൽ കോണിനെ പ്രതിനിധീകരിക്കുന്ന ഒരു ഫ്ലോട്ട് തിരികെ നൽകുകയും ചെയ്യുന്നു.
Usage:
math.atan2(y, x)
പാരാമീറ്റർ |
വിവരണം |
|---|---|
|
y-കോർഡിനേറ്റിനെ പ്രതിനിധീകരിക്കുന്ന ഒരു ഫ്ലോട്ട് അല്ലെങ്കിൽ പൂർണ്ണസംഖ്യ. |
|
x-കോർഡിനേറ്റിനെ പ്രതിനിധീകരിക്കുന്ന ഒരു ഫ്ലോട്ട് അല്ലെങ്കിൽ പൂർണ്ണസംഖ്യ. |
# Calculate the inverse tangent
# of 1/1 in degrees
atan2 = math.atan2(1.0, 1.0)
result = math.degrees(atan2)
brain.screen.print(result)
# result = 45.00
ഡിഗ്രികൾ#
degrees റേഡിയനുകളിൽ നിന്ന് ഒരു കോണിനെ ഡിഗ്രികളാക്കി പരിവർത്തനം ചെയ്ത് ഒരു ഫ്ലോട്ട് തിരികെ നൽകുന്നു.
Usage:
math.degrees(x)
പാരാമീറ്റർ |
വിവരണം |
|---|---|
|
റേഡിയനുകളിൽ ഒരു കോണിനെ പ്രതിനിധീകരിക്കുന്ന ഒരു ഫ്ലോട്ട് അല്ലെങ്കിൽ പൂർണ്ണസംഖ്യ. |
# Convert pi radians to degrees
degrees_result = math.degrees(math.pi)
brain.screen.print(degrees_result)
# degrees_result = 180.00
റേഡിയനുകൾ#
radians ഒരു കോണിനെ ഡിഗ്രിയിൽ നിന്ന് റേഡിയൻസിലേക്ക് ഫ്ലോട്ട് ആയി പരിവർത്തനം ചെയ്യുന്നു.
Usage:
math.radians(x)
പാരാമീറ്റർ |
വിവരണം |
|---|---|
|
ഡിഗ്രിയിൽ ഒരു കോണിനെ പ്രതിനിധീകരിക്കുന്ന ഒരു ഫ്ലോട്ട് അല്ലെങ്കിൽ പൂർണ്ണസംഖ്യ. |
# Convert 180 degrees to radians
radians_result = math.radians(180)
brain.screen.print(radians_result, precision=2)
# radians_result = 3.14
Rounding & Absolute Values#
സീൽ#
ceil ഒരു സംഖ്യയെ ഏറ്റവും അടുത്തുള്ള പൂർണ്ണസംഖ്യയിലേക്ക് റൗണ്ട് ചെയ്യുന്നു.
Usage:
math.ceil(x)
പാരാമീറ്റർ |
വിവരണം |
|---|---|
|
റൗണ്ട് അപ്പ് ചെയ്യേണ്ട ഒരു ഫ്ലോട്ട് അല്ലെങ്കിൽ പൂർണ്ണസംഖ്യ. |
# Round 3.7 up to the nearest integer
ceil_result = math.ceil(3.7)
brain.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)
brain.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)
brain.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)
brain.screen.print(fabs_result, precision=1)
# fabs_result = 3.7
Exponents & Logarithms#
ലോഗ്#
log ഒരു സംഖ്യയുടെ ലോഗരിതം കണക്കാക്കുകയും ഒരു ഫ്ലോട്ട് തിരികെ നൽകുകയും ചെയ്യുന്നു.
Usage:
math.log(x, base)
പാരാമീറ്റർ |
വിവരണം |
|---|---|
|
ഒരു പോസിറ്റീവ് ഫ്ലോട്ട് അല്ലെങ്കിൽ പൂർണ്ണസംഖ്യ. |
|
ഓപ്ഷണൽ. ഉപയോഗിക്കേണ്ട ലോഗരിതം ബേസ്. ഡിഫോൾട്ടായി ഇത് സ്വാഭാവിക ലോഗരിതം ആണ്. |
# Calculate the natural logarithm
# (base e) of 7.389056
log_result = math.log(7.389056)
brain.screen.print(log_result)
# log_result = 2.00
# Calculate the log base 2 of 8
log_result = math.log(8, 2)
brain.screen.print(log_result)
# log_result = 3.00
പവ്#
pow , x നെ y യുടെ ശക്തിയിലേക്ക് ഉയർത്തുകയും ഒരു ഫ്ലോട്ട് തിരികെ നൽകുകയും ചെയ്യുന്നു, രണ്ട് ഇൻപുട്ടുകളും പൂർണ്ണസംഖ്യകളാണെങ്കിൽ പോലും.
Usage:
math.pow(x, y)
പാരാമീറ്റർ |
വിവരണം |
|---|---|
|
ഒരു ഫ്ലോട്ട് അല്ലെങ്കിൽ പൂർണ്ണസംഖ്യാ ബേസ്. |
|
ഒരു ഫ്ലോട്ട് അല്ലെങ്കിൽ പൂർണ്ണസംഖ്യ എക്സ്പോണന്റ്. |
# Calculate 2 raised to the power of 3
power_result = math.pow(2, 3)
brain.screen.print(power_result)
# power_result = 8.00
ചതുരശ്രം#
sqrt ഒരു സംഖ്യയുടെ വർഗ്ഗമൂലം കണക്കാക്കുകയും പൂർണ്ണ വർഗ്ഗങ്ങൾക്ക് പോലും ഒരു ഫ്ലോട്ട് തിരികെ നൽകുകയും ചെയ്യുന്നു.
Usage:
math.sqrt(x)
പാരാമീറ്റർ |
വിവരണം |
|---|---|
|
ഒരു നോൺ-നെഗറ്റീവ് ഫ്ലോട്ട് അല്ലെങ്കിൽ പൂർണ്ണസംഖ്യ. |
# Calculate the square root of 16
square_root = math.sqrt(16)
brain.screen.print(square_root)
# square_root = 4.00
എക്സ്പ്രഷൻ#
exp ഒരു സംഖ്യയുടെ എക്സ്പോണൻഷ്യൽ കണക്കാക്കുകയും ഒരു ഫ്ലോട്ട് തിരികെ നൽകുകയും ചെയ്യുന്നു.
Usage:
math.exp(x)
പാരാമീറ്റർ |
വിവരണം |
|---|---|
|
ഒരു ഫ്ലോട്ട് അല്ലെങ്കിൽ പൂർണ്ണസംഖ്യ. |
# Calculate e raised to the power of 1
exp_result = math.exp(1)
brain.screen.print(exp_result, precision=2)
# exp_result = 2.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)
brain.screen.print(fractional_part, precision=2)
brain.screen.print(integer_part)
# fractional_part = 0.14
# integer_part = 3
ഫ്രെക്സ്പ്#
frexp ഒരു സംഖ്യയെ അതിന്റെ മാന്റിസ്സയായും എക്സ്പോണന്റായും വിഘടിപ്പിച്ച് ഒരു ട്യൂപ്പിൾ (mantissa, exponent)നൽകുന്നു, ഇവിടെ മാന്റിസ്സ ഒരു ഫ്ലോട്ടും എക്സ്പോണന്റ് ഒരു പൂർണ്ണസംഖ്യയുമാണ്.
Usage:
math.frexp(x)
പാരാമീറ്റർ |
വിവരണം |
|---|---|
|
വിഘടിപ്പിക്കാനുള്ള ഒരു ഫ്ലോട്ട് അല്ലെങ്കിൽ പൂർണ്ണസംഖ്യ. |
# Decompose 16 into its mantissa and exponent
mantissa, exponent = math.frexp(16)
brain.screen.print(mantissa, precision=2)
brain.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)
brain.screen.print(fmod_result)
# fmod_result = 1
പകർപ്പ് ചിഹ്നം#
copysign y എന്ന ചിഹ്നത്തോടെ x തിരികെ നൽകുന്നു.
Usage:
math.copysign(x, y)
പാരാമീറ്റർ |
വിവരണം |
|---|---|
|
പരിഷ്ക്കരിക്കേണ്ട മൂല്യം. |
|
ചിഹ്നം പകർത്തേണ്ട മൂല്യം. |
# Return -10 with the sign of 3 (positive)
copysign_result = math.copysign(-10, 3)
brain.screen.print(copysign_result)
# copysign_result = 10
ldexp GenericName#
ldexp x * (2 ** exp)കണക്കാക്കുന്നു, ഇത് x * 2exp ന് തുല്യമാണ്.
Usage:
math.ldexp(x, exp)
പാരാമീറ്റർ |
വിവരണം |
|---|---|
|
അടിസ്ഥാന മൂല്യം. |
|
ഘാതം. |
# Compute 3 * (2 ** 4)
ldexp_result = math.ldexp(3, 4)
brain.screen.print(ldexp_result)
# ldexp_result = 48