Questions

5 Marks Each

🎯

Test yourself on this topic

6 questions · timed · auto-graded

Question 15 Marks
Krishna is confused in Python code given below. Please help him to answer the following questions.

(a) Which line in the above code check for capital letter?

(b) Which line in the above code read the file “story. txt”?

(c) Which line in the above code does not affect the execution of program?

(d) Which line is the above code coverts capital letter to small letter?

(e) Which line is the above code opens the file in write mode?

(f) Which line is the above code saves the data?

(g) Which line(s) is/are the part of selection statement.

(h) Which line(s) is/are used to close story1.txt?

Answer
(a) Line 6(e) Line 2
(b) Line 4 (f) Line 13
(c) Line 10(g) Line 6, Line 8 and Line 11
(d) Line 7(h) Line 15
View full question & answer
Question 25 Marks
Krishna of class 12 is writing a program to read the details of Sports performance and store in the csv file “games.csv” delimited with a tab character. As a programmer, help him to achieve the task.

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

(b)Line 2 : To create an object to enable to write in the csv file.

(c)Line 3 : To store the data in list

(d)Line 4 : To write a record.

(e)Line 5 : To close the file.

Answer
(a)Line 1 : Import csv

(b) Line 2 : csv.writer

(c)Line 3 : rec=[sport,comp,prize]

(d) Line 4 : wobl.writerow(rec)

(e) Line 5 : f.close()

View full question & answer
Question 35 Marks
Dhruv Kumar of class 12 is writing a program to create a CSV file “Teacher.csv” which will store the teacher information entered by user. He has written the following code. As a programmer, help him to successfully execute the given task. Write appropriate statement / function/ code against fill ups.

Answer
(a) Line 1 : import csv

(b) Line 2 with open("LAPS_Teacher12.csv" , "a", newline="") as file:

(c) Line 3 : Write = csv.writer(file)

(d) LST.append([ID1,Name1,Subject])

(e) Write.writerow(LST)

View full question & answer
Question 45 Marks
You are a student in CBSE School. Teacher has given a task to write a python code to perform the following binary file operations with the help of two user defined functions/modules:
(a)
Answer
(a)Statement 1 : student = []

(b) Statement 2 : stu = pickle.load(f)

(c)Statement 3 : student.append(s)

(d) Statement 4 : wb

(e) Statement 5 : if i[0] == r: (f) Statement 6 : break

View full question & answer
Question 55 Marks
Mr. Mathew is a programmer, who has recently joined the company and given a task to write a python code to perform update operation in binary file (stud.dat) which contain admno (Admission No) and fee(Fee paid by student).

He has succeeded in writing partial code and has missed out certain statements, You as an expert of Python have to provide the missing statements.

(a)

Answer
(a) import pickle

(b) stud.dat

(c) file.tell()

(d) file.seek(pos)

(e) pickle.dump(st,file)

(f) (iii) pickle.dump(LST,FILE)

View full question & answer
Question 65 Marks
Mr. Iqbal is a programmer, who has recently joined the company and given a task to write a python code to perform the following binary file operations with the help of two user defined functions/modules:
(a)
Answer
(a) import pickle

(b) stud.dat

(c) file.tell()

(d) file.seek(pos)

(e) pickle.dump(st,file)

(f) (iii) pickle.dump(LST,FILE)

View full question & answer
5 Marks Each - Computer Science STD 12 Humanities Questions - Vidyadip