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
What is a cpu in full explanation?
diamong [38]

Explanation:

The computer's central processing unit (CPU) is the portion of a computer that retrieves and executes instructions. The CPU is essentially the brain of a CAD system. It consists of an arithmetic and logic unit (ALU), a control unit, and various registers. The CPU is often simply referred to as the processor.

8 0
2 years ago
Read 2 more answers
Which protocol is often used in conjunction with ipsec to provide a remote access client vpn with user authentication?
amid [387]

The L2TP or Layer 2 Tunneling Protocol is often used in conjunction with ipsec to provide a remote access client vpn with user authentication.

<h3>What is vpn?</h3>

VPN is known as a Virtual Private Network extends a private network across a public network and activates users to send and receive data across shared or public networks as if their computing devices were directly connected to the private network.

The main difference between VPN proxy and a VPN is encryption and VPNs hides all the web activities performed by the user as well as user's private IP address.

Therefore, the L2TP or Layer 2 Tunneling Protocol is often used in conjunction with ipsec to provide a remote access client vpn with user authentication.

Learn more about VPN here:

brainly.com/question/17272592

#SPJ4

3 0
1 year ago
What is the location used by users to configure delegate access on their own mailboxes? Backstage view &gt; Account Settings Bac
abruzzese [7]

Answer:

A: Backstage view > Account Settings

Explanation:

7 0
2 years ago
A user is experiencing slow performance with their computer. A technician suspects the computer has a virus and runs antivirus s
IceJOKER [234]

Answer:

The answer is "Option A"

Explanation:

Escalation is the process of manipulating a bug, design failure in software program to obtain elevated access to the resources, which are usually shielded from the user, and wrong choices can be described as follows:

  • In option B, It is wrong because It can't provide any type of problem-solving.
  • In option C, It is wrong because it is a searching module.
  • In option D, It is wrong because it is used to verify the system.
6 0
3 years ago
All of these acts performed when doing an oil and filter change except ?
Nat2105 [25]
B. Loosening the drain plug with a screwdriver
6 0
2 years ago
Read 2 more answers
Other questions:
  • Allows an administrator to query a dns database and find the host name associated with a specific ip address or
    15·1 answer
  • Which of the following goals is likely to require funding? Check all that apply.
    6·2 answers
  • 3. Find the product of (a² +3a+5) x (a+7)​
    7·1 answer
  • Please check my answer! (Java)
    7·1 answer
  • Tradegy deals with _____
    14·1 answer
  • Multiple Choice: We have been assigned the task of developing a software testing tool (tester) that can assess reachability of s
    11·1 answer
  • I need help picture above
    14·2 answers
  • Select the correct answer from each drop-down menu.
    7·1 answer
  • Use the ________ tag to configure a generic area on a web page that is embedded within a paragraph or other block display elemen
    12·1 answer
  • An operating system with _____ capabilities allows a user to run more than one program concurrently.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!