Python Functions important MCQs in English/Hindi | Nielit Notes | PDF

In this post, we cover all important Questions from the topic "Python Functions".

These MCQs will definitely help to pass IT and Computer students in any exam and interview that have Pyhton Functions topic.

The Python Functions chapter covers the following topics:

Top-down approach of problem solving, Modular programming and functions,

Function parameters, Local variables, the Return statement, DocStrings, global

statement, Default argument values, keyword arguments, VarArgs parameters.

Library function-input(), eval(),print(), String Functions: count(), find(), rfind(),

capitalize(), title(), lower(), upper(), swapcase(), islower(), isupper(), istitle(),

replace(), strip(), lstrip(), rstrip(), aplit(), partition(), join(), isspace(), isalpha(),

isdigit(), isalnum(), startswith(), endswith(), encode(), decode(), String: Slicing,

Membership, Pattern Matching, Numeric Functions: eval(), max(), min(), pow(),

round(), int(), random(), ceil(), floor(), sqrt(), Date & Time Functions, Recursion


After completion of the Python Functions unit, Students will be able to: 

  • Apply the in-built functions available in Python in solving different problems.
  • Work with modular approach using user-defined functions.


Python Functions MCQs

Here are the 50 most important and frequently asked MCQs from the  "Python Functions" topic.


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

a) Module

b) Class

c) Another function

d) Method

Ans. d)


2. Number of argument pass in index() function ?

a)1

b)2

c)3

d)4

Ans. a)


3. How many argument we pass in append() function ?

a)1

b)2

c)3

d)5

Ans. a)


4.  What is the output of the functions shown below?

float('1e-003')float('2e+003')

a) c)00 and 300 

b) 0.001 and 2000.0

c) 0.001 and 200 

d) Error and 2003

Ans. b)


5. Which of the following are used in function

a)()

b)[]

c){}

d)None of the above

Ans. a)


6. 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

Ans. d)


7. What is the use of tell() function in File handling in python ?

a)It check the available file

b)It return the number of character in file

c)Return file type

d)None of the above

Ans. b)


8. What is the output of the function shown below?

hex(15)

a) f 

b) 0xF 

c) 0Xf 

d) 0xf

Ans. d)


9. Which keyword we use to define a function ?

a)void

b)int

c)any type

d)def

Ans. d)


10. The function complex(‘2-3j’) is valid but the function complex (‘2 – 3j’) is invalid. State whether this statement is true or false.

a) True 

b) False

Ans. a) True 


11. Number of arguments to pass in sleep() function?

a)1

b)2

c)3

d)4

Ans. a)


12. Which of the list function not take care of index value to perform the task?

a)append()

b)pop()

c)clear()

d)All of the above

Ans. d)


13. 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

Ans. d)


14. Which of the function is used to pause the current execution?

a)pause()

b)break()

c)sleep()

d)require()

Ans. c)


15. What is the output of the following code?

print(type(char))

a)int

b)char

c)string

d)All of the above

Ans. b)


16. What is the output of below program?

def say(message, times = 1): print(message * times)say('Hello')say('World', 5)

a) Hello and WorldWorldWorldWorldWorld 

b) Hello and World 5

c) Hello and World,World,World,World,World

d) Hello and HelloHelloHelloHelloHello

Ans. a)


17. Which is essential argument to pass in map() function ?

a)function

b)sequence

c)Both of the above

d)None of the above

Ans. c)


18. What is the output of the functions shown below?

divmod(10.5,5)divmod(b)4,a)2)

a) (b)00, 0.50) and (b)00, 0.00) 

b) (2, 0.5) and (2, 0)

c) (b)0, 0.5) and (b)0, 0.0) 

d) (2, 0.5) and (2)

Ans. c)


19. Which type of function we call as a argument in map() function ?

a)User defined function

b)Build In function

c)lambda function

d)All of the above

Ans. d)


20. What will be the output of the following Python code?

def change(one, *two):

print(type(two))

change(1,2,3,4)

