[go: up one dir, main page]

0% found this document useful (0 votes)
9 views11 pages

Practical File Artificial Intelligence Class 10

The document contains a series of programming tasks related to data manipulation and visualization using Python. It includes creating matrices, data frames with candidate information, plotting bar and line charts for sales and game ratings, calculating statistical measures like mean and variance, and performing image processing using OpenCV. Each task is accompanied by code snippets demonstrating the implementation of the required functionality.

Uploaded by

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

Practical File Artificial Intelligence Class 10

The document contains a series of programming tasks related to data manipulation and visualization using Python. It includes creating matrices, data frames with candidate information, plotting bar and line charts for sales and game ratings, calculating statistical measures like mean and variance, and performing image processing using OpenCV. Each task is accompanied by code snippets demonstrating the implementation of the required functionality.

Uploaded by

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

1. Write a program to develop a matrix of 3x3 with values from 11 t0 28.

2. Write a program to create a data frame to store data of candidates who appeared
in interviews. The dataframe columns are name, score, attempts, and qualify
(Yes/No). Assign rowindex as C001,C002, and so on.

#import pandas

package import pandas

as pd

#Creating Dictionary to store data d={'Name':

['Anil','Bhavna','Chirag','Dhara','Giri'],

'Score':[25,20,22,23,21],

'Attempts':[1,2,2,1,1], 'Qualified':

['Yes','No','Yes','Yes','No']}

#Creating a dataframe

df=pd.DataFrame(d,index=['C001','C002','C003','C004','C005'])

#Printing a dataframe

