Write a program that reads a file containing two columns of floating-point numbers. Prompt the user for the file name. Print the average of each column. Be sure to look at the test cases to see how the output is formatted.

Answers

Answer 1

Answer:

In Python:

file = input("File name: ")

f=open(file,"r")

lines=f.readlines()

col1=[]  

col2=[]

for x in lines:

col1.append(float(x.split(' ')[0]))

for x in lines:

col2.append(float(x.split(' ')[1].rstrip('\n')))

f.close()

sum1 = 0.0

sum2 = 0.0

for i in range(len(col1)):

sum1+=col1[i]

sum2+=col2[i]

print("Average of Column 1: %.2f" %(sum1/len(col1)))

print("Average of Column 2: %.2f" %(sum2/len(col2)))

Explanation:

This prompts the user for file name

file = input("File name: ")

This opens the file

f=open(file,"r")

This reads the lines of the file

lines=f.readlines()

This creates an empty list for column 1

col1=[]  

This creates an empty list for column 2

col2=[]

The following iterations iterate through the lines and puts them in the respective column list

for x in lines:

col1.append(float(x.split(' ')[0]))

for x in lines:

col2.append(float(x.split(' ')[1].rstrip('\n')))

This closes the file

f.close()

This initializes the sum of column 1 to 0

sum1 = 0.0

This initializes the sum of column 2 to 0

sum2 = 0.0

This iterates through each list and adds up the list contents

for i in range(len(col1)):

sum1+=col1[i]

sum2+=col2[i]

This calculates prints the average of the first column to 2 d.p

print("Average of Column 1: %.2f" %(sum1/len(col1)))

This calculates prints the average of the second column to 2 d.p

print("Average of Column 2: %.2f" %(sum2/len(col2)))


Related Questions

Need answer quick plz.

Fill in the blank with the correct response.

A colleague excitedly tells you she has created a interface component for SPSS, a statistics software program. She

has created a

Answers

Answer:

SPSS

IS THE ANSWER

IHOPEIT WILL HELP YOU

Answer:

wassup with it bro i don't even know the answer and i just want the points

Explanation:

Citations that are ______________________________ can be used to build a bibliography when needed. [Create and Modify Citation Sources]
Question 1 options:

underlined

bolded

marked

italics

Answers

Answer:

I think the best option would be C. Marked

Explanation:

hope this helps and sorry if it is incorrect.

it is a JavaScript property used to call a function after a specified time, in milliseconds​

Answers

Answer:

