• Python question of the day

    Which line of code should replace '# Replace this line' in the following code snippet to get the result: 7
    def f1(a=1,b=2,c=3): return a+b+c
    v = {"a":6, "c":-1}
    # Replace this line
     print(f1(v))
     print(f1(*v))
     print(f1(**v))
     print(f1(v{}))
    Explanation:
    The ** operator unpacks the key-value pairs in the dic- tionary and matches those with the keyword arguments. As the second keyword argument b is not declared in the dictionary, it is initialized to its default value.


    Top 100 python interview questions:


datai analytics