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
New cars come with an onboard computer that controls anti-lock brakes, air bag deployment, fuel injection, etc. the software is
nika2105 [10]
Electronic control unit (ECU)is a general term for any of a number of computer modules that receive input from sensors in your automobile and control different electrical functions

The ECM is basically an on-board computer in your car it is the most common

On-board diagnostics (OBD) is an automotive term referring to a vehicle's self-diagnostic and reporting capability. 

ABS controls anti lock breaks
6 0
4 years ago
Read 2 more answers
What is involved with individual user-testing?
MArishka [77]

Answer:

the middle one would make the most sense if not than it is the 3rd

Explanation:

4 0
3 years ago
Read 2 more answers
What type of image digital image is shown here?
madreJ [45]

Answer:

soccer tournament youth league

6 0
3 years ago
Read 2 more answers
Employees in your organization regularly need to print sensitive documents. The employees properly dispose of the hard copies of
Elena-2011 [213]

Answer: Regularly purge all network printers' hard drive caches.

Explanation:

4 0
3 years ago
Background: In mathematical finance, Markov chains are used to model the default risk of a company or country (more specifically
Aleksandr [31]

Answer: Provided in the explanation section

Explanation:

All  explanation to the code below are provided in the code comments

Code:

import numpy as np

# transition probability matrix

# copy all the values given

P = np.array([[92.07, 7.09, 0.63, 0.15, 0.06, 0.00, 0.00, 0.00],

[0.62, 90.84, 7.76, 0.59, 0.06, 0.10, 0.02, 0.01],

[0.05, 2.09, 91.38, 5.79, 0.44, 0.16, 0.04, 0.05],

[0.03, 0.21, 4.10, 89.37, 4.82, 0.86, 0.24, 0.37],

[0.03, 0.08, 0.40, 5.54, 83.24, 8.15, 1.11, 1.45],

[0.00, 0.08, 0.27, 0.34, 5.39, 82.41, 4.92, 6.59],

[0.10, 0.00, 0.29, 0.58, 1.55, 10.54, 52.80, 34.14],

[0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 100.0]])

print('Transition probability matrix:')

print(P)

print()

# probability transition for state 3

# extract 4th row for index 3

P3 = P[3]

print('Probability transition for state 3:')

print(P3)

print()

# probability that AAA company will not default in next 8 years

# for next 8 years, transition probabilities = P^8

P_next8 = np.linalg.matrix_power(P, 8)

# now get probability for transition from AAA to D

# and subtract it from 100 to get not default

P_next8_not_default = (100**8 - P_next8[0][7]) * 100 / 100**8

print('Probability that company rated AAA will not default in next 8 years:', P_next8_not_default)

cheers i hope this helps !!!

4 0
3 years ago
Other questions:
  • Write a function solution that returns an arbitrary integer which is greater than n.
    13·1 answer
  • Compare the specialized and statistical functions in excel
    10·1 answer
  • ‘The increased availability of mobile digital devices has had a positive impact on how young people use their free time’. Make a
    8·1 answer
  • A use case description is the best place to start for the design of the forms for a user interface.​ True False
    15·1 answer
  • Hi need help on this <br> what is cyberspace
    14·1 answer
  • What is the advantage of using a translation look-aside buffer (TLB), also called associative memory, in the logical-physical ad
    15·1 answer
  • Brian needs to see the space available to insert content on a slide in his presentation which feature of the presentation should
    10·1 answer
  • Which of the following is true of lossy and lossless compression algorithms?
    11·1 answer
  • If you answer I will mark brainliest!!! I want to be able to see two websites on my screen at the same time, how do I do that on
    9·1 answer
  • You are dropping your friend back home after a night at the movies. From the car, she turns on the indoor lights in her home usi
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!