Font size
WorksheetsTopic Quiz-1 : Python Basics
Total questions: 10
Worksheet time: 10mins
Which code prints the output [3,7,8] for a given list -
[ [1,2,3] , [5,6,7] , [0,9,8] ]
[i[2] for i in list]
[i(2) for i in list]
[i[3] for i in list]
(i(3) for i in list)
tuple=(10,20,30,40,50)
Which code prints the output(50,40,30,20,10) :
tuple(-1::)
tuple(::-1)
tuple(Sort)
set(tuple)
Given a function that does not return any value, What value is thrown by default when executed in shell.
int
Null
void
None
What will be the output of the following Python code?
str1 = 'hello'
str1=str1+2
hello2
Error
hello
hello 2
Guess the output :
[[[0]], [[[0]], [1]], [[[0]], [[[0]], [1]], [2]]]
[[0], [[0], 1], [[0], [[0], 1], 2]]
[0, None, 1, None, 2, None]
[[[0]], [[[0]], [1]], [[[0]], [[[0]], [1]], [2]]]
Which of the following are true of Python lists?
There is no conceptual limit to the size of a list
These represent the same list:
['a', 'b', 'c']
['c', 'a', 'b']
A given object may appear in a list more than once
A list may contain any type of object except another list
What is the result of this statement:
{'b', 'a', 'r'} & set('qux')
{'b', 'r', 'a'}
set()
{'q', 'r', 'x', 'u', 'b', 'a'}
{}
Consider the above code snippet -
# Python 3. dict.keys() returns a view object, not a list
apple
orange
banana
None
RuntimeError: dictionary changed size during iteration
There will be no output.
Mutable datatypes in python -
List
Strings
Dictionary
Which of these is called lazy evaluation.
range()
xrange()
