Sort by

recency

|

484 Discussions

|

  • + 0 comments
    cube = lambda x:x**3 # complete the lambda function 
    
    def fibonacci(n):
        # return a list of fibonacci numbers
        if n == 0:
            return []
        elif n == 1:
            return [0]
        else:
            fib = [0, 1]
            for i in range(2, n):
                fib.append(fib[i - 1] + fib[i - 2])
            return fib 
    
  • + 0 comments
    cube = lambda x: x ** 3
    
    def fibonacci(n):
        fib = [0, 1]  
        for _ in range(2, n):
            fib.append(fib[-1] + fib[-2])  
        return fib[:n]  
    
    if __name__ == '__main__':
        n = int(input())
        print(list(map(cube, fibonacci(n))))
    
  • + 0 comments
    1. In the program, how it works, you should reject the page: *cube = lambda x: x3 def fibonacci(n): listfibonacci = [0, 1] for i in range(n): x = listfibonacci[-2] y = x + listfibonacci[-1] listfibonacci.append(y) return listfibonacci *

    if name == 'main': n = int(input()) print(list(map(cube, fibonacci(n))))**

  • + 0 comments
    cube = lambda x: pow(x, 3)
    
    def fibonacci(n):
        if n == 0:
            return []
        elif n == 1:
            return [0]
        elif n == 2:
            return [0, 1]
        else:
            fib_seq = [0, 1]
            for i in range(2, n):
                fib_seq.append(fib_seq[-1] + fib_seq[-2])
            return fib_seq
    
    if __name__ == '__main__':
        n = int(input())
        print(list(map(cube, fibonacci(n))))
    
  • + 0 comments

    Here's my code:

    cube = lambda x: x**3
    
    def fibonacci(n):
        res = [0, 1]
        for i in range(2, n):
            res.append(res[i - 1] + res[i - 2])
        return res[:n]