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
Lina20 [59]
2 years ago
6

1. Your task is to process a file containing the text of a book available as a file as follows:A function GetGoing(filename) tha

t will take a file name as a parameter. The function will read the contents of the file into a string. Then it prints the number of characters and the number of words in the file. The function also returns the content of the file as a Python list of words in the text file.A function FindMatches(keywordlist, textlist): The parameter keywordlist contains a list of words. The parameter textlist contains text from a book as a list of words. For each word in keywordlist, the function will print the number of times it occurs in textlist. Nothing is returned.If you implemented the functions correctly then the following program:booktext = GetGoing('constitution.txt') FindMatches (['War', 'Peace', 'Power'], booktext) Will read the file "constitution.txt" and print something like the following:The number of characters is: 42761The number of words is: 7078The number of occurrences of War is: 4The number of occurrences of Peace is: 2The number of occurrences of Power is: 11
Computers and Technology
1 answer:
Irina18 [472]2 years ago
7 0

Answer:

See explaination

Explanation:

#function to count number of characters, words in a given file and returns a list of words

def GetGoing(filename):

file = open(filename)

numbrOfCharacters =0

numberOfWords = 0

WordList = []

#iterate over file line by line

for line in file:

#split the line into words

words = line.strip().split()

#add counn of words to numberOfWords

numberOfWords = numberOfWords + len(words)

#find number of characters in each word and add it to numbrOfCharacters

numbrOfCharacters = numbrOfCharacters + sum(len(word) for word in words)

#append each word from a line to WordList

for word in words:

WordList.append(word)

#display the result

print("The number of characters: ", numbrOfCharacters)

print("The number of Words: ", numberOfWords)

#return the list of words

return WordList

#find matches for keywords given in textlist

def FindMatches(keywordlist, textlist):

for keyword in keywordlist:

keyword = keyword.lower()

print ("The number of occurrences of {} is: {}".format(keyword,len([i for i, s in enumerate(textlist) if s == keyword])))

#main

booktext = GetGoing("constitution.txt")

FindMatches (['War', 'Peace', 'Power'], booktext)

You might be interested in
Data stored in computer systems has a high value because there is a great deal of time and effort that goes into creating an ana
Andrew [12]

Answer:

Data often has intrinsic value.

Explanation:

Data stored in computer systems has a high value because there is a great deal of time and effort that goes into creating an analyzing it and data often has intrinsic value.

5 0
3 years ago
A thin film transistor (TFT) is a/an______________.
Leviafan [203]

Answer:

Option a electronic switch used on FPDs

Explanation:

A thin film transistor (TFT) is an electronic switch which is commonly used in a liquid crystal display (LCD). TFT derives its name by the way how it is produced. It is produced by layering thin films of semiconductor.  TFT is a type of transistor which is used to control state every  individual pixel in a LCD. TCT can change the states of pixels (on and off) very quickly.

6 0
3 years ago
What part of speech is contend
Amiraneli [1.4K]
Assuming the context, it would be considered a verb.

ie: "She contended to me that I was not acting maturely." 
7 0
2 years ago
Convert the following three hexadecimal numbers to both binary and decimal. (Hint: it is probably easier to convert hex to binar
Doss [256]

Answer:

3e : 00111110 (62)

3e0 : 0000001111100000 (992)

3e00 : 0011111000000000 (15872)

Explanation:

Converting the given hexadecimal numbers to binary and decimal format:

1) 3e

3-> 0011

e-> 1110

Combining , 3e -> 00111110

This can be converted to decimal by multiplying each 1 in the binary representation by 2^(position -1) and adding the results.

So 3e = 32+16+8+4+2 = 62

2) 3e0

Binary => 0000001111100000

Converting to decimal : 992  [ This is 16 times a]

3) 3e00

Binary => 0011111000000000

Converting to decimal : 15872 [ This is 16 times b]

So adding a 0 to the hex representation multiplies the decimal number by 16.

6 0
3 years ago
What is the difference between a circuit board and a bread board
stepan [7]

Answer:

A bread board is prototyped (manufactured) in a way where it is less permanent than a pcb (printed circuit board) or an even more permanent pcba (printed circuit board assembly). Bread boards are typically the first step to creating a finished circuit because electronic components are easier to test and take apart when needed; design and investigation can be made effectively as no soldering connections are required. Whereas a circuit board is used for the further finished products because they don't have sockets like the bread board and so there is little room for error and mistakes.

8 0
3 years ago
Other questions:
  • Which action is LEAST important to maintaining a healthy credit score?
    8·2 answers
  • In a transaction-processing system (TPS), if the TPS database can be queried and updated while the transaction is taking place,
    12·1 answer
  • Using Task Manager, you discover an unwanted program that is launched at startup. Of the following items, which ones might lead
    7·1 answer
  • Which social network site has 1.5 billion actives users per month?
    15·1 answer
  • Cognitive psychology is the scientific study of what
    9·1 answer
  • What feature allows you to access previous copies of a document on OneDrive?
    15·2 answers
  • Why is it important to do research prior to making a purchase? What types of sources can be helpful (or not helpful!)
    15·1 answer
  • What is a form of technology that you think will make your life easier?
    10·1 answer
  • Name at least three real-life objects that are instances of each of the following classes:
    7·1 answer
  • Which statement is true about the energy of electromagnetic radiation?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!