setTimeout is a native JavaScript function (although it can be used with a library such as jQuery, as we'll see later on), which calls a function or executes a code snippet after a specified delay (in milliseconds).

Answer:

setTimeout is a native JavaScript function (although it can be used with a library such as jQuery, as we'll see later on), which calls a function or executes a code snippet after a specified delay (in milliseconds).

Identify what a computer needs to
communicate sound:
Driver
Digital sound
Mouse
Keyboard
DONE

Answers

Digital sound because you want be able to hear

Answer:

A B

Explanation:

I got it right

A citation and its ____________________ can be entered at the same time. [Insert Citations]
Question 4 options:

name

date

source

table of contents

Answers

Answer: source

Explanation:

A citation and its source can be entered at the same time. Hence option c is correct.

What is citation?

Citation is defined as how you disclose to your readers that a particular passage in your work was taken from another source. Identifying the sources you used to obtain your knowledge can demonstrate to the reader that you did thorough investigation. to recognize and respect other scholars' work by giving them due credit.

Select the phrase or sentence you wish to cite by clicking at the end of it, and then select Insert Citations from the Citations & Bibliography group on the References tab. Choose the citation you want to use from the list provided under "Insert Citation."

Thus, a citation and its source can be entered at the same time. Hence option c is correct.

To learn more about citation, refer to the link below:

https://brainly.com/question/1272936

#SPJ2

Backing up your data on a regular basis is a part of the ___ process.
A. insurance
B. troubleshooting
C. maintenance
D. regulatory

Answers

Backing up your data on a regular basis is a part of the maintenance  process.

What is data backup?

The term data backup is known to be a term that entails the act of copying of physical or virtual files or databases to nay kind of secondary location for safe keep or preservation.

In any organization, the backing up of system files as well as documents and organisation information are very important in terms of system failure or breakdown.

Hence, Backing up your data on a regular basis is a part of the maintenance  process because it entails a preservation way of keeping data.

Learn more about maintenance  process from

https://brainly.com/question/23545233

#SPJ1

Which comparison operator means ‘is not equal to’?



!=


==


=#


%

Answers

Answer:

A. !=

Explanation:

== Means equal, != is like a block of that, meaning NOT EQUAL

As per the operators, the comparison operator that means 'is not equal to' is !=.

The comparison operator!= is used to detect whether two values are not equal. It is often used to assess conditions in programming languages and logical expressions.

When used, the operator determines if the values on each side of it are not equal. The expression evaluates to true if they are not equal.

This operator is useful for comparing data and executing various code blocks based on their inequality.

Thus, programmers may use the!= operator to generate branching logic and make decisions depending on the equality or inequality of values, increasing the flexibility and control of their program.

For more details regarding operators, visit:

https://brainly.com/question/29949119

#SPJ6

two ways in which some culter views that exist may affect a relationship negatively​

Answers

Answer:

some people say different culture less they get along

Explanation: or more

QUESTION 4 of 10: What term refers to the basic characteristics of a population segment, such as gender, age, and income?

Answers

272727727272727226282829292
Does it offer multiple choices?

Question # 1
Dropdown
Choose the word that matches each definition.
[ ] is the study of designing and building computers and computer-based systems.

Answers

Answer:

Computer engineering

Explanation:

Computer engineering is the answer

What is considered appropriate dress for men and women in the workplace? Select all that apply.

Answers

Answer:

I guess clean, pressured pants or skirt

and

dress shirts and ties

Answer:

the first and last

Explanation:

because you don't want to reveal any things that are inappropriate but you still want to be comfortarible.

Which one way in which using infrared in game console controllers could affect the experience of a person playing the game?

Please answer asap I need it now

Answers

An increasing amount of games is released on multiple platforms, and game designers face the challenge of integrating different interaction paradigms for console and PC users while keeping the core mechanics of a game. However, little research has addressed the influence of game controls on player experience. In this paper, we examine the impact of mouse and keyboard versus gamepad control in first-person shooters using the PC and PlayStation 3 versions of Battlefield: Bad Company 2. We conducted a study with 45 participants to compare player experience and game usability issues of participants who had previously played similar games on one of the respective gaming systems, while also exploring the effects of players being forced to switch to an unfamiliar platform. The results show that players switching to a new platform experience more usability issues and consider themselves more challenged, but report an equally positive overall experience as players on their comfort platform.

I could've been somebody, you know? Esperanza, you go to school. Study hard. . . . Got to take care all your own, she says shaking her head. —"A Smart Cookie," Sandra Cisneros Which inference can you make about Esperanza’s mother based on her words? She believes that good things happen by chance. She believes that people must take responsibility for their futures. She believes that to be somebody, you need to have talent.

Answers

Answer:

B or She believes that people must take responsibility for their futures.

Explanation:

mark me brainliest plz?:)

Answer:

B

Explanation:

i hope you know you are worth it

Jennifer has written a short story for children. What should be her last step before she submits the story for publication?

Answers

Answer: proofreading

Explanation:

The options include:

A. proofreading

B) editing

C) accepting track changes

D) rejecting track changes

Jennifer's last step before she submits the story for publication should be proofreading. Proofreading simply refers to the checking of errors in an article, story or text before such article or text is published.

Proofreading is the final stage when one is writing before it's published. When a story is proofread, spelling, formatting issues, punctuation marks and every other mistakes are checked and removed.

write a Python function that join the two string and print it ​

Answers

Answer:

string1 = "this is string 1"

string2 = " this is string 2"

print(string1 + string2)

Explanation:

the string1 variable is assigned with a string value(aka. str)

string2 is also a variable assigned with a slightly different string value

the 3rd line then prints string 1 and 2 to the console.

Answer:

Nothing complicated

See attached images

Display the IP address of the default gateway of this device.

Answers

Answer:

ipconfig

Explanation:

Type ipconfig and look for a Default Gateway entry that is not blank.

Plz help
Match each engineering job role to its description

Answers

Answer:

Check image, correct on PLATO

Explanation:

The correct matches of each engineering job role to its description are mentioned below.

What is engineering?

Engineering is the application of science and mathematics to problem-solving. While scientists and innovators create new ideas, it is engineers that put these ideas into practice.

It is the integration of scientific concepts to the design and construction of machinery, structures, and other objects such as bridges, tunnels, roads, automobiles, and buildings.

