CBSERanker

Loading

Worksheet #24090801 Data Visualization

Worksheet #24090801 Data Visualization

  1. What is the main purpose of data visualization?
    • a) To make data more difficult to understand
    • b) To summarize data in a visual format
    • c) To delete unnecessary data
    • d) To store data in a text format
  2. Which of the following is a valid Python library used for data visualization?
    • a) NumPy
    • b) Pandas
    • c) Matplotlib
    • d) Scikit-learn
  3. What function is used to create a line plot in Matplotlib?
    • a) plot()
    • b) bar()
    • c) hist()
    • d) line()
  4. In a Matplotlib plot, what does xlabel() do?
    • a) Sets the label for the x-axis
    • b) Sets the label for the y-axis
    • c) Sets the plot title
    • d) Sets the label for the data points
  5. Which method is used to display a plot in Matplotlib?
    • a) show()
    • b) draw()
    • c) view()
    • d) save()
  6. What type of chart is typically used to show the frequency distribution of data?
    • a) Line plot
    • b) Bar graph
    • c) Histogram
    • d) Pie chart
  7. Which argument is used in the plot() function to customize the color of the line?
    • a) color
    • b) label
    • c) legend
    • d) title
  8. What is the purpose of adding a legend to a plot?
    • a) To add labels to the axes
    • b) To add a title to the plot
    • c) To explain the data represented by different elements in the plot
    • d) To change the background color
  9. Which function in Matplotlib saves the plot to a file?
    • a) save()
    • b) savefig()
    • c) export()
    • d) store()
  10. In Matplotlib, which argument is used to set the width of the bars in a bar graph?
    • a) linewidth
    • b) barwidth
    • c) width
    • d) barheight

Programming Questions

  1. Write a Python program to create a simple line plot for the following data: x = [1, 2, 3, 4, 5] and y = [10, 20, 30, 40, 50]. Customize the plot by adding a title, x-axis label, and y-axis label.
  2. Write a program to create a bar graph showing the scores of students in three subjects (Math, Science, English). Use the following data:
    • Names: [‘John’, ‘Alice’, ‘Bob’]
    • Math: [85, 78, 92]
    • Science: [90, 88, 80]
    • English: [75, 85, 95]
  3. Create a histogram for the following data showing the distribution of ages: [21, 22, 23, 22, 21, 24, 25, 22, 23, 23, 22].
  4. Write a program to plot two lines on the same graph using the following data:
    • Line 1: x = [1, 2, 3, 4, 5], y = [2, 4, 6, 8, 10]
    • Line 2: x = [1, 2, 3, 4, 5], y = [1, 3, 5, 7, 9] Add a legend to differentiate between the two lines.
  5. Write a Python program that saves a plot (any plot of your choice) as a PNG image.
  6. Using Matplotlib, create a pie chart showing the percentage distribution of the following data: Apples = 40, Bananas = 30, Cherries = 20, Dates = 10.
  7. Write a Python program to create a bar graph showing the monthly sales of a store over 6 months: Jan = 1500, Feb = 1800, Mar = 1700, Apr = 1600, May = 1900, Jun = 2000.
  8. Create a Python program that generates a scatter plot using the following data points:
    • x = [1, 2, 3, 4, 5], y = [2, 3, 5, 7, 11].
  9. Write a Python program to plot a sine wave using Matplotlib. Use the numpy library to generate values for the sine function.
  10. Create a histogram using the following data and set the number of bins to 5: Data = [5, 10, 10, 15, 20, 20, 20, 25, 30, 35, 35, 40].

Leave a Reply

Your email address will not be published. Required fields are marked *