1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Jet001 [13]
3 years ago
6

Write a program that reads the contents of the two files into two separate lists. The user should be able to enter a boy’s name,

a girl’s name, or both, and the application will display messages indicating whether the names were among the most popular.
Computers and Technology
1 answer:
insens350 [35]3 years ago
3 0

Answer:

Check Explanation.

Explanation:

A programming language is used by engineers, technologists, scientists or someone that learnt about programming languages and they use these programming languages to give instructions to a system. There are many types for instance, c++, python, Java and many more.

So, the solution to the question above is given below;

#define the lists

boyNames=[]

girlNames=[]

#open the text file BoyNames.txt

with open('BoyNames.txt','r') as rd_b_fl:

boyNames=rd_b_fl.readlines()

boyNames=[name.strip().lower() for name in boyNames]

#open the text file GirlNames.txt

with open('GirlNames.txt','r') as rd_b_fl:

girlNames=rd_b_fl.readlines()

girlNames=[name.strip().lower() for name in girlNames]

#print the message to prompt for name

print('Enter a name to see if it is a popular girls or boys name.')

while True:

#prompt and read the name

name=input('\nEnter a name to check, or \"stop\" to stop: ').lower()

# if the input is stop, then exit from the program

if name=='stop':

break

# If the girl name exits in the file,then return 1

g_count=girlNames.count(name)

# if return value greater than 0, then print message

if g_count>0:

print(name.title()+" is a popular girls name and is ranked "

+str(girlNames.index(name)+1))

# if return value greater than 0, then print message

#"Not popular name"

else:

print(name.title()+" is not a popular girls name")

## If the boy name exits in the file,then return 1

b_count=boyNames.count(name)

if b_count>0:

print(name.title()+" is a popular boys name and is ranked "

+str(boyNames.index(name)+1))

# if return value greater than 0, then print message

#"Not popular name"

else:

print(name.title()+" is not a popular boys name")

You might be interested in
What do you think of my profile picture
Gnom [1K]

ayo it's pretty sweet lma.o.

8 0
3 years ago
Read 2 more answers
When a formula contains the address of a cell, it is called a(n)
Shalnov [3]
When a formula contains the address of a cell, it is called a c<span>ell reference.

hope this helps!</span>
8 0
3 years ago
Packet switching was invented by: <br> Apple <br> DARPA <br> Google <br> Microsoft
riadik2000 [5.3K]

Answer:  darpa

Explanation:

8 0
3 years ago
What is the recommended point size for a slide title?<br> 12–22<br> 24–40<br> 44–66<br> 54–80
jenyasd209 [6]
12-22 hope this helps :)
3 0
3 years ago
How does Python recognize a tuple?
Talja [164]

Answer:

B) You use parentheses around the data values

Explanation:

It was C) on my end, but the answer is still the same :)

7 0
3 years ago
Read 2 more answers
Other questions:
  • Robin maintains a web page for updating the metro timings in the city. He would like the website to display the present day's sc
    6·1 answer
  • Suppose two hosts, A and B, are separated by 7,500 kilometers and are connected by a direct link of R = 10 Mbps. Suppose the pro
    7·1 answer
  • In general, what is the leftmost point of a circle with radius r centered at (x,y)?
    8·1 answer
  • What is a Limited Purpose credit card
    11·2 answers
  • Pls help! ive been looking everywhere online but I couldn't find the answer to this:
    5·1 answer
  • The software used to help run the computer hardware is the _____.
    9·2 answers
  • Which role is delegated to personnel of the IT department and is responsible for maintaining the integrity and security of the d
    10·1 answer
  • Please help thank you !!!
    7·2 answers
  • How many grams are in 100 pounds?
    6·2 answers
  • eocs can be fixed locations, temporary facilities, or virtual structures with staff participating remotely.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!