Python Final File
Python Final File
import math
s = float(input("Enter side of cube: "))
r_cyl = float(input("Enter radius of cylinder: "))
h_cyl = float(input("Enter height of cylinder: "))
r_cone = float(input("Enter radius of cone: "))
h_cone = float(input("Enter height of cone: "))
r_sph = float(input("Enter radius of sphere: "))
print("Volume of Cube:", s ** 3)
print("Volume of Cylinder:", math.pi * r_cyl ** 2 * h_cyl)
print("Volume of Cone:", (1/3) * math.pi * r_cone ** 2 * h_cone)
print("Volume of Sphere:", (4/3) * math.pi * r_sph ** 3)
Compute and print roots of quadratic equation ax2+bx+c=0,
where the values of a, b,
and c are input by the user
import math
a = float(input("Enter coefficient a: "))
b = float(input("Enter coefficient b: "))
c = float(input("Enter coefficient c: "))
d = b ** 2 - 4 * a * c
if d >= 0:
r1 = (-b + math.sqrt(d)) / (2 * a)
r2 = (-b - math.sqrt(d)) / (2 * a)
else:
r1 = complex(-b / (2 * a), math.sqrt(-d) / (2 * a))
r2 = complex(-b / (2 * a), -math.sqrt(-d) / (2 * a))
print("Roots:", r1, r2)
Print numbers up to N which are not divisible by 3, 6, 9,, e.g., 1,
2, 4, 5, 7,…
if a == b or b == c or a == c:
print("The triangle is isosceles.")
else:
print("The triangle is not isosceles.")
Print multiplication table of a number input by the user.
for i in range(n):
print(a, end=' ')
a, b = b, a + b
Compute factorial of a given number
import math