Output random number between 30-35 using Random.seed(), 'for' and multiplication in Python
<p>I am new to programming. I had an assignment to write a code that will output a random number between 30 and 35. This code needs to use <code>random.seed()</code>, a FOR statement and a multiplication. I understand the <code>random.seed([x])</code> generates an initial value that could be used in the proceeding section of the code. However, I cant figure out how to proceed after obtaining the value of the random:</p>

<pre><code>import random
random.seed(70)
print(random.random()) # This returns a value of 0.909769237923872
</code></pre>

<p>How do i use this value to generate a random value between 30 and 35?</p>

<p>Note: Without the specific directions above, I have been able to write two codes that functions as desired, so please I am not looking for alternative ways of writing the code.  </p>

<p>Here is another way to do it:</p>

<pre><code>import random
#initial random seed based on current system time
#https://docs.python.org/2/library/random.html#random.seed

random.seed(9) #We set this so random is repeatable in testing
random_range = [30, 31, 32, 33, 34, 35]

while True:
     num = int(round(random.random(),1)*100)
     if num in random_range:
        print num
        break
</code></pre>

<p>The seed is set to 9, so if you run this over and over again you will get the same random value...thus setting a seed.  Note that multiple iterations are run because it was mentioned to not use a choice like random.choice  </p>

python python-3.x random