Disclaimer for ReGyan
If you require any more information or you have any problems regarding copyright or have any questions about our site’s disclaimer, please feel free to contact us by email at hello@regyan.com
Disclaimers for ReGyan
All the information on the website is published in good faith and for general information and educational purpose only. ReGyan does not make any warranties about the completeness, reliability, and accuracy of this information. Any action you take upon the information you find on this website(regyan.com) is strictly at your own risk. will not be liable for any losses and/or damages in connection with the use of our website.
Python Programming Quiz – 9th Week Quiz Solution given in this post. The solution of the 9th-week quiz are given below:-
[1] Assume that theFile is a file object, and the operations are all valid operations (i.e., theFile is open in an appropriate mode). Now if we execute – .numWritten = theFile.write(‘something’)
- (a): It tell whether theFile is open or closed
- (b): Reads and return ‘something’
- (c): Stores the number of characters written to theFile in a variable
- (d): reads a single line from theFile, including the newline character
Answer: (c) Stores the number of characters written to theFile in a variable
[2] Assume that theFile is a file object, and the operations are all valid operations (i.e., theFile is open in an appropriate mode). Now if we execute –
theFile.closed
- (a): tells (True of False) whether theFile is closed or not
- (b): Reads and return ‘something’
- (c): read a single line from theFile, including the newline character
- (d): modify the file object for theFile so that the next read will be from
Answer: (a) tells (True of False) whether theFile is closed or not
[3] Assume that theFile is a file object, and the operations are all valid operations (i.e., theFile is open in an appropriate mode). Now if we execute –
theFile.tell()
- (a): points to the location from where next byte will be read in theFile
- (b): tell whether theFile is open or closed
- (c): Reads and return ‘something’
- (d): Store the number of characters written to theFile in a variable
Answer:(a) points to the location from where next byte will be read in theFile
Also see:- How to get relief from shoulder pain naturally
[4] Assume that theFile is a file object, and the operations are all valid operations (i.e., theFile is open in an appropriate mode). Now if we execute –
theFile.seek(pos, ref)
- (a): tell whether theFile is open or closed
- (b): Read and return at most
- (c): Reads and return ‘something’
- (d): Store the number of characters written to theFile in a variable
Answer: (d) Store the number of characters written to theFile in a variable
[5] Assume that theFile is a file object, and the operations are all valid operations (i.e., theFile is open in an appropriate mode). Now if we execute-
theFile.readline
- (a): tell whether theFile is open or closed
- (b): Read and return at most
- (c): read a single line from theFile, including the newline character
- (d): modify the file object for theFile so that the next read will be from
Answer: (c) read a single line from theFile, including the newline character
[6] Which of the following command is used to open a file “C:\desktop\myfile.txt”, In read-mode only?
A. file_name = open(“C:\desktop\myfile.txt”, “r”) B. file_name = open(“C:\\desktop\myfile.txt”, “r”) C. file_name = open(file = “C:\desktop \myfile.txt”, “r+”) D. file_name = open(file = “C:\desktop\myfile.txt”, “r+”)
- (a): A
- (b): B
- (c): C
- (d): D
Answer: (b)file_name = open(“C:\\desktop\myfile.txt”, “r”)
[7] What will be the output of the following given code?
with open("myfile.txt", "w") as f: f.write("Hello World Python Programming") with open('myfile.txt', 'r') as f: data = f.readlines() for line in data: words = line.split() print (words)
- (a): Hello
- (b): Hello World Python Programming
- (c): [‘Hello’, ‘World’, Python, Programming]
- (d): Runtime Error
Answer: (c) [‘Hello’, ‘World’, Python, Programming]
Also See:- Some Tips to Release Anger in 5 days
[8] Which of the following commands can be used to read the entire contents of a file object (object name myfile)?
- (a): myfile.read(n)
- (b): myfile.read()
- (c): myfile.readline()
- (d): myfile.readlines()
Answer: (b) myfile.read()
Also, see: AICTSD (Albert Einstein International Scholarship Test )
[9] The readlines() method returns ____________
- (a): str
- (b): a list of lines
- (c): a list of single characters
- (d): a list of integers
Answer: (b) a list of lines
[10] To read the remaining lines of the file from a file object infile, we use ____________
- (a): infile.read(2)
- (b): infile.read()
- (c): infile.readline()
- (d): infile.readlines()
Answer: (c) infile.readline()
[11] When will the else part of try-except-else be executed?
- (a): always
- (b): when an exception occurs
- (c): when no exception occurs
- (d): when an exception occurs in to except block
Answer: (c) when no exception occurs
[12] What will be output when ‘1’ == 1 is executed?
- (a): True
- (b): False
- (c): TypeError
- (d): ValueError
Answer: (b) False
[13] What will be output of following given code?
try: print(x) except NameError: print("Variable x is not defined") except: print("Something wrong")
- (a): x
- (b): Something wrong
- (c): Variable x is not defined
- (d): None of these
Answer: (c) Variable x is not defined
[14] How many except statements can a try-except block have?
- (a): zero
- (b): one
- (c): more than one
- (d): more than zero
Answer: (d) more than zero
[15] What will be the output of the following Python code?
def test(): try: print(1) finally: print(2) test()
- (a): 1 2
- (b): 1
- (c): 2
- (d): None of these
Answer: (a) 1 2
That’s all for the Python programming Quiz – 9th Week Quiz Solution. if you have any questions, please comment down below, we will try to answer within the first 24 hours. I hope you liked this content. We will come to another week’s quiz. Thanks for reading.
run this code and see the result
the given answer is right bcz approved by aktu
for more details see my result
Send me screenshot my WhatsApp no 9639712421
ok
sir quiz 9 not shon my id plz reply
The time is over
What kind of exception will be raised by ( using python 3.x version):
assert 5/0 > 0
Value error exception
Assertion error exception
Zero division error exception
No exception is raised the program
Zero division error exception
What kind of exception will be raised by (using python 3.X version):
assert 5/0 > 0
What kind of exception will be raised by (using python 3.X version):
assert 5/0 > 0
What kind of exception will be raised by ( using python 3.x version):
assert 5/0 > 0
Value error exception
Assertion error exception
Zero division error exception
No exception is raised the program
Zero division error exception
What kind of exception will be raised by (using python 3.X version):
assert 5/0 > 0
Zero division error exception
Assume that theFile is a file object, and the operations are all valid operations (i.e., theFile is open in an appropriate mode). Now if we execute –
theFile.seek(pos, ref)
send me the options
Options are
1. Tell whether the file is open or closed.
2.Read and return at most.
3.Reads and return ‘something’.
4. Sets the current file stream position to the ‘pos’ position in the file.
Assume that theFile is a file object, and the operations are all valid operations (i.e., theFile is open in an appropriate mode). Now if we execute –
theFile.seek(pos, ref)
What kind of exception will be raised by (using python 3.X version):
assert 5/0 > 0