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
fgiga [73]
4 years ago
9

Write a function named wordLineCount with the following input and output: Input: a string parameter, inFile, that is the name of

a file Output: return a dictionary in which each unique word in inFile is a key and the corresponding value is the number of lines on which that word occurs The file inFile contains only lower case letters and white space. For example, if the file ben.txt contains these lines tell me and i forget teach me and i remember involve me and i learn then the following would be correct output:
>>> print(wordLineCount('ben.txt')){'remember': 1, 'and': 3, 'tell': 1, 'me': 3, 'forget': 1, 'learn': 1,'involve': 1, 'i': 3, 'teach': 1}

Computers and Technology
1 answer:
Galina-37 [17]4 years ago
6 0

Answer:

def wordLineCount(file):

   dic = {}

   with open(file,'r') as file:

       

       text = file.read()

       text = text.strip().split()

       for word in text:

           if word in dic:

               dic[word] += 1

           else:

               dic[word] = 1

   return dic

print(wordLineCount('ben.txt'))

Explanation:

The programming language used is python.

The program starts by defining the function, an empty dictionary is created to hold the words and the number of times that they occur. the with key word is used to open the file, this allows the file to close automatically as soon as the operation on it is finished.

The data in the file is read to a variable text, it is striped from all punctuation and converted to a list of words.

A FOR loop and an if statement is used to iterate through every word in the list and checking if they are already in the dictionary. if the word is already contained in the dictionary, the number of occurrences increases by one. otherwise, it is added to the dictionary.

check the attachment to see code in action.

You might be interested in
what are the three parts to physical security standards for various types of army equipment and the risk level
zzz [600]

The three parts to physical security standards for various types of army equipment and the risk level is access control, surveillance, and security testing.

<h3>Further explanation</h3>

Physical security is the part of security concerned with physical measures designed to protect the assets and facilities of the organization.  

The three parts to physical security standards for various types of army equipment and the risk level is access control, surveillance, and security testing.

Access control is a security technique in which regulates who/what can view/use resources in a computing environment. The example of physical access control is the locks, badge system, and security guard.

Surveillance is the condition in which the architects seek to build spaces that are more open to security personnel and authorized users. It is also the continuous monitoring of, for example, the disease occurrence. The example of surveillance is Closed-circuit television cameras (CCTV) placed in the streets.

Security testing is the evaluation and testing the information security of hardware, software, networks, and IT environment. Error handling and specific risky functionalities are examples of security testing

<h3>Learn more</h3>

1. Learn more about the security practice in electronic banking brainly.com/question/7668763

 

<h3>Answer details</h3>

Grade:  9

Subject: Computers and Technology

Chapter:  Physical security standards

Keywords:  physical security, access control, surveillance, security testing

3 0
3 years ago
How many times does the following loop execute?int upperCaseLetters = 0;String str = "abcdEfghI";boolean found = false;for (int
damaskus [11]

Answer:

Five times

Explanation:

Given the codes as follows:

  1.        int upperCaseLetters = 0;
  2.        String str = "abcdEfghI";
  3.        boolean found = false;
  4.        for (int i = 0; i < str.length() && !found; i++)
  5.        {
  6.            char ch = str.charAt(i);
  7.            if (Character.isUpperCase(ch))
  8.            {
  9.                found = true;
  10.            }
  11.        }

The for loop will stop when the first uppercase letter is found in the str. This condition is set in the for loop condition ( i < str.length() && !found)

Since the the first upper case letter is the fifth character in the given str, the for loop will run for five rounds. In the fifth round the condition in the if statement (Line 9) will be evaluated to true and then set the true value to found variable (Line 11). This will terminate the loop in the next iteration.

7 0
3 years ago
2. Input a decimal number and test if it is not equal to 16.5.
lubasha [3.4K]

Answer:

2:

decNum = float(input("Decimal number: "))

if decNum != 16.5:

   print("Does not equal")

elif decNum == 16.5:

   print("Equal")

else:

   pass

3:

if x > 57:

   x += 4

   print(x)

4:

numOne = int(input("Enter number: "))

numTwo = int(input("Enter number: "))

if numOne < 100 and numTwo < 100:

   yes = numOne + numTwo

   print(yes // 2)

else:

   pass

Explanation:

Please give me brainliest.

6 0
2 years ago
If A = 5 i + j abd B = 2k then A - B in equal to​
Leto [7]

the answer is A-B=5i+j-2k

8 0
3 years ago
15. The game which lead many critics to rethink their ideas about video games and view games as art was ______.
Igoryamba
I think the answer is D
7 0
3 years ago
Other questions:
  • Before you start creating a database, you should first use paper to plan, test, and revise. True False
    7·2 answers
  • List seven basic internal components found in a computer tower
    13·1 answer
  • Which topology enables only one person, at one time, to send data to others on the network?
    6·1 answer
  • ____ are model building techniques where computers examine many potential solutions to a problem, iteratively modifying various
    5·1 answer
  • Match each document to its respective type.
    8·2 answers
  • Let f and g be two one-argument functions. The composition f after g is defined to be the function x 7→ f (g (x)). Define a proc
    15·1 answer
  • Does this look anywhere close to the APA Format?
    6·1 answer
  • Zara is typing the names of all the States in Pakistan. She has not numbered the list. Suggest her the way by which she can numb
    5·1 answer
  • A python package used in text analysis and natural language processing. True or False
    10·1 answer
  • Why do electronic devices gather so much dust? Thanks
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!