Computers and Technology
Computers and Technology, 08.01.2020 07:31, bm42400

Write a program to look for lines of the form: new revision: 39772and extract the number from each of the lines using a regular expression and the findall() method. compute the average of the numbers and print out the average. there are two data files. you must ask the user for the name of the file he wishes to process. you may assume that he will always enter either mbox. txt or mbox-short. txt. that is, you don't have to do any error trapping (no try/catch).your program should look for lines that begin with the text "new revision: " followed by any number of spaces, followed by any number of digits. extract the digits (they will be extracted as a string and will be inserted into a list that has the string as the only element, e. g. ["12345"]).convert each number into an integer (they will all be integers, no floating point numbers). count the number of such lines that you encounter and sum the numbers. at the end, print out the sum, the count, and the average (sum/count). below is the output for each file. you should get the same results. enter file: mbox. txtsum: 69004133count: 1790average: 38549.79497206704enter file: mbox-short. txtsum: 1073437count: 27average: 39756.92592592593

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 19:30, tfaulk2884
Singing in the rain: this first part of the film shows the early history of motion picture. how accurate do you think the portrayal of the early motion picture industry is? why? is historical accuracy important in films and theater productions? explain.
Answers: 1
image
Computers and Technology, 22.06.2019 22:40, ihatemylife0
Least square fit to polynomial write a function leastsquarefit3pol that solves a linear system of equations to find a least squares fit of a third order polynomial to an experimental data set given as two row arrays. the function leastsquarefit3pol must explicitly solve a set of linear equations and cannot use polyfit. there should be no restriction on the size of the problem that can be solved.
Answers: 1
image
Computers and Technology, 23.06.2019 06:20, Ab20600
Which text function capitalizes the first letter in a string of text? question 10 options: upper capital first proper
Answers: 1
image
Computers and Technology, 23.06.2019 16:30, jessisjawsome
If i wanted to include a built-in calendar in a document, what option could i select? draw table insert table insert chart quick tables
Answers: 1
Do you know the correct answer?
Write a program to look for lines of the form: new revision: 39772and extract the number from each...

Questions in other subjects:

Konu
Mathematics, 07.05.2021 16:20
Konu
Health, 07.05.2021 16:20