-
Notifications
You must be signed in to change notification settings - Fork 0
/
desafio.py
53 lines (29 loc) · 1.09 KB
/
desafio.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
"""
Coding Dojo realizado no Instituto Federal de Pernambuco (IFPE) no dia 26/03/2011.
Problema:
Sampling
Link: http://rubyquiz.com/quiz39.html
"""
import unittest
import random
class AmostrasTest(unittest.TestCase):
def testQuantidadeTres(self):
self.assertEquals(len(amostra(3,10)), 3)
def testAmostrasDez(self):
self.assertTrue(max(amostra(3,10)) <= 10)
def testQuantidadeQuatro(self):
self.assertEquals(len(amostra(4,15)), 4)
def testAmostraTres(self):
self.assertTrue( max(amostra(4, 2)) <= 2)
def testAmostraZeroZero(self):
self.assertEquals( amostra(0, 0), [])
def testAmostraZeroDez(self):
self.assertEquals( amostra(0, 10), [])
def testAmostraDezZero(self):
self.assertEquals( len( amostra(10, 0) ), 10)
def testAmostraInRange(self):
self.assertTrue(len([ i for i in amostra(3,10) \
if i in range(10)]) > 0)
amostra = lambda quantidade,limite:[ random.randint(0,limite) for i in range(quantidade) ]
if __name__ == '__main__':
unittest.main()