美文网首页
Python test

Python test

作者: sszhang | 来源:发表于2018-06-25 14:23 被阅读0次

    (Please answer all questions below in 25 minutes )
    Q1:Fibonacci sequence can be expressed as: 1, 1, 2, 3, 5, 8, 13, 21, 35…Write a function of fib(n) and return the nth number in the fibonacci number (n starts from 0).
    ( hints: using recursive function )

    Q2: a = [1, 2, 3, 4], b= [11,22,33,44] using map function to get list the c = [12, 24, 36,48], where 12 = 1+11, 24 = 22+2, 26 =33+3, 48= 44+4.
    (hints: map and lambda function)

    Q3: There are two lists below:
    names = ['Jack', 'Tom', 'Peter', 'David'],
    scores = [89, 78, 92, 86]
    The items in list names and list scores are responding to each other.Writing a dictionary with list names as the keys, and list scores as the values.
    (hints: there are many methods in creating a dictionary, could use for or zip function here)

    Q4: There are two lists: a = [1,2,3,4], and b = [11,12,13,14]. Do some operations thus making a = [1,2,3], b =[11,4,12,13,14]
    (hints: basic list operations)

    Q5: Assuming there is a goal(a, b) function which returns a list [a, b, a+b]. Please try to insert the goal(a, b) function into the class Object below, thus that the self.items be the return value of the original goals functions.
    (hints: methods in defining a class)

    class Object:
        def __init__(self):
            self.items = []
    
        def goals(self, a, b):
            ....
     
    

    相关文章

      网友评论

          本文标题:Python test

          本文链接:https://www.haomeiwen.com/subject/qvcyyftx.html