The following Python function is designed to search for the marks of a student…

PYQ EMRS TGT/PGT (ESSE) 2025

The following Python function is designed to search for the marks of a student in a CSV file named result.csv. The file contains records in the format RollNo, Marks. The function Search(RollNo) receives a Roll Number as an argument, traverses the CSV file, and displays the marks if a match is found.

(A)

def Search(RollNo):
    Found = False
    try:
        with open("result.csv", (B), (C)) as File:
            Records = (D)
            for Row in Records:
                if Row[0] == RollNo:
                    print("Roll No:", Row[0])
                    print("Marks:", Row[1])
                    Found = True
                    break
            if not Found:
                print("Record not found.")
    except FileNotFoundError:
        print("The file does not exist.")

(A) Write the statement for Blank (A) to import the built-in Python module used for CSV file operations.

(B) In Blank (B), which argument should be passed to the open() to specify the primary purpose (mode) of opening the file?

(C) In Blank (C), which argument should be passed to the open() function to ensure that newline characters are handled correctly across different platforms?

(D) Provide the method call for Blank (D) to create a reader object using the file pointer File.

Attempted by 72 students.

Sign up free to check your answer

Sign up free

Explore the full course: Emrs Cs Tier 2

Loading lesson…