subject
Computers and Technology, 06.09.2021 23:30 Zgt

Write a program, in a file named population. py , which does the following: Your program will read an input string from the keyboard. You will print a prompt ( "file: " ) and then read an input string. Remove all leading and trailing whitespace from the input string, and then open a file with that name. You will then read through that file, reading the lines one at a time, and performing a calculation on the data. You must use a for loop to read the lines of the file; you may either directly use the for loop on the file, or read the lines into a list, and use a for loop over that. Your program should ignore any blank lines within the input (including lines that have some whitespace; treat a line as blank if it contains only whitespace). Likewise, your program should ignore any line within the input where the first non-whitespace character is โ€™#โ€™ (so that we can place comments in the input file). REMEMBER: open(filename) will open a file, and return a file object. You can call readlines() on the object to get the lines of the file as a list.
Input File Format
The input file is a text file where each line (except blank lines and comments, see above) consists of the name of a US state or territory, together with its estimated 2019 population. For example:
Oklahoma 3943079
Oregon 4190713
South Dakota 882235
Pennsylvania 12807060
Northern Mariana Islands 55194
To simplify your input processing, you may assume that, between the words of the placename, we will only use single spaces. However, note that there might be any type of whitespace - and any number of whitespace characters - between the placename and the population number.
The Calculation
Read each line of the input file. For each line (other than the blank or comment lines), print out the information on two lines, as follows:
State/Territory: Oklahoma
Population: 3943079

State/Territory: Oregon
Population: 4190713
and so on.
At the very end of the output, print a blank line, followed by a summary of the information:
# of States/Territories:
Total Population:

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 00:00
What engine component is shown in the above figure?
Answers: 1
question
Computers and Technology, 24.06.2019 21:30
Suppose a router has built up the routing table shown in the table. subnet number 128.96.39.00 28.96.39.128 128.96.40.00 192.4.153.0 default) subnet mask 255.255.255.128 255.255.255.128 255.255.255.128 255.255.255.192 nexthop interface 0 interface 1 r2 r3 r4. the router can deliver packets directly over interfaces 0 and 1, or it can forward packets to routers r2, r3, or r4. describe what the router does with a packet addressed to each of the following destinations: (a) 128.96.39.10 (b) 128.96.40.12 (c) 128.96.40.151 (d) 192.4.153.17 (e) 192.4.153.90
Answers: 3
question
Computers and Technology, 24.06.2019 23:00
Why is it preferable to code web pages in html format? a. to create more lines code b. to apply general formatting rules c. to display properly as search results in all browsers d. to add meaning to the document
Answers: 1
question
Computers and Technology, 25.06.2019 05:10
What is the disadvantage of a mesh topology?
Answers: 1
You know the right answer?
Write a program, in a file named population. py , which does the following: Your program will read a...
Questions
question
Social Studies, 12.01.2021 22:30
question
Mathematics, 12.01.2021 22:30
question
Mathematics, 12.01.2021 22:30
question
Law, 12.01.2021 22:30
Questions on the website: 13722363