.py
file. Be sure your name and assignment description is
on your file.
i
and
j
at the end of each iteration of the loop, and then
state what gets printed by the call to the function.
def func_c(): i=0 j=0 while (i < 16): if i > 3: i += 2 if i < 10: j += i else: j -= 1 i += 1 return j print(func_c())
To generate random numbers, we will use the random
module from Python's standard library. To use this module in your
program, you must add the following statement at the top of your
program:
import randomFrom the
random
module, we will use the
randint
function. This function takes two parameters
that represent the range for which we want our random number and
returns an integer within that range. For
example, calling the randint
function as in random.randint(1,10)
will give us some number
in the range of 1 to 10 (with 1 and 10 included in the range). You
will need to generate two random numbers this way in your function.
(See Section 8.2.1 of your text for more details of generating random
numbers.)