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 with total change amount as an integer input and output the change using the fewest coins, one coin type per lin
notka56 [123]

Answer:

Explanationoojhh

8 0
3 years ago
In Fantasy Football, participants compete against one another by choosing certain players from different NFL teams that they thi
PolarNik [594]

This process that would be considered in the above scenario is Data mining.

<h3>What is data mining?</h3>

Data mining is known to be the act or method of knowing more about data via;

  • Leaning raw data.
  • Finding patterns.
  • Forming models.
  • Testing those models.

Note that  It is a method that uses statistics, machine learning, and database systems and it will be good tool to be used in the scenario above.

Learn more about Data mining from

brainly.com/question/14776357

4 0
1 year ago
What is a defult? pls help if you wouldn't mind
Sunny_sXe [5.5K]

Answer:

a beginner or a novice

Explanation:

5 0
2 years ago
Read 2 more answers
This is used in a program to mark the beginning or ending of a statement, or separate items in a list:_____
hammer [34]

Answer:

B) Punctuation

Explanation:

Punctuation are greatly used in different programming languages for different purposes. In the Java, C++ and C# Programming languages for example, two popular punctuation marks are the comma (,) and semi-colon (;). The comma is used for separating elements of a list and arrays, while the semi-colon indicates end of an executable statement or line of code. Other popular punctuation marks used in programming are periods (dot), question marks, parenthesis angle brackets and braces each implementing a specific grammatical syntax in the language.

5 0
2 years ago
Hexadecimal to denary gcse method
Anuta_ua [19.1K]

There are two ways to convert from hexadecimal to denary gcse method. They are:

  • Conversion from hex to denary via binary.
  • The use of base 16 place-value columns.

<h3>How is the conversion done?</h3>

In Conversion from hex to denary via binary:

One has to Separate the hex digits to be able to know or find its equivalent in binary, and then the person will then put them back together.

Example - Find out the denary value of hex value 2D.

It will be:

2 = 0010

D = 1101

Put them them together and then you will have:

00101101

Which is known to be:

0 *128 + 0 * 64 + 1 *32 + 0 * 16 + 1 *8 + 1 *4 + 0 *2 + 1 *1

= 45 in denary form.

Learn more about hexadecimal from

brainly.com/question/11109762

#SPJ1

3 0
2 years ago
Other questions:
  • What is the opportunity cost of computers when moving from point A to point B? -15 DVDs b. What is the opportunity cost of compu
    13·1 answer
  • Emotional intelligence is a new term to describe personal traits ?
    12·1 answer
  • Whitch action should a user take to ensure that formatting is applied to a row? A. use the ctrl+a keys. B. highlight the whole t
    11·1 answer
  • Grandma Ester normally gives you hugs for your birthday - one for every year old you are. When you turned 15, she squished you w
    8·1 answer
  • before Katie turns in the paper she typed she wants a peer to review it and give her feedback Katie uses her all in one printer
    10·1 answer
  • Question 3
    13·1 answer
  • Xavier wants to print the slides of his PowerPoint presentation to practice and make notes but doesn't want to use too much ink
    5·2 answers
  • Select the correct answer from each drop-down menu.
    5·2 answers
  • What is the meaning of url <br>​
    7·1 answer
  • How is the architecture converted into software code? Elaborate the steps its passes through with help of examples / Diagram.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!