Esempio n. 1
0
 def main(local_argv):
     n=local_argv
     try:
         type(n)==int
     except ValueError:
             print("must be integer")
     
     print(sequences.fibonacci(n)[-1])
     return(sequences.fibonacci(n)[-1])

     """Main function
Esempio n. 2
0
def test3():
    """
    test if fibonacci function can validate the input  
    """
    t = -1
    assert sequences.fibonacci(t) == False
    t = 2.2
    assert sequences.fibonacci(t) == False
    t = 0
    assert sequences.fibonacci(t) == False

    print("input validation success")
    return
Esempio n. 3
0
 def test_fibonacci(self):
     fib_gen = sequences.fibonacci()
     fib_true = [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377,
         610, 987, 1597, 2584, 4181, 6765, 10946, 17711, 28657, 46368,
         75025, 121393, 196418, 317811, 514229, 832040, 1346269, 2178309]
     for ft in fib_true:
         self.assertEqual(next(fib_gen), ft)
Esempio n. 4
0
def main(argv):
    if len(argv) == 2:
        valueList = sequences.fibonacci(argv[1])
        print(valueList[len(valueList) - 1])
    else:
        print(
            "That is not a valid number of inputs.  Input an integer as an argument."
        )
Esempio n. 5
0
def main(local_argv):
    try:
        x = int(local_argv[1])
        fib_result = sequences.fibonacci(x)
        print(fib_result[-1])
        return (fib_result[-1])
    except Exception:
        print("invalid input, input must be a positive integer")
Esempio n. 6
0
def test2():
    """
    out the fibonacci list for a certain valid number and verify the last number of the list
    """
    retList = sequences.fibonacci(8)
    print(retList[7])
    assert retList[7] == 21
    print("test2 success")
    return
def test_first_five():
    """Verify the first five Fibonacci numbers.
    
    Note that the equality test for the assert here only works because the
    integers inside the list support exact equality. For floating point
    numbers (with decimals), you will need to use the approximate equality
    functions in the nose.tools or numpy.testing modules.
    """
    assert sequences.fibonacci(5) == [1, 1, 2, 3, 5]
Esempio n. 8
0
def main(argv):
    """Takes the Python program fibonacci.py and runs it in a new module. This module will not print an entire list of the Fibonacci sequence, and will instead only return 
    the nth number as an integer."""
    n = int(argv[1])
    if n < 0:
        raise ValueError
    else:
        x = sequences.fibonacci(n)
        print(
            x[len(x) - 1]
        )  #Shoutout to Trevor for reminding me that the len function exists
Esempio n. 9
0
def main(local_argv):
    """
    local_argv is the argument list, progrom name is first arugment
    this function prints the fibonacci list calcuated by the command line argument n 
    
    """

    if len(local_argv) != 2:
        print("must add one and only one command argument ")
        return

    argument_n = int(
        local_argv[1])  #remember, this is the 2nd argument in command line
    retList = sequences.fibonacci(argument_n)
    #print("fibonacci("+str(argument_n)+")=")
    returnStr = ''
    for item in retList:
        returnStr += str(item) + ' '
    print(returnStr)
    return retList
Esempio n. 10
0
def test1():
    """
    test if the return value of fiboncci  function match the expected result
    expectedList: the expected list of fiboncci function
    retList: the listed returned by function function
    """

    expectedList = [1, 1, 2, 3, 5]
    retList = sequences.fibonacci(5)

    assert type(retList) == list

    print(retList)

    assert len(retList) == len(expectedList)

    assert expectedList == retList
    print("test1 success")

    return
Esempio n. 11
0
 def test_fibonacci_fourty(self):
     """Test that the function returns the correct valule for the 40th term in the sequence."""
     self.assertEqual(sequences.fibonacci(40), 102334155)
Esempio n. 12
0
 def test_fibonacci_thirty(self):
     """Test that the function returns the correct valule for the 30th term in the sequence."""
     self.assertEqual(sequences.fibonacci(30), 832040)
Esempio n. 13
0
 def test_fibonacci_twenty(self):
     """Test that the function returns the correct valule for the 20th term in the sequence."""
     self.assertEqual(sequences.fibonacci(20), 6765)
Esempio n. 14
0
 def test_fibonacci_two(self):
     """Test that the generator yields 1 as the 2nd term in the sequence."""
     self.assertEqual(sequences.fibonacci(2), 1)
Esempio n. 15
0
def test_3():
      my_list=sequences.fibonacci(10)
      result=my_list[9]
      correct=55
      assert result == correct
Esempio n. 16
0
def main():
    predicate = lambda x: x < 4000000
    domain = takewhile(predicate, even(fibonacci()))
    return sum(domain)
Esempio n. 17
0
 def test_fibonacci():
     result=sequences.fibonacci(5)
     correct=[1,1,2,3,5]
     assert result==correct
Esempio n. 18
0
 def test_fibonacci():
     result=sequences.fibonacci(12)
     correct=[1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144]
     assert result==correct
Esempio n. 19
0
def main(argv):
    print( sequences.fibonacci(int(argv[1]))[int(int(argv[1])-1)])
Esempio n. 20
0
def main(argv):
    n = int(argv[1])
    print(sequences.fibonacci(n)[-1])
Esempio n. 21
0
def main(argv):
    print(sq.fibonacci(int(argv[1]))[int(int(argv[1]) - 1)])
Esempio n. 22
0
import sequences

print('Fibonacci\n')
for x in range(10):
    print(x, sequences.fibonacci(x))

print("Squares\n")
for x in range(10):
    print(x, sequences.squares(x))

print("Triangles\n")
for x in range(10):
    print(x, sequences.triangles(x))


Esempio n. 23
0
def main(local_argv):
    import sequences
    print(sequences.fibonacci(int(local_argv[1]))[-1])
Esempio n. 24
0
 def test_fibonacci_100(self):
     """Test that the function returns the correct valule for the 100th term in the sequence."""
     self.assertEqual(sequences.fibonacci(100), 354224848179261915075)
Esempio n. 25
0
 def test_fibonacci_300(self):
     """Test that the function returns the correct valule for the 300th term in the sequence."""
     self.assertEqual(sequences.fibonacci(300), 222232244629420445529739893461909967206666939096499764990979600)
Esempio n. 26
0
def main(argv):
    a = fibonacci(int(argv[1]))
    print(a[-1])
Esempio n. 27
0
def test_2():
      my_list=sequences.fibonacci(2)
      result=my_list[1]
      correct=1
      assert result == correct
Esempio n. 28
0
 def test_fibonacci_zero(self):
     """Test that the generator yields zero as the zero-th term in the sequence."""
     self.assertEqual(sequences.fibonacci(0), 0)
Esempio n. 29
0
def test_1():
     my_list=sequences.fibonacci(1)
     result=my_list[0]
     correct=1
     assert result == correct
Esempio n. 30
0
 def test_fibonacci_one(self):
     """Test that the generator yields 1 as the 1st term in the sequence."""
     self.assertEqual(sequences.fibonacci(1), 1)