Python math Module In Hindi

📔 : Python 🔗

Python में mathematical operations perform करने के लिए कई built इन functions भी हैं जैसे -

  1. min()
  2. max()
  3. pow()
  4. abs()

Python min(), max()

min(), max() functions का use किसी भी iterable data type (like : list , tuple , set) में minimum और maximum value को return करता है।

Python min(), max() Example
Copy Fullscreen Close Fullscreen Run
print('Maximum in list :', max([12,4,5,66,76,78])) #find max in list.
print('Maximum in tuple :', max((2,4,5,66,76,78))) #find max in tuple.
print('Minimum in set :', min({34,56,45,56,34,32,4})) #find min in set.
print('Minimum in list :', min({23,45,3,44.5, -2,43})) #find min in list.
Output
C:\Users\Rahulkumar\Desktop\python>python min_max.py
Maximum in list : 78
Maximum in tuple : 78
Minimum in set : 4
Minimum in list : -2

Python pow()

pow(x, y) function का use x to the power of y (xy) की value return करता है। हालाँकि उसके लिए आप x**y का use भी कर सकते हैं। दोनों का output same ही होगा।
For Example -

# both are same.
print(pow(2, 3))
print(2**3)

Output :
8
8

Python abs()

abs() function किसी value की absolute positive value return करता है।
Example -

print(abs(-23.4))
print(abs(-23))

Output :
23.4
23

Python math Module

Python में mathematical tasks perform करने के लिए math module भी provide किया है जिसमे कई functions define हैं जिनका use आप अपनी need के according कर सकते हैं।

math Module Functions

Function Name Description
cos()Returns the cosine of a number
cosh()Returns the hyperbolic cosine of a number
degrees()Converts an angle from radians to degrees
fabs()Returns the absolute value of a number
factorial()Returns the factorial of a number
floor()Rounds a number down to the nearest integer.
ceil()Rounds a number up to the nearest integer.
gcd()Returns the greatest common divisor of two integers
isqrt()Rounds a square root number downwards to the nearest integer
log()Returns the natural logarithm of a number, or the logarithm of number to base
log10()Returns the base-10 logarithm of x
pow()Returns the value of x to the power of y
prod()Returns the product of all the elements in an iterable(like : list , tuple , set)
radians()Converts a degree value into radians
sin()Returns the sine of a number
sinh()Returns the hyperbolic sine of a number
sqrt()Returns the square root of a number
tan()Returns the tangent of a number
math Function Example
Copy Fullscreen Close Fullscreen Run
# first import math module.
import math
print('Square root of 81 :', math.sqrt(81))
print('Factorial of 6 :', math.factorial(6))
print(math.ceil(3.4))
print(math.floor(3.4))
print('Absolute Value :', math.fabs(-3.5))
print('sin90 :', math.sin(90))
print('cos30 :', math.cos(30))
print('tan45 :', math.tan(45))
Output
C:\Users\Rahulkumar\Desktop\python>python math_functions.py
Square root of 81 : 9.0
Factorial of 6 : 720
4
3
Absolute Value : 3.5
sin90 : 0.8939966636005579
cos30 : 0.15425144988758405
tan45 : 1.6197751905438615

math Module Constants

इसके अलावा math module में कुछ constants भी हैं, मतलब वो mathematics variables जिनकी values पहले से fixed हैं आप उन्हें change नहीं कर सकते हैं।

Copy Fullscreen Close Fullscreen Run
# first import math module.
import math
print('PI value :', math.pi)
print('TAU value :', math.tau)
print('NAN value :', math.nan)
print('INF value :', math.inf)
print('E value :', math.e)
Output
C:\Users\Rahulkumar\Desktop\python>python math_constants.py
PI value : 3.141592653589793
TAU value : 6.283185307179586
NAN value : nan
INF value : inf
E value : 2.718281828459045

Related Topics :

Rahul Kumar

Rahul Kumar

Hi ! I'm Rahul Kumar Rajput founder of learnhindituts.com. I'm a software developer having more than 4 years of experience. I love to talk about programming as well as writing technical tutorials and blogs that can help to others. I'm here to help you navigate the coding cosmos and turn your ideas into reality, keep coding, keep learning :)

Get connected with me. :) LinkedIn Twitter Instagram Facebook

b2eprogrammers