The outbreak of Corona globally has had a major impact on the global economy, and yet we do not have any cure for this pandemic, many countries have been on lockdown and governments asking their civilian to be in quarantine. There is no industry left across the world which has no impact on Corona, even the programming world facing some major setbacks because of it. However, if we talk about individual programmers, they might also be facing minor social or physical problems after being in quarantine or working from home for 2 or 3 weeks.
Developers and programmers can turn this time in their favor by learning some new skills online because all you need is a computer and a good internet connection. Though the programming world may not be facing too many problems the overall IT industry do, if we look at the stats of developer hiring in the USA, in February the hiring of developer fell by nearly 70,000, which was raised by 52,000 in January, this downfall of developer hiring has a huge impact on the developer demands and it also affects the organization strength of developers.
What a Programmer or Developer can do in Quarantine?
Now, this is a perfect time to learn some new skills, if your city has been on lockdown or you are in Quarantine, now you can use this time to upgrade your programming skills to the next level. If you are a beginner you can learn some new intermediate programming and try something new to add valuable skills to your arsenal. As we know that tools and technologies in the programming world are not stable and you always require to update your skills with treading ones, and time like this may not occur in your life again and we hope it won’t, so open your computer, surf internet and find the best tool for yourself to learn.
How you can calculate the number of affected persons in the world?
Here we have used the web-scraping in python to scrape data from worldometer.com, which lists the live details of cases affected by the coronavirus .
Prerequisite
- python3
- pip
- internet
Python Libraries
- urllib
- bs4 (beautiful soup)
1. urllib
urllib is a powerful, and open-source library of python , it contains various modules such as request, error, parse, and robot parsers which can be used to send the request and collect data from the websites. Here in this example, we have used the urllib request method to send the HTTP request and open the URLs.
install urllib
pip install urllib
2. bs4
Also known as beautiful soup and it is used to pull out the HTML and XML files. It works with your favorite parser to provide idiomatic ways of navigating, searching, and modifying the parse tree. It commonly saves programmers' hours or days of work.
install beautiful soup
pip install bs4
Python Program to Calculate the total number of People affected by Corona:
from bs4 import BeautifulSoup
from urllib.request import urlopen as ureq
#country list
def show_countries(c):
for i in range(len(c)):
print("({0})".format(i+1), c[i])
# WORLDOMETER.INFO
url ="https://www.worldometers.info/coronavirus/"
#sending request to worldometer
client = ureq(url)
page= client.read()
client.close() #connection closed
#parsing the page
page_soup = BeautifulSoup(page,'html.parser')
#getting data present in table celles
container = page_soup.findAll("td")
#geting data from the page
data = [i.text.strip() if i.text.strip() else "0" for i in container ]
countries = [data[i] for i in range(len(data)) if data[i][0].isalpha()]
json_format_data ={}
for i in range(len(data)):
if data[i][0].isalpha():
ele=data[i].lower()
json_format_data[ele]=[]
else:
json_format_data[ele].append(data[i])
print("---------Corona Case Details---------")
label=["Total Cases", "New Cases","Total Deaths","New Deaths", "Total Recovered", "Active Cases", "Serious Critical","Tot Cases/1M pop", "Tot Deaths/1M pop"]
for i in range(9):
print(label[i],"-------->",json_format_data["total:"][i])
enter = int(input("Enter 1 to see the country List or 0 to skip: "))
if enter ==1:
show_countries(countries)
country_name =input("Enter the Country Name, To See its Corona Cases: ").lower()
print("\n\n ------Corona Cases in {0}--------".format(country_name))
for i in range(9):
print(label[i],"-------->",json_format_data[country_name][i])
Output:
---------Corona Case Details---------
Total Cases --------> 470,968
New Cases --------> 48,441
Total Deaths --------> 21,278
New Deaths --------> 2,388
Total Recovered --------> 113,827
Active Cases --------> 335,863
Serious Critical --------> 14,956
Tot Cases/1M pop --------> 60.4
Tot Deaths/1M pop --------> 2.7
Enter 1 to see the country List or 0 to skip: 1
(1) China
(2) Italy
(3) USA
(4) Spain
(5) Germany
(6) Iran
(7) France
(8) Switzerland
(9) UK
(10) S. Korea
(11) Netherlands
(12) Belgium
(13) Austria
(14) Portugal
(15) Canada
(16) Norway
(17) Sweden
(18) Australia
(19) Israel
(20) Brazil
(21) Turkey
(22) Malaysia
(23) Denmar
(24) Czechia
(25) Ireland
(26) Luxembourg
(27) Japan
(28) Chile
(29) Ecuado
(30) Pakistan
(31) Poland
(32) Thailand
(33) Romania
(34) Saudi Arabia
(35) Finland
(36) Indonesia
(37) Russia
(38) Greece
(39) Iceland
(40) India
(41) Diamond Princess
(42) South Africa
(43) Philippines
(44) Singapore
(45) Panama
(46) Estonia
(47) Qatar
(48) Slovenia
(49) Argentina
(50) Croatia
(51) Peru
(52) Mexico
(53) Colombia
(54) Bahrain
(55) Egypt
(56) Hong Kong
(57) Dominican Republic
(58) Serbia
(59) Iraq
(60) Lebanon
(61) UAE
(62) Algeria
(63) Lithuania
(64) Armenia
(65) New Zealand
(66) Hungary
(67) Taiwan
(68) Latvia
(69) Bulgaria
(70) Slovakia
(71) Morocco
(72) Andorra
(73) Uruguay
(74) San Marino
(75) Kuwait
(76) North Macedonia
(77) Costa Rica
(78) Bosniaand Herzegovina
(79) Albania
(80) Tunisia
(81) Jordan
(82) Ukraine
(83) Vietnam
(84) Moldova
(85) Burkina Fas
(86) Faeroe Islands
(87) Malta
(88) Ghana
(89) Cyprus
(90) Azerbaijan
(91) Réunion
(92) Brunei
(93) Kazakhstan
(94) Oman
(95) Venezuela
(96) Senegal
(97) Sri Lanka
(98) Cambodia
(99) Belarus
(100) Afghanistan
(101) Palestine
(102) Ivory Coast
(103) Georgia
(104) Cameroon
(105) Guadeloupe
(106) Montenegro
(107) Martinique
(108) Uzbekistan
(109) Trinidad and Tobago
(110) Cuba
(111) Mauritius
(112) Honduras
(113) DRC
(114) Nigeria
(115) Liechtenstein
(116) Channel Islands
(117) Bangladesh
(118) Kyrgyzstan
(119) Paraguay
(120) Rwanda
(121) Bolivia
(122) Mayotte
(123) Macao
(124) Monaco
(125) Kenya
(126) French Guiana
(127) Jamaica
(128) Gibraltar
(129) French Polynesia
(130) Isle of Man
(131) Guatemala
(132) Madagascar
(133) Togo
(134) Aruba
(135) Barbados
(136) New Caledonia
(137) Uganda
(138) El Salvador
(139) Maldives
(140) Tanzania
(141) Ethiopia
(142) Zambia
(143) Djibouti
(144) Dominica
(145) Mongolia
(146) Saint Martin
(147) Equatorial Guinea
(148) Cayman Islands
(149) Haiti
(150) Suriname
(151) Gabon
(152) Nigeria
(153) Bermuda
(154) Namibia
(155) Seychelles
(156) Curaçao
(157) Benin
(158) Greenland
(159) Laos
(160) Guyana
(161) Bahamas
(162) Fiji
(163) Mozambique
(164) Syria
(165) Cabo Verde
(166) Congo
(167) Eritrea
(168) Guinea
(169) Vatican City
(170) Eswatini
(171) Gambia
(172) Sudan
(173) Zimbabwe
(174) Nepal
(175) Angola
(176) Antigua and Barbuda
(177) CAR
(178) Chad
(179) Liberia
(180) Mauritania
(181) Myanmar
(182) St. Barth
(183) Saint Lucia
(184) Sint Maarten
(185) Belize
(186) Bhutan
(187) British Virgin Islands
(188) Guinea-Bissau
(189) Mali
(190) Nicaragua
(191) Saint Kitts and Nevis
(192) Somalia
(193) Grenada
(194) Libya
(195) Montserrat
(196) Papua New Guinea
(197) St. Vincent Grenadines
(198) Timor-Leste
(199) Turks and Caicos
(200) Total:
(201) China
(202) Italy
(203) USA
(204) Spain
(205) Germany
(206) Iran
(207) France
(208) Switzerland
(209) UK
(210) S. Korea
(211) Netherlands
(212) Austria
(213) Belgium
(214) Canada
(215) Norway
(216) Portugal
(217) Australia
(218) Brazil
(219) Sweden
(220) Turkey
(221) Israel
(222) Malaysia
(223) Denmark
(224) Czechia
(225) Ireland
(226) Luxembourg
(227) Japan
(228) Ecuaor
(229) Chile
(230) Pakistan
(231) Poland
(232) Thailand
(233) Romania
(234) Saudi Arabia
(235) Finland
(236) Greece
(237) Indonesia
(238) Iceland
(239) Diamond Princess
(240) South Africa
(241) Russia
(242) India
(243) Philippines
(244) Singapore
(245) Panama
(246) Qatar
(247) Slovenia
(248) Argentina
(249) Peru
(250) Colombia
(251) Egypt
(252) Croatia
(253) Bahrai
(254) Hong Kong
(255) Mexico
(256) Estonia
(257) Dominican Republic
(258) Serbia
(259) Iraq
(260) Lebanon
(261) UAE
(262) Algeria
(263) New Zealand
(264) Lithuania
(265) Armenia
(266) Bulgaria
(267) Taiwan
(268) Hungary
(269) Morocco
(270) Latvia
(271) Uruguay
(272) Slovakia
(273) San Marino
(274) Costa Rica
(275) Kuwait
(276) Andorra
(277) North Macedonia
(278) Bosnia and Herzegovina
(279) Tunisia
(280) Jordan
(281) Moldova
(282) Vietnam
(283) Albania
(284) Burkina Faso
(285) Ukraine
(286) Cyprus
(287) Faeroe Islands
(288) Malta
(289) Réunion
(290) Brunei
(291) Venezuela
(292) SriLanka
(293) Oman
(294) Senegal
(295) Cambodia
(296) Azerbaijan
(297) Belarus
(298) Afghanistan
(299) Kazakhstan
(300) Ivory Coast
(301) Cameroon
(302) Georgia
(303) Guadeloupe
(304) Palestine
(305) Ghana
(306) Martinique
(307) Trinidad and Tobago
(308) Uzbekistan
(309) Cuba
(310) Montenegro
(311) Honduras
(312) Nigeria
(313) Liechtenstein
(314) DRC
(315) Mauritius
(316) Channel Islands
(317) Kyrgyzstan
(318) Rwanda
(319) Bangladesh
(320) Paraguay
(321) Mayotte
(322) Bolivia
(323) Macao
(324) Monaco
(325) French Guiana
(326) Kenya
(327) Jamaica
(328) Gibraltar
(329) French Polynesia
(330) Guatemala
(331) Isle of Man
(332) Togo
(333) Aruba
(334) Madagascar
(335) Barbados
(336) New Caledonia
(337) Uganda
(338) Maldives
(339) Tanzania
(340) Ethiopia
(341) Zambia
(342) Djibouti
(343) Dominica
(344) Saint Martin
(345) Mongolia
(346) El Salvador
(347) Equatorial Guinea
(348) Cayman Islands
(349) Haiti
(350) Suriname
(351) Niger
(352) Bermuda
(353) Namibia
(354) Seychelles
(355) Curaçao
(356) Gabon
(357) Benin
(358) Greenland
(359) Guyana
(360) Bahamas
(361) Fiji
(362) Mozambique
(363) Syria
(364) Cabo Verde
(365) Congo
(366) Eritrea
(367) Guinea
(368) Vatican City
(369) Eswatini
(370) Gambia
(371) Sudan
(372) Zimbabwe
(373) Nepal
(374) Angola
(375) Antigua and Barbuda
(376) CAR
(377) Chad
(378) Laos
(379) Liberia
(380) Myanmar
(381) St. Barth
(382) Saint Lucia
(383) Sint Maarten
(384) Belize
(385) Bhutan
(386) British Virgin Islands
(387) Guinea-Bissau
(388) Mali
(389) Mauritania
(390) Nicaragua
(391) Saint Kitts and Nevis
(392) Grenada
(393) Libya
(394) Montserrat
(395) Papua New Guinea
(396) St. Vincent Grenadines
(397) Somalia
(398) Timor-Leste
(399) Turks and Caicos
(400) Total:
Enter the Country Name, To See its Corona Cases: china
------Corona Cases in china--------
Total Cases --------> 81,218
New Cases --------> +47
Total Deaths --------> 3,281
New Deaths --------> +4
Total Recovered --------> 73,650
Active Cases --------> 4,287
Serious Critical --------> 1,399
Tot Cases/1M pop --------> 56
Tot Deaths/1M pop --------> 2
Stay Home Stay Safe:
DO THE FIVE
- HANDSWash them often
- ELBOWCough into it
- FACEDon't touch it
- SPACEKeep safe distance
- HOMEStay if you can
- Python Program to Make a Simple Calculator
- Python Program to Find LCM
- Python Program to Convert Decimal to Binary, Octal and Hexadecimal
- Python Program To Display Powers of 2 Using Anonymous Function
- Python Program to Find Armstrong Number in an Interval
- Python Program to Print all Prime Numbers in an Interval
- Python Program to find Hash of File
- Python Program to Illustrate Different Set Operations
- Python Program to Transpose a Matrix
Leave a Comment on this Post