The Apgar Medical group keeps a patient file for each doctor in the office. Each record contains the patient's first and last name, home address, and birth year. The records are sorted in ascending birth year order. Write a program so that display a count of the number of patients born each year John Hanson, 23 Elm, 1927 Mary Locust, 476 Maple, 1950 Susan Monroe, 512 Peachtree, 1957 Carol Fortune, 2819 Locust, 1960 James Fortune, 2819 Locust, 1963 Lawrence Fish, 12 Elm, 1968 Janice Weiss, 234 Birch, 1971 Henry Garza, 199 Second, 1973 Kimberly Swanson, 310 Appletree, 1980 Louis Claude, 2716 Third, 1981 Jill Fox, 12 Oak, 1985 Opal Reynolds, 78 County Line, 1987 Francis Dumas, 67 Fourth, 1992 Madison Conroy, 23 Fifth, 1996 Daniel Moy, 100 Sunset, 1987

Np Ms Office 365/Excel 2016 I Ntermed
1st Edition
ISBN:9781337508841
Author:Carey
Publisher:Carey
Chapter3: Performing Calculations With Formulas And Functions
Section: Chapter Questions
Problem 3.10CP
icon
Related questions
Question
 
  1. The Apgar Medical group keeps a patient file for each doctor in the office. Each record contains the patient's first and last name, home address, and birth year. The records are sorted in ascending birth year order. Write a program so that display a count of the number of patients born each year

    John Hanson, 23 Elm, 1927
    Mary Locust, 476 Maple, 1950
    Susan Monroe, 512 Peachtree, 1957
    Carol Fortune, 2819 Locust, 1960
    James Fortune, 2819 Locust, 1963
    Lawrence Fish, 12 Elm, 1968
    Janice Weiss, 234 Birch, 1971
    Henry Garza, 199 Second, 1973
    Kimberly Swanson, 310 Appletree, 1980
    Louis Claude, 2716 Third, 1981
    Jill Fox, 12 Oak, 1985
    Opal Reynolds, 78 County Line, 1987
    Francis Dumas, 67 Fourth, 1992
    Madison Conroy, 23 Fifth, 1996
    Daniel Moy, 100 Sunset, 1987

     
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

Im still getting an error

¤
A
PCC
Code File Edit Selection View Go Run Terminal Window Help
RUN AND DEBUG
VARIABLES
✓ Locals
> special variables
> year_count: {}
> Globals
WATCH
CALL STACK
[Errno 2] ...
<module> FE2.1.py
BREAKPOINTS
Raised Excepti...
Uncaught Exce...
User Uncaught ...
ΘΟΔΟ
0
Welcome
FE2.1.py X
Users > ravennreaver > FE2.1.py > ...
1
2
3
4
5
6
19
7
8
9
10
11
12
13
14
15
16
17
D# Dictionary to store the count of patients born each year
year_count = {}
# Read patient records from the file
with open("patient_records.txt", "r") as file:
Process each line (patient record) in the file
for line in file:
# Extract birth year from the record
birth_year
=
Search
int(line.split(", ")[-1].strip())
# Display the count of patients born each year
print("Count of patients born each year:")
for year, count in sorted (year_count.items()):
print (f"{year}: {count} patients")
# Update the count for the birth year in the dictionary
year_count [birth_year] = year_count.get(birth_year, 0) + 1
PROBLEMS OUTPUT DEBUG CONSOLE TERMINAL PORTS COMMENTS
/usr/local/bin/python3 /Users/ravennreaver/FE2.1.py
Ⓒravennreaver@Ravenns-MacBook-Air ~ % /usr/local/bin/python3 /Users/rave
nnreaver/FE2.1.py
Traceback (most recent call last):
File "/Users/ravennreaver/FE2.1.py", line 5, in <module>
with open("patient_records.txt", "r") as file:
ΑΛΛΛΛΛΛΑ
FileNotFoundError: [Errno 2] No such file or directory: 'patient_records.txt'
% /usr/local/bin/py
Ⓒravennreaver@Ravenns-MacBook-Air
thon3 /Users/ravenn reaver/FE2.1.py
Traceback (most recent call last):
File "/Users/ravennreaver/FE2.1.py", line 5, in <module>
with open("patient_records.txt", "r") as file:
ID
FileNotFoundError: [Errno 2] No such file or directory: 'patient_records.txt'
O ravennreaver@Ravenns-MacBook-Air ~ % |
Screen Reader Optimized Ln 18, Col 1 Spaces: 4
国
➜•
S
UTF-8 LF
100%
Ơ
80
Wed Dec 6 10:11 AM
the cost of patients are much par
al f
the ch
tv ….. ^
08
Python
Python De...
Python 3.12.0 64-bit ▸tabnine starter →
Transcribed Image Text:¤ A PCC Code File Edit Selection View Go Run Terminal Window Help RUN AND DEBUG VARIABLES ✓ Locals > special variables > year_count: {} > Globals WATCH CALL STACK [Errno 2] ... <module> FE2.1.py BREAKPOINTS Raised Excepti... Uncaught Exce... User Uncaught ... ΘΟΔΟ 0 Welcome FE2.1.py X Users > ravennreaver > FE2.1.py > ... 1 2 3 4 5 6 19 7 8 9 10 11 12 13 14 15 16 17 D# Dictionary to store the count of patients born each year year_count = {} # Read patient records from the file with open("patient_records.txt", "r") as file: Process each line (patient record) in the file for line in file: # Extract birth year from the record birth_year = Search int(line.split(", ")[-1].strip()) # Display the count of patients born each year print("Count of patients born each year:") for year, count in sorted (year_count.items()): print (f"{year}: {count} patients") # Update the count for the birth year in the dictionary year_count [birth_year] = year_count.get(birth_year, 0) + 1 PROBLEMS OUTPUT DEBUG CONSOLE TERMINAL PORTS COMMENTS /usr/local/bin/python3 /Users/ravennreaver/FE2.1.py Ⓒravennreaver@Ravenns-MacBook-Air ~ % /usr/local/bin/python3 /Users/rave nnreaver/FE2.1.py Traceback (most recent call last): File "/Users/ravennreaver/FE2.1.py", line 5, in <module> with open("patient_records.txt", "r") as file: ΑΛΛΛΛΛΛΑ FileNotFoundError: [Errno 2] No such file or directory: 'patient_records.txt' % /usr/local/bin/py Ⓒravennreaver@Ravenns-MacBook-Air thon3 /Users/ravenn reaver/FE2.1.py Traceback (most recent call last): File "/Users/ravennreaver/FE2.1.py", line 5, in <module> with open("patient_records.txt", "r") as file: ID FileNotFoundError: [Errno 2] No such file or directory: 'patient_records.txt' O ravennreaver@Ravenns-MacBook-Air ~ % | Screen Reader Optimized Ln 18, Col 1 Spaces: 4 国 ➜• S UTF-8 LF 100% Ơ 80 Wed Dec 6 10:11 AM the cost of patients are much par al f the ch tv ….. ^ 08 Python Python De... Python 3.12.0 64-bit ▸tabnine starter →
Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
Linux
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Np Ms Office 365/Excel 2016 I Ntermed
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:
9781337508841
Author:
Carey
Publisher:
Cengage
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
Computer Science
ISBN:
9780357392676
Author:
FREUND, Steven
Publisher:
CENGAGE L