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
Airida [17]
3 years ago
14

Create a program that will ask the user to specify a file in the current directory. The program will count and report the number

of lines, words and characters. There are several approaches that can be used. Hint: You may want to consider read(), readlines(), readline(), split() method, and/or a for statement such as 'for line in thisfile' might be helpful. The approach is up to you. It is correct if it works!
Computers and Technology
1 answer:
Reil [10]3 years ago
5 0

Answer:

Explanation:

The following code is written in Python. It is a function that takes in the file directory as an argument, reads the file. Then it counts the lines and words in the file and saves that count in separate variables. Then it loops through the entire file counting the characters, without counting whitespace and newlines breaks. Finally, it prints all of that information out.

def countText(file):

   f = open(file, 'r')

   text = f.read()

   lines = len(text.split('\n'))

   words = len(text.split(' '))

   characters = 0

   for char in text:

       if (char != ' ') and (char != '\n'):

           characters += 1

   print("File Count:")

   print("Lines: " + str(lines))

   print("Words: " + str(words))

   print("Characters: " + str(characters))

You might be interested in
Which of the following correctly describes the syntax of an If statement?
Ber [7]

if(Expression to be tested) {

code to execute

} else if(Expression to be tested) {

code to execute

}


you can have as many else ifs as you want. But that's what it looks like.

8 0
4 years ago
To refine the in-between motions, a computer animator uses a mathematical function called a(n)
RoseWind [281]

Answer:

tweening

Explanation:

4 0
4 years ago
The opportunity cost of earning an advanced college degree is that:
cluponka [151]

What does opportunity cost mean?

Opportunity cost is a term that indicates the benefits, or <em>opportunities, </em>a person or business must give up in order to pursue a certain action or decision. Opportunity cost is often the result of some kind of scarcity (ie lack of time, money, resources etc.)

In this situation the action we are pursuing is to earn an advanced college degree, thus, the opportunity cost of earning an advanced college degree is any action and/or decision we can not take because we are busy earning this advanced college degree.

The answer to this problem is:

A. You will earn less money during the years that you are in college.

In the situation proposed in the question, you are scarce on time, because you choose to spend it earning your degree and studying. You can not use the time you spend going to college to also work and earn money, thus you are not earning as much money as you could were you not in college (not in college = more time you could spend working and earning money)

<u>Here is a further breakdown of why the other responses are incorrect:</u>

<u />

<u>B. You will earn more income during your career.</u>

This is a <em>delayed benefit</em> (not a cost) you'd receive after working hard on a degree that could land you a stable career

<u>C. Some fields require a professional degree before you </u>

This is one <em>motivation </em>possibly pushing you to get your degree

<u>D. There may be a low supply of jobs in your professional  field</u>.

This is a <em>risk </em>you may encounter

3 0
3 years ago
Some technologies like vertical farming have a number of negative effects. Which is a negative outcome of this technology? A. In
Tanya [424]
<span>Vertical farming is the exercise of creating foodstuff and medication in sheer laden layers, vertically inclined exteriors and/or combined in other structures. The modern thoughts of vertical farming use indoor farming methods and controlled-environment agriculture (CEA) technology, where all environmental issues can be well-ordered. So knowing all of this, the negative outcome would be D.</span>
4 0
4 years ago
The motherboard
Ksju [112]

Answer:

a:(allows the different parts of a computer to communicate)

Explanation:

The motherboard is the main command center for the whole pc which recieves your inputs and responds by sending outputs...

3 0
3 years ago
Other questions:
  • The bus width and bus speed together determine the bus's ______ or bandwidth; that is, the amount of data that can be transferre
    5·1 answer
  • Select the correct answer from each drop-down menu.
    10·1 answer
  • Citing the recent increase in earnings by several computer companies, economists feel that a cycle has begun in which personal c
    13·1 answer
  • To computer the equivalent units of production, add: A. units completed plus a percentage of the beginning WIP units B. units co
    10·1 answer
  • The ability of a person booking a flight on Southwest's website to reserve a car from Dollar Rent-A-Car without having to leave
    6·1 answer
  • Which of the following makes a virtual tour different from a printed map
    6·2 answers
  • Now for our sponsor Raid:Shadow legends
    8·2 answers
  • Alexandria works for a non-profit company that asks for donations to help the homeless people in her community. Recently the dat
    12·1 answer
  • As a prospective student, what is the best reason to request an interview with your college application?
    6·1 answer
  • Gaming applications allow users to play solo games as well as play with friends and/or other players
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!