Explore topic-wise InterviewSolutions in .

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

51.

The value returned when we use the function isoweekday() is ______ and that for the function weekday() is ________ if the system date is 19th June, 2017 (Monday).(a) 0,0(b) 0,1(c) 1,0(d) 1,1I had been asked this question in an online interview.My question comes from Datetime Module topic in section Mapping Functions and Modules of Python

Answer»

The correct choice is (C) 1,0

To EXPLAIN: The value returned when we use the function isoweekday() is 1 and that for the function weekday() is 0 if the SYSTEM DATE is 19TH June, 2017 (Monday).

52.

What does math.sqrt(X, Y) do?(a) calculate the Xth root of Y(b) calculate the Yth root of X(c) error(d) return a tuple with the square root of X and YThis question was addressed to me in final exam.This key question is from Math topic in portion Mapping Functions and Modules of Python

Answer» RIGHT option is (C) error

For explanation: The FUNCTION TAKES only ONE argument.
53.

What is the value of x if x = math.sqrt(4)?(a) 2(b) 2.0(c) (2, -2)(d) (2.0, -2.0)I have been asked this question by my college director while I was bunking the class.Asked question is from Math in chapter Mapping Functions and Modules of Python

Answer»

The CORRECT option is (b) 2.0

Explanation: The function returns ONE floating POINT NUMBER.

54.

What is output of print(math.pow(3, 2))?(a) 9(b) 9.0(c) None(d) None of the mentionedThe question was asked in an online interview.The query is from Math topic in division Mapping Functions and Modules of Python

Answer»

Correct OPTION is (b) 9.0

The explanation is: math.pow() RETURNS a floating POINT NUMBER.

55.

What is returned by int(math.pow(3, 2))?(a) 6(b) 9(c) error, third argument required(d) error, too many argumentsI had been asked this question in unit test.This interesting question is from Math in section Mapping Functions and Modules of Python

Answer» CORRECT ANSWER is (B) 9

The EXPLANATION: math.pow(a, b) RETURNS a ** b.
56.

Which of the following aren’t defined in the math module?(a) log2()(b) log10()(c) logx()(d) none of the mentionedThe question was asked in examination.This question is from Math topic in chapter Mapping Functions and Modules of Python

Answer»

Correct choice is (c) LOGX()

To explain I WOULD say: log2() and log10() are DEFINED in the math MODULE.

57.

What is the default base used when math.log(x) is found?(a) e(b) 10(c) 2(d) none of the mentionedThe question was posed to me in final exam.The origin of the question is Math in section Mapping Functions and Modules of Python

Answer»

The correct CHOICE is (a) e

The BEST I can explain: The natural log of x is RETURNED by DEFAULT.

58.

What is returned by math.expm1(p)?(a) (math.e ** p) – 1(b) math.e ** (p – 1)(c) error(d) none of the mentionedThis question was posed to me by my school teacher while I was bunking the class.I'm obligated to ask this question of Math topic in section Mapping Functions and Modules of Python

Answer»

Correct answer is (a) (math.e ** P) – 1

Easy EXPLANATION - One is subtracted from the RESULT of math.exp(p) and RETURNED.

59.

Which of the following is the same as math.exp(p)?(a) e ** p(b) math.e ** p(c) p ** e(d) p ** math.eThe question was posed to me by my college professor while I was bunking the class.I need to ask this question from Math in portion Mapping Functions and Modules of Python

Answer»

Right option is (B) math.e ** p

Best EXPLANATION: math.e is the constant DEFINED in the math MODULE.

60.

What is the output of print(math.trunc(‘3.1’))?(a) 3(b) 3.0(c) error(d) none of the mentionedThe question was asked during an internship interview.I would like to ask this question from Math in portion Mapping Functions and Modules of Python

Answer» RIGHT ANSWER is (c) error

For explanation: TYPEERROR, a STRING does not have __trunc__ method.
61.

What is the result of math.trunc(3.1)?(a) 3.0(b) 3(c) 0.1(d) 1This question was addressed to me in an interview for internship.I would like to ask this question from Math in chapter Mapping Functions and Modules of Python

Answer»

Correct OPTION is (b) 3

Explanation: The INTEGRAL PART of the floating POINT NUMBER is returned.

62.

