Computer Science, asked by ankitmaurya36, 5 months ago

Parth Patel of class 12 is writing a program to create a CSV file “emp.csv”

which will contain employee code and name of some employees. He has

written the following code. As a programmer, help him to successfully

execute the given task.

import ________#Line 1

def addemp(empcode,name):#to write/add data into the CSV file

fo=open('emp.csv','a')

writer=csv.________ (fo) #Line 2

writer.writerow([empcode,name])

fo.close()

#csv file reading code

def reademp():

with open('emp.csv','_______ ') as fin: #Line 3

filereader=csv.reader(fin)

for row in filereader:

for data in row:

print(data,end='\t')

print(end='\n')

fin._______ #Line 4

addemp('E105','Parth')

addemp("E101",'Arunima')

addemp("E102",'Prahalad')

reademp() #Line 5

Answer the following questions: (1 mark each)

(a) Name the module he should import in Line 1.

(b) Fill in the blank in Line 2 to write the data in a CSV file.

(c) In which mode, Parth should open the file to read the data from the

file(Line 3).

(d) Fill in the blank in Line 4 to close the file.

(e) Write the output he will obtain while executing Line 5. no in​

Answers

Answered by dishantyadav70
3

Answer:

1.import CSV

2.csv.writer

3.'emp.csv',' r '

4. fin.close

only 4 answers are required to get full marks in thish question so i am not writing the answer of 5 question

Explanation:

Answered by anusha195sl
1

Answer:

Finding the missing output for CSV file in Python.

Explanation:

Parth Patel of class 12 is writing a program to create a CSV file “emp.csv”which will contain employee code and name of some employees. He has written the following code. As a programmer, help him to successfully execute the given task.

import ________#Line 1

Answer: csv

def addemp(empcode,name):#to write/add data into the CSV file

fo=open('emp.csv','a')

writer=csv.________ (fo) #Line 2

Answer: writer

writer.writerow([empcode,name])

fo.close()

#csv file reading code

def reademp():

with open('emp.csv','_______ ') as fin: #Line 3

Answer: r

filereader=csv.reader(fin)

for row in filereader:

for data in row:

print(data,end='\t')

print(end='\n')

fin._______ #Line 4

Answer: close ( )

addemp('E105','Parth')

addemp("E101",'Arunima')

addemp("E102",'Prahalad')

reademp() #Line 5

Answer the following questions: (1 mark each)

(a) Name the module he should import in Line 1.

Answer: E105 Parth

(b) Fill in the blank in Line 2 to write the data in a CSV file.

Answer: E101 Arunima

(c) In which mode, Parth should open the file to read the data from the

file(Line 3).

Answer: E102 Prahalad

(d) Fill in the blank in Line 4 to close the file.

Answer: close ( )

(e) Write the output he will obtain while executing Line 5. no in

Answer: Employername ( )

#SPJ3

Similar questions