Core Data Type In Python: MCQs Python Language
Core Data Type In Python. Multiple Choice Questions related to Core Data Type In Python.
Core Data Type In Python
What is the return value of trunc() ??
a) int
b) bool
c) float
d) None
Select all options that print –> hello-how-are-you ??
a) print(‘hello’, ‘how’, ‘are’, ‘you’)
b) print(‘hello’, ‘how’, ‘are’, ‘you’ + ‘-‘ * 4)
c) print(‘hello-‘ + ‘how-are-you’)
d) print(‘hello’ + ‘-‘ + ‘how’ + ‘-‘ + ‘are’ + ‘you’)
The following is displayed by a print function call. Select all of the function calls that result in this output ??
tom
dick
harry
a) print(”’tom
\ndick
\nharry”’)
b) print(”’tomdickharry”’)
c) print(‘tom\ndick\nharry’)
d) print(‘tom
dick
harry’)
Which of the following results in a SyntaxError ??
a) ‘”Once upon a time…”, she said.’
b) “He said, ‘Yes!’”
c) ‘3\’
d) ”’That’s okay”’
In order to store values in terms of key and value, we use what core data type ??
a) list
b) tuple
c) class
d) dictionary
Core Data Type In Python
What data type is the object below ??
L = [1, 23, ‘hello’, 1]
a) list
b) dictionary
c) array
d) tuple
What will be the output of the following Python code snippet ??
def example(a):
a = a + ‘2’
a = a*2
return a
>>>example(“hello”)
a) indentation Error
b) cannot perform a mathematical operation on strings
c) hello2
d) hello2hello2
What error occurs when you execute the following Python code snippet ??
apple = mango
a) SyntaxError
b) NameError
c) ValueError
d) TypeError
In python we do not specify types, it is directly interpreted by the compiler, so consider the following operation to be performed ??
>>>x = 13 ? 2
objective is to make sure x has a integer value, select all that apply (python 3.xx)
a) x = 13 // 2
b) x = int(13 / 2)
c) x = 13 % 2
d) All of the mentioned
What is the return type of function id ??
a) int
b) float
c) bool
d) dict
Core Data Type In Python
Which of the following will run without errors ??
a) round(45.8)
b) round(6352.898,2,5)
c) round()
d) round(7463.123,2,1)
What will be the output of the following Python code ??
>>>str=”hello”
>>>str[:2]
>>>
a) he
b) lo
c) olleh
d) hello
Given a function that does not return any value, What value is thrown by default when executed in shell ??
a) int
b) bool
c) void
d) None
Which of these is not a core data type ??
a) Lists
b) Dictionary
c) Tuples
d) Class
What is the average value of the following Python code snippet ??
>>>grade1 = 80
>>>grade2 = 90
>>>average = (grade1 + grade2) / 2
a) 85.0
b) 85.1
c) 95.0
d) 95.1
…