Case Study Based Questions Class 12
Q1. Aman is working in an IT company writing a program to add record in an already existing CSV file “stud.csv”. He has written the following code. As a friend of Aman, help him to complete the code given below.
__________________ #Statement-1 fn = open(_____, _____, newline='') #Statement-2 sdata = csv._____ #Statement-3 temp = [ ] sid = int(input("Enter Student Id : ")) sname = input("Enter Student Name : ") class = input("Enter Class : ") record = [ _____ ] #Statement-4 temp.___________ (record) #Statement-5 sdata. dump ( ___________ ) #Statement-6 fn.close()
1. Fill in the blank for statement1:
(a) load CSV (b) read csv (c) import csv (d) import CSV
Ans. (c) import csv
2. Fill in the blank for statement2:
(a) "stud .csv", "wb"
(b) "stud .csv", "a"
(c) "stud .csv", "w"
(d) "stud .cvs", "a"
Ans. (b) “stud .csv”, “a”
3. Fill in the blank for statement3:
(a) writer(fn) (b) reader(fn) (c) readline(fn) (d) writeline(fn)
Ans. (a) writer(fn)
4. Fill in the blank for statement4:
(a) Sid, Sname, Class (b) sid, sname, class (c) SID,SNAME,CLASS (d) “sid”, ”sname”, "class”
Ans. (d) “sid”, ”sname”, “class”
5. Fill in the blank for statement5:
(a) add (b) writes (c) append (d) dump
Ans. (c) append
6. Fill in the blank for statement6:
(a) record (b) temp (c) fn (d) csv
Ans. (b) temp
Case Study Based Questions Class 12
Q2. Srishti is a class 12 Computer Science student. She has been assigned an incomplete python code (shown below) to create a CSV file ‘book.csv’ and display the file content (as shown below). Help her to complete the following code.
CSV File bookid, subject, class b1, Hindi, VI b2, Science, VII b3, Math, VI
import____________ #Statement-1 fn = open(____________, __________) #Statement-2 fno = csv._________ #Statement-3 fno.writerow(["bookid","subject", "class"]) fno.writerow(["b1", "Hindi", "VI"]) fno.writerow(["b2", "Science", "VII"]) fno.writerow(["b3", "Math", "VI"]) fn.____________ #Statement-4 _______ open("book.csv","r") as fn: #Statement-5 rd=csv._________ #Statement-6 for rec in rd: print(rec) fn.close()
1. Choose the correct code for Statement1.
a. csv b. CSV c. cvs d. csv file
Ans. a. csv
2. Choose the correct code for Statement2.
a. "book.csv", "r" b. "book.csv", "w" c. "book.csv file", "w" d. "book", "w"
Ans. b. “book.csv”, “w”
3. Choose the correct code for Statement3.
a. reader(fn) b. read(book) c. writer(fn) d. write(fn)
Ans. c. writer(fn)
4. Choose the correct code for Statement4.
a. dump( ) b. close( ) c. exit( ) d. end( )
Ans. b. close( )
5. Choose the correct code for Statement5.
a. fn = b. with c. With d. as
Ans. b. with
6. Choose the correct code for Statement6.
a. readlines(fn) b. read(fn) c. readrows() d. reader(fn)
Ans. d. reader(fn)
Case Study Based Questions Class 12
Q3. Amit, a student of class 12th is trying to write a program to search the record from “data.csv” according to the admission number input from the user. Structure of record saved in “data.csv” is Adm_no, Name, Class, Section, Marks. He has written the partial code and has missed out certain statements, You as an expert
of Python have to provide the answers of missing statements based on the following code of Amit.
Ans. import _____________________ #Statement1 f = open(__________________) #Statement2 d=csv._______________________(f) #Statement3 next(f) #To Skip Header Row k = 0 adm = int(input("Enter admission number")) for row in d: if int(row[0])_______________adm: #Statement4 print("Adm no = ", row[0]) print("Name = ", row[___________]) #Statement5 print("Class = ", row[2]) print("Section = ", row[3]) print("Marks = ", row[4]) break _____________ : #Statement6 print("Record Not Found")
1. Choose the correct module for Statement1.
a. CSV b. Csv c. Picke d. csv
Ans. d. csv
2. Choose the correct code for Statement2
a. "data.csv", "r" b. "data.csv", "w" c. "data.csv", "a" d. "data.csv", "wb"
Ans. a. “data.csv”, “r”
3. Choose the correct function for Statement3
a. Reader b. reader( ) c. reader d. read
Ans. c. reader
4. Choose the correct operator for Statement4
a. > b. >= c. == d. !=
Ans. c. ==
5. Choose the correct index for Statement5.
a. 0 b. 1 c. 2 d. 3
Ans. b. 1
6. Choose the correct selection statement for Statement6.
a. if b. else c. elif d. if-
Ans. b. else
Case Study Based Questions Class 12
Q4. Rohit, a student of class 12th, is learning CSV File Module in Python. During examination, he has been assigned an incomplete python code (shown below) to create a CSV File ‘Student.csv’ (content shown below). Help him in completing the code which creates the desired CSV File. [C.B.S.E. Question Bank]
CSV File 1,AKSHAY,XII,A 2,ABHISHEK,XII,A 3,ARVIND,XII,A 4,RAVI,XII,A 5,ASHISH,XII,A
Incomplete Code import_____ #Statement-1 fh = open(_____, _____, newline='') #Statement-2 stuwriter = csv._____ #Statement-3 data = [ ] header = ['ROLL_NO', 'NAME', 'CLASS', 'SECTION'] data.append(header) for i in range(5): roll_no = int(input("Enter Roll Number : ")) name = input("Enter Name : ") Class = input("Enter Class : ") section = input("Enter Section : ") rec = [_____] #Statement-4 data.append(rec) stuwriter. _____ (data) #Statement-5 fh.close()
1. Identify the suitable code for blank space in line marked as Statement-1.
a) csv file
b) CSV
c) csv
d) Csv
Ans. c) csv
2. Identify the missing code for blank space in line marked as Statement-2?
a) “School.csv”,”w”
b) “Student.csv”,”w”
c) “Student.csv”,”r”
d) “School.csv”,”r”
Ans. b) “Student.csv”,”w”
3. Choose the function name (with argument) that should be used in the blank space of line marked as Statement-3
a) reader(fh)
b) reader(MyFile)
c) writer(fh)
d) writer(MyFile)
Ans. c) writer(fh)
4. Identify the suitable code for blank space in line marked as Statement-4.
a) ‘ROLL_NO’, ‘NAME’, ‘CLASS’, ‘SECTION’
b) ROLL_NO, NAME, CLASS, SECTION
c) ‘roll_no’,’name’,’Class’,’section’
d) roll_no,name,Class,sectionc) co.connect()
Ans. c) ‘roll_no’,’name’,’Class’,’section’
5. Choose the function name that should be used in the blank space of line marked as Statement-5 to create the desired CSV File?
a) dump()
b) load()
c) writerows()
d) writerow()
Ans. c) writerows()
Case Study Based Questions Class 12
Q5. Krrishnav is looking for his dream job but has some restrictions. He loves Delhi and would take a job there if he is paid over Rs.40,000 a month. He hates Chennai and demands at least Rs. 1,00,000 to work there. In any another location he is willing to work for Rs. 60,000 a month. The following code shows his basic strategy for evaluating a job offer. [C.B.S.E. Question Bank]
pay= _________ location= _________ if location == "Mumbai": print ("I’ll take it!") #Statement 1 elif location == "Chennai": if pay < 100000: print ("No way") #Statement 2 else: print("I am willing!") #Statement 3 elif location == "Delhi" and pay > 40000: print("I am happy to join") #Statement 4 elif pay > 60000: print("I accept the offer") #Statement 5 else: print("No thanks, I can find something better") #Statement 6 On the basis of the above code, choose the right statement which will be executed when different inputs for pay and location are given
1. Input: location = “Chennai”, pay = 50000
a. Statement 1
b. Statement 2
c. Statement 3
d. Statement 4
Ans. b. Statement 2
2. Input: location = “Surat” ,pay = 50000
a. Statement 2
b. Statement 4
c. Statement 5
d. Statement 6
Ans. d. Statement 6
3. Input- location = “Any Other City”, pay = 1
a Statement 1
b. Statement 2
c. Statement 4
d. Statement 6
Ans. d. Statement 6
4. Input location = “Delhi”, pay = 500000
a. Statement 6
b. Statement 5
c. Statement 4
d. Statement 3
Ans. c. Statement 4
5. v. Input- location = “Lucknow”, pay = 65000
a. Statement 2
b. Statement 3
c. Statement 4
d. Statement 5
Ans. d. Statement 5
Disclaimer : I tried to give you the correct answers of ” Case Study Based Questions Class 12 ” , but if you feel that there is/are mistakes in the answers of “ Case Study Based Questions Class 12 “ given above, you can directly contact me at csiplearninghub@gmail.com. CBSE study material available on website is used to create above “ Case Study Based Questions Class 12 “.
Case Study Based Questions Class 12
MCQ of Computer Science Chapter Wise
1. File Handling (Text File, Binary file, CSV File)
3. Flow of Control (Loop and Conditional statement)
4. 140+ MCQ on Introduction to Python
5. 120 MCQ on String in Python
8. 100+ MCQ on Flow of Control in Python
9. 60+ MCQ on Dictionary in Python
Important Links
100 Practice Questions on Python Fundamentals
120+ MySQL Practice Questions
90+ Practice Questions on List
50+ Output based Practice Questions
100 Practice Questions on String
70 Practice Questions on Loops
120 Practice Questions of Computer Network in Python
70 Practice Questions on if-else
40 Practice Questions on Data Structure
Computer Science Syllabus 2021-2022.
Informatics Practices Syllabus 2021-2022
Class 12 Computer Science Chapter wise MCQ
Case Study Based Questions Class 12
Case Study Based Questions Class 12
useful