a) Integer

b) Tuple

c) Dictionary

d) An exception is thrown

Ans. b)


21. Which of the following is valid to find the inverse of cosine?

a)cosa

b)acos

c)cosi

d)icos

Ans. b)


22. If function is defined inside the class then it is called

a)Module

b)class

c)Object

d)Method

Ans. d)


23. What are the outcomes of the following functions?

 chr(‘97’)

 chr(97)

a) a and Erro

b) ‘a’

c) Error 

d) ErrorError

Ans. c)


24. What is return by the islower() function ?

a)True

b)False

c)True or False

d)None of the above

Ans. c)


25. What will be the output of the following Python code?

y = 6

z = lambda x: x * y

print z(8)

a) 48

b) 14

c) 64

d) None of the mentioned

Ans. a)


26. What we pass in split() function ?

a)string

b)integer

c)list

d)array

Ans. a)


27. Function that are defined without the use of def keyword are

a)predefined function

b)pass by value function

c)lambda function

d)All of the above

Ans. c)


28. Number of argument we pass in sum() function ?

a)1

b)2

c)3

d)As much we want

Ans. d)


29. What will be the output of the following Python code?

def say(message, times = 1):

print(message * times)

say('Hello')

say('World', 5)


a)

Hello

WorldWorldWorldWorldWorld


b)

Hello

World 5


c)

Hello

World,World,World,World,World


d)

Hello

HelloHelloHelloHelloHello

View Answer


Ans. a)


30. What is the output of the functions shown below?

min(max(False,-3,-4), 2,7)

a) 2 

b) False 

c) -3 

d) -4

Ans. b)



31. Which of the function are used to get the value from the user side?

a)scan()

b)scanf()

c)scand()

d)input()

Ans. d)


32. Which of the following functions does not throw an error?

a) ord()

b) ord(‘ ‘)

c) ord(”)

d) ord(“”)

Ans. b)


33. Which of the following is valid for reverse the sequence ?

a)reverse()

b)reversed()

c)Both of the above

d)None of the above

Ans. c)


34. 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))

a) 2

b) 3

c) The numbers are equal

d) None of the mentioned

Ans. b)


35. What is return by the isdigit() function ?

a)True

b)False

c)True or False

d)None of the above

Ans. c)


36. What are the outcomes of the function shown below?x=3eval('x^2')

a) Error 

b) 1 

c) 9 

d) 6

Ans. b)


37. What are the two main types of functions?

a) Custom function

b) Built-in function & User defined function

c) User function

d) System function

Ans. b)


38. what is the output of the following program

l=[1,2,3,4]

join(l)

a)123

b)Ascii value

c)Error

d)None of the above

Ans. c)


39. What we pass in ord() function ?

a)Any character

b)Alphabet

c)Number

d)Only special character

Ans. a)


40. 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

Ans. a)


41. Append() function in python is used for

a)Insertion

b)Deletion

c)Clear the data

d)Traverse the data

Ans. a)


42. 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)

a) zzz

b) zz

c) An exception is executed

d) Infinite loop

Ans. a)


43. Which of the following is used to read the text file ?

a)read()

b)readline()

c)readlines()

d)All of the above

Ans. d)


44. What is the output of the function:

all(3,0,d)2)

a) True 

b) False 

c) Error 

d) 0

Ans. c)


45. What we pass in index() function ?

a)Number

b)String

c)List

d)All of the above

Ans. d)


46. numpy.array() is a function which convert

a)list to array

b)array to list

c)string to array

d)array to string

Ans. a)


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

a) lambda

b) pi

c) anonymous

d) none of the mentioned

Ans. a)


48. type() function in python is

a)User defined function

b)Predefined function

c)It is not function

d)None of the above

Ans. b)


49. How many argument we pass in map() function ?

a)1

b)2

c)3

d)4

Ans. b)


50. 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)

a) 9997

b) 9999

c) 9996

d) None of the mentioned

Ans. c)

No comments:

Powered by Blogger.