answer.
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
Sidana [21]
2 years ago
13

Implement a function printWordsLines() that takes as a parameter the name of an input file. It opens the input file and then pri

nts the number of lines and the number of words found in the file. Words are strings separated by spaces, and lines are strings terminated by the newline character. Don't forget to close the input file after you are done reading it. Sample runs:
>>> printWordsLines('test1.txt')

The file test1.txt contains 17 words and 3 lines

>>> printWordsLines('test2.txt')

The file test2.txt contains 38 words and 5 lines

use python3.7
Computers and Technology
1 answer:
Talja [164]2 years ago
7 0

Answer:

def printWordsLines(filename):

   file = open(filename, 'r')

   lines = 0

   words = 0

   for line in file:

       line.rstrip()

       lines += 1

       word = line.split(' ')

       words += len(word)

   print('the file ',filename,' contains ',words,' and ', lines, ' lines')

   file.close()

printWordsLines('words')

Explanation:

the file used was words in txt format and its contents are given as follows

hello aamir jan khan

parallelogram abdullah

anaconda ali

pycharm notebook

You might be interested in
Define a function ComputeGasVolume that returns the volume of a gas given parameters pressure, temperature, and moles. Use the g
lara [203]

Answer:

double ComputeGasVolume(double pressure, double temperature, double moles){

   double volume = moles*GAS_CONST*temperature/pressure;

    return volume;        

}

Explanation:

You may insert this function just before your main function.

Create a function called ComputeGasVolume that takes three parameters, pressure, temperature, and moles

Using the given formula, PV = nRT, calculate the volume (V = nRT/P), and return it.

6 0
2 years ago
A(n) ______of the audio or video clip makes the content easily accessible to people with hearing disabilities.
defon

subtitles

hope that helped you

7 0
2 years ago
Read 2 more answers
Write a while loop that prints userNum divided by 2 (integer division) until reaching 1. Follow each number by a space. Example
jasenka [17]

Answer:

public class Main

{

public static void main(String[] args) {

    int userNum = 40;

    while(userNum > 1){

        userNum /= 2;

        System.out.print(userNum + " ");

    }

}

}

Explanation:

*The code is in Java.

Initialize the userNum

Create a while loop that iterates while userNum is greater than 1. Inside the loop, divide the userNum by 2 and set it as userNum (same as typing userNum = userNum / 2;). Print the userNum

Basically, this loop will iterate until userNum becomes 1. It will keep dividing the userNum by 2 and print this value.

For the values that are smaller than 1 or even for 1, the program outputs nothing (Since the value is not greater than 1, the loop will not be executed).

4 0
2 years ago
Which data type change will require the app builder to perform the additional steps in order to retain existing functionalities?
Readme [11.4K]

Answer:

Option D is the correct option.

Explanation:

The following option is correct because the lead alteration from number to text and the number to text types of data will reconstruct the important number of the app builder to accomplish those steps which is extra to continue to have that functionality which is in the existence. That's why the app builder has to be reconstructed the types of data for the custom fields.

7 0
2 years ago
Suppose we used an Internet Addressing protocol that used 4 bits to encode a single address. How many devices would be supported
Allushta [10]
C. is the answer my guy
8 0
2 years ago
Other questions:
  • Select the correct answer. Rachel needs to make a presentation on ethics and etiquettes in college. She has about 30 minutes to
    13·1 answer
  • A network design engineer has been asked to design the IP addressing scheme for a customer network. The network will use IP addr
    6·1 answer
  • You learned that properly edited resumes are necessary for making a good impression on a university or a potential employer. Dis
    13·1 answer
  • Write a function that computes the average and standard deviation of four scores. The standard deviation is defined to be the sq
    15·1 answer
  • Some numbers are formed with closed paths. the digits 0, 4, 6 and 9 each have 1 closed path and 8 has 2. None of the other numbe
    6·1 answer
  • XYZ Corp.’s facilities in Nashua, New Hampshire, are two office buildings 400 feet apart, each with its own LAN. To connect the
    9·1 answer
  • Develop an EER model for the following situation using the traditional EER notation, the Visio notation, or the subtypes inside
    8·1 answer
  • Consider the following class definitions.
    10·1 answer
  • Exercise 4: Bring in program grades.cpp and grades.txt from the Lab 10 folder. Fill in the code in bold so that the data is prop
    12·1 answer
  • Choose the correct function to convert the user’s response to the number 3.5. >>> answer = input("How much does the sam
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!