Pythons Library Math Functions Programs
top of page

Pythons Library Math Functions Programs


Write a program to input the value of x and calculate the result of the following equation:

ex +cos x+ √ X

Program:

import math

x=float(input("Enter the value for x:"))

a=math.exp(x)

b=math.cos(x*(3.14/180))

c=math.sqrt(x)

d=a+b+c

print("The result of this Equaction=",d)

Output:

Enter the value for x:12

The result of this Equaction= 162759.2336902897



Write a program to input the values of x and y. Calculate and print result of the following equation:

Log√ x/y

Program:

import math

x=float(input("Enter the value for x: "))

y=float(input("Enter the value for y: "))

z=x/y

a=math.sqrt(z)

b=math.log(a)

print("The result of given equation is ", b)


Output:

Enter the value for x:20

Enter the value for y:5


The result of given equation is 0.6931471805599453


Write a program to print three sides of a triangle. Calculate and print its area using Heron's Formula.

Program:

import math

x=float(input(" Enter one side of triangle :"))

y=float(input(" Enter Second side of triangle :"))

z=float(input(" Enter third side of triangle :"))

s=(x+y+z)/3

A=math.sqrt(s*(s-x)*(s-y)*(s-z))

print("The Area of triangle is ", A)

Output:

Enter one side of triangle :7

Enter Second side of triangle :5

Enter third side of triangle :2

The Area of triangle is 3.11111111111111

16 views0 comments

Recent Posts

See All

Python program to calculate the factorial of a number

Write a Python function to calculate the factorial of a number (a non-negative integer). The function accepts the number as an argument. This program is most for O Level Practical Exam so read it care

NumPy program to find the most frequent value in the list.

This program is most for O Level Practical Exam so read it carefully. Program: import numpy as np x = np.array([1,2,3,4,5,7,2,1,1,1,8,9,1]) print(x) print("most frequent value in the list:") print(np.

bottom of page