What is returned by math.modf(1.0)?(a) (0.0, 1.0)(b) (1.0, 0.0)(c) (0.5, 1)(d) (0.5, 1.0)I got this question by my school teacher while I was bunking the class.This intriguing question originated from Math topic in division Mapping Functions and Modules of Python

Answer»

Right ANSWER is (a) (0.0, 1.0)

To explain: The FIRST element is the FRACTIONAL part and the SECOND element is the integral part of the ARGUMENT.

63.

What is the value of x if x = math.ldexp(0.5, 1)?(a) 1(b) 2.0(c) 0.5(d) none of the mentionedThis question was posed to me in an interview.This key question is from Math in section Mapping Functions and Modules of Python

Answer»

Correct choice is (d) none of the mentioned

Best EXPLANATION: The value RETURNED by ldexp(x, y) is x * (2 ** y). In the current CASE x is 1.0.

64.

What is x if x = math.isfinite(float(‘0.0’))?(a) True(b) False(c) None(d) errorThe question was asked in semester exam.Question is from Math topic in section Mapping Functions and Modules of Python

Answer»

Right ANSWER is (a) True

To EXPLAIN I would SAY: float(‘0.0’) is a finite number.

65.

What is returned by math.isfinite(float(‘nan’))?(a) True(b) False(c) None(d) errorThe question was posed to me in quiz.My question is from Math in chapter Mapping Functions and Modules of Python

Answer» RIGHT answer is (B) False

Easy EXPLANATION - float(‘nan’) is not a FINITE NUMBER.
66.

What is returned by math.isfinite(float(‘inf’))?(a) True(b) False(c) None(d) errorI got this question during an online interview.My question is based upon Math topic in section Mapping Functions and Modules of Python

Answer»

The CORRECT ANSWER is (b) False

Easy explanation - FLOAT(‘INF’) is not a finite number.

67.

What is the result of sum([.1 for i in range(20)])?(a) 2.0(b) 20(c) 2(d) 2.0000000000000004The question was posed to me by my college professor while I was bunking the class.Question is taken from Math topic in chapter Mapping Functions and Modules of Python

Answer»

Right ANSWER is (d) 2.0000000000000004

Explanation: There is some LOSS of ACCURACY when we use sum with FLOATING point numbers. Hence the function fsum is preferable.

68.

What is the result of math.fsum([.1 for i in range(20)])?(a) 2.0(b) 20(c) 2(d) 2.0000000000000004I had been asked this question by my college professor while I was bunking the class.My doubt is from Math in portion Mapping Functions and Modules of Python

Answer»

Right ANSWER is (a) 2.0

Easy EXPLANATION - The FUNCTION fsum returns an ACCURATE floating POINT sum of the elements of its argument.

69.

What does the function math.frexp(x) return?(a) a tuple containing the mantissa and the exponent of x(b) a list containing the mantissa and the exponent of x(c) a tuple containing the mantissa of x(d) a list containing the exponent of xI had been asked this question during an online interview.Asked question is from Math topic in chapter Mapping Functions and Modules of Python

Answer»

Correct CHOICE is (a) a tuple containing the mantissa and the exponent of x

Easy explanation - It RETURNS a tuple with two ELEMENTS. The FIRST ELEMENT is the mantissa and the second element is the exponent.

70.

What is math.floor(0o10)?(a) 8(b) 10(c) 0(d) 9This question was addressed to me during an online interview.Query is from Math in portion Mapping Functions and Modules of Python

Answer» RIGHT ANSWER is (a) 8

Explanation: 0o10 is 8 and FLOOR(8) is 8.
71.

What will be the output of print(math.factorial(4.5))?(a) 24(b) 120(c) error(d) 24.0The question was posed to me in an interview for job.Query is from Math in section Mapping Functions and Modules of Python

Answer»

Right choice is (C) error

The EXPLANATION is: FACTORIAL is only DEFINED for non-negative INTEGERS.

72.

What is math.factorial(4.0)?(a) 24(b) 1(c) error(d) none of the mentionedI have been asked this question in a job interview.This intriguing question originated from Math topic in section Mapping Functions and Modules of Python

Answer»

The CORRECT OPTION is (a) 24

Explanation: The FACTORIAL of 4 is RETURNED.

73.

Is the output of the function abs() the same as that of the function math.fabs()?(a) sometimes(b) always(c) never(d) none of the mentionedThis question was addressed to me in an online quiz.My question is based upon Math topic in portion Mapping Functions and Modules of Python

