Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

The Maurya School, Palam Vihar, Gurugram

Academic Session 2022-2023


Practical File
TERM 1
Class X

PIP
It allows you to install and manage additional packages that are not part of the Python
standard library.
Arrays are collection of values of same data types that can be arranged in 1 or more
dimensions.
Arrays can be accessed by package Numpy only.
Matplot is the data visualization package.
Numpy: Numerical Array data handlimg package
Opencv Image processing package

What is Pyplot library in Python?


pyplot is a plotting library used for 2D graphics in python programming
language. It can be used in python scripts, shell, web application servers and other
graphical user interface toolkits

Part A – Advanced Python


1. Write a program to :

a. Display the sum of 1st 10 natural numbers.

b. Check whether the user is eligible to vote or not. (Input the age from user)

c. Check if the number entered by the user is positive, negative or zero.

d. Print the pattern:

*
**
***
****
*****
e. Calculate the cube of all numbers from 1 to a given number

Part B – Data Science


1. Write the program to:

a. Create an array using numpy

b. Add two arrays

2. Create a scatter plot for given data.

i) x = ['Ram','Shyam','Jeena','Sheena','Tam','Tom']

y = [99,86,87,88,111,86]

ii) Change the color of the scatterplot to green.

3. Create and compare the scatter plots for the given data in the same figure.

Car age Speed Car age Speed


5 90 4 88
8 86
7 86 9 84
8 84 10 85
7 85 12 82
2 99
7 84
17 56
8 83
2 89
9 75
9 76

4. Visualize the marks of 6 students in Science using Bar chart and change:

i) the width of the bars to 0.1

ii) color to red

iii) Ttile to BAR CHART and its font seize as 30 and color as red

5. Visualize the data of five subjects of a student using pie chart and:

i) Change the color of the wedges to any color of your choice


ii) Give the title as ‘Name of the student’.

# Creating arrays using numpy

import numpy as np

arr = np.array([1, 2, 3, 4, 5])

print(arr)

print(type(arr))

# addition of arrays
import numpy as np

a1 = np.array([1, 2, 3, 4, 5])
a2=np.array([3,4,5,6,7])

print(a1+a2)
c) #using scatterplot
i) import matplotlib.pyplot as plt

x = ['Ram','Shyam','Jeena','Sheena','Tam','Tom']
y = [99,86,87,88,111,86]
plt.title('scatter plot')
plt.xlabel('Names')
plt.ylabel('Marks')
plt.scatter(x, y)
plt.show()

ii) import matplotlib.pyplot as plt

x = ['Ram','Shyam','Jeena','Sheena','Tam','Tom']
y = [99,86,87,88,111,86]
plt.title('scatter plot')
plt.xlabel('Names')
plt.ylabel('Marks')
plt.scatter(x, y, color='green')
plt.show()

d) #using Bar chart


import matplotlib.pyplot as plt

x = ['Ram','Shyam','Jeena','Sheena','Tam','Tom']
y = [99,86,87,88,111,86]
plt.title('BAR CHART',fontsize=30,color='red')
plt.xlabel('Names')
plt.ylabel('Marks')
plt.bar(x, y,color="yellow", width=.1)
plt.show()

#pie chart
import matplotlib.pyplot as plt
m1=[31,25,49,78,96]
sub=['maths','eng','sst','science','hindi']
mycolors=['red','green','blue','pink','yellow']
plt.pie(m1,labels=sub,colors=mycolors)
plt.title('Shyam')
plt.show()

You might also like