1) Which of the following command is used to open a file “c:\temp.txt” in read-mode only? a) infile = open(“c:\temp.txt”, “r”) b) infile = open(“c:\\temp.txt”, “r”) c) infile = open(file = “c:\temp.txt”, “r+”) d) infile = open(file = “c:\\temp.txt”, “r+”) 2) Which of the following command is used to open a file “c:\temp.txt” in write-mode only? a) infile = open(“c:\temp.txt”, “r”) b) infile = open(“c:\\temp.txt”, “r”) c) infile = open(file = “c:\temp.txt”, “r+”) d) infile = open(file = “c:\\temp.txt”, “r+”) 3) Which of the following command(s) is used to open a file “c:\temp.txt” in append-mode? a) outfile = open(“c:/temp.txt”, “a”) b) outfile = open(“c:\\temp.txt”, “rw”) c) outfile = open(“c:\temp.txt”, “w+”) d) outfile = open(“c:\\temp.txt”, “r+”) e) outfile = open(“c:\\temp.txt”, “a”) 4) Which of the following statements are true regarding the opening modes of a file? a) When you open a file for reading, if the file does not exist, an error occurs. b) When you open a file for writing, if the file does not exist, an error occurs. c) When you open a file for reading, if the file does not exist, the program will open an empty file. d) When you open a file for writing, if the file does not exist, a new file is created. e) When you open a file for writing, if the file exists, the existing file is overwritten with the new file. 5) Which of the following commands can be used to read “n” number of characters from a file using the file object <file>? a) file.read(n) b) n = file.read() c) file.readline(n) d) file.readlines() 6) Which of the following commands can be used to read the entire contents of a file as a string using the file object <tmpfile>? a) tmpfile.read(n) b) tmpfile.read() c) tmpfile.readline() d) tmpfile.readlines() 7) Which of the following commands can be used to read the next line in a file using the file object <tmpfile>? a) tmpfile.read(n) b) tmpfile.read() c) tmpfile.readline() d) tmpfile.readlines() 8) Which of the following commands can be used to read the remaining lines in a file using the file object <tmpfile>? a) tmpfile.read(n) b) tmpfile.read() c) tmpfile.readline() d) tmpfile.readlines() 9) What does the <readlines()> method returns? a) str b) a list of lines c) list of single characters d) list of integers 10) Which of the following functions can be used to check if a file “logo” exists? a) os.path.isFile(logo) b) os.path.exists(logo) c) os.path.isfile(logo) d) os.isFile(logo) 11) Which of the following command is used to open a file “c:\temp.txt” for writing in binary format only? a) outfile = open(“c:\temp.txt”, “w”) b) outfile = open(“c:\\temp.txt”, “wb”) c) outfile = open(“c:\temp.txt”, “w+”) d) outfile = open(“c:\\temp.txt”, “wb+”) 12) Which of the following command is used to open a file “c:\temp.txt” for reading in binary format only? a) outfile = open(“c:\temp.txt”, “r”) b) outfile = open(“c:\\temp.txt”, “rb”) c) outfile = open(“c:\temp.txt”, “r+”) d) outfile = open(“c:\\temp.txt”, “rb+”) 13) Which of the following functions do you use to write data in the binary format? a) write b) output c) dump d) send 14) Which of the following functions displays a file dialog for saving a file? a) tmpfile = askopenfilename() b) tmpfile = openfilename() c) tmpfile = asksaveasfilename() d) tmpfile = saveasfilename()
0%
Data File Handling
Μοιραστείτε
Μοιραστείτε
Μοιραστείτε
από
Sunilvats1981
Επεξεργασία περιεχομένου
Εκτύπωση
Ενσωμάτωση
Περισσότερα
Αναθέσεις
Κατάταξη
Εμφάνιση περισσότερων
Εμφάνιση λιγότερων
Ο πίνακας κατάταξης είναι ιδιωτικός. Κάντε κλικ στην επιλογή
Μοιραστείτε
για να τον δημοσιοποιήσετε.
Ο πίνακας κατάταξης έχει απενεργοποιηθεί από τον κάτοχό του.
Ο πίνακας κατάταξης είναι απενεργοποιημένος, καθώς οι επιλογές σας είναι διαφορετικές από τον κάτοχό του.
Επαναφορά επιλογών
Κουίζ
είναι ένα ανοικτό πρότυπο. Δεν δημιουργεί βαθμολογίες πίνακα κατάταξης.
Απαιτείται σύνδεση
Οπτικό στυλ
Γραμματοσειρές
Απαιτείται συνδρομή
Επιλογές
Αλλαγή προτύπου
Εμφάνιση όλων
Θα εμφανιστούν περισσότερες μορφές καθώς παίζετε τη δραστηριότητα.
Ανοιχτά αποτελέσματα
Αντιγραφή συνδέσμου
Κωδικός QR
Διαγραφή
Επαναφορά αυτόματα αποθηκευμένου:
;