Geschreven door studenten die geslaagd zijn Direct beschikbaar na je betaling Online lezen of als PDF Verkeerd document? Gratis ruilen 4,6 TrustPilot
logo-home
Tentamen (uitwerkingen)

Computer Science – Data File Handling

Beoordeling
-
Verkocht
-
Pagina's
149
Cijfer
A+
Geüpload op
03-09-2024
Geschreven in
2024/2025

Computer Science – Data File Handling – 300 Multiple Choice Questions with Answers – 70 Assertion & Reason Type Questions with Answers - 149 Pages – Helpful for Students and Teachers

Instelling
Vak

Voorbeeld van de inhoud

Name of the Chapter- DATA FILE HANDLING



Question Question Content Learning Objective(if
No Provided)
Q1. Suppose content of ‘mytext.txt’ file is: Knowledge



What will be the output of the following code?
file = open(“mytext.txt”, ‘r’)
txt = file.read()
print(file.read(10))

(A) The key to
(B) obstacles.
(C) Error
(D No Output
Q2. Consider the following directory structure: Application




There are three directories under root directory ‘Admin’.
The current working directory is Final. Identify the
relative path name for file ‘Result1.xlsx’.
(A) .\Result1.xlsx
(B) Admin\Final\First Term\Result1.xlsx
(C) ..\First Term\Result1.xlsx
(D) First Term\Result1.xlsx

Q3. Which of the following statements is correct regarding Understanding
file access modes?
(A) In ‘r’ mode, we can read and write data from/in the
file.
(B) In ‘a’ mode, the existing data will be over-written if
the file exists.

, (C) In ‘w’ mode, the data in the file is retained and new
data will be appended to the end.
(D) In ‘a+’ mode, both reading and writing operations can
take place and new data is appended to the end of the
existing file.

Q4. Consider a statement Understanding
fileobj = open(“myblog.txt”, ‘r’)
Which of the following options can be used to print the
last line of a text file ‘myblog.txt’?
(A) print(fileobj.readlines() -1)
(B) disp = fileobj.readlines()
print(disp[-1])
(C) print(fileobj.readlines(-1))
(D) print(fileobj.read(-1))

Q5. Which of the following statements is used to open a text Understanding
file to add new contents at the end of the already existing
text file named ‘mydiary.txt’?
(i) with open(“’mydiary.txt”, ‘w’) as fileobj:
(ii) fileobj = open(“mydiary.txt”, ‘a’)
(iii) with open(“mydiary.txt”,’a’) as fileobj:
(iv) with open(“mydiary”, ‘r+’) as fileobj:

(A) Only (i)
(B) Only (ii)
(C) Both (ii) and (iii)
(D) Both (i) and (iv)

Q6. “The information is stored in machine-readable format Understanding
and pickle module is used for reading and writing
data from/in the file.”
Identify the type of file discussed in the above lines?
(A) Text files
(B) CSV files
(C) Binary file
(D) All of the above

Q7. Assume that you are writing in a text file; now you want Knowledge
to identify where the cursor is currently at in the
file. Which function will you use for the same?
(A) seek()
(B) hide()
(C) tell()
(D) type()

,Q8. Consider the statements given below: Evaluation
Fileobj = open(“Report.txt”, ‘r’)
Fileobj.seek(25,0)
Choose the statement that best explains the second
statement.
(A) It will place the pointer at 25 bytes ahead of the
current file pointer position.
(B) It will place the pointer at 25 bytes behind from the
end-of file.
(C) It will place the pointer at 25 bytes from the
beginning of the file.
(D) It returns 25 characters from the 0th index.

Q9. To read 4th line from text file, which of the following Knowledge
statement is true?
(A) dt = f.readlines();print(dt[3])
(B) dt=f.read(4) ;print(dt[3])
(C) dt=f.readline(4);print(dt[3])
(D) All of these

Q10. Which of the following groups of functions belongs to Application
CSV module?
(A) reader(), writer()
(B) readlines(), writelines()
(C) writerow(), read()
(D) writer(), readline()

Q11. Which is/are the basic I/O (input-output) stream(s) in Application
file?

(A) Standard Input
(B) Standard Output
(C) Standard Errors
(D) All of the above
Q12. Consider the content of the file ‘Story.txt’: Application




What is the output of the following code?

, Fileobj = open("story.txt", 'r')
S1= Fileobj.read(20)
S2= Fileobj.tell()
Fileobj.seek(34,0)
S3= Fileobj.read(20)
print(S3)

(A) The Tortoise meanwhi
(B) slowly but steadily
(C) Hare was sleeping
(D) he Tortoise in time

Q13. Consider a file “online.txt” Evaluation




What will be the output of the following code?
fileobj=open('online.txt','r')
count = 0
l=fileobj.readline()
for i in l:
if 'o' in i:
count=count+1
print(count)
fileobj.close()

(A) 10
(B) 8
(C) 9
(D) 20

Q14. Which function is used to write all the characters? Understanding

(A) write()
(B) writecharacters()
(C) writeall()
(D) writechar()

Q15. What is the difference between r+ and w+ modes? Knowledge

(A) No difference.
(B) In r+ mode, the pointer is initially placed at the
beginning of the file and for w+, the pointer is placed at

Geschreven voor

Vak

Documentinformatie

Geüpload op
3 september 2024
Aantal pagina's
149
Geschreven in
2024/2025
Type
Tentamen (uitwerkingen)
Bevat
Vragen en antwoorden

Onderwerpen

€5,93
Krijg toegang tot het volledige document:

Verkeerd document? Gratis ruilen Binnen 14 dagen na aankoop en voor het downloaden kun je een ander document kiezen. Je kunt het bedrag gewoon opnieuw besteden.
Geschreven door studenten die geslaagd zijn
Direct beschikbaar na je betaling
Online lezen of als PDF

Maak kennis met de verkoper
Seller avatar
kbzone

Ook beschikbaar in voordeelbundel

Maak kennis met de verkoper

Seller avatar
kbzone ICSE
Volgen Je moet ingelogd zijn om studenten of vakken te kunnen volgen
Verkocht
-
Lid sinds
3 jaar
Aantal volgers
0
Documenten
284
Laatst verkocht
-
Notes On All Subjects

A Store where Notes, Presentations, Questions & Answers, Classnotes, Study mqaterials and Studyguides are available at a very nominal preice. The notes are very useful for both the Students and Teachers.

0,0

0 beoordelingen

5
0
4
0
3
0
2
0
1
0

Recent door jou bekeken

Waarom studenten kiezen voor Stuvia

Gemaakt door medestudenten, geverifieerd door reviews

Kwaliteit die je kunt vertrouwen: geschreven door studenten die slaagden en beoordeeld door anderen die dit document gebruikten.

Niet tevreden? Kies een ander document

Geen zorgen! Je kunt voor hetzelfde geld direct een ander document kiezen dat beter past bij wat je zoekt.

Betaal zoals je wilt, start meteen met leren

Geen abonnement, geen verplichtingen. Betaal zoals je gewend bent via iDeal of creditcard en download je PDF-document meteen.

Student with book image

“Gekocht, gedownload en geslaagd. Zo makkelijk kan het dus zijn.”

Alisha Student

Bezig met je bronvermelding?

Maak nauwkeurige citaten in APA, MLA en Harvard met onze gratis bronnengenerator.

Bezig met je bronvermelding?

Veelgestelde vragen