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
nata0808 [166]
2 years ago
9

Implement the function charCnt. charCnt is passed in a name of a file and a single character (type char). This function should o

pen the file, count the number of times the character is found within the file, close the file, and then return the count. If the file does not exist, this function should output an error message and then call the exit function to exit the program with an error value of 1.
Computers and Technology
1 answer:
SVEN [57.7K]2 years ago
7 0

Answer:

Answered below

Explanation:

//Program is written in Python programming language

def charCnt( fileName, char){

if not fileName.exists( ):

return sys.exit(1)

else:

openFile = open("$fileName.txt", "r")

readFile = openFile.read( )

fileLength = len (readFile)

count = 0

for character in range(fileLength):

if readFile[character] == char:

count++

openFile.close( )

return count

}

You might be interested in
Who is the CEO of Quora?
irina [24]
Adam D'Angelo is the CEO and co-founder of Quora, an online knowledge market. He was also chief technology officer and <span>vice president of engineering for Facebook.</span>
5 0
2 years ago
Tricia listed her assets and liabilities. Credit Card Bill Car Loan Bonds Piano Bank Account Bicycle Which are Tricia’s liabilit
DIA [1.3K]
<span>Her liabilities are her credit card bill and her car loan. These are things that she owes and has to pay off, so they are liabilities due to the fact that she owes for these items. Her bonds, piano, bank account, and bicycle are counted as assets.</span>
7 0
2 years ago
Read 2 more answers
#Write a function called "in_parentheses" that accepts a
zimovet [89]

Answer:

import regex as re

def in_parentheses(a_string):

   regeX = re.compile(".*?\((.*?)\)")

   result = re.findall(regeX, a_string)

   return str(result).replace("[","").replace("]","")

print("test 1: "+in_parentheses("Open ( only"))

print("test 2: "+in_parentheses("This is a sentence (words!)."))

8 0
3 years ago
Quality answers will be appriciated! :)​
Naddika [18.5K]
<h2>1.</h2>

  1. F
  2. T
  3. T
  4. T
  5. F
  6. F
  7. T

________

<h2>2.</h2>

  1. A
  2. B
  3. D5*E5
  4. A

6 0
2 years ago
Read 2 more answers
File "f2" has a size of 2. Why? A. It contains the string "f1". B. It contains two blank lines.
Aneli [31]

Answer:

A. It contains the string "f1"

7 0
3 years ago
Other questions:
  • Which of the following can you NOT apply for at any FLHSMV office? A. Certificate of title B. License plates C. Vehicle registra
    15·2 answers
  • Who is good with Introduction to photography? I don’t know nothing about cameras if you do please contact me ASAP
    13·1 answer
  • In 1-2 paragraphs discuss the three main purposes of design and provide examples for each. Also explain how a design might serve
    15·1 answer
  • To create a button that will allow a user to send the form data to the server you use a type of ____
    5·1 answer
  • What does this say:<br> √ans
    6·2 answers
  • "Technician A says that Ohm's law can be used to determine circuit current flow if total circuit resistance and total voltage ar
    14·1 answer
  • A Silicon Valley billionaire purchases 3 new cars for his collection at the end of every month. Let a_n denote the number of car
    8·1 answer
  • The convergence of information technology and operations technology, offering the potential for tremendous improvements in effic
    14·1 answer
  • Identify three best -selling tablet on the market, and decide on the one that you would like to buy? justify your respone
    9·1 answer
  • When was the Ethics Resource Center (ERC) established? In the 1970s In the 1980s In the 1990s In the 2000s
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!