Prutor Python Quiz 9 by anupmaurya June 13, 2021 written by anupmaurya 0 comment 358 views Welcome to your Prutor Python Quiz 9 1. If we have a file object as fileobj, then What does the attribute 'closed' will tell on this file obj ? 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 1 out of 5 2. In python, _____ method gets the position of file handle while ____ method changes the position of file handle to the specific position. a) seek, tell b) tell, seek c) read, tell d) tell, change 2 out of 5 3. What will be the output of following python code? with open("myfile.txt", "w") as f: f.write("Hello World Python Programming") with open('myfile.txt', 'w+') as f: f.write("Hello") f.seek(0) 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 3 out of 5 4. In the readlines() method - a) it returns a string. b) it returns a list of lines. c) an optional parameter sizehint can be used to limit the number of bytes to read from a file. d) Both 2 and 3 4 out of 5 5. In python, try-except has an optional else clause, which will execute - a) always b) when try clause does not raise exception c) when OSError happens d) All of the above. 5 out of 5 Time is Up! Time's up Share 0 FacebookTwitterLinkedinRedditWhatsappTelegramEmail anupmaurya Hey there, My name is Anup Maurya. I was born with love with programming and works at TCS. One of best global (IT) services and consulting company as System Administrator . I also love graphics designing. It's my pleasure to have you here. previous post Prutor Python Quiz 2 next post Prutor Python Quiz 4 Leave a Comment Cancel Reply Save my name, email, and website in this browser for the next time I comment. * By using this form you agree with the storage and handling of your data by this website.