Page 318 - Touhpad Ai
P. 318
LEFT JOIN
left right
table table
Syntax : SELECT table1.column1,table1.column2,table2.column1,....
FROM table1
LEFT JOIN table2
ON table1.matching_column = table2.matching_column;
Question 8 (10)
36. Consider the following data of rainfall in five Indian cities. Write Python code to plot average monthly rainfall for
the five cities using different coloured line graphs.
Month Delhi Mumbai Chennai Kolkata Bengaluru
January 20 3 25 10 2
February 15 2 18 15 4
March 10 5 10 20 5
April 5 10 12 30 10
May 25 40 30 60 25
June 70 540 45 300 90
July 120 800 60 400 110
August 140 700 100 380 95
September 100 350 180 320 85
October 60 100 250 150 60
November 25 15 210 40 25
December 10 5 60 15 10
Ans. import matplotlib.pyplot as plt
# Data
months = [‘Jan’, ‘Feb’, ‘Mar’, ‘Apr’, ‘May’, ‘Jun’,
‘Jul’, ‘Aug’, ‘Sep’, ‘Oct’, ‘Nov’, ‘Dec’]
delhi = [20, 15, 10, 5, 25, 70, 120, 140, 100, 60, 25, 10]
mumbai = [3, 2, 5, 10, 40, 540, 800, 700, 350, 100, 15, 5]
chennai = [25, 18, 10, 12, 30, 45, 60, 100, 180, 250, 210, 60]
kolkata = [10, 15, 20, 30, 60, 300, 400, 380, 320, 150, 40, 15]
bengaluru = [2, 4, 5, 10, 25, 90, 110, 95, 85, 60, 25, 10]
# Plot multiple lines
plt.figure(figsize=(10,6))
plt.plot(months, delhi, marker=’o’, label=’Delhi’)
plt.plot(months, mumbai, marker=’o’, label=’Mumbai’)
plt.plot(months, chennai, marker=’o’, label=’Chennai’)
plt.plot(months, kolkata, marker=’o’, label=’Kolkata’)
plt.plot(months, bengaluru, marker=’o’, label=’Bengaluru’)
# Add titles and labels
plt.title(‘Average Monthly Rainfall (in mm) in Five Indian Cities’)
316 Touchpad Artificial Intelligence - XI

