Write a Python function fun3(e) to update a list of numbers e such that the first and last elements have been exchanged. The function needs to also return multiplication of elements of e. You should assume that the list e has at least 2 elements.Example:

>>>lst = [4, 1, 2, -1]

>>>fun3(list)

-8

Answers

Answer 1
Answer:

Answer:

Here is code in Python:

#function to swap first and last element of the list

#and calculate product of all elements of list

def fun3(e):

   product = 1

   temp = e[0]

   e[0] = e[-1]

   e[-1] = temp

   for a in e:

       product *= a

   return product

#create a list

inp_lst = [4, 1, 2, -1]

#call the fun3() with parameter inp_lst

print("product of all elements of list is: ",fun3(inp_lst))

#print the list after swapping

print("list after swapping first and last element: ",inp_lst)

Explanation:

Create a list "inp_lst" and initialize it with [4,1,2,-1]. In the function fun3() pass a list parameter "e". create a variable "product" to calculate the product of all elements.Also create a temporary variable to swap the first and last element of the list.

Output:

product of all elements of list is:  -8                                                                                        

list after swaping first and last element:  [-1, 1, 2, 4]


Related Questions

- If we place records from different tables in adjacent____________, it would increase efficiency of a database.Physical locationTableFormempty location
When do you need to apply for program completion andreview?a. 1-2 semesters before program completionb. one month before program completionc. a couple of weeks before program completiond.Never, you don’t need to complete any paperwork to prepare for program completion
Jenae helps maintain her school web site and needs to create a web site poll for students. Which tool will she use?
What is the speedup of going from a 1-issue processor to a 2-issue processor? use your code from part a for both 1-issue and 2-issue, and assume that 1,000,000 iterations of the loop are executed. as in part b, assume that the processor has perfect branch predictions, and that a 2-issue processor can fetch any two instructions in the same cycle?
Which of the following tools is specifically designed to test the dc voltage on a hard disk drive

Please explain in 2-4 sentences why diligence is needed and is important in building a pc. Thank you

Answers

Diligence is required for a variety of reasons. I’m going to give you two. Remember, when you’re building a PC, you’re handling hundreds of dollars worth of hardware that are also very fragile (a cord could make all the difference). Two, you need to know and understand how to make a PC. If you have no idea how to build one, RESEARCH FIRST.

Hope this helps.

What is not an operating system

Answers

The answer is MS-Word

What did networks of the 1960s use to connect computers?telephone lines

wireless technology

television signals

telegraph cables

Answers

Answer:

Explanation:

Telephone lines

You are troubleshooting network connectivity issues on a workstation. Which command would you use to request new IP configuration information from a DHCP server?

Answers

Answer:

ipconfig / release command will be used to request new IP configuration information from a DHCP server

Explanation:

The ipconfig /release sends a DHCP release notification to the client so that the client immediately releases the lease henceforth updating the server's status information . This command also mark the old client's id as being available. Thus, the command ipconfig /renew then request a new IP address.

Factory Design Pattern Assignment This assignment will give you practice in using the Factory/Abstract Factory Design Pattern. You are going to create a Terraforming program. What does terraform mean

Answers

Answer:

Terraform is an open-source infrastructure as code software tool that enables you to safely and predictably create, change, and improve infrastructure.

Direct current is produced by an electric motor. an armature. a solenoid. a battery.

Answers

Answer:

D

Explanation:

I just did it

I believe D or A would be the answer. D for sure is correct