print(df)
3. Write a program to create a dataframe named player and store their data in the
columns like team, no. of matches, runs, and average. Assign player name as
row index and Display only those player details whose score is more than 1000.
#import pandas package
import pandas as pd
#Creating Dictionary to store data d={'Team':
['India','Pakistan','England','Asutralia'],
'Matches':[25,23,19,17],
'Runs':[1120,1087,954,830], 'Average':
[44.80,47.26,50.21,48.82]}
#Creating a dataframe
player=pd.DataFrame(d,index=['Virat kohli','Babar Azam','Ben Stokes','Steve
Smith'])
#Displaying data whose runs > 1000
print(player[player['Runs']>1000])
4. Write a program to represent the data on the ratings of mobile games on bar
chart. The sample data is given as: Pubg, FreeFire, MineCraft, GTA-V, Call of
duty, FIFA 22. The rating for each game is as: 4.5,4.8,4.7,4.6,4.1,4.3.
#Import package for Matplot Library

import matplotlib.pyplot as plt

#Creating lists for data

games=['Pubg', 'FreeFire', 'MineCraft', 'GTA-V','Call of duty', 'FIFA 22']

rating=[4.5,4.8,4.7,4.6,4.1,4.3]

#Creating bar graph with different bar colours

plt.bar(games,rating,color=['black', 'red', 'green', 'blue', 'yellow'])

#Customizing the bar graph

plt.title("Games Rating 2022")

plt.xlabel('Games')

plt.ylabel('Rating')

plt.legend();plt.show()
5. Consider the following data of a clothes store and plot the data on the line chart:
Month Jeans T-Shirts Shirts
March 1500 4400 6500
April 3500 4500 5000
May 6500 5500 5800
June 6700 6000 6300
July 6000 5600 6200
August 6800 6300 4500
Customize the chart as you wish.
#imort package for line chart
import matplotlib.pyplot as pp
#creating list data
mon =['March','April','May','June','July','August']
jeans= [1500,3500,6500,6700,6000,6800]
ts = [4400,4500,5500,6000,5600,6300]
sh = [6500,5000,5800,6300,6200,4500]
#Creating Line chart
pp.plot(mon,jeans,label='Mask',color='g',linestyle='dashed', linewidth=4,\
marker='o', markerfacecolor='k', markeredgecolor='r')
pp.plot(mon,ts,label='Mask',color='b',linestyle='dashed', linewidth=4,\
marker='3', markerfacecolor='k', markeredgecolor='g')
pp.plot(mon,sh,label='Mask',color='r',linestyle='dashed', linewidth=4,\
marker='v', markerfacecolor='k', markeredgecolor='b')
#Cusotmizing plot
pp.title("Apna Garment Store")
pp.xlabel("Months")
pp.ylabel("Garments")
pp.legend()
pp.show()
6. Observe the given data for monthly sales of one of the salesmen for 6 months.
Plot them on the line chart.

Month January February March April May June


Sales 2500 2100 1700 3500 3000 3800

Apply the following customizations to the chart:

 Give the title for the chart - "Sales Stats"


 Use the "Month" label for X-Axis and "Sales" for Y-Axis.
 Display legends.
 Use dashed lines with the width 5 point.
 Use red color for the line.
 Use dot marker with blue edge color and black fill color.

#Import pyplot
import matplotlib.pyplot as pp
#Prepraing data
mon =['January','February','March','April','May','June']
sales = [2500,2100,1700,3500,3000,3800]
#Crating line chart
pp.plot(mon,sales,label='Sales',color='r',linestyle='dashed', linewidth=4,\
marker='o', markerfacecolor='k', markeredgecolor='b')
#Customizing the chart
pp.title("Sales Report")
pp.xlabel("Months")
pp.ylabel("Sales")
pp.legend()
pp.show()
7. Write a menu-driven program to calculate the mean, mode and median for
the given data:

[5,6,1,3,4,5,6,2,7,8,6,5,4,6,5,1,2,3,4]

#import statistics
import statistics
#Creating list
l=[5,6,1,3,4,5,6,2,7,8,6,5,4,6,5,1,2,3,4]
#Display mean, mode and median value using functions
print("Mean Value:%.2f"%statistics.mean(l))
print("Mode Value:%.2f"%statistics.mode(l))
print("Median Value:%.2f"%statistics.median(l))

8. Write a program to calculate variance and standard deviation for the given

data: [33,44,55,67,54,22,33,44,56,78,21,31,43,90,21,33,44,55,87]
#import statistics

import statistics

#Creating list

l=[33,44,55,67,54,22,33,44,56,78,21,31,43,90,21,33,44,55,87]

#Display varaince and standard deviation value using functions

print("Variance:%.2f"%statistics.variance(l))

print("Standard Deviation:%.2f"%statistics.stdev(l))
Unit 5 Computer Vision

1. Visit this link (https://www.w3schools.com/colors/colors_rgb.asp). On the basis of


this online tool, try and write answers of all the below-mentioned questions.
o What is the output colour when you put R=G=B=255?
o What is the output colour when you put R=G=255,B=0?
o What is the output colour when you put R=255,G=0,B=255?
o What is the output colour when you put R=0,G=255,B=255?
o What is the output colour when you put R=G=B=0?
o What is the output colour when you Put R=0,G=0,B=255?
o What is the output colour when you Put R=255,G=0,B=0?
o What is the output colour when you put R=0,G=255,B=0?
o What is the value of your colour?

Solution:

1. White
2. Yellow
3. Pink
4. Cyan
5. Black
6. Blue
7. Red
8. Green
9. R=0,G=0,B=255

22. Create your own pixels on piskelapp (https://www.piskelapp.com/) and make a


gif image.

Steps:
1. Open piskelapp on your browser.
2. Apply background for the picture.
3. Use pen to draw letter A
4. Copy the layer and paste it
5. Now erase letter A written previously
6. Apply the background colour for layer 2
7. Change the pen colour and Write I
8. Export the image.
9. Follow this link to access animated GIF: Click here

23. Do the following tasks in OpenCV.


a. Load an image and Give the title of the image
b. Change the colour of image and Change the image to grayscale
c. Print the shape of image
d. Display the maximum and minimum pixels of image
e. Crop the image and extract the part of an image
f. Save the Image
1. Load Image and Give the title of image

#import required module cv2, matplotlib and numpy

import cv2

import matplotlib.pyplot as plt

import numpy as np

#Load the image file into memory

img = cv2.imread('octopus.png')

#Display Image

plt.imshow(img)

plt.title('Octopus')

plt.axis('off')

plt.show()

2. Change the colour of image and Change the image to


grayscale
#import required module cv2, matplotlib and numpy
import cv2
import matplotlib.pyplot as plt
import numpy as np
#Load the image file into memory
img = cv2.imread('octopus.png')
#Chaning image colour image colour
plt.imshow(cv2.cvtColor(img, cv2.COLOR_BGR2RGB))
plt.title('Octopus')
plt.axis('off')
plt.show()
3. Print the shape of image
import cv2
img = cv2.imread('octopus.png',0)
(1920, 1357)
print(img.shape)
4. Display the maximum and minimum pixels of image
import cv2
img = cv2.imread('octopus.png',0)
print(img.min()) 0
255
print(img.max())
5. Crop the image and extract the part of an image
import cv2
import matplotlib.pyplot as plt
img = cv2.imread('octopus.png')
pi=img[150:400,100:200]
plt.imshow(cv2.cvtColor(pi, cv2.COLOR_BGR2RGB))
plt.title('Octopus')
plt.axis('off')
plt.show()
6. Save the Image
import cv2
import matplotlib.pyplot as plt
img = cv2.imread('octopus.png')
plt.imshow(img)
cv2.imwrite('oct.jpg',img)
plt.title('Octopus')
plt.axis('off')
plt.show()

You might also like