Home > other >  For help
For help

Time:10-29

(5) the application of the tuple
Problem description: write a program, generated by the generator derivated tuple containing n integers elements, each element value is not greater than m, and filter out the even integers, and the output,

CodePudding user response:

 import random 

N, m=10, 40
Print (tuple (filter (lambda x: x %==1 and 2 x & lt;=m, the random sample (range (100), n))))

CodePudding user response:

Import the random
N, m=map (int, input (). The split ())
A=(random randrange (0, m, 2) for I in range (n)) # generator here
Print (a tuple) (a)

CodePudding user response:

Wrong, is to generate even above,
Odd number is
Import the random
N, m=map (int, input (). The split ())
A=(random randrange (1 m, 2) for I in range (n)) # generator here
Print (a tuple) (a)
  • Related