Monday, 8 February 2021

Practical No.: 12 : - Write a program in Python to create a CSV file with the details of 5 students.

 

'''

Practical No. 12: Write a program in Python to create a CSV file with the details

of 5 students(Rollno, Name, Marks).

'''

import csv

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

cw=csv.writer(f)

cw.writerow(['Rollno','Name','Marks'])

for i in range(5):

    print("Student Record of ",(i+1))

    rollno=int(input("Enter Roll No. : "))

    name=input("Enter Name: ")

    marks=float(input("Enter Marks: "))

    sr=[rollno,name,marks]

    cw.writerow(sr)

f.close()

print("File Created Successfully")










No comments:

Post a Comment