# (Solved) : Santa Claus Needs Automate Compiling Naughty Nice Lists Program Read Child S Name Count Ma Q42697265 . . .

Santa Claus needs to automate the compiling of the naughty andnice lists. Your program will read in each child’s name and theircount of major and minor good deeds and their major and minor baddeeds. With that information, compute an overall score anddetermine if they go on the naughty or nice list.

Major good deeds might be something like shoveling the walk anddriveway for the chronologically challenged lady down the street, aminor good deed would be bringing her newspaper up from the driveto the porch on a rainy day. Bad deeds, well, you get thepoint.

Save the kids_list.txt file to yourworking folder.

The scoring

In the data file, each child’s name is followed by 4integers:

Joe Smith 5 12 4 7

where the numbers are, in order: major good deeds, minor gooddeeds, major bad deeds, minor bad deeds.

Overall score is calculated as follows:

score = 5 * major good + minor good – 10 * major bad – 0.5 *minor bad

If the resulting value is positive, the child will go on thenice list. If negative, on the naughty list. If exactly 0, randomlychoose which list (flip of a coin, see below)

Functions

Your program must have the following functions:

read_data( ) given the file name,opens and checks the file, reads each line of the file, consistingof first and last names followed by four numbers, into a list,converts the four number to integer values, adds to overall list ofchildren. Returns the list, empty list if file was empty, or -1 ifthe file fails to open

naughty_nice( ) given a list withfour integers, computes the total score using formula above.Returns True if positive, False if negative, randomly True or Falseif 0

write_lists( ) given a listcontaining lists with children’s’ names and True or False toindicate nice or naughty, as well as the names of the nice andnaughty files, opens and checks the files, writes each child’s nameto the appropriate file. Returns -1 if a file fails to open, totalcount of records written otherwise.

main( ) may do all the remainingprogram actions: call read_data, iterate through the chidlrens’records, passing only the scores to the naughty_nice function. Aseach child is scored, built list with only names and True or False.Pass score list and output file names to write_lists. Comparereturn value with count of children to ensure all recordswritten

Error conditions

You must check the return values from read_data and write_lists.A return of -1 indicates the respective file did not open, thusthere is no data to process. Display an error message and return atthat point.

Also test that the list returned from read_data actually hascontent, it’s possible the file existed but was empty. If thelength of the list is 0, display a message and return at thatpoint.

Test that the number of records written by write_lists matchesthe number of records in the actual data list.

Files

The kids_list.txt file is formattedas:

Sally Jones 10 15 2 6

Bob Smith 7 22 3 9

Ed Martin 12 20 2 8

good_kids.txt should have thefollowing:

Sally Jones

Bob Smith

Ed Martin

Marty Miller

Martha Raye

Billy Martin

Jane Walters

bad_kids.txt should have thefollowing:

Alan Gollum

Sam Johnson (Sam could be on either list, his score is 0)

John Robertson

Johnny Eller

Rhonda Flack (Rhonda could be on either list, her score is0)

Kathy Jackson

The lists

The main data list will look like:

[[‘Sally’, ‘Jones’, 10, 15, 2, 6], [‘Bob’, ‘Smith’, 7, 22, 3,9], …

A list that is sent to the naughty_nice function will looklike:

[10, 15, 2, 6]

The list that is sent to the write_lists function will looklike:

[[‘Sally’, ‘Jones’, True], [‘Bob’, ‘Smith’, False]

I’m writing this in Python Geany

## Expert Answer

Answer to Santa Claus needs to automate the compiling of the naughty and nice lists. Your program will read in each child’s name…

## About

We are the best freelance writing portal. Looking for online writing, editing or proofreading jobs? We have plenty of writing assignments to handle.

Browse Solutions

Place Order

About Us

#### Contact

support@coursehigh.com

+91 8634554387