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
Fifty-three percent of U.S households have a personal computer. In a random sample of 250 households, what is the probability th
aleksley [76]

Answer:

The correct Answer is 0.0571

Explanation:

53% of U.S. households have a PCs.

So, P(Having personal computer) = p = 0.53

Sample size(n) = 250

np(1-p) = 250 * 0.53 * (1 - 0.53) = 62.275 > 10

So, we can just estimate binomial distribution to normal distribution

Mean of proportion(p) = 0.53

Standard error of proportion(SE) =  \sqrt{\frac{p(1-p)}{n} } = \sqrt{\frac{0.53(1-0.53)}{250} } = 0.0316

For x = 120, sample proportion(p) = \frac{x}{n} = \frac{120}{250} = 0.48

So, likelihood that fewer than 120 have a PC

= P(x < 120)

= P(  p^​  < 0.48 )

= P(z < \frac{0.48-0.53}{0.0316}​)      (z=\frac{p^-p}{SE}​)  

= P(z < -1.58)

= 0.0571      ( From normal table )

6 0
3 years ago
Difference between multi-national and global company​
trapecia [35]

A multinational corporation, or MNC, is a company which produces goods and services and has offices in several other countries while a global corporation or company is a company which also has trade relations with several other countries. ... MNCs have official headquarters while global companies do not.

5 0
3 years ago
Read 2 more answers
What is a list of data organized for easy access?
ozzi

Answer:

An Array

Explanation:

Array and Object is a good use for storing data and accessing it

6 0
2 years ago
25 POINTS!!!!!!!!!!!!!
Paladinen [302]
A leaking data exhaust
7 0
3 years ago
Read 2 more answers
Create a short document titled "Guide to web searches" that Sergio can give to users of the facility he supervises. The document
Studentka2010 [4]

Answer:

Jobs Seeker's

Web Search Guide

Sergio Escobar

PERFORMING A SEARCH:

All search engines will have a search field in which you are able to enter your search terms,

criteria, keywords, or even a website.

Search terms are the keywords a search engine will use to try to find the most relevant search

results.

If you’re looking for general information, just enter the name of the topic you’re

interested in into the search field.

So, if you’re looking for work, you can use the search terms ‘employment’ and ‘jobs’.

The search engine will return you a list of web pages that include the words

‘employment’ and ‘jobs’.

IF you’re looking for more specific information, you can narrow your search results by

using more specific search terms.

So, if you wanted employment opportunities in Phoenix, AZ, you could use the search terms:

‘local’, ‘employment’, ‘jobs’ and ‘Phoenix’.

Once you’ve entered your search terms and selected the search or go button, the search

engine will provide you with a list oF search results.

Depending on your search, you could get thousands or even millions of search results. This is

because search engines will usually list every single web page on the Internet that used those

search terms somewhere on a web page.

(However, the most current and/ or relevant results should be at the top of the list.)

Searching Strategy:

Using Boolean Operators:

use AND,OR,NOT between the words

ex: LOCAL AND JOBS

JOBS NOT IN NEWYORK

Proximity Operators:

With some search engines you can use proximity operators such as OpenText's NEAR operators or Webcrawler's ADJecent or the FOLLOWED BY operator.

With each of these operators, word order is important.

For example: if you place square brackets such as [local jobs] causes a hit if they are found within 100 words of each other.

Truncation (*)

You can use truncation on most search engines.

That is, you can use the asterisk (*) operator to end a root word.

For example: searching for comput* will find computer, computing, and computer jobs.

Note: the asterisk can not be the first or second letter of a root word.

Wildcard (?)

You can find words that share some but not all characters using the question mark (?) operator.

For example: Com?er J?b will find Computer Jobs and Computer Job.

Note: the ? can not be the first character in the search.

You may also use combinations of truncation (*) and single character wildcard (?) in your searches.

Conclusion:

These are just a few of the strategies and new tools trainers can use to make working on the web more productive.

As trainers continue to use the web they will soon see the next generation of web "knowledge tools" begin to emerge.

These will include multidimensional tools that are created to manage data on the web using factors such as "virtual neighborhoods of information,

" "organic structuring," and "mental model based searching and flying mechanisms" .

These are tools which are intended to make the world wide web more manageable for the user.

Let us now go back to my original statement...that the goals of search strategies and engines should be to increase your efficiency

and effectiveness when looking for information on the web.

Only you can decide which search/knowledge management strategies and tools actually improve your productivity.

It is my hope that this article helps you with making these decisions.

8 0
4 years ago
Other questions:
  • Desktop, laptop, and tablet computers, and mobile devices are classified as _______.
    7·1 answer
  • The LTE (cellular telephone) standard supports only packet switching"". What cellular services are morst affected by this change
    15·1 answer
  • A bug collector collects bugs every day for 5 days. Write a program that keeps a running total of the number of bugs collected d
    12·1 answer
  • How to reply to text from unknown number?
    11·1 answer
  • Which one of the following items would you be most likely to keep in a database? A. Payroll records B. Address book C. Financial
    7·1 answer
  • When can we feel electricity?? Tell me the volt
    15·1 answer
  • Create the code that will find
    11·1 answer
  • Write the definition of a function named fscopy. This function can be safely passed two fstream objects, one opened for reading,
    11·1 answer
  • Hi who plays among us
    9·1 answer
  • What is a cookie? *
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!