Explore topic-wise MCQs in Testing Subject.

This section includes 657 Mcqs, each offering curated multiple-choice questions to sharpen your Testing Subject knowledge and support exam preparation. Choose a topic below to get started.

1.

print(a)

A. 10
B. 25
C. junk value
D. error
Answer» C. junk value
2.

What happens if a local variable exists with the same name as the global variable you want to access?

A. error
B. the local variable is shadowed
C. undefined behavior
D. the global variable is shadowed
Answer» E.
3.

On assigning a value to a variable inside a function, it automatically becomes a global variable.

A. true
B. false
Answer» C.
4.

Which of the following data structures is returned by the functions globals() and locals()?

A. list
B. set
C. dictionary
D. tuple
Answer» D. tuple
5.

(1,2) print(total)

A. error
B. 7
C. 8
D. 15
Answer» C. 8
6.

,2,3,4 f(5,10,15)

A. 1 2 3 4
B. 5 10 15 4
C. 10 20 30 40
D. 5 10 15 40
Answer» D. 5 10 15 40
7.

(2,[3,4]))

A. [3,2,4]
B. [2,3,4]
C. error
D. [3,4,2]
Answer» E.
8.

f1()

A. error
B. 12
C. 15
D. 1512
Answer» D. 1512
9.

How are default arguments specified in the function heading?

A. identifier followed by an equal to sign and the default value
B. identifier followed by the default value within backticks (“)
C. identifier followed by the default value within square brackets ([])
D. identifier
Answer» B. identifier followed by the default value within backticks (“)
10.

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

A. null
B. you cannot access it
C. the program’s name
D. the first argument
Answer» D. the first argument
11.

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

A. getopt
B. os
C. getarg
D. main
Answer» B. os
12.

What is the type of sys.argv?

A. set
B. list
C. tuple
D. string
Answer» C. tuple
13.

How are variable length arguments specified in the function heading?

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
Answer» B. one underscore followed by a valid identifier
14.

): print(foo(i))

A. [0] [1] [2]
B. [0] [0, 1] [0, 1, 2]
C. [1] [2] [3]
D. [1] [1, 2] [1, 2, 3]
Answer» C. [1] [2] [3]
15.

, 2, 3])

A. 3 1
B. 1 3
C. error
D. none of the mentioned
Answer» B. 1 3
16.

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

A. zero
B. one
C. zero or more
D. one or more
Answer» D. one or more
17.

How are keyword arguments specified in the function heading?

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
Answer» D. two underscores followed by a valid identifier
18.

What is the length of sys.argv?

A. number of arguments
B. number of arguments + 1
C. number of arguments – 1
D. none of the mentioned
Answer» C. number of arguments – 1
19.

What is the type of each element in sys.argv?

A. set
B. list
C. tuple
D. string
Answer» E.
20.

',B='2')

A. string
B. tuple
C. dictionary
D. an exception is thrown
Answer» D. an exception is thrown
21.

If a function doesn’t have a return statement, which of the following does the function return?

A. int
B. null
C. none
D. an exception is thrown without the return statement
Answer» D. an exception is thrown without the return statement
22.

,2,3,4)

A. integer
B. tuple
C. dictionary
D. an exception is thrown
Answer» C. dictionary
23.

, i = 2)

A. an exception is thrown because of conflicting values
B. 1 2
C. 3 3
D. 3 2
Answer» E.
24.

What is a variable defined inside a function referred to as?

A. a global variable
B. a volatile variable
C. a local variable
D. an automatic variable
Answer» D. an automatic variable
25.

What is a variable defined outside a function referred to as?

A. a static variable
B. a global variable
C. a local variable
D. an automatic variable
Answer» C. a local variable
26.

min(101*99, 102*98)

A. 9997
B. 9999
C. 9996
D. none of the mentioned
Answer» D. none of the mentioned
27.

who('Arthur')

A. arthur sir
B. sir arthur
C. arthur
D. none of the mentioned
Answer» C. arthur
28.

f(2, 30, 400)

A. 432
B. 24000
C. 430
D. no output
Answer» B. 24000
29.

Lambda contains block of statements.

A. true
B. false
Answer» C.
30.

Lambda is a statement.

A. true
B. false
Answer» C.
31.

print z(8)

A. 48
B. 14
C. 64
D. none of the mentioned
Answer» B. 14
32.

Python supports the creation of anonymous functions at runtime, using a construct called

A. lambda
B. pi
C. anonymous
D. none of the mentioned
Answer» B. pi
33.

Does Lambda contains return statements?

A. true
B. false
Answer» C.
34.

print x

A. 9
B. 3
C. 27
D. 30
Answer» D. 30
35.

Which of the following refers to mathematical function?

A. sqrt
B. rhombus
C. add
D. rhombus
Answer» B. rhombus
36.

Which of the following is the use of id() function in python?

A. id returns the identity of the object
B. every object doesn’t have a unique id
C. all of the mentioned
D. none of the mentioned
Answer» B. every object doesn’t have a unique id
37.

What is called when a function is defined inside a class?

A. module
B. class
C. another function
D. method
Answer» E.
38.

Where is function defined?

A. module
B. class
C. another function
D. all of the mentioned
Answer» E.
39.

What are the two main types of functions?

A. custom function
B. built-in function & user defined function
C. user function
D. system function
Answer» C. user function
40.

Which are the advantages of functions in python?

A. reducing duplication of code
B. decomposing complex problems into simpler pieces
C. improving clarity of the code
D. all of the mentioned
Answer» E.
41.

Which of the following is a feature of DocString?

A. provide a convenient way of associating documentation with python modules, functions, classes, and methods
B. all functions should have a docstring
C. docstrings can be accessed by the     doc      attribute on objects
D. all of the mentioned
Answer» E.
42.

print(maximum(2, 3))

A. 2
B. 3
C. the numbers are equal
D. none of the mentioned
Answer» C. the numbers are equal
43.

printMax(3, 4)

A. 3
B. 4
C. 4 is maximum
D. none of the mentioned
Answer» D. none of the mentioned
44.

Which keyword is used for function?

A. fun
B. define
C. def
D. function
Answer» D. function
45.

Which of the following is the use of function in python?

A. functions are reusable pieces of programs
B. functions don’t provide better modularity for your application
C. you can’t also create your own functions
D. all of the mentioned
Answer» B. functions don’t provide better modularity for your application
46.

, 4, 6])

A. 4
B. 3
C. error
D. 6
Answer» B. 3
47.

Which of the following functions does not throw an error?

A. ord()
B. ord(‘ ‘)
C. ord(”)
D. ord(“”)
Answer» C. ord(”)
48.

Which of the following functions will not result in an error when no arguments are passed to it?

A. min()
B. divmod()
C. all()
D. float()
Answer» E.
49.

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?

A. reverse(l)
B. list(reverse[(l)])
C. reversed(l)
D. list(reversed(l))
Answer» E.
50.

Which of the following functions accepts only integers as arguments?

A. ord()
B. min()
C. chr()
D. any()
Answer» D. any()