PW Akshay

Generation

generate functionFri, 02 Dec 2022

Create a binary file with roll number, name and marks. Input a roll number and update the marks

def update_marks(rollno): with open('data.txt', 'r') as f: data = f.read() data = data.split('\n') for i in range(len(data)): data[i] = data[i].split() if data[i][0] == rollno: data[i][2] = input('Enter new marks: ') with open('data.txt', 'w') as f: for i in data: f.write(' '.join(i) + '\n') update_marks('101')

Questions about programming?Chat with your personal AI assistant