Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
4 views7 pages

SEC1

The document outlines a semester project for a B.Sc. (Major) in Computer Science at Derozio Memorial College, featuring various coding tasks in Python. It includes implementations of data visualization using Matplotlib, image processing with OpenCV, and basic statistical calculations using NumPy. Each section demonstrates different programming techniques and functionalities relevant to the course.

Uploaded by

Om Gupta
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)
4 views7 pages

SEC1

The document outlines a semester project for a B.Sc. (Major) in Computer Science at Derozio Memorial College, featuring various coding tasks in Python. It includes implementations of data visualization using Matplotlib, image processing with OpenCV, and basic statistical calculations using NumPy. Each section demonstrates different programming techniques and functionalities relevant to the course.

Uploaded by

Om Gupta
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/ 7

DEROZIO MEMORIAL COLLEGE

B.Sc. (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 matplotlib.pyplot as plt
import numpy as np

x = np.array([6, 9, 3, 5, 8])
y = np.array([73, 45, 56, 79, 120])
sorted = np.argsort(x)
x = x[sorted]
y = y[sorted]

plt.plot(x, y, marker = 'o')


plt. tle('Sorted data Plot')
plt.xlabel('X values')
plt.ylabel('Y values')
plt.grid(True)
plt.show

Q2.
import cv2 as cv
import numpy as np
from matplotlib import pyplot as plt
Import sys

img = cv.imread('Myself.jpg',0)
equ = cv.equalizeHist(img)
x, neg = cv.threshold(img, 127, 255,
cv.THRESH_BINARY_INV)

res = np.hstack((img,neg)) #stacking images side-


by-side
#cv.imshow('Actual Image', img)
#cv.imshow('Enhanced Image', equ)
cv.imshow('Neg ve Image', res)
cv.waitKey(0)
Q3.
import matplotlib.pyplot as plt
import numpy as np

x = np.arange(0, 10*np.pi, 0.1)


cosx = np.cos(x)
plt.subplot(3,2,1)
plt.plot(x,cosx,ms=10)
plt. tle("cosx")
sinx = np.sin(x)
plt.subplot(3,2,2)
plt.plot(x,sinx,ms=10)
plt. tle("sinx")
tanx = np.tan(x)
plt.subplot(3,2,3)
plt.plot(x,tanx,ms=10)
plt. tle("tanx")
logx = np.log(x)
plt.subplot(3,2,4)
plt.plot(x,logx,ms=10)
plt. tle("logx")
y = x**2-4*x+10
plt.subplot(3,2,5)
plt.plot(x,y,ms=10)
plt. tle("Binomial Equa on")

# Adjust the spacing between subplots


plt.subplots_adjust(hspace=0.5, wspace=0.5)

plt.show()

Q4.
Q5.
import matplotlib.pyplot 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 = array.sort()

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 matplotlib.pyplot as plt
import numpy as np

matrix = np.array([
[4,5,6],
[7,8,9],
[3,2,1]
])
print(matrix)

OUTPUT:
[[4 5 6]
[7 8 9]
[3 2 1]]
Q7.
import matplotlib.pyplot as plt
import numpy as np

# Define a sample matrix


matrix = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])

# Sum of all elements in the matrix


sum_all_elements = np.sum(matrix)
print("Sum of all elements:", sum_all_elements)

# Sum of each column


sum_each_column = np.sum(matrix, axis=0)
print("Sum of each column:", sum_each_column)

# Sum of each row


sum_each_row = np.sum(matrix, axis=1)
print("Sum of each row:", sum_each_row)

# Transpose of the matrix


transpose_matrix = np.transpose(matrix)
print("Transpose of the matrix:\n", transpose_matrix)

# Mean of all elements in the matrix


mean_all_elements = np.mean(matrix)
print("Mean of all elements:", mean_all_elements)
# Mean of each column
mean_each_column = np.mean(matrix, axis=0)
print("Mean of each column:", mean_each_column)
# Mean of each row
mean_each_row = np.mean(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 matplotlib.pyplot as plt
import numpy as np

# Given integers
integers = [5, 7, 89, 9]

# Calculate mean and median


mean_value = np.mean(integers)
median_value = np.median(integers)

print(f"Mean: {mean_value}")
print(f"Median: {median_value}")

OUTPUT:
Mean: 27.5
Median: 8.0

Q9.
import matplotlib.pyplot 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 = np.mean(numbers)
median = np.median(numbers)
#mode = np.mode(numbers)[0][0]
standard_devia on = np.std(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 matplotlib.pyplot as plt
import numpy as np

# Generate random numbers


random_numbers = np.random.randint(0, 200, 50)

# Calculate mean, median, and standard devia on


mean = np.mean(random_numbers)
median = np.median(random_numbers)
std_dev = np.std(random_numbers)

print(f"Mean: {mean}")
print(f"Median: {median}")
print(f"Standard Devia on: {std_dev}")

x = range(len(random_numbers))

plt.plot(x,random_numbers,label= 'Random Numbers')


plt.plot(x, [mean]*len(x), label='Mean')
plt.plot(x, [median]*len(x), label='Median')
plt.plot(x, [std_dev]*len(x), label='Standard Devia on')
plt.sca er(x, random_numbers)
plt.legend()
plt.show()

OUTPUT:
Mean: 98.96
Median: 95.0
Standard Devia on: 56.44925508808774

You might also like