python_quiz4

python_quiz4

9th - 12th Grade

15 Qs

quiz-placeholder

Similar activities

DTD - 5AI

DTD - 5AI

12th Grade

17 Qs

Python Recap

Python Recap

7th Grade - University

20 Qs

DATA FILE HANDLING

DATA FILE HANDLING

12th Grade

10 Qs

Y10 Python Text Files

Y10 Python Text Files

10th Grade

10 Qs

Kiểm tra

Kiểm tra

11th - 12th Grade

10 Qs

TIN 10 F4 Vào ra

TIN 10 F4 Vào ra

12th Grade

11 Qs

HTML Basics Quiz

HTML Basics Quiz

9th Grade - University

11 Qs

Exploring File Handling in Python

Exploring File Handling in Python

12th Grade

16 Qs

python_quiz4

python_quiz4

Assessment

Quiz

Computers

9th - 12th Grade

Medium

Created by

Ibrahim Khaleel

Used 1+ times

FREE Resource

15 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following is not a method of opening files?

Append

Replace

Read

Write

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the last action that must be performed on a file?

End

Write

Save

Close

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

When will the else part of try-except-else be executed?

always

when an exception occurs

when no exception occurs

never

Answer explanation

The else part is executed when no exception occurs.

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Is the following Python code valid?

try:

# Do something

except:

# Do something

else:

# Do something

no, there is no such thing as else

no, else cannot be used with except

no, else must come before except

yes

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the function used to open a file in Python?

open()

read()

write()

close()

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the default mode for opening a file in Python?

'r'

'w'

'a'

'x'

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the syntax for opening a file in write mode?

file = open("filename.txt", "w")

file = open("filename.txt", "r")

file = open("filename.txt", "a")

file = open("filename.txt", "x")

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?