gs gs109 Python Files - Python Files - Quiz No.2
gs gs109 Python Quiz
This quiz belongs to book/course code gs gs109 Python of gs organization. We have 134 quizzes available related to the book/course Python. This quiz has a total of 10 multiple choice questions (MCQs) to prepare and belongs to topic Python Files. NVAEducation wants its users to help them learn in an easy way. For that purpose, you are free to prepare online MCQs and quizzes.
NVAEducation also facilitates users to contribute in online competitions with other students to make a challenging situation to learn in a creative way. You can create one to one, and group competition on an topic of a book/course code. Also on NVAEducation you can get certifications by passing the online quiz test.
Question 1: Which are the two built-in functions to read a line of text from standard input, which by default comes from the keyboard?
Raw_input & Input
Input & Scan
Scan & Scanner
Scanner
Question 2: What will be the output of the following Python code?
str = raw_input("Enter your input: "); print "Received input is : ", str
Enter your input: Hello Python Received input is : Hello Python
Enter your input: Hello Python Received input is : Hello
Enter your input: Hello Python Received input is : Python
None of the mentioned
Question 3: What will be the output of the following Python code?
str = input("Enter your input: "); print "Received input is : ", str
Enter your input: [x*5 for x in range(2,10,2)] Received input is : [x*5 for x in range(2,10,2)]
Enter your input: [x*5 for x in range(2,10,2)] Received input is : [10, 30, 20, 40]
Enter your input: [x*5 for x in range(2,10,2)] Received input is : [10, 10, 30, 40]
None of the mentioned
Question 4: Which one of the following is not attributes of file?
closed
softspace
rename
mode
Question 5: What is the use of tell() method in python?
tells you the current position within the file
tells you the end position within the file
tells you the file is opened or not
none of the mentioned
Question 6: What is the current syntax of rename() a file?
rename(current_file_name, new_file_name)
rename(new_file_name, current_file_name,)
rename(()(current_file_name, new_file_name))
none of the mentioned
Question 7: What is the current syntax of remove() a file?
remove(file_name)
remove(new_file_name, current_file_name,)
remove(() , file_name))
none of the mentioned
Question 8: What will be the output of the following Python code?
fo = open("foo.txt", "rw+") print "Name of the file: ", fo.name # Assuming file has following 5 lines # This is 1st line # This is 2nd line # This is 3rd line # This is 4th line # This is 5th line for index in range(5): line = fo.next() print "Line No %d - %s" % (index, line) # Close opened file fo.close()
Compilation Error
Syntax Error
Displays Output
None of the mentioned
Question 9: What is the use of seek() method in files?
sets the file’s current position at the offset
sets the file’s previous position at the offset
sets the file’s current position within the file
none of the mentioned
Question 10: What is the use of truncate() method in file?
truncates the file size
deletes the content of the file
deletes the file size
none of the mentioned