Class 12 CBSE FM-40 TIME:1:30 Hours

  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.(5)
  2. 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”.(5)
  3. Write a python program to accept a list from a user and also accept an
    element from the user then check if the element is present in the list or not by
    using linear search technique.(5)
  4. Write a program to count the words “to” and “the” present in a text file
    “Poem.txt”.(4)
  5. 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). (6)
    Example: If the file content is as follows:
    Updated information
    As simplified by official websites.
    The EUCount() function should display the output as :
    A or a : 4
    M or m: 2
    6.Write a Python program to create a binary file “students.dat” to store the roll
    number, name, and marks of multiple students using pickle module. Then, read
    and display the contents of the file.(5)
    7.Write a Python program to create push(),pop()and display() functions using
    stack.(5)
    8.Explain the concept of random access in binary file handling. Write a Python
    program to modify a specific record in a binary file using seek() and write().
    (5)

Solutions:

Leave a Comment