[go: up one dir, main page]

0% found this document useful (0 votes)
26 views13 pages

Grade 10 AI - Project File

Uploaded by

varshirajasekar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views13 pages

Grade 10 AI - Project File

Uploaded by

varshirajasekar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Program No.

Topic

1 Python program that takes two numbers as input and calculates both
their Highest Common Factor (HCF) and Least Common Multiple (LCM).

2 Python program to find the sum of the first 10 natural numbers.

3 Python program to create a list of student names and arrange them in


alphabetical order.

4 Python program to find all numbers between 1000 and 2000 that are
divisible by 7 and are multiples of 5.

5 Python program to input an employee's name, age, and basic salary.


Calculate the employee's total salary by adding 10% Dearness Allowance
(DA) and 10% House Rent Allowance (HRA) to the basic salary.
6 Python program that calculates the mean, median, and mode of a list of
numbers.

7 Python program that generates a line chart representing a straight line


between the points (2, 5) and (9, 10).

8 Python program that generates a scatter chart for the following points
(2,5), (9,10),(4,8), (6,18).

9 Python program to read an image file and display it on the screen.

10 Python program that takes height as input in centimetres and converts it


to inches and feet.
11 Python program to check if a number is an Armstrong number

12 Python program that generates a specific pattern.

13 Python program that collects temperature readings for all seven days of
the week and calculates the average temperature for the week.

14 Python program that checks whether a number entered by the user is a


palindrome

15 Python program that checks whether a number entered by the user is


positive, negative, or zero.

Page 1 of 13
Program 1

Write a Python program that takes two numbers as input and calculates both their Highest Common
Factor (HCF) and Least Common Multiple (LCM).

# Input two numbers

num1 = int(input("Enter the first number: "))

num2 = int(input("Enter the second number: "))

# Find the HCF

a, b = num1, num2

while b != 0:

a, b = b, a % b

hcf = a

# Find the LCM

lcm = (num1 * num2) // hcf

# Output HCF and LCM

print("HCF:", hcf)

print("LCM:", lcm)

Output

Enter the first number: 150


Enter the second number: 120
HCF: 30
LCM: 600

Page 2 of 13
Program 2

Write a Python program to find the sum of the first 10 natural numbers.

sum = 0

for i in range(1, 11):

sum += i

print("Sum of the first 10 natural numbers:", sum)

Output

Sum of the first 10 natural numbers: 55

Program 3

Write a Python program to create a list of student names and arrange them in alphabetical order.

students = ["Alice", "Bob", "Charlie", "David"]

students.sort()

print(students)

Output

['Alice', 'Bob', 'Charlie', 'David']

Page 3 of 13
Program 4

Write a Python program to find all numbers between 1000 and 2000 that are divisible by 7 and are
multiples of 5.

for number in range(1000, 2001):

if number % 7 == 0 and number % 5 == 0:

print(number)

Output

1015
1050
1085
1120
1155
1190
1225
1260
1295
1330
1365
1400
1435
1470
1505
1540
1575
1610
1645
1680
1715
1750
1785
1820
1855
1890
1925
1960
1995

Page 4 of 13
Program 5

Write a Python program to input an employee's name, age, and basic salary. Calculate the
employee's total salary by adding 10% Dearness Allowance (DA) and 10% House Rent Allowance
(HRA) to the basic salary.

# Input employee details

name = input("Enter employee name: ")

age = int(input("Enter employee age: "))

basic_salary = float(input("Enter employee basic salary: "))

# Calculate allowances

da = 0.10 * basic_salary # 10% Dearness Allowance

hra = 0.10 * basic_salary # 10% House Rent Allowance

# Calculate total salary

total_salary = basic_salary + da + hra

# Display total salary

print(f"Employee Name: {name}")

print(f"Employee Age: {age}")

print(f"Total Salary (with 10% DA and 10% HRA): {total_salary}")

Output

Enter employee name: Ram


Enter employee age: 35
Enter employee basic salary: 35000
Employee Name: Ram
Employee Age: 35
Total Salary (with 10% DA and 10% HRA): 42000.0

Page 5 of 13
Program 6

Write a Python program that calculates the mean, median, and mode of a list of numbers.

# Sample list of numbers

numbers = [1, 2, 2, 3, 4, 4, 4, 5, 6]

# Calculate mean

mean = sum(numbers) / len(numbers)

print("Mean:", mean)

# Calculate median

sorted_numbers = sorted(numbers)

n = len(sorted_numbers)

if n % 2 == 0:

