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
Can someone please answer this for me I will answer one of yours.
julsineya [31]
4 is preview i think.
4 0
4 years ago
Zohan uses the following analogy to describe a concept of object-oriented programming. A button can have many uses. When it is p
Vika [28.1K]

Answer:

Polymorphism

Explanation:

You can have a basic button class that gets inherited by other classes.

class Button {

function pushButton(){}

}

class ElevatorButton extends Button{};

class BigRedButton extends Button{};

With these new classes, they inherit from the basic button class. They can decide what happens when the method pushButton() is called.

You don't need to worry about what pushButton() actually does, you can just call it if the object is of the type "Button" and you can expect it to work.

4 0
2 years ago
There is an increasing need for private security personnel because of declining resources for many government agencies and a sho
aivan3 [116]
<span>True
</span><span>There is an increasing need for private security personnel because of declining resources for many government agencies and a shortage of police officers in many communities due to lack of funding.

</span>
8 0
4 years ago
A bitmap picture can be represented by hexadecimal numbers. Each two-digit hexadecimal number represents a row. To convert a num
adelina 88 [10]

Answer:

answer C. 00 38 44 etc.

Explanation:

Divide the bitmap in horizontal strips of 4 pixels (let's call them nibbles).

Use the following table to map each nibble to a hexadecimal number where 0 =white, 1=black:

0000 = 0

0001 = 1

0010 = 2

0011 = 3

0100 = 4

0101 = 5

0110 = 6

0111 = 7

1000 = 8

1001 = 9

1010 = A

1011 = B

1100 = C

1101 = D

1110 = E

1111 = F

4 0
3 years ago
An organization is assigned a Class-C network 200.120.80.0 and wants to form subnets for its threedepartments: D1 (60hosts), D2
Nataliya [291]

Answer:

D1= 60 HOSTS

network address - 200.120.80.64/26

subnet mask -255.255.255.192/26

D2 = 90 HOSTS

network address - 200.120.80.0/25

subnet mask -255.255.255.128/25

D3 = 90 HOSTS

network address - 200.120.80.128/25

subnet mask -255.255.255.128/25

5 0
4 years ago
Other questions:
  • If you quote an author from a website in a paper, it will be important to create a _____ in your writing to give them credit for
    7·2 answers
  • Software that people commonly use in the workplace to make their lives easier is called?
    6·1 answer
  • Select the correct answer. Which sentence best describe an effective management strategy? A. Conceal game-related clippings prio
    12·2 answers
  • Life changing technology is easy to fall in love with. Describe a feature of a product that did it for you and highlight its ben
    13·1 answer
  • In which of the following situations should you expect to provide your Social Security number?
    13·1 answer
  • 6.13: Word Count
    15·1 answer
  • A Linux-based OS is called a _____.
    9·1 answer
  • What devices gives input​
    5·1 answer
  • There are many advantages and some disadvantages to using social media. Explain at least one of the advantages to
    5·1 answer
  • A compound Boolean expression created with the _________ operator is true if either of its subexpressions is true.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!