You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Status/Day_18.md
+19-15Lines changed: 19 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,18 +21,18 @@ print random.choice([i for i in range(11) if i%2==0])
21
21
----------------
22
22
**My Solution: Python 3**
23
23
```python
24
-
#to be written
25
-
24
+
import random
25
+
resp = [i for i inrange(2,11,2)]
26
+
print(random.choice(resp))
26
27
```
27
28
---------------------
28
29
29
30
30
-
31
31
# Question 71
32
32
33
33
### **Question**
34
34
35
-
>***Please write a program to output a random number, which is divisible by 5 and 7, between 0 and 10 inclusive using random module and list comprehension.***
35
+
>***Please write a program to output a random number, which is divisible by 5 and 7, between 10 and 150 inclusive using random module and list comprehension.***
36
36
37
37
----------------------
38
38
### Hints
@@ -43,13 +43,14 @@ print random.choice([i for i in range(11) if i%2==0])
43
43
**Main author's Solution: Python 2**
44
44
```python
45
45
import random
46
-
print random.choice([i for i inrange(201) if i%5==0and i%7==0])
46
+
print random.choice([i for i inrange(10,151) if i%5==0and i%7==0])
47
47
```
48
48
----------------
49
49
**My Solution: Python 3**
50
50
```python
51
-
#to be written
52
-
51
+
import random
52
+
resp = [i for i inrange(10,151) if i %35==0 ]
53
+
print(random.choice(resp))
53
54
```
54
55
---------------------
55
56
@@ -69,14 +70,14 @@ print random.choice([i for i in range(201) if i%5==0 and i%7==0])
69
70
```python
70
71
71
72
import random
72
-
print random.sample(range(100), 5)
73
-
73
+
print random.sample(range(100,201), 5)
74
74
```
75
75
----------------
76
76
**My Solution: Python 3**
77
77
```python
78
-
#to be written
79
-
78
+
import random
79
+
resp = random.sample(range(100,201),5)
80
+
print(resp)
80
81
```
81
82
---------------------
82
83
@@ -103,8 +104,9 @@ print random.sample([i for i in range(100,201) if i%2==0], 5)
103
104
----------------
104
105
**My Solution: Python 3**
105
106
```python
106
-
#to be written
107
-
107
+
import random
108
+
resp = random.sample(range(100,201,2),5)
109
+
print(resp)
108
110
```
109
111
---------------------
110
112
@@ -132,8 +134,10 @@ print random.sample([i for i in range(1,1001) if i%5==0 and i%7==0], 5)
0 commit comments