1. Python script for checking the given year is leap year or not.
year = int(input("enter Year: "))
if (year % 400 == 0) or (year % 4 ==0 and year % 100 != 0):
print("Leap Year")
else:
print("Not a Leap year")
OUTPUT:
1. enter Year: 2000
Leap Year
2. enter Year: 1900
Not a Leap year
2. Python script to check if a number belongs to the Fibonacci
Sequence.
n = int(input("Enter number: "))
a, b = 0, 1
found = False
while a <= n:
if a == n:
found = True
break
a, b = b, a + b
print("Fibonacci Number" if found else "Not a Fibonacci Number")
OUTPUT:
1. Enter number: 3
Fibonacci Number
2. Enter number: 4
Not a Fibonacci Number
3. Python Script to solve Quadratic Equation
import math
# Take input from user
a = float(input("Enter coefficient a: "))
b = float(input("Enter coefficient b: "))
c = float(input("Enter coefficient c: "))
# Check if a is zero
if a == 0:
print("This is not a quadratic equation.")
else:
# Calculate discriminant
discriminant = b**2 - 4*a*c
if discriminant > 0:
root1 = (-b + [Link](discriminant)) / (2*a)
root2 = (-b - [Link](discriminant)) / (2*a)
print("Two real and distinct roots:")
print("Root 1 =", root1)
print("Root 2 =", root2)
elif discriminant == 0:
root = -b / (2*a)
print("One real root (repeated):")
print("Root =", root)
else:
real_part = -b / (2*a)
imaginary_part = [Link](-discriminant) / (2*a)
print("Two complex roots:")
print("Root 1 =", complex(real_part, imaginary_part))
print("Root 2 =", complex(real_part, -imaginary_part))