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
Rudiy27
3 years ago
11

Two files named numbers1.txt and numbers2.txt both have an unknown number of lines, each line consisting of a single positive in

teger. Write some code that reads a line from one file and then a line from the other file. The two integers are multiplied together and their product is added to a variable called scalar_product which should be initialized to zero. Your code should stop when it detects end of file in either file that it is reading. For example, if the sequence of integers in one file was "9 7 5 18 13 2 22 16" and "4 7 8 2" in the other file, your code would compute: 4*9 + 7*7 + 8*5 + 2*18 and thus store 161 into scalar_product.
Computers and Technology
1 answer:
Reika [66]3 years ago
6 0

Answer:

see explaination for program code

Explanation:

scalar_product = 0

li=[]

li2=[]

#reading numbers1.txt and numbers2.txt intoli and li2 respectively

with open('numbers1.txt') as n1, open('numbers2.txt') as n2:

for line1 in n1:

li.append(int(line1))

for line2 in n2:

li2.append(int(line2))

#storing min list size into variable l

a=len(li)

b=len(li2)

if a<b:

l=a

else:

l=b

#calculating scalar product

for i in range(l):

scalar_product=scalar_product+li[i]*li2[i]

print("scalar product is",scalar_product)

You might be interested in
Write a program that accepts as input the mass, in grams, and density, in grams per cubic centimeters, and outputs the volume of
rewona [7]

Answer:

Program for the above question in python:

mass = float(input("Enter the mass in grams")) # It is used to take the mass as input.  

density = float(input("Enter the density grams per cm cube")) # It is used to take the input for the grams.

print("Volume ={:.2f}".format(mass/density)) #It is used to print the Volume.

Output:

  • If the user inputs as 2.98 and 3.2, then it will results as 0.92.

Explanation:

  • The above code is in python language, in which the first statement is used to take the inputs from the user for the mass and sore it into a mass variable.
  • Then the second statement also takes the input from the user and store it into a density variable.
  • Then the third statement of the code is used to print the volume up to two places using the above-defined formula.
3 0
3 years ago
______ is a disadvantage of EDI.
Artist 52 [7]

Answer:The number of standards

Explanation:Electronic data interchange (EDI)  is the mechanism through which data is interchanged in the system electronically.It is mostly found in the business field for exchanging of data.

As EDI helps in making message accurate by decreasing the length and also has beneficial features of maintaining the security and increasing productivity ,hence these factor are not considered as the disadvantage .

Too many standard present in the EDI make the working complex by limiting the processing in the small business as compared with large organization.

 

6 0
3 years ago
In cell N2, enter a formula using the IF function and structured references as follows to determine which work tier Kay Colbert
sattari [20]

The IF Function based formula that can be entered into cell N2 that will return 2 if true, and 1 if false is =IF(M2 >=4, 2, 1).

<h3>How is the IF function used?</h3>

An IF function allows us to be able to sort through data by analyzing data to find out if it conforms to a certain characteristic that we are looking for.

If the data corresponds, the IF function will return a value that means True, but if it doesn't, the value returned would be false.

After typing in the IF function, the next thing to do is specify the cell where the data you want to analyze is. In this case that data is in cell M2. You immediately follow this up by the parameter being compared.

In this case, we want to know if the figure in cell M2 is greater or equal to 4 so the next entry is M2>=

The next entry is the return if the comparison is true. In this case, the number for true is 2 and the one for false is 1. The full formula becomes:

=IF(M2 >=4, 2, 1).

In conclusion, the function is =IF(M2 >=4, 2, 1).

Find out more on the spreadsheets at brainly.com/question/1429504.

#SPJ1

8 0
1 year ago
Which keyboard shortcut would you press to copy cells that are selected in a spreadsheet?
CaHeK987 [17]

Answer:

ctrl c

Explanation:

4 0
2 years ago
Malwar is the short form for malicious software and used to refer​
bearhunter [10]

Answer:

Malware is the shortened form of malicious software. Malware is an umbrella term used to refer to a variety of forms of hostile or intrusive software including Ransom wares, Computer Viruses, Worms, Trojan Horses, Spyware, Adware, Scareware etc.

7 0
3 years ago
Other questions:
  • What is the purpose of a title slide on power point
    14·2 answers
  • What is the cell membrane used for ​
    14·2 answers
  • Which table attributes would this code produce?
    15·1 answer
  • JAVA QUESTION::
    10·1 answer
  • Scenario
    7·1 answer
  • What can provides access to the only menu in office 2007​
    13·1 answer
  • 14. Which of the following is NOT a
    6·2 answers
  • Davingould1115...................answer 3​
    11·1 answer
  • Fiona was talking to her colleagues about how advancements in digital technology had a negative effect on her life. Which aspect
    9·1 answer
  • What is the difference between a field and an infoobject? What is the advantage of using infoobjects instead of fields in an ads
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!