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 is string literal in Java?
4vir4ik [10]

Answer:

A string literal in Java is basically a sequence of characters from the source character set used by Java programmers to populate string objects or to display text to a user. These characters could be anything like letters, numbers or symbols which are enclosed within two quotation marks.

Explanation:

8 0
3 years ago
Lucy wants to access the webpage. She is using her computer to access the webpage. What types of information will be in one fram
ANTONII [103]

The types of information will be in one frame from Lucy’s computer as a sender until it gets to the webserver as a receiver is known to be her IP address and what she is searching for.

<h3>What is the network about?</h3>

In Communication using a webpage, it often start with a message, or what we call the information, that is known to be sent from one person or device to any other.

Note that in this exchange, there are three elements that are known to be in common which are :

  • The  message source, or sender.
  • The destination, or receiver, of the message.
  • The channel, made up of the transmission media.

Note that if a ‘message’ such as a file, image or video is known to be sent across a network, it is first  divided into small blocks known to be segments. These are known to be kept in containers known as packets, by the Internet Protocol (IP).

Hence, The types of information will be in one frame from Lucy’s computer as a sender until it gets to the webserver as a receiver is known to be her IP address and what she is searching for.

Learn more about webserver from

brainly.com/question/20818461

#SPJ1

6 0
2 years ago
When entering numbers that start with a zero, apply the _____ number format.
yuradex [85]

Answer:

The Answer is gonna be D. Zero decimal

3 0
3 years ago
True or False. A list can have only the same data type values.
shepuryov [24]

the answer its false.

hope this helps

6 0
3 years ago
if you love games played on facebook, such as farmville, what might be your motivation for playing games
castortr0y [4]

Plato users the answer is Social Interaction!

3 0
4 years ago
Other questions:
  • Which function is used to display a string value to the screen?
    8·1 answer
  • Google Apps are an example of​ ________. A. platform as a service​ (PaaS) B. software as a product​ (SaaP) C. platform as a prod
    7·1 answer
  • Which service is used when your email program exchanges messages with the mail server on a distant network?
    5·1 answer
  • Assume that someone dictates you a sequence of numbers and you need to write it down. For brevity, he dictates it as follows: fi
    14·1 answer
  • Write a C# program named InchesToCentimeters that declares a named constant that holds the number of centimeters in an inch: 2.5
    14·1 answer
  • Lets say if my computer shut down every 10 minutes. What can you do to solve the problem. Hint: Use these word in you answer: ha
    10·2 answers
  • Dgvdsgf cvdzgb fgvsdxchygfdrzvdszfgvsdzxd
    9·1 answer
  • c) If you are at foreign country visit, which banking card would you prefer to keep with you during visit (Debit Card or Credit
    10·1 answer
  • Write the code to produce a for loop that counts down from 20 to 0 by 2’s and prints the number each time it goes through the lo
    15·1 answer
  • Priortization is an example of a skill that helps you reach long term goals because
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!