Answer»

Right option is (a) sometimes

Easy EXPLANATION - math.fabs() always returns a FLOAT and does not WORK with COMPLEX numbers whereas the return type of abs() is determined by the type of value that is passed to it.

74.

What is the value of x if x = math.factorial(0)?(a) 0(b) 1(c) error(d) none of the mentionedI got this question during an interview for a job.Question is from Math topic in chapter Mapping Functions and Modules of Python

Answer»

The CORRECT option is (b) 1

The BEST I can explain: FACTORIAL of 0 is 1.

75.

What is the value returned by math.fact(6)?(a) 720(b) 6(c) [1, 2, 3, 6](d) errorI had been asked this question during an internship interview.Enquiry is from Math in portion Mapping Functions and Modules of Python

Answer»

Right ANSWER is (d) error

The EXPLANATION is: NameError, FACT() is not defined.

76.

What will be the output of print(math.copysign(3, -1))?(a) 1(b) 1.0(c) -3(d) -3.0I had been asked this question during an online interview.Origin of the question is Math topic in portion Mapping Functions and Modules of Python

Answer»

The correct option is (d) -3.0

The BEST explanation: The copysign FUNCTION returns a float whose absolute VALUE is that of the FIRST argument and the sign is that of the second argument.

77.

What is displayed on executing print(math.fabs(-3.4))?(a) -3.4(b) 3.4(c) 3(d) -3The question was posed to me in a national level competition.My doubt stems from Math in division Mapping Functions and Modules of Python

Answer»

The correct OPTION is (b) 3.4

The best EXPLANATION: A NEGATIVE FLOATING point number is returned as a POSITIVE floating point number.

78.

What is returned by math.ceil(3.4)?(a) 3(b) 4(c) 4.0(d) 3.0I have been asked this question in final exam.Asked question is from Math topic in chapter Mapping Functions and Modules of Python

Answer»

The correct CHOICE is (b) 4

The explanation: The ceil function returns the SMALLEST integer that is bigger than or EQUAL to the number itself.

79.

What is the value returned by math.floor(3.4)?(a) 3(b) 4(c) 4.0(d) 3.0This question was posed to me during a job interview.My question is based upon Math in division Mapping Functions and Modules of Python

Answer» RIGHT answer is (a) 3

Best explanation: The FLOOR function returns the biggest NUMBER that is smaller than or equal to the number itself.
80.

What is the order of namespaces in which Python looks for an identifier?(a) Python first searches the global namespace, then the local namespace and finally the built-in namespace(b) Python first searches the local namespace, then the global namespace and finally the built-in namespace(c) Python first searches the built-in namespace, then the global namespace and finally the local namespace(d) Python first searches the built-in namespace, then the local namespace and finally the global namespaceI had been asked this question during a job interview.This interesting question is from Python Modules topic in division Mapping Functions and Modules of Python

Answer» RIGHT option is (b) PYTHON first SEARCHES the local NAMESPACE, then the GLOBAL namespace and finally the built-in namespace

Easiest explanation - Python first searches for the local, then the global and finally the built-in namespace.
81.

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 producedI had been asked this question by my school principal while I was bunking the class.The origin of the question is Python Modules in chapter Mapping Functions and Modules of Python

Answer» RIGHT option is (c) In the “from-import” form of import, all IDENTIFIERS regardless of whether they are private or public are imported

Easiest EXPLANATION - In the “from-import” form of import, identifiers beginning with two UNDERSCORES are private and aren’t imported.
82.

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: identifierThe question was asked in semester exam.This interesting question is from Python Modules topic in section Mapping Functions and Modules of Python

Answer»

The correct answer is (B) This form of import prevents name clash

For explanation: In the “from-import” form of import, there MAY be name CLASHES because names of the imported identifiers aren’t specified ALONG with the module name.

83.

Which of the following is not a valid namespace?(a) Global namespace(b) Public namespace(c) Built-in namespace(d) Local namespaceI got this question in unit test.The query is from Python Modules topic in section Mapping Functions and Modules of Python

Answer» RIGHT ANSWER is (b) Public namespace

Easy explanation - During a PYTHON program execution, there are as many as THREE namespaces – built-in namespace, global namespace and LOCAL namespace.
84.

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.identifierThe question was posed to me in my homework.Query is from Python Modules in division Mapping Functions and Modules of Python

