DEROZIO MEMORIAL COLLEGE
[Link]. (MAJOR) IN COMPUTER SCIENCE
SEC PROJECT
SEMESTER-I
REGISTRATION NUMBER : 113241016000133
NAME : CHANCHAL PAL
ROLL : 125116
NUMBER : 20911
SUBJECT : COMPUTER SCIENCE
PAPER CODE : CMSACOR01T
Q1.
import [Link] as plt
import numpy as np
x = [Link]([6, 9, 3, 5, 8])
y = [Link]([73, 45, 56, 79, 120])
sorted = [Link](x)
x = x[sorted]
y = y[sorted]
[Link](x, y, marker = 'o')
plt. tle('Sorted data Plot')
[Link]('X values')
[Link]('Y values')
[Link](True)
[Link]
Q2.
import cv2 as cv
import numpy as np
from matplotlib import pyplot as plt
Import sys
img = [Link]('[Link]',0)
equ = [Link](img)
x, neg = [Link](img, 127, 255,
cv.THRESH_BINARY_INV)
res = [Link]((img,neg)) #stacking images side-
by-side
#[Link]('Actual Image', img)
#[Link]('Enhanced Image', equ)
[Link]('Neg ve Image', res)
[Link](0)
Q3.
import [Link] as plt
import numpy as np
x = [Link](0, 10*[Link], 0.1)
cosx = [Link](x)
[Link](3,2,1)
[Link](x,cosx,ms=10)
plt. tle("cosx")
sinx = [Link](x)
[Link](3,2,2)
[Link](x,sinx,ms=10)
plt. tle("sinx")
tanx = [Link](x)
[Link](3,2,3)
[Link](x,tanx,ms=10)
plt. tle("tanx")
logx = [Link](x)
[Link](3,2,4)
[Link](x,logx,ms=10)
plt. tle("logx")
y = x**2-4*x+10
[Link](3,2,5)
[Link](x,y,ms=10)
plt. tle("Binomial Equa on")
# Adjust the spacing between subplots
plt.subplots_adjust(hspace=0.5, wspace=0.5)
[Link]()
Q4.
Q5.
import [Link] as plt
import numpy as np
n = int(input("Enter the number of elements"))
array = [int(input(f"Enter element{i+1}:"))for i in range(n)]
sorted_array = [Link]()
print(array)
print(sorted_array)
OUTPUT:
Enter the number of elements: 5
Enter element1: 4
Enter element2: 6
Enter element3: 7
Enter element4: 3
Enter element5: 9
[3, 4, 6, 7, 9]
None
Q6.
import [Link] as plt
import numpy as np
matrix = [Link]([
[4,5,6],
[7,8,9],
[3,2,1]
])
print(matrix)
OUTPUT:
[[4 5 6]
[7 8 9]
[3 2 1]]
Q7.
import [Link] as plt
import numpy as np
# Define a sample matrix
matrix = [Link]([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
# Sum of all elements in the matrix
sum_all_elements = [Link](matrix)
print("Sum of all elements:", sum_all_elements)
# Sum of each column
sum_each_column = [Link](matrix, axis=0)
print("Sum of each column:", sum_each_column)
# Sum of each row
sum_each_row = [Link](matrix, axis=1)
print("Sum of each row:", sum_each_row)
# Transpose of the matrix
transpose_matrix = [Link](matrix)
print("Transpose of the matrix:\n", transpose_matrix)
# Mean of all elements in the matrix
mean_all_elements = [Link](matrix)
print("Mean of all elements:", mean_all_elements)
# Mean of each column
mean_each_column = [Link](matrix, axis=0)
print("Mean of each column:", mean_each_column)
# Mean of each row
mean_each_row = [Link](matrix, axis=1)
print("Mean of each row:", mean_each_row)
OUTPUT:
Sum of all elements: 45
Sum of each column: [12 15 18]
Sum of each row: [ 6 15 24]
Transpose of the matrix:
[[1 4 7]
[2 5 8]
[3 6 9]]
Mean of all elements: 5.0
Mean of each column: [4. 5. 6.]
Mean of each row: [2. 5. 8.]
Q8.
import [Link] as plt
import numpy as np
# Given integers
integers = [5, 7, 89, 9]
# Calculate mean and median
mean_value = [Link](integers)
median_value = [Link](integers)
print(f"Mean: {mean_value}")
print(f"Median: {median_value}")
OUTPUT:
Mean: 27.5
Median: 8.0
Q9.
import [Link] as plt
import numpy as np
# Prompt the user to input integers
user_input = input("Enter integers separated by spaces: ")
numbers = list(map(int, user_input.split()))
# Calculate mean and median
mean = [Link](numbers)
median = [Link](numbers)
#mode = [Link](numbers)[0][0]
standard_devia on = [Link](numbers)
print(f"Mean: {mean}")
print(f"Median: {median}")
#print(f"Mode: {mode}")
print(f"Standard Devia on: {standard_devia on}")
OUTPUT:
Enter integers separated by spaces: 45 78 99 69 37
Mean: 65.6
Median: 69.0
Standard Devia on: 22.464193731358353
Q10.
import [Link] as plt
import numpy as np
# Generate random numbers
random_numbers = [Link](0, 200, 50)
# Calculate mean, median, and standard devia on
mean = [Link](random_numbers)
median = [Link](random_numbers)
std_dev = [Link](random_numbers)
print(f"Mean: {mean}")
print(f"Median: {median}")
print(f"Standard Devia on: {std_dev}")
x = range(len(random_numbers))
[Link](x,random_numbers,label= 'Random Numbers')
[Link](x, [mean]*len(x), label='Mean')
[Link](x, [median]*len(x), label='Median')
[Link](x, [std_dev]*len(x), label='Standard Devia on')
[Link] er(x, random_numbers)
[Link]()
[Link]()
OUTPUT:
Mean: 98.96
Median: 95.0
Standard Devia on: 56.44925508808774