Math Modules in Python

#----------------------------- 1- ceil & remainder in math  --------------------------

import math # pip install math

n = int(input("Enter the number  : "))

cei  = math.ceil(n)
print("Ceil : ",cei)
#math.remainder(a,b)
rem = math.remainder(n,3)	#Returns the closest value that can make numerator completely divisible by the denominator
print("Remainder : ", rem)
#----------------------------- 2- sin , cos & tan in math ----------------------------

import math # pip install math

n = int(input("Enter the number : "))

c = math.cos(n) # Returns the cosine of a number	
print("Cos  value: ",c)

s = math.sin(n)	# Returns the sine of a number
print("sin  value: ",s)

t = math.tan(n)	# Returns the tangent of a number
print("tan  value: ",t)

#----------------------------- 3- pow , sqrt & trunc in math ------------------------

import math # pip install math


n = int(input("Enter the number : "))
pw = int(input("Enter the power : "))

p = math.pow(n,pw)	# 	Returns the value of a to the power of b
print(n,"to the power ",pw,"  is :",p)

s = math.sqrt(n)	 # Returns the square root of a number
print("Square root of ",n, " is : ", s)

t = math.trunc(n)	# Returns the truncated integer parts of a number
print("Truncated value is : ",t)
#----------------------------- 4- fabs, prod, radians in math  -----------------------


import math # pip install math

n = eval(input("Enter the number : "))

f = math.fabs(n)  # returns abosolute value of the number 	
print("Absolute value is : ",f)

n2 = int(input("Enter the second number : "))
n3 = int(input("Enter the third number : "))
n= (n2,n3)
p = math.prod(n)	 # returns the product of two numbers
print("Product is : ",p)
deg = int(input("Enter the degree : "))

r = math.radians(deg)	# returns the radian value of the degree 
print("Radian value is : ",r)
#----------------------------- 5- factorial in math  --------------------------

import math # pip install math

n = int(input("Enter the number : "))

fact =math.factorial(n)	
print("The factorial of " ,n ," is ",fact)
#----------------------------- 6- floor in math  --------------------------

import math # pip install math

n = float(input("Enter the number : "))

floo =math.floor(n)  #Rounds a number down to the nearest integer

print("The value after floor is :",floo)
#----------------------------- 7- lcm & gcd in math  --------------------------

import math # pip install math


n1 = int(input("Enter the 1st number  : ")) 
n2 = int(input("Enter the 2nd number  : ")) 
n3 = int(input("Enter the 3rd number  : ")) 


gd =math.gcd(n1,n2,n3)	# find and returns the greatest common divisor
print("The GCD is :",gd)

lm = math.lcm(n1,n2,n3)  # find and returns the least common divisor
print("The LCM  is :",lm)
#----------------------------- 8- log, log10 & log2 in math  -------------------------

import math #pip install math
n= int(input("Enter the number :"))

lg =math.log(n)	
print("The log value is : ",lg)

lg10 = math.log10(n)	
print("The log base-10 value is : ",lg)


lg2 = math.log2(n)	
print("The log base-2 value is : ",lg)
#----------------------------- 9- erf in math  --------------------------

import math # pip install math
x =math.erf(999122199) #Returns the error function of a number

print("The error function is : ", x)

Join our team, where career growth knows no limits.

For More Details

Our internship program guarantees personalized attention for optimal career development in the tech industry.

+91 97879 68375

-> You should bring your own laptop during the internship

Who can apply?

Internships are open for students who: B.E / B.Tech / M.E / M.Tech / B.Sc / M.Sc / M.C.A / B.C.A / Diploma.

  • Ongoing Students Only
  • days, 5days/ 10days or Based on Student Preference
  • Limited 1 to 10 students per slot
  • Registration fees : 1000 INR
  • Slots are filling quickly only fewer slots are available