Python Coding Questions - MCQ - Coding Test - Part 02


Python Coding Question

Chapter 05: Data type, Conversion

Q. 1: What is the number of Built-in data types in python?

(a) 6

(b) 10

(c) 7

(d) 8

Ans: (c) 7 (Test type, Numeric type, Mapping type, Sequence type, Set type, Boolean type, and Binary type)

 

Q. 2: Binary data types of python are ________

(a) set, forzenset

(b) int, float, complex

(c) list, tuple, range

(d) bytes, bytearray, memoryview

Ans: (d) bytes, bytearray, memoryview

 

Q. 3: Memoryview is a _______

(a) Boolean data type

(b) Binary data type

(c) Mapping data type

(d) Sequence data type

Ans: (b) Binary data type

 

Q. 4: What is the function name of getting a data type in python?

(a) type()

(b) convert()

(c) conversion()

(d) transfer()

Ans: (a) type()

 

Q. 5: Output of the below program.

a = “hello”

print(type(a))

(a) <class ‘int’>

(b) undefined

(c) <class ‘str’>

(d) <class ‘float’>

Ans: (c) <class ‘str’>

 

Q. 6: Write down the output of this program

s = b“hello”

print(type(s))

(a) <class ‘bytes’>

(b) <class ‘int’>

(c) <class ‘str’>

(d) <class ‘float’>

Ans: (a) <class ‘bytes’>

 

Q. 7: How will you implement the below equation in python ?

2j+56

(a) string (2j+56)

(b) memoryview (2j+56)

(c) set (2j+56)

(d) complex (2j+56)

Ans: (d) complex (2j+56)

 

Q. 8: What is the output of variable ‘a’?

a = memoryview(bytes(40))

(a) Output will be an ‘int’ type  

(b) Output will be a ‘string’ type

(c) Output will be an ‘address memory’ type

(d) Output will  be a ‘boolean’ type

Ans: (c) Output will be an ‘address memory’ type

 

Q. 9: Write down the output of ‘b’ variable _______

a = float (100.20)

b = float (a)

b = int (b)

Ans: 100

 

Q. 10: Output of the ‘y’ variable is _________

y = range (5)

print(y)

(a) 1, 2, 3, 4, 5  

(b) 0, 1, 2, 3, 4

(c) 1, 5

(d) range (0, 5)

Ans: (d) range (0, 5)

 

 

 

Python Coding Question

Chapter 06: String

Q. 1: Find out the valid sentence based on python language rules.

(a) ‘python’ and “python” are not the same.

(b) ‘python’ and “python” are the same.

(c) ‘python’ and “python” both are not valid.

(d) None of the above.

Ans: (b) ‘python’ and “python” are the same.

 

Q. 2: What is the output of the below python program?

S1=”python”

S2=’program’

Print( s1, s2)

(a) pythonprogram

(b) This program is not valid

(c) python, program

(d) python program

Ans: (d) python program

 

Q. 3: Fill in the gap of the below sentence.

Strings are __________

(a) Sets

(b) Arrays

(c) Tuples

(d) Dictionaries

Ans: (d) python program

 

Q. 4: Output of the following python program is ______

S1=”python program”

S2= 2

Print( s1[s2])

(a) pyt

(b) t

(c) hon

(d) tho

Ans: (b) t

 

 

Q. 5: Choose the output of the following program.

S=” python programming is best”

Print( “are” in s)

(a) True

(b) False

(c) Undefined

(d) None of the above

Ans: (b) False

 

 

Q. 6: Choose the output for the print function.

S=” hello how are you?”

Print( “hello” in str)

(a) True

(b) False

(c) str is not defined

(d) argument of this type is not iterable

Ans: (d) argument of this type is not iterable

 

 

Q. 7: What will the print function show in the below program?

S=” Wish ! a good day”

If “good” in s1:

     print (“yes”)

else:

     print (“no”)

Print( “hello” in str)

(a) no

(b) yes

(c) undefined

(d) true

Ans: (b) yes

 

 

 

Post a Comment

Previous Post Next Post