Table of Contents
This article presents Multiple Choice Quiz About Python - Part 3 in a clear, structured format. It helps readers review key concepts, test their understanding, and learn from the material.
Understanding Multiple Choice Quiz About Python
- Question 1: What does opening file with mode 'a' mean?
- Opening files in read-only mode.
- Open the file in recording mode.
- Open the recording mode file at the end of the file.
- Open the file to read and write.
- Question 2: What does the code below mean?
f = open ("test.txt")- Open the test.txt file that is allowed to read and write to the file.
- Open test.txt file and only read file.
- Open the test.txt file and be allowed to overwrite the file.
- Open the file test.txt and be allowed to write to the file.
- Question 3: Which code automatically closes the file when an exception occurs?
-
with open ("test.txt", encoding = 'utf-8') as f: -
try:f = open ("test.txt", encoding = 'utf-8')finallf.close () - There is no exact answer.
- Both answers are correct
-
- Question 4: Which assertion is correct about the code below?
f = open ('test.txt', 'r', encoding = 'utf-8')f.read ()- This program reads the content of test.txt file.
- If test.txt is downstream, the read () function will return the new line's start symbol 'n'.
- You can pass an integer type parameter to read ().
- All of the above answers are correct.
- Question 5: What does the code below mean?
os.listdir ()- Print out the current working directory.
- Print out all folders (not files) inside the given folder.
- Print out all folders and files inside the given folder.
- Create a new folder.
- Question 6: Which of the following statements is correct?
- Exception is an error that arises when executing the program (runtime error).
- The syntax error is also an exception.
- Exceptions are used by Python to remove a block of code from the program.
- All of the above answers are correct.
- Question 7: What happens if you try to open a file that doesn't exist?
- Python automatically creates a new file under the name you are calling.
- Nothing happens because the file does not exist.
- Caused an exception
- There is no right answer
- Question 8: What is the result of the code below?
number = 5.0try:r = 10/numberprint (r)except:print ("Oops! Error occurred.")- Oops! Error occurred.
- 2.0
- 2.0 Oops! Error occurred.
- 5.0
- Question 9: What does the following code do?
try:# ?o?n code có th? gây ra l?ipassexcept (TypeError, ZeroDivisionError):print ("Python Quiz")- Print 'Python Quiz' if an exception occurs (no matter what the exception is).
- Print out 'Python Quiz' if no exception occurs.
- Print 'Python Quiz' if one of the exceptions TypeError and ZeroDivisionError occurs.
- Only print 'Python Quiz' when both exceptions TypeError and ZeroDivisionError happen.
- Question 10: Which exception occurs when it detects an error does not belong to any other category?
- ReferenceError
- SystemError
- RuntimeError
- LookupError
- Question 11: Which result is the output of the code below?
def myfunc ():try:print ('Monday')finally:print ('Tuesday')myfunc ()- Tuesday
- Monday Tuesday
- Tuesday Monday
- Monday
- Question 12: Which result is the output of the code below?
try:print ("throw")except:print ("except")finally:print ("finally")- finally throw
- finally except
- except finally
- throw finally
- Question 13: Which assertion is correct about the program below?
class A:def __init__(self):self.a = 1self.__b = 1def getY (self):return self.__bobj = A ()obj.a = 45print (obj.a)- The program has an error because '__b' is a private property, not accessible from outside the class.
- The program runs normally and the printed result is 1.
- The program has an error because 'a' is a private property, not accessible from outside the class.
- The program runs normally and the printed result is 45.
- Question 14: Which assertion is correct about the program below?
class A:def __init__(self):self.x = 1self.__y = 1def getY (self):return self.__ya = A ()ax = 45print (ax)- The program has an error because 'x' is a private property, not accessible from outside the class.
- The program runs normally and the printed result is 1.
- The program has an error because '__y' is a private property, not accessible from outside the class.
- The program runs normally and the printed result is 45.
- Question 15: What does opening file with mode 'wb' mean?
- Open the file to record.
- Open the file to read and write.
- Open the file to record for binary format.
- Open the file to read and write to binary.
FAQ
What is the main point of Multiple Choice Quiz About Python - Part 3?
Question 1: What does opening file with mode 'a' mean? Opening files in read-only mode.
Why is Multiple Choice Quiz About Python - Part 3 important?
Multiple Choice Quiz About Python - Part 3 matters because it can affect how readers understand, choose, use, or respond to the subject discussed in the article.
What should readers verify about Multiple Choice Quiz About Python - Part 3?
Check the date, product or software version, compatibility, and any current guidance before acting, especially when technology, security, health, or pricing is involved.
Reader Comments 0
Sign in with email or Google to join the discussion.