Search Header Logo

python_quiz4

Authored by Ibrahim Khaleel

Computers

9th - 12th Grade

Used 1+ times

python_quiz4
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

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")

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?