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
I want to solve this question in C program, Please.
inn [45]

Answer:

#include <stdio.h>

#include <math.h>

int is_armstrong(int n) {

int cubedSum = 0;

int r = n;

while (r) {

         cubedSum += (int)pow(r % 10, 3);

          r = r / 10;

}

return cubedSum == n;

}

int stack_count(int n) {

int sum = 0;

while (n) {

         sum += n % 10;

         n = n / 10;

}

return sum;

}

int is_magical(int n) {

while (n > 9) {  

 n = stack_count(n);

 printf("%d ", n);

}

return n == 1;

}

int main()

{

int input = 0;

int isMagical, isArmstrong;

while (true) {

 printf("Enter a number: ");

 scanf_s("%d", &input, sizeof(int));

 if (input == -1) break;

 isArmstrong = is_armstrong(input);

 isMagical = is_magical(input);  

 if (isArmstrong && isMagical) {

  printf("%d is both an armstrong and a magical number.\n", input);

 } else if (isArmstrong) {

  printf("%d is an armstrong number\n", input);

 } else if (isMagical) {

  printf("%d is a magical number\n", input);

 } else {

  printf("%d is neither an armstrong or a magical number.\n", input);

 }

}

}

Explanation:

Here is a starting point. What's the definition of a magical number?

4 0
2 years ago
When you are working on an unsaved document on a PC, where is the document temporarily saved?
Serga [27]

Answer:

RAM

Explanation:

RAM or Random Access Memory is a volatile storage memory which means if a power is turned off and turned on again it will be clear, that is why, if we do not save our work and a power failure occurs, our data is lost. It is where all our running programs are located while we are working. There is another memory, which is ROM(Read Only Memory). This is a non-volatile storage and saved work is stored in ROM.

3 0
2 years ago
Differenciate between foreign key and primary key in database.
enot [183]

Answer:

A primary key is utilized to guarantee the information in the particular segment is interesting. A foreign key is a section or gathering of segments in a social data set table that gives a connection between information in two tables. It particularly recognizes a record in the social information base table.

3 0
1 year ago
What is a critique of the feature detector model of object recognition?​?
Leya [2.2K]
Found a similar question that had choices, here are the choices:
a.Specific neurons that respond to round, square or irregular shapes do not integrate their signals to recognize multi-shaped objects.
b. It accounts only for the recognition of simple two dimensional shapes, not more complex three-dimensional shapes.
c.Feature detector neurons have been found in non-human primates, but not in humans themselves.
<span>d. It does not account for the fact that our expectations influence what we see.

My answer:
d. It does not account for the fact that our expectations influence what we see.

We all have different expectations, thus, our view on certain object is subjective. It is a product of said expectations. </span>
4 0
2 years ago
What are two options available for highlighting changes in the Highlight Changes dialog box?
lukranit [14]

Answer: D

Within a specific time period or by a specific user

Explanation:

4 0
2 years ago
Read 2 more answers
Other questions:
  • A form’s height is ______________________.<br><br> A property<br><br> A method<br><br> An event
    10·1 answer
  • Describe the dynamic Network Address Translation (NAT).
    9·1 answer
  • In order to get a comprehensive evaluation of the computer programmers he managed, Justin organized a(n) __________, where he as
    11·1 answer
  • Rewrite each condition below in valid Java syntax (give a boolean expression): a. x &gt; y &gt; z b. x and y are both less than
    7·1 answer
  • What is a project?
    5·2 answers
  • What are the words that make up a high-level programming language called?
    6·1 answer
  • Can someone find out what this binary number thing is. Just find out the message, I'm having a difficult time
    13·1 answer
  • mary needs to rename her report.txt file to final_report.txt. which command will allow her to do this?
    10·2 answers
  • Which of the expressions is false? when a = 10 and b = 4
    8·1 answer
  • Write a program that produces the following output: CCCCCCCCC ++ ++ CC ++ ++ CC ++++++++++++++ +++++++++++++++ CC ++++++++++++++
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!