median = (sorted_numbers[n // 2 - 1] + sorted_numbers[n // 2]) / 2

else:

median = sorted_numbers[n // 2]

print("Median:", median)

# Calculate mode

max_count = 0

mode = None

for i in numbers:

count = 0

for j in numbers:

if i == j:

count += 1

if count > max_count:

max_count = count

mode = i

print("Mode:", mode)

Output

Mean: 3.4444444444444446
Median: 4
Mode: 4
Page 6 of 13
Program 7

Write a Python program that generates a line chart representing a straight line between the points
(2, 5) and (9, 10).

import matplotlib.pyplot as plt

# Points to plot

x = [2, 9]

y = [5, 10]

# Create the line chart

plt.plot(x, y)

# Show the chart

plt.title('Line from (2, 5) to (9, 10)')

plt.xlabel('X-axis')

plt.ylabel('Y-axis')

plt.grid()

plt.show()

Output

Page 7 of 13
Program 8

Write a Python program that generates a scatter chart for the following points (2,5), (9,10)(4,8),
(6,18).

import matplotlib.pyplot as plt

# Define the points

x = [2, 9, 4, 6] # x-coordinates

y = [5, 10, 8, 18] # y-coordinates

# Create the scatter chart

plt.scatter(x, y, color='blue', marker='o')

# Add titles and labels

plt.title('Scatter Chart for Given Points')

plt.xlabel('X-axis')

plt.ylabel('Y-axis')

# Show grid

plt.grid()

# Display the chart

plt.show()

Output

Page 8 of 13
Program 9

Write a Python program to read an image file and display it on the screen.

import matplotlib.pyplot as plt

import matplotlib.image as mpimg

# Read the image

img = mpimg.imread('path/to/your/image.jpg')

# Display the image

plt.imshow(img)

plt.axis('off') # Hide axes

plt.show()

Output

Image display

Program 10

Create a Python program that takes height as input in centimeters and converts it to inches and feet.

# Input height in centimeters

height_cm = float(input("Enter height in centimeters: "))

# Conversion factors

inches = height_cm / 2.54 # 1 inch = 2.54 cm

feet = inches / 12 # 1 foot = 12 inches

# Display the results

print(f"Height in inches: {inches:.2f}")

print(f"Height in feet: {feet:.2f}")

Output

Enter height in centimeters: 200


Height in inches: 78.74
Height in feet: 6.56
Page 9 of 13
Program 11

Write a Python program to check if a number is an Armstrong number.

# Input a number from the user

num = int(input("Enter a number: "))

# Convert the number to string to calculate the number of digits

num_str = str(num)

num_digits = len(num_str)

# Calculate the sum of the digits raised to the power of the number of digits

sum_of_powers = sum(int(digit) ** num_digits for digit in num_str)

# Check if the number is an Armstrong number

if sum_of_powers == num:

print(f"{num} is an Armstrong number.")

else:

print(f"{num} is not an Armstrong number.")

Output

Enter a number: 586


586 is not an Armstrong number.

Page 10 of 13
Program 12

Create a Python program that generates a specific pattern.

11111

2222

333

44

# Number of rows for the pattern

rows = 5

# Generate the pattern

for i in range(rows, 0, -1):

print((str(i) + ' ') * i)

Program 13

Create a Python program that collects temperature readings for all seven days of the week and
calculates the average temperature for the week.

# Input temperatures for 7 days

total = 0

# Collect temperatures for 7 days

for day in range(1, 8):

temp = input(f"Enter temperature for day {day}: ") # Get input as string

total += int(temp) # Convert input to integer and add to total

# Calculate average temperature

average_temp = total / 7

# Display the average

print("Average temperature for the week is:", average_temp)

Output

Page 11 of 13
Enter temperature for day 1: 20
Enter temperature for day 2: 25
Enter temperature for day 3: 22
Enter temperature for day 4: 28
Enter temperature for day 5: 29
Enter temperature for day 6: 28
Enter temperature for day 7: 30
Average temperature for the week is: 26.0

Program 14

Write a Python program that checks whether a number entered by the user is a palindrome.

# Input number from the user

number = input("Enter a number: ")

# Check if the number is a palindrome

if number == number[::-1]:

print(f"{number} is a palindrome.")

else:

print(f"{number} is not a palindrome.")

Output

Enter a number: 100


100 is not a palindrome.

Page 12 of 13
Program 15

Write a Python program that checks whether a number entered by the user is positive, negative, or
zero.

# Input number from the user

number = float(input("Enter a number: "))

# Check if the number is positive, negative, or zero

if number > 0:

print(f"{number} is positive.")

elif number < 0:

print(f"{number} is negative.")

else:

print("The number is zero.")

Output

Enter a number: 100


100.0 is positive.

Page 13 of 13

You might also like