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
BRAINLIEST You have a small company and want to keep your costs low, but it is important your employees share data. Which networ
solmaris [256]

Answer:Peer-to-peer

Explanation: I hope this helps

5 0
2 years ago
Read 2 more answers
Which of the following statements is true of a server? Question 18 options: A) It supports processing requests from remote compu
TiliK225 [7]

Answer:

Option (A) is the correct answer of this question.

Explanation:

The server supports the processing requests from the remote computers. A system is a device built to accommodate inquiries from many other external systems and customers to execute transactions. Employees are called private computer ,tablets, including phones which connect websites.

Network resources are handled through servers.The server is a software application or tool providing a service to some other software program and its customer, also identified as those of the user.

Other options are incorrect because they are not related to the given scenario.

5 0
3 years ago
Can someone that been helping me answer one more question for please and thx
Gnom [1K]

Answer:

D

Explanation:

Federal Tax, not state

5 0
3 years ago
Who developed the idea of a universal network?
polet [3.4K]
Alan Turing fathered the machines we now lovingly call computers, however it was Nicola Tesla that birthed the idea of a world-wide wireless system.
7 0
3 years ago
When we focus on stereotypes we may ___________________. a. experience culture shock b. develop ethnocentrism c. unconciously lo
alisha [4.7K]
When we focus on stereotypes we may <span>unconsciously look for information to support our generalizations .</span>
3 0
2 years ago
Read 2 more answers
Other questions:
  • Jesse purchases a new smartphone and is immediately able to use it to send a photo over the Internet to a friend who lives in a
    12·1 answer
  • Where do scanned documents go in windows 10?
    11·1 answer
  • How could you fact check a news report that you saw on television
    12·1 answer
  • You have found statistics on the Internet that you would like to use in your speech.
    6·1 answer
  • The version of Windows that first provided networking capabilities was _____.
    12·2 answers
  • You are creating a database for your computer club. Most of the students live in your town, Durham. How can you make Durham appe
    11·1 answer
  • Draw a dfd that shows how data will be stored, processed, and transformed in the tims system
    9·1 answer
  • Write a program that accepts any number of scores ranging from 0 to 10
    14·1 answer
  • Which wireless standard uses the 2.4 GHz frequency band only?
    5·1 answer
  • An IP address specifically belongs to:
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!