Write a function called max_age(inFile, outFile, breed), that takes three strings as input parameters. The function reads all the data from the inFile (1st input parameter) and writes data to the outFile (2nd input parameter) as described below.   Each line in the input file represents a pet record and has the following format.    name, breed, age where name and breed are strings, and age is an integer value. Your function must find the oldest pet of a given breed (3rd input parameter) from the inFile and write the following information to the outFile.     breed, total records of this breed  name of the oldest pet, age of the oldest pet Note that outFile must only have these two lines of information.   Suppose, inFile contains the following data:     shadow, longhair, 3   poshi, bangal, 5   mikus, longhair, 4   tigger, calico, 9 If you call this function with breed = "longhair", then the following must be written in the outFile:     longhair, 2   mikus, 4   Your function must return True if both reading and writing were successful, and False otherwise. This function should properly handle all exceptions so that your program does NOT crash.  You do not have to write a main() function for this program.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Write a function called max_age(inFile, outFile, breed), that takes three strings as input parameters. The function reads all the data from the inFile (1st input parameter) and writes data to the outFile (2nd input parameter) as described below.

 

Each line in the input file represents a pet record and has the following format.

   name, breed, age

where name and breed are strings, and age is an integer value.

Your function must find the oldest pet of a given breed (3rd input parameter) from the inFile and write the following information to the outFile.   

 breed, total records of this breed

 name of the oldest pet, age of the oldest pet

Note that outFile must only have these two lines of information.  

Suppose, inFile contains the following data:

    shadow, longhair, 3

  poshi, bangal, 5

  mikus, longhair, 4

  tigger, calico, 9

If you call this function with breed = "longhair", then the following must be written in the outFile:

    longhair, 2

  mikus, 4

 

Your function must return True if both reading and writing were successful, and False otherwise. This function should properly handle all exceptions so that your program does NOT crash

You do not have to write a main() function for this program.

Expert Solution
steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Similar questions
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY