We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5eb45d4 commit c9fea54Copy full SHA for c9fea54
interview-cake/p37.py
@@ -3,22 +3,25 @@
3
generates a random integer from 1 to 5.
4
"""
5
import numpy as np
6
+
7
8
def rand7():
9
return int(np.random.random()*7+1)
10
11
12
def rand5():
13
result = 7
14
while result > 5:
15
result = rand7()
16
return result
17
18
19
def rand5_v1():
20
stop = False
21
- while stop == False:
22
+ while stop is False:
23
num = rand7()
24
if num <= 5:
- stop = True
25
return num
26
27
# Test rand7():
interview-cake/p38.py
@@ -0,0 +1,5 @@
1
+"""
2
+You have a function rand5() that generates a random integer from 1 to 5. Use it to write a function rand7() that
+generates a random integer from 1 to 7.
0 commit comments