GRADE X AI - PRCATICAL PROGRAMS
GRADE X AI - PRCATICAL PROGRAMS
Program:
Output:
3 Write a Python program to find square of number 7.
Program:
number = 7
square = number ** 2
Output:
OR
Program:
number = 7
square = pow(number, 2)
Output:
4 Write a Python program to find the sum of two numbers 15 and 20.
Program:
num1 = 15
num2 = 20
sum = num1 + num2
print("The sum of", num1, "and", num2, "is:", sum)
Output:
5 Write a Python program to convert length given in kilometers into meters.
Program:
# Conversion factor
meters = kilometers * 1000
# Display result
print(kilometers, "kilometers is equal to", meters, "meters.")
Output:
number = 5
Output:
7 Write a Python program to calculate Simple Interest if the
principle_amount = 2000, rate_of_interest = 4.5 and time = 10.
Program:
principal_amount = 2000
rate_of_interest = 4.5
time = 10
Output:
# Calculate Area
area = length * width
# Calculate Perimeter
perimeter = 2 * (length + width)
Output:
9 Write a Python program to calculate Area of a triangle with Base and
Height.
Program:
# Calculate Area
area = 0.5 * base * height
Output:
# Calculate average
average_marks = (subject1 + subject2 + subject3) / 3
Output:
11 Write a Python program to calculate discounted amount with discount %.
Program:
Output:
# Calculate Volume
volume = length * width * height
# Check eligibility
if age >= 18:
print("You are eligible to vote.")
else:
print("You are not eligible to vote.")
Output:
Output:
Output:
Output:
18 Write a Python program to print odd numbers from 1 to n.
Program:
Output:
19 Write a Python program to print the sum of the first 10 natural numbers.
Program:
Output:
20 Write a Python program to print factorial of a number.
Program:
# Initialize factorial to 1
factorial = 1
# Calculate factorial
if number < 0:
print("Factorial is not defined for negative numbers.")
elif number == 0:
print("The factorial of 0 is 1.")
else:
for i in range(1, number + 1):
factorial *= i
print("The factorial of", number, "is:", factorial)
Output:
while True:
print("\nMenu:")
print("1. Area of Circle")
print("2. Area of Rectangle")
print("3. Area of Triangle")
print("4. Area of Square")
print("5. Exit")
if choice == '1':
radius = float(input("Enter the radius of the circle: "))
area = 3.14 * radius ** 2
print("Area of the circle:", area)
elif choice == '2':
length = float(input("Enter the length of the rectangle: "))
width = float(input("Enter the width of the rectangle: "))
area = length * width
print("Area of the rectangle:", area)
elif choice == '3':
base = float(input("Enter the base of the triangle: "))
height = float(input("Enter the height of the triangle: "))
area = 0.5 * base * height
print("Area of the triangle:", area)
elif choice == '4':
side = float(input("Enter the side of the square: "))
area = side ** 2
print("Area of the square:", area)
elif choice == '5':
print("Exiting the program.")
break
else:
print("Invalid choice. Please enter a number between 1 and 5.")
Output:
22 Write a python program to plot a bar graph using the data given below:
# Sample data
categories = ['Category A', 'Category B', 'Category C', 'Category D']
values = [10, 15, 7, 12]
Output:
23 Write a python program to plot a line graph using the data given below:
Output:
24 Write a python program to Plot a line chart using the given temperature
data.
Program:
Output:
25 Write a python program to Plot a bar graph using the given data.
Program:
Output: