Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please answer in Python (no imports) Directions: - This function takes two parameters: file_in is a path to a .txt file (as a string); file_out

Please answer in Python (no imports)

Directions: - This function takes two parameters: file_in is a path to a .txt file (as a string); file_out is a path to the output file. (function: def ages(file_in, file_out):) - This function splits people into 3 categories: older, younger than 21 years old, or exactly 21 using the current year, 2023. Age can be determined by only using the year in each line (2023 - 2010 = 13) - This function shouldn't return anything. - Information that should be returned: 1. file header: "name,older than 21" 2. on each line: "name, 1 if older than 21, -1 if younger than 21, and 0 if exactly 21"(there should be no space after each name)

Doctests: >>> age_map('files/info_1.txt', 'files/age_1_out.txt') >>> with open('files/age_1_out.txt', 'r') as outfile1: ... for line in outfile1: ... print(line.strip()) name,older than 21 Rob,-1 Ella,1 Mary,-1 >>> age_map('files/info_2.txt', 'files/age_2_out.txt') >>> with open('files/age_2_out.txt', 'r') as outfile2: ... for line in outfile2: ... print(line.strip()) name,older than 21 Rob,-1 Ezra,1 Mary,1 Ron,0 Harry,0

>>> age_map('files/header.txt', 'files/empty_out.txt') >>> with open('files/empty_out.txt', 'r') as outfile: ... for line in outfile: ... print(line.strip()) name,older than 21

Sample Input file: Name, City, DOB Rob, Chicago, 10/10/2010 Ella, New York, 04/09/1970 Mary, New York. , 01/01/2004

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design And SQL For DB2

Authors: James Cooper

1st Edition

1583473572, 978-1583473573

More Books

Students also viewed these Databases questions