Home / CSE MCQs / Python MCQs :: Python Argument Passing, and Recursion

CSE MCQs :: Python MCQs

  1. How are keyword arguments specified in the function heading?
  2. A.
    one star followed by a valid identifier
    B.
    one underscore followed by a valid identifier
    C.
    two stars followed by a valid identifier
    D.
    two underscores followed by a valid identifier

    View Answer

    Workspace

    Discuss Discuss in Forum


  3. How many keyword arguments can be passed to a function in a single function call?
  4. A.
    zero
    B.
    one
    C.
    zero or more
    D.
    one or more

    View Answer

    Workspace

    Discuss Discuss in Forum


  5. Which module in the python standard library parses options received from the command line?
  6. A.
    getopt
    B.
    os
    C.
    getarg
    D.
    main

    View Answer

    Workspace

    Discuss Discuss in Forum


  7. What is the type of sys.argv?
  8. A.
    set
    B.
    list
    C.
    tuple
    D.
    string

    View Answer

    Workspace

    Discuss Discuss in Forum


  9. What is the output of the code shown below?

    def f1():
        x=100
        print(x)
    x=+1
    f1()
  10. A.
    Error
    B.
    100
    C.
    101
    D.
    99

    View Answer

    Workspace

    Discuss Discuss in Forum


  11. On assigning a value to a variable inside a function, it automatically becomes a global variable. State whether true or false.
  12. A.
    True
    B.
    False
    C.
    Error
    D.
    Not mentioned

    View Answer

    Workspace

    Discuss Discuss in Forum


  13. What happens if a local variable exists with the same name as the global variable you want to access?
  14. A.
    Error
    B.
    The local variable is shadowed
    C.
    Undefined behavior
    D.
    The global variable is shadowed

    View Answer

    Workspace

    Discuss Discuss in Forum


  15. Which of these is false about recursion?
  16. A.
    Recursive function can be replaced by a non-recursive function
    B.
    Recursive functions usually take more memory space than non-recursive function
    C.
    Recursive functions run faster than non-recursive function
    D.
    Recursion makes programs easier to understand

    View Answer

    Workspace

    Discuss Discuss in Forum


  17. What is the output of the code shown below?

    l1=[1, 2, 3, [4]]
    l2=list(l1)
    id(l1)==id(l2)
  18. A.
    True
    B.
    False
    C.
    Error
    D.
    Address of l1

    View Answer

    Workspace

    Discuss Discuss in Forum