Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
30 views

Web Scraping Using Python - Assignment Solutions

The document provides an assignment on web scraping a website using Python libraries and analyzing the scraped data. It details scraping population and land area data for countries from a website, then creating scatter plots, line plots, and bar plots to analyze the data using Matplotlib and Seaborn.

Uploaded by

Anand Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views

Web Scraping Using Python - Assignment Solutions

The document provides an assignment on web scraping a website using Python libraries and analyzing the scraped data. It details scraping population and land area data for countries from a website, then creating scatter plots, line plots, and bar plots to analyze the data using Matplotlib and Seaborn.

Uploaded by

Anand Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Web Scraping using Python - Assignment

Solutions

Use the Worldometer website link and solve the following question.

1. Scrape the Worldometer website using the BeautifulSoup and


Requests library.
URL:-https://www.worldometers.info/geography/how-many-countries-a
re-there-in-the-world/
2. Collect the data of Country wise Population, World_Share(%)
and 'Land_Area_Km².
3. Analyze the data by using matplotlib and seaborn library.
a. Make a Scatter plot by using Seaborn and Matplotlib of
'Population(2020) vs Land_Area_Km²' and apply the
following customization.
● Make the Figure size (8,6)
● Make a scatter plot such as
x='Population(2020)',y='Land_Area_Km²',palette='Set'
● Add a title to the Plot with fontsize = 15 and color =
purple as 'Population(2020) vs Land_Area_Km²'
● Add Grid to the plot using grid() function
● Also Show the plot using matplotlib show() function

b. Create a Line plot of 'Country vs Land_Area_Km² for top 5


countries by population' and apply the Following
customization to the plot.
● Make the Figure size (15,8)
● Make line/markers color 'indigo'
● Make line width as 2 and line style as '-.'
● Add label as Land_Area_Km²
● Add markers as 'o' with markersize = 10
● Add a title to the Plot with fontsize = 15 and color =
purple
● Add X-Label as Country & Y-Label as Land_Area_Km²

1
● Add Grid to the plot using grid() function
● Show the legend for the plot using legend() funct
● Also Show the plot

c. Create a Line plot of 'Country wise Population(2020)' of


top 5 countries based on population and apply the
Following customization to the plot.
● MMake a plot by setting figure size (10,6) using
seaborn set() function.
● Set the color palette for the plot using the
set_palette() function as "tab10".
● Set the style for the plot using the set_style()
function as "darkgrid".
● Set the context for the plot using set_cotext()
function with following customization ("paper",
font_scale = 2, rc={"grid.linewidth": 0.5}).
● Make a Bar plot using seaborn barplot() function
setting x='Country',y='Population(2020)'.
● Add the title to the plot as 'Country wise
Population(2020)'.
● Add X-label as 'Country' and Y-label as 'Country wise
Population(2020)'
● Make the Xticks rotate 45 degrees.
● Show the plot using show() function of matplotlib

Solution:- The Complete solution reference notebook for the above


questions is given below. The solution can vary from person to person.

Reference Solution
● Worldometer website link
● Jupyter Notebook Download Link
● Scrapped World Population Dataset Download Link

You might also like