Home > other >  Python topic ah, quick save me
Python topic ah, quick save me

Time:11-02

The second question:
Defines a parameter variable length (variable) fun type of function, and pass in a list and dictionary, calculating the elements in the list and the multiplicative value values of the dictionary, and the output, calls the function fun, incoming list [1, 2, 3], the dictionary {' a ': 4,' b ': 5,' c ': 6}, the result of the multiplicative is: 720 ps: the concept of multiplicative: x, y, z is multiplicative x * y * z

CodePudding user response:

 the from functools import reduce 

Def fun nums (*) :
Return the reduce (lambda x, y, x * y, nums [0] + list (nums [1]. The values ()))


Deficiency in this fun function can only run the first incoming is list, the second is a dictionary
  • Related