Class XII - Data Visualization (Slip Test) Solutions
Q1. Horizontal Bar Graph
import [Link] as p
Year = [2000, 2002, 2004, 2006]
Rate = [21.0, 20.7, 21.2, 21.6]
[Link](Year, Rate) # To draw a line graph
[Link]('Year')
[Link]('Rate')
[Link]('Fuel Rates in every Two Year')
[Link]("[Link]") # To save the graph
[Link]()
Q2. Pollution Index Bar Chart
import [Link] as plt
city = ["Delhi","Mumbai","Bangalore","Hyderabad"]
pollution = [23456123,20083104,18456123,13411093]
[Link](city, pollution, color='red')
[Link]("City")
[Link]("Pollution")
[Link]("Pollution Index")
[Link]()
Q3. Histogram
import [Link] as plt
data = [10,15,10,10,10,15,20,20,20,20,20,25,25]
[Link](data, bins=10, color='blue')
[Link]("Score")
[Link]("Frequency")
[Link]("Frequency of Score")
[Link]()
Q4. Weekly Attendance
import [Link] as pl
Days=['Mon', 'Tue', 'Wed', 'Thurs', 'Fri', 'Sat']
Present=[36, 37, 32, 31, 35, 39]
[Link](Days, Present) # Statement1
[Link]() # Statement2
Q5. Horizontal Bar Graph (Languages)
import [Link] as plt
x = ['Java', 'Python', 'PHP', 'JS', 'C#', 'C++']
popularity =[22.2, 17.6, 8.8, 8, 7.7, 6.7]
[Link](x, popularity, color="green") # Statement1
[Link]("Popularity")
[Link]("Languages")
[Link]()
Q6. Workshop Participants
import [Link] as plt
x = ['JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN']
y = [30, 20, 30, 50, 10, 60]
[Link](x, y) # Statement 1
[Link]("No. of Students attended") # Statement 2
[Link]()
Q7. Line Chart
import [Link] as plt
x = ['JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN']
y = [30, 20, 30, 50, 10, 60]
[Link](x, y) # Statement 1
[Link]("Status of Workshop") # Statement 2
[Link]()
Q8. Subject Scores
import [Link] as plt
subjects = ['IP', 'Math', 'History']
scores = [91, 85, 78]
[Link](subjects, scores)
[Link]("Subject-wise Scores")
[Link]("Score")
[Link]("Subjects")
[Link]()
Q9. Error
Error: x and y lengths mismatch (x has 4 values, y has 3).
Q10. Correction
import [Link] as plt
subjects = ['IP', 'Math', 'English']
scores = [90, 85, 88]
[Link](subjects, scores)
[Link]()
Q11. Correction
import [Link] as plt
data = [12,15,13,17,19,21,22,22,23,25,28,29,30,31,32,35,36,37,38,40]
[Link](data, bins=8, color='skyblue', edgecolor='black')
[Link]('Value')
[Link]('Frequency')
[Link]('Sample Histogram')
[Link]()
Q12. Output
Bar chart with subjects Math, Science, History (Green bars, scores 85, 90, 80).
Q13. DataFrame
import pandas as pd
data = {'City': ['Mumbai', 'Delhi', 'Bengaluru'],
'Population': [20400000,16700000,8400000]}
df = [Link](data)
print(df)
Q14. Line Graph
import [Link] as plt # Statement-1
students = ['John', 'Sarah', 'Mike', 'Emily']
scores = [88, 92, 75, 85]
[Link](students, scores, label='Test Scores') # Statement-2
[Link]('Student Name')
[Link]('Test Score') # Statement-3
[Link]()
[Link]('Student Test Scores') # Statement-4
[Link]()
Q15. Lux Soap
import [Link] as plt
months = ['JAN', 'FEB', 'MARCH']
sales = [100, 78, 90]
[Link](months, sales)
[Link]("Month")
[Link]("Sales")
[Link]("Lux Soap")
[Link]("lux_sales.png")
[Link]()
Q16. Medal Comparison
import [Link] as plt # Statement1
X=["JAPAN","CHINA","INDIA","USA"]
Y=[45,91,6,126]
[Link]("COUNTRIES")
[Link]("TOTAL MEDALS") # Statement2
[Link](X,Y) # Statement3
[Link]("Medal Comparison") # Statement4
[Link]()
Q17. India Medal Tally
import [Link] as plt
medal_category=['Gold', 'Silver', 'Bronze']
medal=[20,15,18]
[Link](medal_category, medal, color='blue')
[Link]("Medal Type")
[Link]("Medal")
[Link]("Indian Medal tally in Olympics")
[Link]("[Link]")
[Link]()
Q18. Onion Price
import [Link] as plt # Statement-1
week=[1,2,3,4,5]
price=[25,30,40,60,20]
[Link](week, price, label='Onion') # Statement-2
[Link]('Week')
[Link]('Onion Price') # Statement-3
[Link]()
[Link]("Weekly onion price chart") # Statement-4
[Link]()