Gaurav has written a Python Code to create a bar plot as given below using the following data :
City |
Happiness_Index Male |
Happiness_Index Female |
Delhi |
60 |
30 |
Beijing |
40 |
60 |
Washington |
70 |
70 |
Tokyo |
65 |
55 |
Moscow |
85 |
75 |
import ....... as...... #Statement 1
City=['Delhi','Beijing','Washington','Tokyo','Moscow']
Gender=['Male','Female'] Happiness_Index_Male=[60,40,70,65,85]
Happiness_Index_Female=[30,60,70,55,75]
plt.bar([0.25,1.25,2.25,3.25,4.25],Happiness_Index_Male,color='blue',label=" Male",width=.5)
plt .......([.75,1.75,2.75,3.75,4.75],Happiness_Index_Female,color='Green',w idth=.5,label="Female") #Statement 2
pos=range(len(City)) print(pos)
plt.xticks(pos,City,fontsize=10) plt.xlabel('City', fontsize=16) plt.ylabel('Happiness_Index', fontsize=16)
............. #Statement 3
............ #Statement 4
............ #Statement 5
i. Identify the suitable code to be used in the blank space in line marked as Statement1.
a. matplotlib as plt
b. numpy as np
c. pandas as pd
d. matplotlib.pyplot as plt
ii. What is the name of the function to plot the required bar graph in the line marked as Statement 2
a. hist()
b. pie()
c. bar()
d. scatter()
iii. Fill in the blank in statement 3 to set Chart Title as “Happiness Index acrosscities by gender “and font size as 18.
a. plt.xtitle("Happiness Index across cities by gender",fontsize=18)
b. plt.title("Happiness Index across cities by gender",fontsize=18)
c. plt.ytitle("Happiness Index across cities by gender",fontsize=18)
d. plt.show("Happiness Index across cities by gender",fontsize=18)
iv. Identify the suitable code for line marked as Statement 4 to display the legends as shown in the plot.
a. plt.showlegend()
b. plt.legend()
c. plt.display()
d. plt.show()
v. Fill in the blank marked in Statement 5 to display the plot.
a. plt.plot()
b. plt.showplot()
c. plt.display()
d. plt.show()