It's a question from Python def

Asked 2 years ago, Updated 2 years ago, 16 views

I'm studying Python, but I don't understand it well, so I'm asking you a question.

It's my first time asking this question...I don't even know if this is the right form.

Def understood,

result = add_mul('add', 1,2,3,4,5)
result = add_mul('mil', 1,2,3,4,5)

I don't know how to multiply and add here

I think multiplication is

(Result * 1) + (result * 2) + .....

I think it's going to be like this...

I don't know why the numbers in the tuple are multiplied at once and multiplied by result = 1.

python

2022-09-21 17:55

1 Answers

The reduce is implemented using for as shown below. Think of the multiplication pie symbol of the sequence (the sum is sigma). An example of a code in question is 5!

In [7]: result = 1                                                                                                                                                                                                                                                              

In [8]: (((result * 1) * 2) * 3) * 4) * 5) # for.                                                                                                                                                                                                                                    
Out[8]: 120


2022-09-21 17:55

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.