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
Posted Date:-2022-01-01 18:53:40
What will be the output of the following Python code? def foo(k): k = [1] q = [0] foo(q) print(q)
1.[0]
2.[1]
3.[1, 0]
4.[0, 1]
Posted Date:-2022-01-01 18:44:40
What will be the output of the following Python code? i=0 def change(i): i=i+1 return i change(1) print(i)
1. 1
2. Nothing is displayed
3. 0
4.An exception is thrown
Posted Date:-2022-01-01 18:27:06
Which are the advantages of functions in python?
1.Reducing duplication of code
2.Decomposing complex problems into simpler pieces
3.Improving clarity of the code
4. All of the mentioned
Posted Date:-2022-01-01 18:15:45
Which of the following is a feature of DocString?
1.Provide a convenient way of associating documentation with Python modules, functions, classes, and methods
2.All functions should have a docstring
3.Docstrings can be accessed by the __doc__ attribute on objects
4.All of the mentioned
Posted Date:-2022-01-01 18:11:28
hat will be the output of the following Python code? def change(one, *two): print(type(two)) change(1,2,3,4)
1.Integer
2. Tuple
3.Dictionary
4.An exception is thrown
Posted Date:-2022-01-01 18:28:24
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
Posted Date:-2022-01-01 18:51:57
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
Posted Date:-2022-01-01 18:37:11
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
Posted Date:-2022-01-01 18:45:30
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
Posted Date:-2022-01-01 18:37:40
Suppose there is a list such that: l=[2,3,4]. If we want to print this list in reverse order, which of the following methods should be used?
1.reverse(l)
2.list(reverse[(l)])
3.reversed(l)
4. list(reversed(l))
Posted Date:-2022-01-01 17:53:39
What are the two main types of functions?
1.Custom function
2. Built-in function & User defined function
3.User function
4.System function
Posted Date:-2022-01-01 18:16:09
What is a variable defined inside a function referred to as?
1. A global variable
2.A volatile variable
3.A local variable
4.An automatic variable
Posted Date:-2022-01-01 18:26:27
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
Posted Date:-2022-01-01 18:36:06
What is the type of each element in sys.argv?
1.set
2.list
3.tuple
4.String
Posted Date:-2022-01-01 18:35:11
What is the type of sys.argv?
1. set
2.list
3. tuple
4.string
Posted Date:-2022-01-01 18:47:18
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
Posted Date:-2022-01-01 18:50:33
What will be the output of the following Python code? def a(b): b = b + [5] c = [1, 2, 3, 4] a(c) print(len(c))
1.4
2. 5
3. 1
4. An exception is thrown
Posted Date:-2022-01-01 18:27:30
What will be the output of the following Python code? def change(i = 1, j = 2): i = i + j j = j + 1 print(i, j) change(j = 1, i = 2)
1.An exception is thrown because of conflicting values
2.1 2
3.3 3
4.3 2
Posted Date:-2022-01-01 18:28:01
What will be the output of the following Python code? def display(b, n): while n > 0: print(b,end="") n=n-1 display('z',3)
1. zzz
2. zz
3.An exception is executed
4. Infinite loop
Posted Date:-2022-01-01 18:28:58
What will be the output of the following Python code? def f(x, y, z): return x + y + z f(2, 30, 400)
1. 432
2.24000
3.430
4.No output
Posted Date:-2022-01-01 18:24:31
What will be the output of the following Python code? def find(a, **b): print(type(b)) find('letters',A='1',B='2')
1. String
2. Tuple
3.Dictionary
4.An exception is thrown
Posted Date:-2022-01-01 18:29:28
What will be the output of the following Python code? def foo(): return total + 1 total = 0 print(foo())
1. 0
2.1
3.error
4.none of the mentioned
Posted Date:-2022-01-01 18:38:30
What will be the output of the following Python code? def foo(): total += 1 return total total = 0 print(foo())
1.0
2. 1
3.error
4.none of the mentioned
Posted Date:-2022-01-01 18:39:05
What will be the output of the following Python 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
Posted Date:-2022-01-01 18:38:06
What will be the output of the following Python 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]
Posted Date:-2022-01-01 18:42:27
What will be the output of the following Python code? 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]]]
Posted Date:-2022-01-01 18:56:34
What will be the output of the following Python 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
Posted Date:-2022-01-01 18:41:02
What will be the output of the following Python 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
Posted Date:-2022-01-01 18:54:35
What will be the output of the following Python code? def maximum(x, y): if x > y: return x elif x == y: return 'The numbers are equal' else: return y print(maximum(2, 3))
1. 2
2.3
3.The numbers are equal
4.None of the mentioned
Posted Date:-2022-01-01 18:11:03
What will be the output of the following Python code? def writer(): title = 'Sir' name = (lambda x:title + ' ' + x) return name who = writer() who('Arthur')
1.Arthur Sir
2.Sir Arthur
3.Arthur
4.none of the mentioned
Posted Date:-2022-01-01 18:24:56
What will be the output of the following Python code? min = (lambda x, y: x if x < y else y) min(101*99, 102*98)
1. 9997
2.9999
3.9996
4. None of the mentioned
Posted Date:-2022-01-01 18:25:21
What will be the output of the following Python code? x = 50 def func(): global x print('x is', x) x = 2 print('Changed global x to', x) func() print('Value of x is', x)
1.x is 50 Changed global x to 2 Value of x is 50
2.x is 50 Changed global x to 2 Value of x is 2
3.x is 50 Changed global x to 50 Value of x is 50
4.none of the mentioned
Posted Date:-2022-01-01 18:09:43
What will be the output of the following Python code? def cube(x): return x * x * x x = cube(3) print x
1. 9
2.3
3.27
4.30
Posted Date:-2022-01-01 18:17:55
What will be the output of the following Python code? def foo(k): k[0] = 1 q = [0] foo(q) print(q)
1.[0]
2. [1]
3.[1, 0]
4.[0, 1]
Posted Date:-2022-01-01 18:36:39
What will be the output of the following Python code? def printMax(a, b): if a > b: print(a, 'is maximum') elif a == b: print(a, 'is equal to', b) else: print(b, 'is maximum') printMax(3, 4)
1.3
2. 4
3.4 is maximum
4.none of the mentioned
Posted Date:-2022-01-01 18:08:26
What will be the output of the following Python code? def say(message, times = 1): print(message * times) say('Hello') say('World', 5)
1.Hello WorldWorldWorldWorldWorld
2.Hello World 5
3.Hello World,World,World,World,World
4.Hello HelloHelloHelloHelloHello
Posted Date:-2022-01-01 18:10:17
What will be the output of the following Python code? def sayHello(): print('Hello World!') sayHello() sayHello()
1.Hello World! Hello World!
2.'Hello World!' 'Hello World!'
3.Hello Hello
4. None of the mentioned
Posted Date:-2022-01-01 18:07:40
What will be the output of the following Python code? lamb = lambda x: x ** 3 print(lamb(5))
1. 15
2.555
3. 125
4. None of the mentioned
Posted Date:-2022-01-01 18:23:54
What will be the output of the following Python code? x = 50 def func(x): print('x is', x) x = 2 print('Changed local x to', x) func(x) print('x is now', x)
1.x is 50 Changed local x to 2 x is now 50
2.x is 50 Changed local x to 2 x is now 2
3.x is 50 Changed local x to 2 x is now 100
4.none of the mentioned
Posted Date:-2022-01-01 18:09:02
What will be the output of the following Python function? hex(15)
1.f
2. 0xF
3.0Xf
4.0xf
Posted Date:-2022-01-01 18:00:46
What will be the output of the following Python function? float(' -12345 ') (Note that the number of blank spaces before the number is 5)
1. -12345.0 (5 blank spaces before the number)
2. -12345.0
3.Error
4.-12345.000000000…. (infinite decimal places)
Posted Date:-2022-01-01 17:59:10
Where are the arguments received from the command line stored?
1.sys.argv
2.os.argv
3.argv
4.none of the mentioned
Posted Date:-2022-01-01 18:55:33
Which keyword is used for function?
1.Fun
2. Define
3.Def
4. Function
Posted Date:-2022-01-01 18:06:35
Which module in the python standard library parses options received from the command line?
1.getopt
2.os
3.getarg
4.main
Posted Date:-2022-01-01 18:46:35
Which of the following functions accepts only integers as arguments?
1.ord()
2.min()
3.chr()
4.any()
Posted Date:-2022-01-01 17:53:05
Which of the following functions does not throw an error?
1.ord()
2.ord(‘ ‘)
3.ord(â€)
4.ord(“â€)
Posted Date:-2022-01-01 18:02:52
Which of the following functions will not result in an error when no arguments are passed to it?
1.min()
2.divmod()
3.all()
4. float()
Posted Date:-2022-01-01 18:00:09
Which of the following is the use of function in python?
1.Functions are reusable pieces of programs
2. Functions don’t provide better modularity for your application
3.you can’t also create your own functions
4.all of the mentioned
Posted Date:-2022-01-01 18:04:54
Which of the following refers to mathematical function?
1.sqrt
2.rhombus
3.add
4.rhombus
Posted Date:-2022-01-01 18:16:56