Write a Python program to find the circumference and area of a circle with a given radius , Squreroot of given number and find roots of quadratic equations using the Math module.
Code:
import math
def circle_properties(radius):
circumference = 2 * math.pi * radius
area = math.pi * radius ** 2
return circumference, area
def square_root(number):
return math.sqrt(number)
def quadratic_roots(a, b, c):
discriminant = b**2 - 4*a*c
if discriminant < 0:
return "No real roots"
elif discriminant == 0:
root = -b / (2*a)
return root
else:
root1 = (-b + math.sqrt(discriminant)) / (2*a)
root2 = (-b - math.sqrt(discriminant)) / (2*a)
return root1, root2
# Example usage
radius = 5
circumference, area = circle_properties(radius)
print("Circle Properties:")
print("Radius:", radius)
print("Circumference:", circumference)
print("Area:", area)
number = 25
print("\nSquare Root of", number, "is:", square_root(number))
a = 1
b = -3
c = 2
roots = quadratic_roots(a, b, c)
print("\nRoots of Quadratic Equation:", roots)
0 Comments