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
Assume that a file contains students' ids, full names, and their scores (Assignments grade, quizzes grade,
elixir [45]

Answer:

اope its heمحبعم

Explanation:

3 0
3 years ago
How does social media affect communication skills negatively?
AnnZ [28]
How social media affects communication negatively
The following are the ways in which social media affects communication negatively
1)Internet-the internet has made it easier to communicate too much use can result to addiction . Internet addiction make most of youths skip vital activities like homework,social activities among others. 
2)Text messages-The use of instant messaging has become popular especially among teens.Use of symbols such as emojis and abbreviated words has made many people to become too cusual on language use.
The use of fewer syllables and shorter words is likely to make teens leave out important aspects of verbal communication and may lead to misinterpretation of messages.
3)Dialogue-  Internet communication mostly takes place in the written form as opposed to the spoken form. Teens primarily communicate through textual posts,emails e.t.c all of which are in the written form.
Since written communication typically occurs in form of monologue, teens addicted to the internet may find it difficult to engage in dialogue a feature of verbal communication.For instance they may find it difficult to effectively use aspects of verbal communication such as tonal variation turn taking and speed.
<span>4)Informal language- </span>The use  of informal language is a salient feature of internet communication.This has a negative effect on teens mastery of formal language.
Internet language has features of informal language such as short turn taking, exclusion of auxiliary verbs and pronouns.
This could be due to the reason that teens put more emphasis on speed and efficiency at the expense of grammar.
5)Listening skills-
listening skills is an important aspect of verb communication and effective listening enhances communication.
Effective listening entails being information literate which is the ability to identify which information is needed when it is needed,where to find it, and effectively using it.
4 0
3 years ago
A product/process is referred to as a key Technology during which of the
Rufina [12.5K]

The correct answer is D. Mature Phase

Explanation:

Most products go through four different phases, this includes the emerging phase, the growing phase, the mature phase, and the decline phase. In each of these phases, the product has a different impact on the general market.

In the case of the mature phase, this occurs once the product is established in the market, which means the product is known by many people and is considered as key or necessary. For example, nowadays smartphones are in the mature phase because these are an important part of the market or are key. Moreover, this phase occurs after the product grows in the market, and before it declines. Thus, a product is a key technology during the mature phase.

5 0
2 years ago
The text help readers understand the relationship between gender and sports?THESE PUMPKINS SURE CAN KICK!
AleksAgata [21]

Answer:

What's the question?????I don't understand

4 0
3 years ago
write pseudocode to represent the logic of a program that allows the user to enter two values. The program outputs the sum of an
valkas [14]

The pseudocode representing the above described logic of a program is:

start

input num1

input  num2

set product  =  num1*num2

output product

stop

See the related flow chart is attached.

<h3>What is a pseudocode?</h3>

Pseudocode is a precise yet comprehensible explanation of what a computer program or algorithm must perform, written in normal language rather than programming language.

Pseudocode is occasionally used as a detailed phase in the development of a program.

Learn more about Pseudocode:
brainly.com/question/24953880
#SPJ1

4 0
2 years ago
Other questions:
  • In Linux, the most popular remote access tool is OpenSSH. Which software performs the same remote command line (CLI) access from
    7·1 answer
  • The computers connected to the main server are called ______.
    14·2 answers
  • How do u determine the voltage across diode
    15·1 answer
  • Java provides a(n) ____ class, which contains many useful methods for manipulating arrays.
    5·1 answer
  • Classes cannot:
    10·1 answer
  • What makes the huns a formidable force for the roman empire?
    5·1 answer
  • Grab the stniop or they will dissapear
    12·1 answer
  • Difference between switch and switch lite
    10·1 answer
  • it is good to know and use the npsd framework while solution envisioning as part of the value discovery cycle. What is NPSD?
    10·1 answer
  • 4. Ernesto works in a small office with five other people. What are two possible connection
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!