Each engineering job role's correct match to its description is shown here.

Heads the engineering department and ensures that it operates smoothly  - chief engineerperforms administrative work to ensure projects comply with engineering codes and standards  - office engineerperforms a variety of onsite tasks, such as supervision and equipment installation -  field engineerensures projects end on time through careful planning and organization - project engineerensures proper sequencing of events to minimize project duration - planning engineer.

Learn more about engineering here:

https://brainly.com/question/19117846

#SPJ2

In the current situation, how do you access information as a student? How will you integrate the use of ICT in your daily life and your chosen track?

Answers

Answer:

Explanation:

As a computer science student information is accessed in every possible way. This can be through a local school lan network, mobile devices, e-mail, etc. All of these help information flow to and from various people and makes obtaining this information incredibly simple as a student. Especially in the field of computer science, I need to integrate as many ICT devices with me in my everyday life, to send emails, check calendar updates, research information on the web, check school reports, and even speak with clients.

In object-oriented programming, what is an instance of a class? A. A code used to create multiple classes B. An individual object of a class C. The attributes and behaviors of one class D. The moment an object becomes a class

Answers

Answer:

I'm thinking it's B. An individual object of a class

Sorry if I'm wrong :(

Which keyboard shortcut is used to move the cursor one cell to the right of the insertion point?

Tab
Shift+Tab
Down arrow
Shift+Left Arrow

Answers

Answer:

Tab

Explanation:

Pressing the tab button moves the cursor one cell to the right of the insertion point

Answer:

A. Tab

Explanation:

edge

Brandon realized that his program wasn’t running properly because he used a colon instead of a semi-colon. What kind of error did Brandon make?
syntax error

Boolean error?

logic error?

iteration error?

Answers

Answer:

Syntax Error

Explanation:

Syntax Errors a simple errors where you could forget something simple like a comma or maybe misspell a word.

Answer:

The error Brandon made by using a colon instead of a semi-colon is Syntax error

The ________________________ option allows one to start a numbered list on any number desired. [Set Starting Number Values]
Question 7 options:

Number Formats

Change List Level

Define New Number Format

Set Numbering Value

Answers

Answer:

Set Numbering Value.

Explanation:

Microsoft Word refers to a word processing software application or program developed by Microsoft Inc. to enable its users to type, format and save text-based documents.

In Microsoft Word 2019, the users are availed with the ability to edit the word document in the following view type;

I. View Mode.

II. Print Mode.

III. Drift Layout.

A numbered list can be defined as a list of items that are ordered numerically or sorted sequentially.

Basically, it is best suited for steps or procedures that are to be done sequentially or in order i.e in an ascending order. Thus, a numbered list is an ordered list that starts from 1.

The Set Numbering Value option allows one to start a numbered list on any number desired. To automatically create a numbered list in Microsoft Word, you should press 1 followed by a period, leave a space, type a text and then press the enter button.

