CBSE CS and IP

CBSE Class 11 & 12 Computer Science and Informatics Practices Python Materials, Video Lecture

Data Visualization (2 Marks Questinos)

  1. Compare bar() and barh() function using examples.
  2. What is the use of matplotlib and pyplot?
  3. A list namely temp contains average temperatures for 7 days of last week. You want to see how temperature charged in last 7 days. Which chart type will you plot for the same and why? 
  4. Write a program to draw a sin and cos graph (with 100 continuous observations) in the same line chart. 
  5. Given an ndarray p as ([1,2,3,4]). Write code to plot a bar chart having bars for p and p**2 (with red color) and another bar for p vs p*2 (with blue color). Assume that libraries have been included.
  6. Mr. Sanjay wants to plot a bar graph for the given set of values of subject on x-axis and number of students who opted for that subject on y-axis.
    Complete the code to perform the following :
    • To plot the bar graph in statement 1
    • To display the legends in the Graph in statement 2
      import matplotlib.pyplot as plt
      x=['Hindi', 'English', 'Science', 'SST']
      y=[10,20,30,40]
      _____________________ Statement 1
      _____________________ Statement 2
      
      Click Here for Solution
  7. What will be the output of the following code:
    import matplotlib.pyplot as p
    x=[6,7,8,9,10]
    y=[60,40,55,30,70]
    p.title('Secondary Class Strength')
    p.xlabel('Class')
    p.ylabel('No. of students')
    p.bar(x,y)
    p.show()
    

  8. Fill in the blank with appropriate pyplot methods:
    import matplotlib.pyplot as p
    Year=[2000,2002,2004,2006]
    Rate=[21.0,20.7,21.2,21.6]
    ____________________________        # To draw a line graph
    p.xlabel('Year')              
    p.ylabel('Rate')                
    p.title('Fuel Rates in every Two Year')                 
    ___________________(“Graph1.pdf”)   # To save the graph 
    p.show()
    

  9. What is the structure of a histogram if cumulative attribute is set to be True.
  10. Write a code to plot the speed of a passenger train as shown in the figure given below:
  11. Mr. Sanjay wants to plot a bar graph for the given set of values of subject on x-axis and number of students who opted for that subject on y-axis.
    Complete the code to perform the following :
    • To plot the bar graph in statement 1
    • To display the graph in statement 2
    import matplotlib.pyplot as plt
    x=['Hindi', 'English', 'Science', 'SST']
    y=[10,20,30,40]
    _____________________ Statement 1
    _____________________ Statement 2
    

  12. Mr. Harry wants to draw a line chart using a list of elements named LIST.
    Complete the code to perform the following operations:
    • To plot a line chart using the given LIST.
    • To give a y-axis label to the line chart named "Sample Numbers"
    • import matplotlib.pyplot as PLINE
      LIST=[10,20,30,40,50,60]
      _____________________ Statement 1
      _____________________ Statement 2
      PLINE.show()
  13. what is boxplot ? how do you create it in pyplot.
  14. Write commands to plot the chart as per given instructions:
    • Plot a line y=x+5 for 100 points of x in range -50 to 50.

No comments:

Post a Comment