PROGAM of 11
PROGAM of 11
#program 3
#to check weather a year is leap year or not
OUTPUT
year=int(input("enter year number: "))
enter year number: 2000
if (year % 4 == 0 and year % 100 != 0) or
2000 is a leap year.
(year % 400 == 0):
print(f"{year} is a leap year.")
else:
print(f"{year} is not a leap year.")
# program 4
#to calculate the area of cylinder and sphere
radiusc=int(input("enter the radius of a cylinder "))
heightc=int(input("enter the height of a cylinder "))
radiuss=int(input("enter the radius of a sphere "))
pi=3.14
volume_cylinder = pi * (radiusc ** 2) * heightc
print(f"The volume of the cylinder with radius {radiusc} and height {heightc} is
{volume_cylinder:.2f} cubic units.")
OUTPUT
enter the radius of a cylinder 3
enter the height of a cylinder 4
enter the radius of a sphere 3
The volume of the cylinder with
radius 3 and height 4 is 113.04
cubic units.
The volume of the sphere with
radius 3 is 113.04 cubic units.
#program 5
#to check biggest number among them
num1=int(input("enter the number 1"))
num2=int(input("enter the number 2"))
num3=int(input("enter the number 3")) enter the number 1: 4
if num1 >= num2 and num1 >= num3: enter the number 2: 67
biggest = num1
enter the number 3: 72
elif num2 >= num1 and num2 >= num3:
The biggest number among 4, 67,
biggest = num2 and 72 is 72.
else:
biggest =num3
print(f"The biggest number among {num1}, {num2}, and {num3} is {biggest}.")
#program 7
#to calculate the roots of quadratic eq ax^2+bx+c=0
a=int(input("enter cofficent of x^2"))
b=int(input("enter cofficent of x"))
c=int(input("enter constant term"))
# Calculate the discriminant
discriminant = b**2 - 4*a*c
# Calculate the roots OUTPUT
if discriminant > 0: enter cofficent of x^2 2
root1 = (-b + discriminant**0.5) / (2*a) enter cofficent of x 6
root2 = (-b - discriminant**0.5) / (2*a)
enter constant term 4
print(f"The roots are real and different: {root1} and {root2}")
The roots are real and different: -
elif discriminant == 0: 1.0 and -2.0
root1 = root2 = -b / (2*a)
print(f"The roots are real and the same: {root1} and {root2}")
else:
real_part = -b / (2*a)
imaginary_part = (-discriminant)**0.5 / (2*a)
print(f"The roots are complex: {real_part} + {imaginary_part}i and {real_part} - {imaginary_part}i")
#to find weather a number is a prime or not
a=int(input("enter a number ")) OUTPUT
if a==1:
enter a number 4
print("it is not a prime ")
it is not a prime number
if a>1:
enter a number 47
for i in range(2,a):
it is a prime number
if a%i==0:
print ("it is not a prime number")
break
else:
print("it is a prime number ")
sum=sum+n%10 40
n=n//10
print(sum)