A SMALL PRACTICAL PROJECT
We assume that you have read the material about
text files in [
Lesson 20].
A great American physicist, [
James S. Trefil], once said:
"
The computer is a tool, like a hammer, to help people in their endeavors, nothing more".
There is nothing more exciting than applying what we have learned by doing a
practical project!
We were living in challenging times during the
global pandemic, and the virus showed no signs of letting up soon. So, wasn't it interesting to have our own
statistics on its evolution?
For the sake of programming in Python, of course... there are already very detailed reports available on the Internet.
Let's not think too much about it, ... we have an idea, let's implement it quickly!
STEP 1. THE DATA
I think I can use the
lists we have already studied. So, I created a structure for the
text file, named in this case "
covid.in",
which stores the data as follows:
• on the first line,
the number of new cases
• on the second line,
the number of tests performed
Each line will have the same number of elements (separated by a space, referring to a specific day). The days are consecutive,
over a certain period of time (July 22 - August 8, 2020, 1000+ cases/day, locally):
1030 1112 1119 1284 1120 1104 1151 1182 1356 1295 1225 1075 823 1232 1309 1345 1378 1350
24877 23346 22964 34127 15118 7633 21165 22529 23402 24977 23451 14215 8045 20581 26323 24147 23946 21444
The data was taken from the site [
worldometers.info].
The first values on each line are associated with the day of July 22, 2020, and so on.
For example: there were
1032 new cases, with
24877 tests performed.
You can enter values for a different period or from other countries, as well as other important data. You can try more lines...
the essential thing is to remember the principle.
Review the information provided,
then move on to the next page.