1.
Area and perimeter of rectangle
l = float(input("Enter length: "))
b = float(input("Enter breadth: "))
print("Area =", l*b)
print("Perimeter =", 2*(l+b))
2. Hypotenuse & area of right triangle
import math
base = float(input("Base: "))
height = float(input("Height: "))
hyp = [Link](base**2 + height**2)
area = 0.5 * base * height
print("Hypotenuse =", hyp)
print("Area =", area)
3. Area of circle
import math
r = float(input("Radius: "))
print("Area =", [Link] * r * r)
4. Celsius to Fahrenheit
c = float(input("Celsius: "))
f = (c * 9/5) + 32
print("Fahrenheit =", f)
5. HCF of two numbers
a = int(input("a: "))
b = int(input("b: "))
while b:
a, b = b, a % b
print("HCF =", a)
6. Check prime
n = int(input("Enter number: "))
flag = True
if n < 2:
flag = False
else:
for i in range(2, int(n**0.5)+1):
if n % i == 0:
flag = False
break
print("Prime" if flag else "Not prime")
7. Reverse digits
num = int(input("Enter number: "))
rev = 0
while num > 0:
d = num % 10
rev = rev*10 + d
num //= 10
print("Reversed =", rev)
8. Sum of digits
num = int(input("Enter number: "))
s = 0
while num > 0:
s += num % 10
num //= 10
print("Sum of digits =", s)
9. Product of digits
num = int(input("Enter number: "))
p = 1
while num > 0:
p *= (num % 10)
num //= 10
print("Product of digits =", p)
10. Leap year
year = int(input("Enter year: "))
if (year % 400 == 0) or (year % 4 == 0 and year % 100 != 0):
print("Leap year")
else:
print("Not leap year")
12. Sum of first n natural numbers
n = int(input("n: "))
print("Sum =", n*(n+1)//2)