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
Expand and simplify the following expressions. 1/2 [ 2x + 2 ( x - 3)] *​
Lerok [7]

Answer: 2

x

−

3

Explanation:

4 0
3 years ago
Name the technique used to separate the mixture of colours in black ink ​
Nitella [24]

Answer:

chromatography

hope it helps

6 0
2 years ago
Read 2 more answers
_______ allow(s) you to apply colorful, eye catching designs to a presentation all at once.
astraxan [27]

What are some options of answers, or is there none?


4 0
3 years ago
Read 2 more answers
Which access method would be most appropriate if your manager gave you a special cable and told you to use it to configure the s
GrogVix [38]
Console Port Method

Connecting a computer to a Cisco device through the console port requires a special console cable.
8 0
3 years ago
Is the weegy face real?or is it computer generated?
allsm [11]
Weegy face is known to be a computer generated program that was designed well by expert developers. It's a type of image that usually works whenever you use the Internet Explorer, and works most of the time on that browser.
3 0
3 years ago
Other questions:
  • Jameis is researching at his local library when he finds a perfect source to use in his paper. When he goes to check the book ou
    12·2 answers
  • You need a version of usb technology that will support older usb devices, of which you have many, as well as newer ones. what wo
    12·1 answer
  • What key do you press so you can switch tabs quickly?
    5·1 answer
  • Help with this chart please
    9·1 answer
  • 1- Which of the following is the java keyword used to declare a class?
    5·2 answers
  • The exponential distribution is often used to model what in a queuing system?
    12·1 answer
  • please help no one is helping me on this one
    9·1 answer
  • (PLEASE HELP)
    5·1 answer
  • Tinh T = a1*a2*a3*...an<br><br> Giúp em với
    13·1 answer
  • Diane, a developer, needs to program a logic component that will allow the user to enter a series of values
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!