File Handling || Type C || Sumita Arora || Class 12 || Computer science || Information practices || Solution


Q 1. Write a program that reads a text file and creates another file that is identical except that every sequence of consecutive blank spaces is replaced by a single space.


Q2. A file sports.dat contains information in following format :
Event ~ Participant
Write a function that would read contents from file sports.dat and creates a file named Atheletic.dat copying only those records from sports.dat where the event name is " Atheletics ".



Q3. A file contains a list of telephone numbers in the following form:
Arvind 7258031
Sachin 7259197 .
The names contain only one word the names and telephone numbers are separated by white spaces Write program to read a file and display its contents in two columns.



Q4. Write a program to count the words "to" and "the" present in a text file "Poem.txt".


Q5. Write a function AMCount() in Python, which should read each character of a text file STORY.TXT, should count and display the occurrence of alphabets A and M (including small cases a and m too).


Q6. Write a program to count the number of upper- case alphabets present in a text file "Article.txt".


Q7. Write a program that copies one file to another. Have the program read the file names from user ?


Q8. Write a program that appends the contents of one file to another. Have the program take the filenames from the user.


Q9. Write a method/function DISPLAYWORDS() in python to read lines from a text file STORY.TXT, and display those words, which are less than 4 characters.


Q10. Write a program that reads characters from the keyboard one by one. All lower case characters get stored inside the file LOWER, all upper case characters get stored inside the file UPPER and all other characters get stored inside file OTHERS.


Q11. Write a function in Python to count and display the number of lines starting with alphabet 'A' present in a text file " LINES.TXT". e.g., the file "LINES.TXT" contains the following lines:
A boy is playing there.
There is a playground.
An aeroplane is in the sky.
Alphabets & numbers are allowed in password.
The function should display the output as 3.



Q12. Write a program that counts the number of characters up to the first $ in a text file.


Q13. Write a program that will create an object called filout for writing, associate it with the filename STRS.txt. The code should keep on writing strings to it as long as the user wants.


Q14. Consider the following definition of dictionary Member, write a method in python to write the content in a pickled file member.dat.

Member = {'MemberNo.': _____, 'Name': _____}



Q15. Consider the following definition of dictionary Staff, write a method in python to search and display the content in a pickled file staff.dat, where Staffcode key of the dictionary is matching with 'S0105'.

Staff = {‘Staff Code': _____, 'Name' = _____}



Q16. Considering the following definition of dictionary COMPANY, write a method in Python to search and display the content in a pickled file COMPANY.DAT, where CompID key of the dictionary is matching with the value '1005'.

Company = {'CompID' = ____, 'CName' = ____, ‘Turnover’ = ____}



Q17. Write a function in to search and display details of all trains, whose destination is Delhi from a binary file TRAIN.DAT. Assuming the binary file is containing the objects of the following dictionary type:

Train = { 'Tno': ___, ‘From’: ____, 'To' : ____}



Q18. A binary file "Book.dat" has structure [BookNo, Book Name, Author, Price].

(i) Write a user defined function CreateFile() to input data for a record and add to Book.dat.

(i) Write a function CountRec(Author) in Python which accepts the Author name as parameter and count and return number of books by the given Author are stored in the binary file "Book.dat".



Q19. Write a function Show_words() in python to read the content of a text file ‘NOTES.TXT’ and display only such lines of the file which have exactly 5 words in them.


Q20. Write a Python program to read a given CSV file having tab delimiter.


Q21. Write a Python program to write a nested Python list to a csv file in one go. After writing the CSV read the CSV file and display the content.


Q22. Write a function that reads a csv file and creates another csv file with the same content, but with a different delimiter.


Q23. Write a function that reads a csv file and creates another csv file with the same content except the lines beginning with 'check'.


35 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

  1. please upload type b also

    ReplyDelete
  2. Thanks for uploading helped me a. Lot

    ReplyDelete
  3. Can you upload type A
    Thanks for the rest

    ReplyDelete
  4. Will u give solution for it and include typeA

    ReplyDelete
  5. where is part b?

    ReplyDelete
    Replies
    1. I starting of blog . I have Uploaded all answer

      Delete
  6. please upload file handling practical book solutions

    ReplyDelete
    Replies
    1. OK, it will upload very soon. Please wait..... : )

      Delete
  7. Please upload networking questions

    ReplyDelete
  8. where is question 11 to 22 solution

    ReplyDelete
  9. Thx brother for this. It helped me alot thx alot

    ReplyDelete
  10. output is not there from 12th to 23

    ReplyDelete
  11. please upload type c 11 to 23 outputs file handaling

    ReplyDelete
  12. thanks for uploading all the answers it helped me a lot :-)!!!!

    ReplyDelete
  13. Some questions are added extra in latest books. Plz have a look and upload the answers

    ReplyDelete
  14. I had sent you in Instagram. Plz have a look

    ReplyDelete
  15. Getting 95/100 by your solutions!!
    THANKS

    ReplyDelete
  16. thank you so muchh :)!!
    Could you also please add a tag on which are the important ones?

    ReplyDelete
    Replies
    1. Welcome : ).
      I have also uploaded important questions.

      Delete

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post