Python/Python Functions MCQS Set 2 Sample Test,Sample questions

Question:
 What type of error is returned by following statement?
print(int(“a”))

1.Syntax error

2.ValueError

3.TypeError

4.Name Error


Question:
 Which of the following module is used for function max( )??

1.math

2.csv

3.random

4. No module is required


Question:
 Write the output of the following :
def var(var, lst):
    lst[0] = var
k = 33
a = [1, 2, 3]
var(k, a)
print(a)

1.1, 2, 3]

2.[33, 1, 2, 3]

3. [33, 1, 2]

4.Error


Question:
 Write the output of the following :
t=(32, 34, 33, 33.5, 41, 44, 33)
print(sum(t) + t.count(33))

1.252.0

2.253.0

3.252.5

4.254


Question:
 Write the output of the following.
print(abs(-8))

1.-8

2.8

3. 8.0

4.None of the above


Question:
 Write the output of the following:
def lst(l1):
   for x in l1:
        print(x.lower(),end="---")
lst(["MCQ","PAPER"])

1.MCQ—PAPER—

2.mcq—paper—

3.—mcq—paper

4.None of the above


Question:
How many numbers will be printed by the following code:
def fun(n1,n2):
for x in range(n1,n2+1):
   if x%4==0:
         print(x, end=" ")
fun(100,120)

1.5

2.6

3.7

4.8


Question:
Name the function required to check if a string contains only uppercase letters?

1.upper( )

2. isup( )

3.isupper( )

4.iscapital( )


Question:
Which method of pickle module reads data from a binary file?

1.dump( )

2. load( )

3.read( )

4.reader( )


Question:
Which of the following function is not invoked by math module?

1.ceil( )

2.floor( )

3.sqrt( )

4.mean( )


Question:
Which of the following function returns the length of a sequence?

1.len( )

2.length( )

3. lenseq( )

4.None of the above


Question:
Which of the following mathematical function return absolute value of a number?

1.absolute( )

2.abs( )

3.perfect( )

4. absl( )


Question:
Which of the following mathematical function return factorial of a number?

1.fact( )

2.facto( )

3.factorial( )

4.fct( )


Question:
Which of the following module is used with binary files?

1.math

2.csv

3.random

4.pickle


Question:
Which of the following module which need to be imported to invoke randint( ) function?

1.randoms

2.random

3.random( )

4.None of the above


Question:
Which of the following Python module need to be imported to invoke sin( ) function?

1.math

2.Maths

3.mathematics

4.None of the above


Question:
Write the output of : print((range(5)))

1.range(0, 5)

2.0, 1, 2, 3, 4

3.[0, 1, 2, 3, 4]

4.Error


Question:
Write the output of : print(float())

1. 1.0

2.0.0

3.Any floating number

4.Any integer


Question:
Write the output of : print(sum(1,2,1))

1.Error

2.4

3.2

4.3


Question:
Write the output of the following :
print(round(34.5671,2))
print(round(34.3631,2))

1.34.57 34.36

2.34.56 34.37

3.34.57 35.36

4.36.00 34.36


Question:
Write the output of the following:
def c(x, y):
    if x % y :
         return x+5
    else:
        return y+10
print(c(20, 5))

1.26

2.15

3.30

4.10


Question:
Write the output of the following:
def calc(x):
    r=2*x**2
    return r
print(calc(3))

1.18

2.8

3.36

4.9


Question:
Write the output of the following:
def disp(m="A", t = 1):
    for i in range(t):
        print(m * 1, end="#")
disp('B', 5)

1.B#B#B#B#B#

2.BBBBB

3.BBBBB#

4.#BBBBB#


Question:
Write the output of the following:
def guess(n="k", a=20, r="t"):
     return a, n, r
t=guess("k", "t", 7)
print(t)

1.(‘k’, ‘t’, 7)

2.(‘t’, ‘k’, 7)

3.(7, ‘t’, ‘k’)

4.(‘t’, 7, ‘k’)


Question:
Write the output of the following:
print(list(i * 2 for i in range(4)))
print(list(range(4)))

1.[0, 2, 4, 6] [3]

2.[0, 2, 4, 6] [0, 1, 2, 3]

3.[0, 1, 2, 3] [0, 1, 2, 3]

4.None of the above


Question:
Write the output of the following:
print(max(2, 5, 4, 8, 29, 24))

1. Error as there should be math.max( )

2.29

3.2

4.2 5 4 8 29 24


Question:
Write the output of the following:
print(min(“Hell”, “Hello”, “he”))

1.Hell

2.he

3.Hello

4.Error


Question:
Write the output of the following:
val = 20
def display (N):
    val = 25
        if N%5 == 0:
            val = val + N
        else:
            val = val - N
    print(val, end="#")
display(70)
print(val)

1.70#20

2.95#20

3.75#20

4.50#20


Question:
Write the output of the following: if user entered 7
a=input("Enter age")
print(type(a))

1.str

2.int

3.float

4.None of the above


More MCQS

  1. Python MCQS - Function
  2. Python MCQS - GUI in python
  3. Python MCQS - Operators
  4. Python MCQS - Data type in python
  5. Python MCQS - loops in python
  6. Python MCQS - Numpy
  7. Python MCQS - sqlite3
  8. Python MCQS - Library
  9. Python MCQS - Pandas
  10. Python MCQs
  11. Dictionary Python MCQ set 1
  12. Dictionary Python MCQ set 2
  13. MCQ For Python Fundamentals
  14. MCQ Introduction to Python Section 1
  15. MCQ Introduction to Python Section 2
  16. MCQ Introduction to Python Section 3
  17. MCQ on Flow of Control in Python Set 1
  18. MCQ on Flow of Control in Python Set 2
  19. MCQ on Python String Set 1
  20. File Handling in Python section 1
  21. File Handling in Python section 2
  22. Python Functions MCQS Set 1
  23. Python Functions MCQS Set 2
  24. MCQ on List in Python
  25. Pandas MCQ Questions Set 1
  26. Pandas MCQ Questions Set 2
  27. Tuple MCQ in Python
  28. Python dataframe MCQ
  29. Python Mcq Set 1
  30. Python Mcq Set 2
  31. Python Mcq Set 3
  32. Python Mcq Set 4
  33. Python Mcq Set 5
  34. Python Mcq Set 6
  35. Python Mcq Set 7
  36. Python Mcq Set 8
  37. Python Mcq Set 9
  38. Python Mcq Set 10
  39. Python Mcq Set 11
  40. Python Mcq Set 12
  41. Python Mcq Set 13
  42. Python Mcq Set 14
  43. Python Mcq Set 15
  44. Python Mcq Set 16
  45. Python Mcq Set 17
  46. Python Mcq Set 18
  47. Python Mcq Set 19
  48. Python Mcq Set 20
  49. Python Mcq Set 21
  50. Python MCQ
Search
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!