Similar Collections


    No collections found

questions

Title
What is the length of sys.argv

What is the length of sys.argv?


  1. number of arguments
  2. number of arguments + 1
  3. number of arguments – 1
  4. none of the mentioned
discuss
What is the output of the following code

What is the output of the following code?

def foo(k):
    k[0] = 1
q = [0]
foo(q)
print(q)

  1. [0].
  2. [1].
  3. [1, 0].
  4. [0, 1].
discuss
How are keyword arguments specified in the function heading

How are keyword arguments specified in the function heading?


  1. one star followed by a valid identifier
  2. one underscore followed by a valid identifier
  3. two stars followed by a valid identifier
  4. two underscores followed by a valid identifier
discuss
How many keyword arguments can be passed to a function in a single function call

How many keyword arguments can be passed to a function in a single function call?


  1. zero
  2. one
  3. zero or more
  4. one or more
discuss
What is the output of the following code

What is the output of the following code?

def foo(fname, val):
    print(fname(val))
foo(max, [1, 2, 3])
foo(min, [1, 2, 3])

  1. 3 1
  2. 1 3
  3. error
  4. none of the mentioned
discuss
What is the output of the following code

What is the output of the following code?

def foo():
    return total + 1
total = 0
print(foo())

  1. 0
  2. 1
  3. error
  4. none of the mentioned
discuss
What is the output of the following code

What is the output of the following code?

def foo():
    total += 1
    return total
total = 0
print(foo())

  1. 0
  2. 1
  3. error
  4. none of the mentioned
discuss
What is the output of the following code

What is the output of the following code?

def foo(x):
    x = ['def', 'abc']
    return id(x)
q = ['abc', 'def']
print(id(q) == foo(q))

  1. True
  2. False
  3. None
  4. Error
discuss
What is the output of the following code

What is the output of the following code?

def foo(i, x=[]):
    x.append(i)
    return x
for i in range(3):
    print(foo(i))

  1. [0] [1] [2].
  2. [0] [0, 1] [0, 1, 2].
  3. [1] [2] [3].
  4. [1] [1, 2] [1, 2, 3].
discuss
What is the output of the following code

What is the output of the following code

def foo(k):
    k = [1]
q = [0]
foo(q)
print(q)

  1. [0].
  2. [1].
  3. [1, 0].
  4. [0, 1].
discuss
How are variable length arguments specified in the function heading

How are variable length arguments specified in the function heading?


  1. one star followed by a valid identifier
  2. one underscore followed by a valid identifier
  3. two stars followed by a valid identifier
  4. two underscores followed by a valid identifier
discuss
Which module in the python standard library parses options received from the command line

Which module in the python standard library parses options received from the command line?


  1. getopt
  2. os
  3. getarg
  4. main
discuss
What is the type of sys.argv

What is the type of sys.argv?


  1. set
  2. list
  3. tuple
  4. string
discuss
What is the value stored in sys.argv[0]

What is the value stored in sys.argv[0]?


  1. null
  2. you cannot access it
  3. the program’s name
  4. the first argument
discuss
How are default arguments specified in the function heading

How are default arguments specified in the function heading?


  1. identifier followed by an equal to sign and the default value
  2. identifier followed by the default value within backticks (“)
  3. identifier followed by the default value within square brackets ([])
  4. identifier
discuss
How are required arguments specified in the function heading

How are required arguments specified in the function heading?


  1. identifier followed by an equal to sign and the default value
  2. identifier followed by the default value within backticks (“)
  3. identifier followed by the default value within square brackets ([])
  4. identifier
discuss
What is the output of the following code

What is the output of the following code?

def foo(x):
    x[0] = ['def']
    x[1] = ['abc']
    return id(x)
q = ['abc', 'def']
print(id(q) == foo(q))

  1. True
  2. False
  3. None
  4. Error
discuss
Where are the arguments received from the command line stored

Where are the arguments received from the command line stored?


  1. sys.argv
  2. os.argv
  3. argv
  4. none of the mentioned
discuss
What is the output of the following

What is the output of the following?

def foo(i, x=[]):
    x.append(x.append(i))
    return x
for i in range(3):
    y = foo(i)
print(y)

  1. [[[0]], [[[0]], [1]], [[[0]], [[[0]], [1]], [2]]].
  2. [[0], [[0], 1], [[0], [[0], 1], 2]].
  3. [0, None, 1, None, 2, None].
  4. [[[0]], [[[0]], [1]], [[[0]], [[[0]], [1]], [2]]].
discuss
The output of the code shown below is

The output of the code shown below is:

def f1():
    x=15
    print(x)
x=12
f1()

  1. Error
  2. 12
  3. 15
  4. 1512
discuss
total MCQs: 68

MCQs

68

Views

85

Best Answers

299

Points

5