Answer»

Correct ANSWER is (a) The namespace of imported module BECOMES part of importing module

The explanation: In the “IMPORT modulename” FORM of import, the namespace of imported module becomes AVAILABLE to, but not part of, the importing module.

85.

Which of the following isn’t true about main modules?(a) When a python file is directly executed, it is considered main module of a program(b) Main modules may import any number of modules(c) Special name given to main modules is: __main__(d) Other main modules can import main modulesI had been asked this question in quiz.My enquiry is from Python Modules in portion Mapping Functions and Modules of Python

Answer»

The CORRECT ANSWER is (d) Other main modules can import main modules

The explanation: Main modules are not meant to be imported into other modules.

86.

In top-down design every module is broken into same number of submodules.(a) True(b) FalseThe question was posed to me in examination.I need to ask this question from Python Modules in section Mapping Functions and Modules of Python

Answer»

Correct option is (B) False

The explanation: In top-down design EVERY module can even be BROKEN down into different NUMBER of SUBMODULES.

87.

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 addressedI got this question during a job interview.Query is from Python Modules topic in portion Mapping Functions and Modules of Python

Answer»

Correct answer is (c) The OVERALL design of the PROGRAM is ADDRESSED before the details

For explanation: Top-down design is an APPROACH for deriving a MODULAR design in which the overall design.

88.

______ is a string literal denoted by triple quotes for providing the specifications of certain program elements.(a) Interface(b) Modularity(c) Client(d) DocstringThis question was posed to me by my school principal while I was bunking the class.This key question is from Python Modules in chapter Mapping Functions and Modules of Python

Answer»

Correct option is (d) Docstring

The explanation is: Docstring USED for providing the specifications of PROGRAM ELEMENTS.

89.

Program code making use of a given module is called a ______ of the module.(a) Client(b) Docstring(c) Interface(d) ModularityThe question was posed to me by my college professor while I was bunking the class.My question comes from Python Modules in portion Mapping Functions and Modules of Python

Answer»

Correct answer is (a) Client

The EXPLANATION is: PROGRAM code MAKING USE of a given module is called the client of the module. There may be multiple clients for a module.

90.

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 programI had been asked this question at a job interview.My question is taken from Python Modules topic in portion Mapping Functions and Modules of Python

Answer»

Right option is (C) Provides a MEANS of REDUCING the size of the program

Explanation: The total size of the program remains the same REGARDLESS of whether modules are used or not. Modules simply divide the program.

91.

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 codeI had been asked this question by my college professor while I was bunking the class.The question is from Python Modules in division Mapping Functions and Modules of Python

Answer»

The correct answer is (b) Design and IMPLEMENTATION of specific FUNCTIONALITY to be incorporated into a PROGRAM

To EXPLAIN: The term “module” refers to the implementation of specific functionality to be incorporated into a program.

92.

Which of these is false about a package?(a) A package can have subfolders and modules(b) Each import package need not introduce a namespace(c) import folder.subfolder.mod1 imports packages(d) from folder.subfolder.mod1 import objects imports packagesThis question was addressed to me at a job interview.The doubt is from Mapping Functions in section Mapping Functions and Modules of Python

Answer»

The correct option is (B) Each import package need not introduce a namespace

To EXPLAIN: Packages provide a WAY of STRUCTURING PYTHON namespace. Each import package introduces a namespace.

93.

Which of these is the definition for packages in Python?(a) A folder of python modules(b) A set of programs making use of Python modules(c) A set of main modules(d) A number of files containing Python definitions and statementsI have been asked this question in an internship interview.My question is taken from Mapping Functions in portion Mapping Functions and Modules of Python

Answer» RIGHT CHOICE is (a) A folder of PYTHON modules

To EXPLAIN: A folder of python PROGRAMS is called as a package of modules.
94.

Is Python code compiled or interpreted?(a) Python code is only compiled(b) Python code is both compiled and interpreted(c) Python code is only interpreted(d) Python code is neither compiled nor interpretedI had been asked this question in an online interview.The question is from Mapping Functions topic in division Mapping Functions and Modules of Python

Answer»

Correct answer is (b) PYTHON code is both compiled and interpreted

Easiest explanation - Many LANGUAGES have been implemented using both COMPILERS and interpreters, INCLUDING C, Pascal, and Python.