Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
1.8k views
in General by (29.8k points)

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()

Please log in or register to answer this question.

1 Answer

+1 vote
by (29.6k points)

i. d. matplotlib.pyplot as plt 

ii. c. bar() 

iii. b. plt.title("Happiness Index across cities by gender",fontsize=18) 

iv. b. plt.legend() 

v. d. plt.show()

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...