Friday, June 28, 2019

mathematical functions in python

Example1:

from math import *
print(sqrt(2))


output:
1.4142135623730951


Example2:

from math import *
diameter = 5
perimeter = 2 * pi * diameter
print(perimeter)

output:
31.41592653589793

Example 3:

from math import *
Ueff = 230
amplitude = Ueff * sqrt(2)
print(amplitude)

output:
325.2691193458119


Example 4:

""" Calculate area of a circle"""
from math import *
d = float(input("Diameter: "))
A = pi * d**2 / 4
print( "Area = ",A)

output:
Diameter: 2.5
Area =  4.908738521234052

No comments:

Post a Comment

python class topic video