# 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

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

What is the output, if userVal is 5? int x; x = 100; if (userVal != 0) { int tmpVal; tmpVal = x / userVal; System.out.print(tmpVal); }

The output is 20

Explanation:

This line divides the value of x by userVal

tmpVal = x / userVal;

i.e.

tmpVal = 100/5

tmpVal = 20

This line then prints the value of tmpVal

System.out.print(tmpVal);

i.e 20

Hence, The output is 20

The provided Java code checks if the variable userVal does not equal 0. As this is the case when userVal is 5, another variable tmpVal is assigned the value of another variable x (which is 100) divided by userVal. Hence, the output of the code would be 20.

### Explanation:

In the given piece of code, the variable userVal is assigned a value of 5. The program also contains a variable x which is assigned a value of 100. An if statement checks whether userVal does not equal 0 - since 5 != 0, the condition is true. A new variable tmpVal is then declared and assigned the value of x divided by userVal, so tmpVal equals 100 / 5, which is 20. So, the output of this code when userVal is 5 would be 20.

brainly.com/question/34106786

#SPJ3

Which of these is outside the scope of an art director's responsibility?

Establishing Tight deadlines for a rush job.

Explanation:

The time taken for a rush job has nothing to do with the art director because it has nothing to do with art. Also rush jobs already call for tight deadlines so technically the deadline is already established.

Answer: cropping a photograph for the sake of space

Explanation: edge 22

What are the different options in a page layout feature ? Select three options

Half Center Right Left, theres four

Explanation:

Which of the following tools is specifically designed to test the dc voltage on a hard disk drive

A power supply tester is specifically designed to test DC voltage on most connectors coming from a PC power supply. A multimeter measures electrical properties such as voltage, amps, and resistance.

Population Growth The world population reached 7 billion people on October 21, 2011, and was growing at the rate of 1.1% each year. Assuming that the population
continues to grow at the same rate, approximately when will the population reach
8 billion? using python