/**/ Python & MySQL: Unit Test - IP (Class 12) 2024-25

Tuesday, September 3, 2024

Unit Test - IP (Class 12) 2024-25

 Unit Test - Class - XII

Subject - Informatics Practices (IP - 065)       

                                                                         MM: 20

============================

1. Pyplot is an interface of Python’s _________ library.

  1. Seaborn
  2. Plotly
  3. Ggplot
  4. Matplotlib

2. Which of the following is not a valid chart type?

  1. Histogram
  2. Statistical
  3. Pie
  4. Bar

3. The command used to give a heading to a graph is ________

  1. plt.show()
  2. plt.plot()
  3. plt.xlabel()
  4. plt.title()

4. Which function would you use to set the limits for x-axis of the plot?

  1. limits()
  2. xlimits()
  3. xlim()
  4. lim()

5. Which function is used to show legends?

  1. display()
  2. show()
  3. legend()
  4. legends()

6. Write a program to plot a line chart to depict the changing weekly onion prices for four weeks. Give appropriate axes labels.

Solution:

import matplotlib.pyplot as plt

week = [1,2,3,4]

prices = [40, 80, 100, 50]

plt.plot(week, prices)

plt.xlabel('week')

plt.ylabel('Onion prices')

plt.show()

7. Create an array, A, in the range 1 to 20 with values 1.25 apart. Another array B, contains the log values of the elements in the array A.

Write a program to create a scatter plot of first vs. second array (array A vs. B) with red circle marker ; specify the x-axis (containing first array’s values) title as ‘Random Values’ and y-axis title as ‘Logarithm Values’.

Solution:

import matplotlib.pyplot as plt

import numpy as np

a = np.arange(1, 20, 1.25)

b = np.log(a)

plt.plot(a, b, 'ro')

plt.xlabel('random Values')

plt.ylabel('Logarithm values')

plt.show()

8. Write a program to plot a bar chart from the medals won by India. make sure that Gold, Silver, Bronze and Total tally is represented through different colours.

Solution:

import matplotlib.pyplot as plt

info = ['Gold', 'Silver', 'Bronze', 'Total']

India = [30, 20, 20, 70]

plt.bar(info, India, color =['gold', 'silver', 'brown', 'black'])

plt.xlabel("Medal Type")

plt.ylabel('Medal Count')

plt.show()

9. Prof. Awasthi is doing some research in the field of Environment. For some plotting purpose, he has generated some data as:

mu = 100

sigma = 15

x = mu + sigma * numpy.random.randn(10000)

Write a program to plot this data on a horizontal histogram with this data. 

Solution:

import matplotlib.pyplot as plt

import numpy as np

mu = 100

sigma = 15

x = mu+sigma*np.random.randn(10000)

plt.hist(x, bins = 30, orientation = 'horizontal')

plt.title('Research data Histogram')

plt.show()

==============================

MCQ Answer: 1. Matplotlib,   2. Statistical      3. plt.title( )

                        4. xlim( )       5. legend( )

===============================


No comments:

Post a Comment

Please do not any spam in the comment box.

CLASS XI HALF YEARLY QP WTH MS 2024

  Half Yearly Examination: 2024-25 Informatics Practices (065) Class- XI       Time Allowed: 3hrs                                     ...