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.

The function complex(‘2-3j’) is valid but the function complex(‘2 – 3j’) is invalid.

A. true
B. false
Answer» B. false
2.

If a class defines the     str    (self) method, for an object obj for the class, you can use which command to invoke the     str      method.

A. obj.    str    ()
B. str(obj)
C. print obj
D. all of the mentioned
Answer» E.
3.

To retrieve the character at index 3 from string s=”Hello” what command do we execute (multiple answers allowed)?

A. s[]
B. s.getitem(3)
C. s.    getitem    (3)
D. s.getitem(3)
Answer» D. s.getitem(3)
4.

What is “Hello”.replace(“l”, “e”)?

A. heeeo
B. heelo
C. heleo
D. none
Answer» B. heelo
5.

Say s=”hello” what will be the return value of type(s)?

A. int
B. bool
C. str
D. string
Answer» D. string
6.

What will be displayed by print(ord(‘b’) – ord(‘a’))?

A. 0
B. 1
C. -1
D. 2
Answer» C. -1
7.

Suppose s is “\t\tWorld\n”, what is s.strip()?

A. \\t\\tworld\\n
B. \\t\\tworld\\n
C. \\t\\tworld\\n
D. world
Answer» E.
8.

Given a string example=”hello” what is the output of example.count(‘l’)?

A. 2
B. 1
C. none
Answer» B. 1
9.

Bitwise                    gives 1 if either of the bits is 1 and 0 when both of the bits are 1.

A. or
B. and
C. xor
D. not
Answer» D. not
10.

It is not possible for the two’s complement value to be equal to the original value in any case.

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

What will be the output of the following Python expression?0x35 | 0x75

A. 115
B. 116
C. 117
D. 118
Answer» D. 118
12.

Which is the correct operator for power(xy)?

A. x^y
B. x**y
C. x^^y
D. none of the mentioned
Answer» C. x^^y
13.

begins with lower case letters.

A. keywords
B. variables
C. tokens
D. functions
Answer» C. tokens
14.

are identified by their addresses, we give them names (field names / variable names) using words.

A. memory variables
B. memory locations
C. memory addresses
D. data variables
Answer» C. memory addresses
15.

is used to show hierarchy in a pseudo code.

A. indentation
B. curly braces
C. round brackets
D. semicolon
Answer» B. curly braces
16.

A                is a connector showing the relationship between the representative shapes.

A. line
B. arrow
C. process
D. box
Answer» C. process
17.

The action performed by a                         structure must eventually cause the loop to terminate.

A. sequence
B. case
C. repetition
D. process
Answer» D. process
18.

A                              is diagram that depicts the flow of a program.

A. algorithm
B. hash table
C. graph
D. flowchart
Answer» E.
19.

The word                         comes from the name of a Persian mathematician Abu Ja’far Mohammed ibn-i Musa al Khowarizmi.

A. flowchart
B. flow
C. algorithm
D. syntax
Answer» D. syntax
20.

g=f(8) print(next(g))

A. 8
B. 9
C. 7
D. error
Answer» C. 7
21.

k = foo() print(k)

A. 1
B. 2
C. 3
D. error, there is more than one return statement in a single try-finally block
Answer» C. 3
22.

Let A and B be objects of class Foo. Which functions are called when print(A + B) is executed?

A.     add    (),     str    ()
B.     str    (),     add    ()
C.     sum    (),     str    ()
D.     str    (),     sum    ()
Answer» B.     str    (),     add    ()
23.

] test[1] = 'D' del test[2] print(len(test))

A. 0
B. 2
C. error as the key-value pair of 1:’a’ is already deleted
D. 1
Answer» C. error as the key-value pair of 1:’a’ is already deleted
24.

>>>2 * t

A. (1, 2, 1, 2)
B. [1, 2, 1, 2]
C. (1, 1, 2, 2)
D. [1, 1, 2, 2]
Answer» B. [1, 2, 1, 2]
25.

2 TUPLES (TUPLE ASSIGNMENT, TUPLE AS RETURN VALUE)

A. [1, 2, 3]
B. (1, 2, 3)
C. {1, 2, 3}
D. {}
Answer» C. {1, 2, 3}
26.

