import random
random.seed()
MAXINT = 100
def get_even_rand():
x = random.randint(0, MAXINT//2)
yield x*2
>>> print get_even_rand().next()
56
>>> print get_even_rand().next()
62
>>> print get_even_rand().next()
94
>>> print get_even_rand().next()
90
>>> print get_even_rand().next()
16
>>> import random
>>>
>>> def g(start=1, end=1000000):
... n = random.randint(start, end - 1)
... return (n % 2 == 0 and n) or n + 1
...
>>> [g() for _ in range(10)]
[841196, 137368, 240392, 14588, 431038, 737926, 203080, 678028, 694386, 154716]
>>>
>>> [g(5, 20) for _ in range(10)]
[14, 10, 8, 8, 18, 8, 6, 14, 12, 12]
>>> [g(5, 20) for _ in range(10)]
[10, 16, 18, 6, 18, 8, 10, 8, 8, 14]
>>>
>>> [g(6, 20) for _ in range(10)]
[18, 6, 18, 6, 20, 8, 10, 16, 12, 16]
>>>