Python Forum
Filtering with IF Statement
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Filtering with IF Statement
#3
1. Write each line as part of a table, include a header before the table, and a summary line at the end. Use a fixed width for each column (don’t try to find the largest width like you did in the previous unit). Not every field of the original line is used in the output. You will have to do some research about the .format() function to print the number of cases with a comma. If you can’t get the comma in the number column, move on and come back to that once you have more of the program written. The key is to have all the columns line up.

2. Use some if statements to add three filters to your program that let the user select exactly one state, disease and year to include in the report. Prompt the user to enter these values.

example

Enter state: Colorado
Enter disease: smallpox
Enter year: 1928
State Disease Number Year

COLORADO SMALLPOX 340 1928
Total 340

3. Change your program so that if the user just hits return for a prompt, the program includes all the data for that field. For example:
Enter state (Empty means all): Colorado
Enter disease (Empty means all):
Enter year (Empty means all): 1928
State Disease Number Year

COLORADO MEASLES 2,099 1928
COLORADO POLIO 71 1928
COLORADO SMALLPOX 340 1928
Total 2,510

Attached Files

.csv   health-no-head-sample.csv (Size: 1.84 KB / Downloads: 168)
Reply


Messages In This Thread
Filtering with IF Statement - by Mike2607 - Nov-28-2019, 09:40 PM
RE: Filtering with IF Statement - by Larz60+ - Nov-28-2019, 09:44 PM
RE: Filtering with IF Statement - by Mike2607 - Nov-28-2019, 10:09 PM
RE: Filtering with IF Statement - by Larz60+ - Nov-28-2019, 11:35 PM
RE: Filtering with IF Statement - by Mike2607 - Nov-29-2019, 01:31 AM
RE: Filtering with IF Statement - by Larz60+ - Nov-29-2019, 01:58 AM
RE: Filtering with IF Statement - by Mike2607 - Nov-29-2019, 02:05 AM
RE: Filtering with IF Statement - by Larz60+ - Nov-29-2019, 04:56 AM
RE: Filtering with IF Statement - by perfringo - Nov-29-2019, 08:20 AM
RE: Filtering with IF Statement - by Mike2607 - Nov-29-2019, 01:59 PM
RE: Filtering with IF Statement - by perfringo - Nov-29-2019, 07:18 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020