Answer:
Surface of a Cylinder Code:
#import math package to use math.pi for the value of PI
import math
#take radius of the base of a cylinder from user
r=float(input("Enter r of a cylinder"))
#take height of the curve surface of a cylinder from user
h=float(input("Enter the Height of a cylinder"))
#calculate the surface area of cylinder
s_area=2*math.pi*pow(r,2)*h
#calculate the volume of cylinder
volume=math.pi*pow(r,2)*h
print("surface area of a cylinder wll be %.2f" %s_area)
print("volume of a cylinder will be %.2f" %volume)
Quadratic Equation Code:
import math
a = int(input("Enter the coefficients of a: "))
b = int(input("Enter the coefficients of b: "))
c = int(input("Enter the coefficients of c: "))
d = b**2-4*a*c # discriminant
if d < 0:
print ("This equation has no real solution")
elif d == 0:
x = (-b+math.sqrt(b**2-4*a*c))/2*a
print ("This equation has one solutions: "), x
else:
x1 = (-b+math.sqrt((b**2)-(4*(a*c))))/(2*a)
x2 = (-b-math.sqrt((b**2)-(4*(a*c))))/(2*a)
print ("This equation has two solutions: ", x1, " or", x2)