Your program has a two-dimensional array, scores. You are implementing your array with lists. Each member in the array is a pair of
scores, composed of [your team score, the opponent's score).
Which line of code will add a new pair of scores to the array?
scores.insert(6,2)
O scores.append([6.2])
O scores.insert[62]
O scores.append(6,2)

Answers

Answer:

scores.append([6, 2])

Or simply D

Explanation:

Note: Be sure to look carefully or you'll get tripped up. Trust me, I know!

input data that can be accepted by a function in Python is called as​

Answers

Answer:

Getting User Input from Keyboard

Explanation:

There are two functions that can be used to read data or input from the user in python: raw_input() and input(). The results can be stored into a variable.

Answer:

also know as IDE

Explanation:

Does anybody play nba2k21 On ps4

Answers

Answer:

yeah but I gotta re-download it

Answer:

Nope but can i get it on switch

Explanation:

Describe white blood cells you see at 10X?

Answers

Answer:

White blood cells are part of the body's immune system. They help the body fight infection and other diseases. Types of white blood cells are granulocytes (neutrophils, eosinophils, and basophils), monocytes, and lymphocytes (T cells and B cells). ... Also called leukocyte and WBC.

Explanation:

How does setting user permissions increase the security of a system?

Answers

Answer: This can allow for less hackers to acquire your most essential and private information. It will be kept private to you and only others you share with.

Explanation: For example, if I wanted to edit a document without being given the consent to do so this will breach the security of user permissions, but if the individual was to set the document to view only, I would not have access to edit or even change little aspects of it.

who plays oblox .............................

Answers

Answer:

Me

Explanation:

MEEEE!!! i love scary games

1 2

3 4

Question #4

Multiple Choice

Which statement is true about the random and secrets modules?

O Only the secrets module can generate random numbers.

O Both modules can generate random numbers.

Neither module can generate random numbers.

O Only the random module can generate random numbers.

Answers

Answer:

Both modules can generate random numbers.

Explanation:

Both the random and secrete modules are builtin programming modules used for generating random number variables. The random module consists of a number of methods in its module for random. number generation such as seed() ; getstate() ; random() ; choice() ; randrange() ; randint() and so on. Random methids are best for generating random numbers which are to be adopted for simulation or modeling. The secrete modules does the same however, numbers generated are stronger and less predictable than the random number modules. Secrete modules are usually adopted in the generation of authentication token and security pins.

Answer:

Neither module can generate random numbers.

Explanation:

Because I took the quiz and that's the right answer.

Which of the following algorithmic efficiencies would be considered LEAST efficient?

A. Linear
B. Constant
C. Polynomial
D. Exponential

Answers

Answer:exponential

Explanation: I believe

Other Questions
I NEED HELP PLZ!!!!!!!!!! Question 3 (10 points) True or False: Power Walking has the same benefits as everyday, around-the-house walking. Question 3 options: True False PLZ HELP I WILL GIVE YOU BRAINLIST!! A ball is thrown into the air with a speed of 32 feet per second. The function h=32t - 16t^2 models the height of the ball after t seconds. How many seconds does it take for the ball to reach its maximum height? patrick walks at 6/8 kilometer per 8 hour. how far will he in 5 hours? A small radio station can broadcast in a circular range with a radius of 20 miles. About how many square miles is the area covered by this range? Use 3.14 for . 9.LOOK AND CHOOSE THE CORRECT SENTENCES AFFIRMATIVE My cousin _____ English very well.SpeakSpeakingSpeaks Plz show all work. Quick thank youWhat is the solution to the equation?3\root(5)((x+2)^(3))+3=27 match the word with the definition wordh. to eat 1. crucial 2. scavenger 3. domino4. native 5. invasive 6. biodiversity 7. consume 8. thrivedefinition a. chain reaction b. to do well c. species that naturally lives in a spaced. large variety of living thingse. eats dead things f. species that does not belong g. important Please help me I need this ASAP Findh in the paralelogram20 ft10 ft12 ft What is the measure of angle B?Triangle A B C. Angle A is 50 degrees and angle C is 28 degrees.7892102282 Plz help me ASAP , thxs cuando eran ninos, mis abuelos (visitar) Colombia Palpatine runs a facial cream business. He can make 100,000 bottles of facial cream per year and sell them for $3.50 each. It costs Palpatine $250,000 for the raw materials to produce the facial cream. Additionally, he must pay $30,000 annually to rent the factory needed to produce his cream. In order to start his business Palpatine withdrew $200,000 from his own savings account. The bank is currently paying a 3% interest rate on saving accounts. Before Palpatine opened his business he worked as a political consultant where he earned $80,000 per year.What is the total revenue Palpatine earns in a year?What are the explicit costs Palpatine incurs while producing bottles of facial cream? [2 Points](c) What are the implicit costs Palpatine incurs while producing bottles of facial cream? [2 Points](d) What is the amount of Palpatines accounting profit? [2 Points](e) What is the amount of Palpatines economic profit? How many moles are in 6.7 grams of sodium hydroxide?How many grams are in 2.5 moles of calcium carbonate? HELLPPP! WILL MARK BRAINLISESTthe ratio of boys to girls in a class is 7:5. If there are 132 total students. How many boys are there New Zealand and Spain each produce apples and plums. New Zealand can produce a maximum of 60 apples or 15 plums or some combination of both. Spain can produce a maximum of 60 apples or 60 plums or some combination of both. If they decide to specialize and trade, the trade rate is 25 apples for 17 plums.a. Which nation should specialize in plums and which should specialize in apples In a recent flu epidemic, the number of flu cases increased by 40% each week. There were 3,000 flu cases during the first week of January. How many more people were affected by the flu during the third week of January than during the first week?A.1,200B.2,880C.3,280D.4,200 Please help i will give you brainliest! Its due in 30 minutes