, 5): print(a[i],end = " ")

A. 5 5 1 2 3
B. 5 1 2 3 4
C. 2 3 4 5 1
D. 2 3 4 5 5
Answer» E.
27.

san(12)

A. 13
B. 10
C. 2
D. 5
Answer» B. 10
28.

print(foo())

A. 0
B. 1
C. error
D. none of the mentioned
Answer» D. none of the mentioned
29.

) print(i)

A. 1
B. nothing is displayed
C. an exception is thrown
Answer» D.
30.

) oct(‘7’)

A. error 07
B. 0o7 error
C. 0o7 error
D. 7
Answer» D. 7
31.

eval('x^2')

A. error
B. 1
C. 9
D. 6
Answer» C. 9
32.

:]: print(i, end = " ")

A. a a a a a a
B. a
C. no output
D. error
Answer» D. error
33.

Which of the statements about modules is false?

A. in the “from-import” form of import, identifiers beginning with two underscores are private and aren’t imported
B. dir() built-in function monitors the items in the namespace of the main module
C. in the “from-import” form of import, all identifiers regardless of whether they are private or public are imported
D. when a module is loaded, a compiled version of the module with file extension .pyc is automatically produced
Answer» D. when a module is loaded, a compiled version of the module with file extension .pyc is automatically produced
34.

Which of the following is false about “from-import” form of import?

A. the syntax is: from modulename import identifier
B. this form of import prevents name clash
C. the namespace of imported module becomes part of importing module
D. the identifiers in module are accessed directly as: identifier
Answer» C. the namespace of imported module becomes part of importing module
35.

Which of the following is false about “import modulename” form of import?

A. the namespace of imported module becomes part of importing module
B. this form of import prevents name clash
C. the namespace of imported module becomes available to importing module
D. the identifiers in module are accessed as: modulename.identifier
Answer» B. this form of import prevents name clash
36.

Which of the following is not a valid namespace?

A. global namespace
B. public namespace
C. built-in namespace
D. local namespace
Answer» C. built-in namespace
37.

All modular designs are because of a top- down design process.

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

In top-down design every module is broken into same number of submodules.

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

             is a string literal denoted by triple quotes for providing the specifications of certain program elements.

A. interface
B. modularity
C. client
D. docstring
Answer» E.
40.

Program code making use of a given module is called a              of the module.

A. client
B. docstring
C. interface
D. modularity
Answer» B. docstring
41.

Which of the following is true about top- down design process?

A. the details of a program design are addressed before the overall design
B. only the details of the program are addressed
C. the overall design of the program is addressed before the details
D. only the design of the program is addressed
Answer» D. only the design of the program is addressed
42.

Which of the following is not an advantage of using modules?

A. provides a means of reuse of program code
B. provides a means of dividing up tasks
C. provides a means of reducing the size of the program
D. provides a means of testing individual parts of the program
Answer» D. provides a means of testing individual parts of the program
43.

Which of these definitions correctly describes a module?

A. denoted by triple quotes for providing the specification of certain program elements
B. design and implementation of specific functionality to be incorporated into a program
C. defines the specification of how it is to be used
D. any program that reuses code
Answer» C. defines the specification of how it is to be used
44.

Which of the following blocks will be executed whether an exception is thrown or not?

A. except
B. else
C. finally
D. assert
Answer» D. assert
45.

An exception is

A. an object
B. a special function
C. a standard module
D. a module
Answer» B. a special function
46.

Syntax errors are also known as parsing errors.

A. true
B. false
Answer» B. false
47.

                                               exceptions are raised as a result of an error in opening a particular file.

A. valueerror
B. typeerror
C. importerror
D. ioerror
Answer» E.
48.

Which of the following is not a standard exception in Python?

A. nameerror
B. ioerror
C. assignmenterror
D. valueerror
Answer» D. valueerror
49.

43')

A. importerror
B. valueerror
C. typeerror
D. nameerror
Answer» C. typeerror
50.

+ '3'

A. nameerror
B. indexerror
C. valueerror
D. typeerror
Answer» E.