Using Python Write Program Reads Following List Baby Names Produces Two Files Boystxt Boys Q37101527

Using Python Write a program that reads all of the followinglist of baby names and produces two files (boys.txt) with just theboys names and girls.txt with just the girls names.

Use the code below as a guide

LIMIT = 50.0

def main() :
inputFile = open(“babynames.txt”, “r”)

boyTotal = 0.0
girlTotal = 0.0
while boyTotal < LIMIT or girlTotal < LIMIT :
# Extract the data from the next line and split it.
line = inputFile.readline()
dataFields = line.split()

# Extract the individual field values.
rank = int(dataFields[0])
boyName = dataFields[1]
boyPercent = float(dataFields[2].rstrip(“%”))
girlName = dataFields[3]
girlPercent = float(dataFields[4].rstrip(“%”))
  
# Process the data.
print(“%3d ” % rank, end=””)
boyTotal = processName(boyName, boyPercent, boyTotal)
girlTotal = processName(girlName, girlPercent, girlTotal)
print()
  
inputFile.close()

## Prints

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.