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
Nuetrik [128]
2 years ago
8

Given two lists of integers, write a function multLists(list1, list2) that multiplies each value of the list1 by the values of l

ist2 and returns list1 with it's updated values. The lists will be obtained for you, just write the function and print the result.
Computers and Technology
1 answer:
Fynjy0 [20]2 years ago
3 0

Answer:

FIRST SOLUTION

def multLists(list1,list2):

   for i in range(len(list1)):

       list1.append(list1[i]*list2[i])

   return list1

SECOND SOLUTION

def multLists(list1,list2):

   newlist = [ ]

   for i in range(len(list1)):

       newlist.append(list1[i]*list2[i])

   return newlist

Explanation:

First we define the function and call it MultLists. Then using a for statement, we loop through the list the number of times that is equivalent to the length of the list1. In the first solution, we append the element-wise multiplication in the two list and append this to list1. The return of the first solution, is list1 which contains list1 in addition to the product of the elements from list1 and list2

In the second solution, we create a new list, and using the append function, we populate it with the values of the element-wise multiplication from the two lists. The return of the second solution, is a new containing only to the product of the elements from list1 and list2

You might be interested in
Write a do-while loop that continues to prompt a user to enter a number less than 100, until the entered number is actually less
nataly862011 [7]

Complete Question:

Write a do-while loop that continues to prompt a user to enter a number less than 100, until the entered number is actually less than 100. End each prompt with a newline. Ex: For the user input 123, 395, 25, the expected output is:

Enter a number (<100):

Enter a number (<100):

Enter a number (<100):

Your number < 100 is: 25

Answer:

import java.util.Scanner;

public class num8 {

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       int n;

       do{

           System.out.println("Enter a number (<100):");

           n= in.nextInt();

       }while(n>100);

       System.out.println("Your number < 100 is: "+n);

   }

}

Explanation:

Using Java programming language

Import the scanner class to receive user input

create an int variable (n) to hold the entered value

create a do while loop that continuously prompts the user to enter a number less than 100

the condition is while(n>100) It should continue the loop (prompting the user) until a number less than 100 is entered.

4 0
2 years ago
Read 2 more answers
The factor that has the greatest impact on your credot score is
Sav [38]

Your payment history. While other factors can effect your credit score, the most important factor is your payment history, as it shows those creditors that you are able and willing to repay your debts.

5 0
3 years ago
gven an IP address and mask of 192.168.12.0/24, design an IP addressing scheme that satisfies the following requirements. Subnet
Reika [66]
Uh 69 +23= 92
Hope this helps :)
8 0
3 years ago
What characters are in Tekken 3
MrMuchimi

Answer:Tekken 3 features a largely new cast of characters, including the debut of several now-staple characters such as Jin Kazama, Ling Xiaoyu, Bryan Fury, Eddy Gordo and Hwoarang, with a total of twenty-three characters.

Explanation: I feel like the answer is pretty strait forward.

6 0
3 years ago
What is your opinion about Sophia, just a robot or human robot (explain your answer<br> with merits
Ray Of Light [21]
Who’s Sophia and pls give more context
3 0
2 years ago
Read 2 more answers
Other questions:
  • Access controls are enforced automatically in FMS service routines that access and manipulate files and directories.
    9·1 answer
  • Which functions are performed by server-side code??​
    10·1 answer
  • Universal Containers is setting up an external Business Intelligence (BI) system and wants to extract 1,000,000 Contact records.
    11·1 answer
  • Given half a chance other people at work will take advantage of you
    11·1 answer
  • Write a class called Course that represents a course taken at a school. Represent each student using the modified Student class
    6·1 answer
  • Varun wants to start his own business. Suggest him at least four functions of an entrepreneur.
    8·2 answers
  • Match the metric units with these measurements
    8·1 answer
  • If Word finds a potential error in a document, a red, green, or blue wavy underline flags the problem.
    14·1 answer
  • , 13 dB correspond to a power ratio of ....?
    14·1 answer
  • Why is distance learning better
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!