Computer Science
Write a statement in Python to perform the following operations:
(a) To open a text file "BOOK.TXT" in read and append mode
(b) To open a text file "BOOK.TXT" in write mode
(c) To open a text file "BOOK.TXT" in append mode
Related Questions
Given a binary file "STUDENT.DAT", containing records of the following type:
[S_Admno, S_Name, Percentage]
Where these three values are:
S_Admno — Admission Number of student (string)
S_Name — Name of student (string)
Percentage — Marks percentage of student (float)Write a function in Python that would read contents of the file "STUDENT.DAT" and display the details of those students whose percentage is above 75.
Write statements to open a binary file C:\Myfiles\Text1.txt in read and write mode by specifying file path in two different formats.
What is the following code doing?
import csv File = open("contacts.csv", "a") Name = input("Please enter name: ") Phno = input("Please enter phone number: ") data = [Name, Phno] csvwriter = csv.writer(File) csvwriter.writerow(data) File.close()
Write code to open the file in the previous question and print it in the following form:
Name : <name> Phone: <phone number>