Computer Science, asked by sanjayyadav6095, 5 hours ago

Program 9:
WRITE A MENU-DRIVEN PROGRAM IMPLEMENTING USER-DEFINED FUNCTIONS TO PERFORM DIFFERENT FUNCTIONS ON A
CSV FILE "STUDENT"(rollno,name,phy,chem,math,cs) SUCH AS:
(A) WRITE A SINGLE RECORD TO CSV
(B) WRITE ALL THE RECORDS IN ONE SINGLE GO ONTO THE CSV.
(C) DISPLAY THE CONTENTS OF THE CSV FILE.
(D)DISPLAY THE TOTAL MARKS FOR EACH STUDENT (E) COUNT THE NUMBER OF STUDENTS GETTING MORE THAN 320

Answers

Answered by nehaprasanth1889
3

Answer:

import csv

while True:

   ch=int(input("a. Write a single record to csv\nb. Write all the records in one single go onto the csv\nc. Display the contents of the csv file.\nd. Exit\nEnter your choice: "))

   if ch==1:

       write()

   elif ch==2:

       writeall()

   elif ch==3:

       display()

   elif ch==4:

       break

   else:

       print("invalid entry")

def write():

   import csv

   f=open("student.csv","w")

   writer=csv.writer(f)

   fields=["no","name","stream","marks"]

   writer.writerow(fields)

   r=int(input("no: "))

   n=input("name: ")

   s=input("stream: ")

   m=float(input("marks: "))

   writer.writerow([r,n,s,m])

   f.close()

Explanation:

sorry, i could only figure out the first part, hope this helps!

Similar questions