Class 10 AI Python Programs

Class 10 AI Python Programs


1. Python program to find Area of a Triangle

b = float(input("Enter base: "))
h = float(input("Enter height: "))
area = 0.5 * b * h
print("Area of Triangle:", area)

2. Python program to find Area of a Circle

r = float(input("Enter radius: "))
area = 3.14159 * r * r
print("Area of Circle:", area)

3. Python program to find Simple Interest

p = float(input("Enter principal: "))
r = float(input("Enter rate: "))
t = float(input("Enter time: "))
si = (p * r * t) / 100
print("Simple Interest:", si)

4. Python program to find Compound Interest

p = float(input("Enter principal: "))
r = float(input("Enter rate: "))
t = float(input("Enter time: "))
ci = p * ((1 + r/100) ** t - 1)
print("Compound Interest:", ci)

5. Python program to find Calculate BMI (Body Mass Index)

w = float(input("Enter weight in kg: "))
h = float(input("Enter height in meters: "))
bmi = w / (h ** 2)
print("BMI:", bmi)
if bmi < 18.5:
    print("Underweight")
elif bmi < 25:
    print("Normal weight")
else:
    print("Overweight")

6. Python program to find Check for Leap Year

year = int(input("Enter a year: "))
if (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0):
    print("Leap Year")
else:
    print("Not a Leap Year")

7. Python program to find Calculate Perimeter of Rectangle

l = float(input("Enter length: "))
b = float(input("Enter breadth: "))
perimeter = 2 * (l + b)
print("Perimeter:", perimeter)

8. Python program for find Speed = Distance / Time

d = float(input("Enter distance (km): "))
t = float(input("Enter time (hours): "))
if t > 0:
    speed = d / t
    print("Speed:", speed, "km/h")
else:
    print("Time must be greater than zero")

9. Python program for Temperature Converter (Celsius to Fahrenheit)

c = float(input("Enter temperature in Celsius: "))
f = (c * 9/5) + 32
print("Fahrenheit:", f)

10. Python program for Electricity Bill Calculation

units = int(input("Enter units consumed: "))
if units <= 100:
    bill = units * 5
else:
    bill = 100 * 5 + (units - 100) * 7
print("Electricity Bill: ₹", bill)

11. Python program for Triangle Validity Check

a = int(input("Enter first side: "))
b = int(input("Enter second side: "))
c = int(input("Enter third side: "))
if a + b > c and a + c > b and b + c > a:
    print("Valid Triangle")
else:
    print("Invalid Triangle")

12. Python program to find grade depending upon marks.

marks = int(input("Enter marks: "))
if marks >= 90:
    grade = "A"
elif marks >= 75:
    grade = "B"
elif marks >= 50:
    grade = "C"
elif marks >= 35:
    grade = "D"
else:
    grade = "F"
print("Grade:", grade)

13. Python program to find Roots of a Quadratic Equation

import math
a = float(input("Enter a: "))
b = float(input("Enter b: "))
c = float(input("Enter c: "))
d = b**2 - 4*a*c

if d > 0:
    r1 = (-b + math.sqrt(d)) / (2*a)
    r2 = (-b - math.sqrt(d)) / (2*a)
    print("Real and Different Roots:", r1, r2)
elif d == 0:
    r = -b / (2*a)
    print("Real and Equal Roots:", r)
else:
    print("Complex Roots")

14. Python program to convert Currency  from INR to USD

inr = float(input("Enter amount in INR: "))
rate = 83  # example conversion rate
usd = inr / rate
print("Amount in USD:", usd)

15. Python program to calculate  discount.

price = float(input("Enter price: "))
discount = float(input("Enter discount %: "))
final_price = price - (price * discount / 100)
print("Final Price after discount:", final_price)

16. Python program to find Area of Square

side = float(input("Enter side of square: "))
area = side ** 2
print("Area of Square:", area)

17. Python program to find Area of a Parallelogram

base = float(input("Enter base: "))
height = float(input("Enter height: "))
area = base * height
print("Area of Parallelogram:", area)

18. Python program for Profit or Loss Calculator

cp = float(input("Enter cost price: "))
sp = float(input("Enter selling price: "))
if sp > cp:
    print("Profit:", sp - cp)
elif cp > sp:
    print("Loss:", cp - sp)
else:
    print("No Profit No Loss")

19.  Python program to find Volume of a Cube

side = float(input("Enter side length: "))
volume = side ** 3
print("Volume of Cube:", volume)

20. Python program to check Voting Eligibility

age = int(input("Enter age: "))
if age >= 18:
    print("Eligible to vote")
else:
    print("Not eligible to vote")

 

21. Python program to find Average of 3 Numbers

a = float(input("Enter first number: "))
b = float(input("Enter second number: "))
c = float(input("Enter third number: "))
average = (a + b + c) / 3
print("Average:", average)
if average >= 50:
    print("Pass")
else:
    print("Fail")

22. Python program to Check Body Temperature 

temp = float(input("Enter body temperature in °F: "))
if temp > 98.6:
    print("You may have a fever.")
else:
    print("Normal temperature.")

23.  Python program to find Area of a Trapezium

a = float(input("Enter first base: "))
b = float(input("Enter second base: "))
h = float(input("Enter height: "))
area = 0.5 * (a + b) * h
print("Area of Trapezium:", area)

24. Python program to  Calculate Time (Time = Distance / Speed)

d = float(input("Enter distance (km): "))
s = float(input("Enter speed (km/h): "))
if s > 0:
    time = d / s
    print("Time required:", time, "hours")
else:
    print("Speed must be greater than zero.")

25. Python program to Convert Days to Weeks and Days

days = int(input("Enter number of days: "))
weeks = days // 7
remaining_days = days % 7
print(f"{weeks} week(s) and {remaining_days} day(s)")

26. Python program to find Area of a Rhombus

d1 = float(input("Enter diagonal 1: "))
d2 = float(input("Enter diagonal 2: "))
area = 0.5 * d1 * d2
print("Area of Rhombus:", area)

27. Python program to calculate GST. 

amount = float(input("Enter amount: "))
gst_rate = float(input("Enter GST rate (%): "))
gst = (amount * gst_rate) / 100
total = amount + gst
print("GST Amount:", gst)
print("Total Amount (with GST):", total)

28. Python program to Check whether a Number is Positive, Negative, or Zero

num = float(input("Enter a number: "))
if num > 0:
    print("Positive Number")
elif num < 0:
    print("Negative Number")
else:
    print("Zero")

29. Python program to  find Area of an Equilateral Triangle

import math
side = float(input("Enter side length: "))
area = (math.sqrt(3) / 4) * side ** 2
print("Area of Equilateral Triangle:", area)

30. Python program to  Check a number for Perfect Square

import math
num = int(input("Enter a number: "))
root = math.sqrt(num)
if root == int(root):
    print("Perfect Square")
else:
    print("Not a Perfect Square")

 

Lesson tags: Class 10 AI Python Programs
Back to: Class 10 Artificial Intelligence