Question: Python: I need help writing a code that reads a text file then answers the following questions: 1. How many girl babies have been born

Python: I need help writing a code that reads a text file then answers the following questions:

1. How many girl babies have been born since 1910?

2. How many boy babies have been born since 1910?

3. How many girl babies were born 1910? In 2012?

4. How many boy babies were born in 1910? In 2012?

5. What are the total number of babies born in Texas in 2012?

6. What are the total number of babies born in Texas with your name since 1910?

7. What are the total number of babies born in Texas with your name between 1910 and 1960? If you have a very uncommon name, feel free to pick any name that you might be curious about.

8. What name was the most popular (had the highest count in one year): * For males * For females

9. What name was that? * For males * For females

10. What year was that? * For males * For females

11. In what year was your name the most popular (had the highest count)?

THIS IS MY CODE:

text_file = open("TXBabyNames.txt", "r") lines = text_file.readlines() print lines print len(lines) text_file.close()

def check(): datafile = file('TXBabyNames.txt') found = False for line in datafile: if 1910 in line: found = True break

return found

found = count() if found: print lines else:

The Text File is a list of years with names.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!