Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Lesson 42-Various opening modes in file

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

What will be the ouput -

f=open('abc.txt','w')

x=f.read()

f.close()

print(x)

a)

Error(not readable)

b)

Error(not writable)

c)

It will read all the data of the file.

d)

none

2.

What will be the output-

f=open('abc.txt','a')

text="xyz"

f.write(text)

f.close()

a)

Writing into the file without erasing old content

b)

Writing into the file by erasing old content

c)

reading from the file without erasing old content

d)

reading from the file by erasing old content

3.

If you will have to store marks of 10 students then which python datatype will you use ?

a)

Dictionary

b)

set

c)

list

d)

string

4.

If you will have to store roll numbers of all the students, then which python datatype will you use ?

a)

set

b)

Dictionary

c)

list

d)

tuple

5.

Which operator used to compares equality ?

a)

==

b)

=

c)

<

d)

>

6.

What will be the output-

x=""

if(!x):

print("hello")

else:

print("bye")

a)

hello

b)

bye

c)

error

d)

none

7.

which function is used to find the length of the list ?

a)

len()

b)

size()

c)

length()

d)

none

8.

Which logical operator is used to checks for each and every condition is true ?

a)

and

b)

or

c)

not

d)

none

9.

Which logical operator used to check for any one condition to be true ?

a)

or

b)

and

c)

not

d)

none

10.

Which of the following operator is used for negation ?

a)

!

b)

not

c)

both ! and not

d)

none