WorksheetsLesson 42 - file related functions
Total questions: 10
Worksheet time: 5mins
What will be the output-
f=open('abc','w')
l=['kolkata\n','delhi\n','chennai\n','mumbai\n']
f.write(l)
f.close()
print("written all the elements of list")
written all the elements of list
wrong arguments in write function error
file not available error
Opening wrong file mode error
What is the output of the following program :
print "Hello World"[::-1]
dlroW olleH
Hello Worl
d
Error
What is the output of the following code :
print 9//2
4
4.5
4.0
error
Which of these is not a core data type?
class
list
dictionary
set
What data type is the object below ? L = [1, 23, ‘hello’, 1]
List
Dictionary
tuple
Array
What will be the output of the following code :
print type(type(int))
type 'int'
type 'type'
error
0
What is the output of the following program :
y = 8
z = lambda x : x * y
print z(6)
48
14
64
none
Suppose list1 is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after list1.pop(1)?
[3, 5, 20, 5, 25, 1, 3]
[1, 3, 4, 5, 20, 5, 25]
[1, 3, 3, 4, 5, 5, 20, 25]
[3, 4, 5, 20, 5, 25, 1, 3]
What is the output of the expression : 3*1**3
27
3
9
1
Which of the following is invalid?
_a = 1
__a = 1
__str__ = 1
none
