0% found this document useful (0 votes)
3 views6 pages

Data Analytics and Visualization Using Python PYQ III

This document is a question paper for a course on Data Analysis and Visualization using Python, containing various questions on topics such as sampling methods, data manipulation with Pandas, and plotting with Matplotlib. It includes instructions for candidates, sections with compulsory and optional questions, and practical coding tasks related to data analysis. The paper assesses knowledge on data types, statistical concepts, and programming skills in Python.
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)
3 views6 pages

Data Analytics and Visualization Using Python PYQ III

This document is a question paper for a course on Data Analysis and Visualization using Python, containing various questions on topics such as sampling methods, data manipulation with Pandas, and plotting with Matplotlib. It includes instructions for candidates, sections with compulsory and optional questions, and practical coding tasks related to data analysis. The paper assesses knowledge on data types, statistical concepts, and programming skills in Python.
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

5325 12 [This question paper contains 12 printe'd pages.

[Link]|)atch(triangle) Your Roll No ...............

ax.set_aspect(`equal', `box')
Sr. No. of Question paper : 5325 J
ax.set_xlim(0, 1)

ax.set_ylim(0, 1) Unique paper code : 2344001201

[Link]()
Name of the Paper : DataAnalysis andvisualization
using Python
(b) State differences between following by giving
appropriate examples : (9)
Name of the Course : Generic Elective (G.E.)

(i) Simple random sampling and Stratified


Semester : 11
sampling

Duration : 3 Hours Maximum Marks : 90


(ii) rand( ), randint( ) functions in Numpy.

(iii) Deep and shallow copy in Numpy array.


Instructions for Candidates

1. Write your Roll No. on the top immediately on receipt


of this question paper.

2. Paper has two sections. All the questions in Section


A are compulsory.

3. Answer any four questions from Section 8.

4. Parts of question must be answered together.

5. Use of simple calculator is permitted.

(500) P.T.O.
5325 2 5325 11

Section A (iv) Using [Link](), display a frequency


(Compulsory) table showing the count of students for each
course and device combination. Add totals
using margins=True.
1. (a) What is the purpose of using Matylotlib in python?
Describe briefly any three types of plots that can
7. (a) Find the output of the following Python code.
be created usiflg Matplotlib. (1+3=4)
Illustrate the shapes along with their dimensions
and colour that will be displayed on the plot.
(b) What is the output of following code, give reasons :
(6)
(2+2-4)
import pandas as pd import [Link] as pit

import numpy as np import [Link] as patches

fig, ax = [Link]()
df = [Link]({
rectangle = [Link]((0.1, 0.1), 0.3, 0.4,
`keyl': [`a', 'a', `b', `b', `a'],
1inewidth=2,
`key2': [`one', `two', `one', `two', `one'],
edgecolor = `blue', facecolor=`lightblue')
`datal ': [Link](5), [Link] patch(rectangle)

circle = [Link]((0.7, 0.7), 0.2,1inewidth=2,


. `data2': [Link](5)
edgecolor='green',
)) facecolor=`lightgreen')

print(dD ax. addj)atch(circlc)

mean data = df[`datal'].groupby([df[`keyl'], triangle = [Link]([(0.5, 0.1), (0.9, 0.5),

(0.1, 0.5)],
df[`.key2']]).mean()
closed=True, 1inewidth=2, edgecolor=`red',
print(mean_data) facecolor=`1ightcoral')

P.T.O.
5325 10 5325

(c) A data analyst is working with a survey dataset


strident id -C0ursc gender day devise Score attonpts
Mobile 78 2
that includes fields like gender, age, income,
Slot Python Female Monday .
slo2 Java Male Tuesday Laptop 85 1 education level, and satisfaction rating.
S103 Python Male Monday Laptop 74 3

S104 Da',asci Female Wednesday Mobile 90 2 Classify each field as either qualitative or
S105 Java Male Monday Tablet 68 1
quantitative, and identify the type of data (Nominal,
S106 Python Female. Tuesday Laptop 88 2
Ordinal, Interval or Ratio) associated with each.
•Wednesday. • Mobile 76 2
S107 Datasci Male
(5)
S108 Java Female Monday Laptop 92 I

(d) What is a Numpy ndarray? How does it differ


(i) Create a DataFrame in Python using the from a Python list? Consider the following code
above .data. snippet. Predict the output and explain the reason
behind the result:
(ii) Add a new column score|)ct to store the
import numpy as np
percentage score (i.e., score/ 100).
arr = [Link](10)
(iii) Using Pandas pivot_table() method: sliced = arr[2:6]

(a) Display the average score_pct and sliced):] = 99

average attempts
print(arr) (I+2+2-5)

(b) Use gender and day as row indices


(e) What is correlation? How does it help in
and device as columns
understanding relationships between two variables?
Based on the scatter plots shown below, estimate
(c) Use margins = True to include row
the type and strength of correlation for each plot
and column totals
(e.g., strong positive, weak negative, no correlation,
(d) Round the result to 2 decimal places etc.). Justify your answer. (1+1+4=6)

P.T.O.
J`

(I

5325 '( 5325 9

(ii) import numpy as np

arr = [Link](1,10).reshape(3, 3)

print(arr)

print(arr[1 :, 1 :])

(I) Create a Pandas DataFrame that holds employee (iii) import pandas as pd
data with the columns : , (2+2+2=6)
data = [1, 5, 9,12,15,18, 22, 25, 30]

Name, Age, and Salary, including some missing


bins = [0,10, 20, 30]
values.
output = [Link](data, bins)
Then, Perform the following actions :
print(output)
(i) Drop all rows that contain missing values.

6. (a) Given the dataset [12, 18, 20, 25, 30], perform
(ii) Filter and display the employee records
Min-Max. scaling to the range [0, 1]. Show the
where the Salary is greater than €50,000.
minimum and maximum values, the scaling formula
used, and the resulting scaled dataset. (3)
Section 8

(b) You are given the following dataset of student


2. (a) Describe the key stages in the data analysis enrollments in various online courses:

process. For each step, explain its purpose and (2+2+4+4=12)


significance using relevant examples. (5)

P.T.O.
5325 5325

5. (a) Write a Python program to plot a quadratic (b) The IRIS dataset is a well-known multivariate
function using Numpy and Matplotlib. dataset that contains 150 [Link] of .iris flowers,

(1+1+1+2+1=6) with the following four features (attributes):


(2+2+3+3-10)
(i) Generate a list of integer values from -10
to 10 using a suitable Nunrpy function sepal length (cm), sepal width (cm), pet;1 length
(cm), petal [Link] (cm).
(ii) Compute the corresponding values of the
function y = x2 - 4x + 3 Each flower sample belongs to one of three species
(class [Link]\s).. Setosa, Versicolor, or Virginica.
(iii) Plot the function using a blue dotted line
Write a Python program to perform the following
(iv) Add suitable labels for the X and Y axes operations on the IRIS dataset:
and a meaningful title
(i) Load the IRIS dataset using [Link].
(v) Display the plot
(ii) Display the feature names and target
(class) names.
(b) What will be the output of the following? Explain
your answer. (9)
(iii) Compute and display the mean, median, and
standard deviation for each feature.
(i) import numpy as .np

a = [Link]([1, 2, 3, 4]) (iv) Plot a correlation heatmap for the features.

b = [Link]([5, 6, 7, 8])
3. (a) Explain what hierarchical indexing is in pandas.
print(a + b)
How do you create and access data using
print(a * b) hierarchical indexing? (2+3=5)

P.T.O.
5325 5325 7

(b) You are given Sales Data as following : (iv) Create a bar chart to compare total sales
(2+2+2+2+2=10) for each product across the 6-month period.

import pandas as pd (v) Add a title to each plot and display them
clearly.
data = {`Month': [`Jan', `Feb', `Mar', `Apr',
`May', `Jun'], `Sales_A': [100,120,130,90,110,
4. Write a python program using Nunrpy to perform the
150], `Sales `8': [80, 95,100, 70, 85,120]
following tasks : (2+2+1+2+2+6=15)
)
(i) Create a 3x4 Numpy array containing random
df = [Link](data)
integers between 10 and 50.

From above dataset containing monthly sales data


(ii) Slice and display the first two rows of the array.
for two products - r,

\t' (iii) Replace the last column of the array with zeros.
Product A and Product 8, write the code for the
following :
(iv) Transpose the modified array and display its
shape.
(i) Create a line plot showing monthly sales
of both products on the same chart. (v) Compute and display the mean and standard
deviation along each column of the original
(ii) Add labels for the x-axis (Month) and y- (modified) array.
axis (Sales).
(vi) Explain the use of the .following ndarray
attributes with suitable Python code examples:
(iii) Add a legend to distinguish between
Product A and Product 8. .shape, .ndim and .dtype

P.T.O.

You might also like