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's the difference between help desk and service desk?
Mekhanik [1.2K]

Answer:

A help desk is considered to be focused on break-fix (like a incident management), where a service desk is there to assist with break-fix and with service requests (requests for new services) and requests for information (ex. “how do I do <u>X</u>?”).

Hope this helps!

3 0
2 years ago
Which of the following sorting algorithms is described by this text? "Take the item at index 1 and see if it is in order compare
trasher [3.6K]

Answer:

b. selection sort

b. 8 11 17 30 20 25

Explanation:

The options above are the correct answers to the given questions.

Selection sort is a simple comparison-based sorting algorithm.

selection sort. (algorithm) Definition: A sort algorithm that repeatedly searches remaining items to find the least one and moves it to its final location. The run time is Θ(n²), where n is the number of elements. The number of swaps is O(n).

It is this sorting algorithm that will best ne suitable in the given event.

7 0
3 years ago
Which device performs the function of determining the path that messages should take through internetworks?.
bija089 [108]

Answer:

A router

Explanation:

8 0
2 years ago
Show the exact output of the following codesegments:(a) for(x=0; x&lt;20; x=x+2)cout&lt;&lt; x &lt;&lt; ‘ ‘;cout&lt;&lt; endl ;(
egoroff_w [7]

Answer:

a)

for(x=0;x<20;x=x+2)

cout<< x << ' ';

cout<< endl ;

<u>Output</u>

0 2 4 6 8 10 12 14 16 18

In this code we are initialing x with 0, check if it is less than 20, then printing the value 0.

Then we increment x value with 2 and check and print again until the x value tends to be equal or more than 20.

<u>C++ program for verifying</u>

#include <iostream>

using namespace std;

int main()

{

   int x;

   for( x=0;x<20;x=x+2)

      cout<< x << ' ';

      cout<< endl ;

   return 0;

}

<u>Output</u>

0 2 4 6 8 10 12 14 16 18

(You can check on any ide for confirmation)

b)

i=10;

for (;i>0; i =i/2;)

cout<< i;

This code will produce error expected ‘)’ before ‘;’ token

  for(;i>0; i =i/2;)

because for loop consist three parameters and in this loop there are 4 parameters.

If we remove semicolon after i/2,

for(;i>0; i =i/2)

then it will produce an output.

10 5 2 1

<u>C++ program for verifying</u>

#include <iostream>

using namespace std;

int main() {

int i=10;

 for(;i>0; i =i/2;)

 cout<< i;

return 0;

}

<u>Output</u>

Error-expected ‘)’ before ‘;’ token

  for(;i>0; i =i/2;)

3 0
3 years ago
list the six external parts of a computer system, identify which is the output device and which is the input device?
Mariulka [41]
1.mouse input
2.keyboard input
3.monitor output
4.speakers output
5.printer output , and input if has scanner
5.microphone input
4 0
3 years ago
Read 2 more answers
Other questions:
  • You have already learned about the various types of lenses. Now, conduct online research and mention as many possible types of l
    9·1 answer
  • Your hometown probably has little to offer in terms of photography because you've already seen it. True False
    14·1 answer
  • A recursive method without a special terminating case would _________. Hint: Self Check 13.3 had infinite number of isLucky() me
    5·1 answer
  • A function ________ contains the statements that make up the function.
    5·1 answer
  • True or False? At any point in time, an open file has a current file pointer indicating the place where the next read or write o
    15·1 answer
  • Help me pls, thank you
    12·2 answers
  • Anyone know a way to trade in a Xbox with a Ps4?
    10·2 answers
  • What is theory of knowledge?​
    13·1 answer
  • 5. Give one word answers:
    6·1 answer
  • What type of software repairs or improves a larger application that is already installed on a system?
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!