Exemple #1
0
def test_fibo(benchmark):
    from fibo import fibo

    benchmark(fibo, 0, 1, 1000)

    assert fibo(5, 8, 5) == (55, 89, [5, 8, 13, 21, 34])
    assert fibo(55, 89, 5) == (610, 987, [55, 89, 144, 233, 377])
Exemple #2
0
    def test_more(self):
        assert_equal(fibo(10), 55)
        assert_equal(fibo(15), 610)


## Funcion 2
## Para un numero dado una funcion que imprima solo los numeros impares

## Funcion 3
# # Para un numero dado retorne el total de numeros menores a el divisibles por 3, 4 y 5
#
# func3(100) = {
#     3: 34
#     4: 25
#     5: 20
# }
def test_fibo_small_number():
    """Test cases with small-size numbers."""
    assert fibo(1) == 1
    assert fibo(2) == 1
    assert fibo(3) == 2
    assert fibo(4) == 3
    assert fibo(5) == 5
    assert fibo(6) == 8
    assert fibo(7) == 13
def test_fibo():
    assert fibo(0) == 0
    assert fibo(6) == 8
    assert fibo(2) == 1
    assert fibo(-1) == 1
    assert fibo(-6) == -8
 def test_edge_case(self):
     self.assertEqual(0, fibo(0))
     self.assertEqual(1, fibo(1))
 def test_nominal_case(self):
     self.assertEqual(8, fibo(6))
     self.assertEqual(55, fibo(10))
Exemple #7
0
def main():
    fibo.fibo(4000000000)
Exemple #8
0
from fibo import fibo
from NumToString import NumToString

x = 1

while x < 10:
    print(str(fibo(x)) + (' - ') + (NumToString(fibo(x))))
    x += 1
Exemple #9
0
def test_fibo2_shouldbe_1():
    assert 1 == fibo(2)
Exemple #10
0
def test_fibo():
    assert fibo(0) == 1
    assert fibo(2) == 2
    assert fibo(3) == 3
Exemple #11
0
import fibo
print fibo.fibo(38)
Exemple #12
0
from fibo import fibo
print fibo(40)
 def test_fibo_0(self):
     self.assertEqual(fibo.fibo(10, 20), None)
 def test_fibo_0(self):
     self.assertEqual(fibo.fibo(20, 10), None)
def test_fibo_big_number():
    """Test cases with big-size numbers."""
    assert fibo(30) == 832040
Exemple #16
0
def test_fibo3_shouldbe_2():
    assert 2 == fibo(3)
Exemple #17
0
def test_fibo1_shouldbe_1():
    assert 1 == fibo(1)
Exemple #18
0
import fibo

fibo.fibo(500)

print fibo.fibo2(500)
Exemple #19
0
import fibo

x = int(input())
fibo.fibo(x)
fibo.fibo_numbers(x)
Exemple #20
0
'''Runs a the fibo.py module for a specific use case'''

import fibo

print(fibo.fibo(24))
Exemple #21
0
non_null = string1 or string2 or string3
print(non_null) # 'Trondheim'
# assignment cannot occur inside expressions
print((1, 2, 3)              < (1, 2, 4)) # all 7 will print True
print([1, 2, 3]              < [1, 2, 4])
print('ABC' < 'C' < 'Pascal' < 'Python')
print((1, 2, 3, 4)           < (1, 2, 4))
print((1, 2)                 < (1, 2, -1))
print((1, 2, 3)             == (1.0, 2.0, 3.0))
print((1, 2, ('aa', 'ab'))   < (1, 2, ('abc', 'a'), 4))

#----------------------------------------------------------------------------------------------------------------------------------------

# Section 6: Modules
import fibo # customarily at the beginning
fibo.fibo(1000) # 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987
print(fibo.fibo2(100)) # [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
print(fibo.__name__) # 'fibo'
fibo = fibo.fibo # assign a local name
fibo(500) # 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377
del fibo
from fibo import fibo, fibo2 # directly imports without having to assign local name
fibo(500) # 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377
import sys, builtins
print(dir(fibo))
print(dir(sys))
print(dir(builtins))

#----------------------------------------------------------------------------------------------------------------------------------------

# Section 7: Input and Output
Exemple #22
0
 def test_first3(self):
     assert_equal(fibo(1), 1)
     assert_equal(fibo(2), 1)
     assert fibo(3) == 2
     assert fibo(4) == 3
from fibo import fibo

print(fibo(10))
Exemple #24
0
import fibo
print fibo.fibo(40)