Class 10 Programs for Project File
Class 10 Programs for Project File
Code:
# Number of rows for the pattern
rows = 5
# Print i asterisks
for j in range(i):
print()
if n <= 1:
else:
is_prime = True
# Check if n is divisible by i
if n % i == 0:
is_prime = False
break
if is_prime:
else:
4. Write a python program to input two numbers and find their HCF and LCM.
Code:
# Find HCF
hcf = 1
for i in range(1, min(num1, num2) + 1):
print(number)
else:
if num == num[::-1]:
else:
list1 = [1, 2, 3]
list2 = [4, 5, 6]
added_list = [ ]
added_list.append(list1[i] + list2[i])
print(added_list)
9. Write a python program to perform addition and multiplication on two #different arrays.
Code:
import numpy as np
# Perform multiplication
10. Write a python program to create one dimensional array with values ranging from 10 to 100, i.e.,
multiples of 10
Code:
import numpy as np
11. Write a python program to create a two dimensional array(2X3) with random integer values less than
Code:
import numpy as np
# Create a 2x3 array with random integers less than 20
print(array_2d)
12. Write a program to find the maximum value in each row and each column of a 2D array.
Code:
array_2d = [
[7, 1, 6, 14],
[10, 4, 11, 9]
max_in_rows = []
max_in_columns = []
max_in_rows.append(max(row))
for col in range(len(array_2d[0])): # Assume all rows have the same number of columns
max_in_columns.append(max(column_values))
print("Original 2D Array:")
print(row)
print(max_in_rows)
print(max_in_columns)
13. Write a program to sort the elements of an array in descending order and find the sum of all values
array.
Code:
total_sum = sum(array)
14. Write a program to calculate mean, median and mode using Numpy
Code:
import statistics
ages=[20,35,32,40,80,79,64,50]
print("Mean: ",mean)
print("Median: ",median)
print("Mode: ",mode)
15. Write a program to display a scatter chart for the following points (2,5), (9,10),(8,3),(5,7),(6,18).
Code:
x = [2, 9, 8, 5, 6]
plt.xlabel('X-axis')
plt.ylabel('Y-axis')
plt.xlim(0, 10)
plt.ylim(0, 20)
# Show grid
plt.grid()
plt.show()
code:
x = [2, 9]
y = [5, 10]
plt.xlabel('X-axis')
plt.ylabel('Y-axis')
plt.xlim(0, 10)
plt.ylim(0, 12)
# Show grid
plt.grid()
plt.show()
17. Read csv file saved in your system and display its information
Code:
import pandas as pd
# Read the CSV file
data = pd.read_csv('C:\\Users\\USER\\Desktop\\examslist.csv')
print(data)
18. Read csv file saved in your system and display first 5 records.
Code:
import pandas as pd
data = pd.read_csv(file_path)
print(data.head(5))
Code:
import cv2
import numpy as np
# To load or read an image into computers memory, we use imread() function from OpenCV library
image = cv2.imread(r'C:\Users\USER\Pictures\Screenshots\logo.png')
cv2.imshow('Image', image)
cv2.waitKey(0)
cv2.destroyAllWindows()
20. Write a program to read an image and identify its shape (height, width, channel) using computer vi
Code:
import cv2
import numpy as np
# Read the image. OpenCV tores images in BGR order rather than RGB
image = cv2.imread(r'C:\Users\USER\Pictures\Screenshots\flower.jpg')
plt.imshow(cv2.cvtColor(image,cv2.COLOR_BGR2RGB))
plt.axis('on')
plt.show()
height,width,channels=image.shape
print("Height: ",height)
print("Width: ",width)