Important Questions Data Handling Class 11 Computer Science

Important Questions Data Handling Class 11 Computer Science

Important Questions Class 11

Please refer to Important Questions Data Handling Class 11 Computer Science below. These questions and answers have been prepared based on the latest examination guidelines and NCERT book issued for Class 11 Computer Science for the current academic year. We have provided Important Questions for Class 11 Computer Science for all chapters here. Data Handling is an important chapter in Class 11 Computer Science, following Important Questions and their solutions will help you to get more marks in examinations.

Data Handling Class 11 Computer Science Important Questions

Question. The pickle module in Python is used for:
(a) Serializing any Python object structure
(b) De-serializing Python object structure
(c) Both a and b
(d) None of these

Answer

C

Question. Which of the following function is used to read the data in binary file?
(a) read()
(b) open()
(c) dump()
(d) load()

Answer

D

Question. seek() function is used for _______.
(a) positions the file object at the specified location.
(b) It returns the current position of the file object
(c) It writes the data in binary file
(d) None of these

Answer

A

Question. Which is not the valid mode for binary files?
(a) r
(b) rb
(c) wb
(d) wb+

Answer

A

Question. This method returns an integer that specifies the current position of the file object.
(a) seek()
(b) load()
(c) position()
(d) tell()

Answer

D

Question. Out of the followings which mode is used for both reading and writing in binary format in file?
(a) wb
(b) wb+
(c) w
(d) w+

Answer

B

Question. Which of the following is not true about binary files?
(a) Binary files are store in terms of bytes
(b) When you open binary file in text editor will show garbage values
(c) Binary files represent ASCII value of characters
(d) All of the above

Answer

C

Question. Suresh wants to open the binary file student.dat in read mode. He writes the following statement but he does not know the mode. Help him to find the same.
F=open(‘student.dat’, ____)
(a) r
(b) rb
(c) w
(d) wb

Answer

B

Question. Which method is used to convert Python objects for writing data in binary file?
(a) write()
(b) load()
(c) store()
(d) dump()

Answer

D

Question. What is the difference between wb and wb+ mode?
(a) wb mode is used to open binary file in write mode and wb+ mode open binary file both for read and write operation.
(b) In wb mode file open in write mode and wb+ in read mode
(c) File pointer is at beginning of file in wb mode and in wb+ at the end of file
(d) No difference

Answer

A

Question. What is pickling?
(a) It is the process to read binary file
(b) It is the process to position the file pointer
(c) It is a process by which a Python object is converted to a byte stream
(d) None of these

Answer

C

Very Short answer Type Questions 

Question: What will be the output of the following
(a) 12/4
(b) 14//14
(c) 14%4
(d) 14.0/4
(e) 14.0//4
(f) 14.0%4
Answer: (a) 3.0 (b) 1 (c) 2 (d) 3.5 (e) 3.0 (f) 2.0

Question: int(„a‟) produces error. Why?
Answer: This is because ‗a‘ is an invalid literal for int() with base 10.

Question: What will be the output of the following ?
(a) bool(0) (b) bool(„0‟) (c) bool(int(„0‟))
(d) bool(str(0.0)) (e) bool(0j) (f) bool(0.0)
Answer: (a) False (b) True (c) False
(d) True (e) False (f) False

Question: Identify the data types of the following values given bellow –
3, 3j, 13.0, „12‟,”14”, 2+0j,19, [1,2,3],(3,4,5)

Answer: 3 – int 3j – complex 13.0 – float ‗12‘ – string ―14‖ – string
2+0j – complex 19 – int [1,2,3] – list (3,4,5) – tuple

Question: Write following expressions in Python. 
(a) 1/3b2h
(b) d= √((x2 – x1)2 + (y2 – y1)2)
(c) x = -b±√(b2 – 4 ac) / za
(d) an x am = an+m

Answer: (a) (b*b*h)/3
(b) d=math.sqrt(pow(x2-x1,2)+pow(y2-y1,2))
(c) x1=((-b) + math.sqrt((b*b)-(4*a*c)))/(2*a)
x2=((-b) – math.sqrt((b*b)-(4*a*c)))/(2*a)
(d) pow(a,n) * pow(a,m) = pow(a,m+n)

Question: What will be the output of the following ?
(a)87//5 (b)(87//5.0) == (87//5) (c) 87//5.0 (d) 17%5.0
Answer: (a) 17 (b) True (c) 17.0 (d) 2.0

Question: What will be the output of the following ?

Important Questions Data Handling Class 11 Computer Science

Answer: 4
4.25
1
4

Short Answer Type Questions

Question: Which data types of Python handle Numbers?
Answer: It is cleared by name that Number data types are used to store numeric value in Python. The
Numbers in Python have following core data types:
(i) Integers
a. Integers (signed)
b. Booleans
(ii) Floating-Point Numbers
(iii) Complex Numbers

Question: What are data types? What are Python‟s built-in core data types?
Answer: Every value in Python has a datatype. Since everything is an object in Python programming,
data types are actually classes and variables are instance (object) of these classes.
There are various data types in Python. Some of the important types are listed below.
(i) Numbers (ii) String (iii) List (iv) Tuple (v) Dictionary

Question: What do you understand by term „immutable‟?
Answer: Immutable types are those data types that can never change their value in place. In Python the
following types are immutable:
(i) integers
(ii) floating-point numbers
(iii) Boole ans
(iv) Strings
(v) Tuples

Question: Why is Boolean considered a sub type of Integers?
Answer: Because Boolean Values False and True behave like the values 0 and 1, respectively. So Boolean type is a subtype of plain integers.

Question: What will be the out put of the following code? Why?
(a) 13 or len(13) (b) len(13) or 13
Answer: (a) 13 (b) Type Error: object of type ‘int’ has no len().

Question: What are augmented assignment operators? How are they useful?
Answer: An augmented assignment is generally used to replace a statement where an operator takes a variable as one of its arguments and then assigns the result back to the same variable. A simple example is x += 1 which is expanded to x = x + (1). Similar constructions are oftenavailable for various binary operators. They are helpful in making the source code small.

Question: What are mutable and immutable types in Python? List both of them.
Answer: Mutable types means those data types whose values can be changed at the time of execution. They are as follows:

  • Lists
  • Dictionaries
  • Sets
    Immutable types are those data types that can never change their value in place. In Python the following types are immutable:
  • integers
  • floating-point numbers
  • Booleans
  • Strings
  • Tuples

Skill Based Questions

Question: WAP to check the given year is leap year or not.
Answer: 

Important Questions Data Handling Class 11 Computer Science

Question: WAP to take the temperatures of all 7 days of the week and displays the averagetemperature of that week.
Answer: 

Important Questions Data Handling Class 11 Computer Science

Question: WAP to take two numbers and check that the first number is fully divisible by second
number or not.
Answer: 

Important Questions Data Handling Class 11 Computer Science

Question: WAP to calculate compound simple interest after taking the principle, rate and time.
Answer: 

Important Questions Data Handling Class 11 Computer Science

Question: What will be the output of the following?

Important Questions Data Handling Class 11 Computer Science

Answer:  4.0

Question: WAP to take value of x,y,z from the user and calculate the equation 4x4 + 3y3 + 9z2 + 6π
Answer

Question: What will be the output of the following?

Answer:  -2 6561

Case Study Based Questions :

Mr. Zack Sullivan loves programming. He joined an institute for learning. He is learning python. He learned all the python concepts like strings, lists, tuple , dictionaries etc. but he wants to learn file handling in python. He is trying to learn binary file handling. His teacher gave him partial code to write and read data from employee.dat having structure empno, name, salary. Help Zack to complete the code:
___________________ # statement 1
def addrecords():
fw= _____________ #statement 2
dict={}
ch=’y’
while ch==’y’:
eno=int(input(“enter employee number”))
nm= input(“enter employee name”)
sal=int(input(“enter employee salary”))
dict={‘empno’:eno,’name’:nm,’salary’:sal}
____________________ # statement 3
ch=input(“add more record”)
fw.close()
# function to diplay recordsdef display():
dict={}
fr= _____________ # statement 4
dict=____________ # statement 5
fr.close()
print(“data :”,dict)

Question. Which statement is used from the following for statement 3 to write dictionary data created in above code, namely dict, is written in binary file employee.dat file?
(a) pickle.dump(dict,fw)
(b) pickle.write(dict,fw)
(c) pickle.save(dict,fw)
(d) pickle.store(dict)

Answer

A

Question. Which statement is used from the following for statement 4 to open the binary file in read mode?
(a) open(“employee.dat”,’r’)
(b) open(“employee.dat”,’r+’)
(c) open(“employee.dat”,’a’)
(d) open(“employee.dat”,’rb’)

Answer

D

Question. Compelete statement 5 to read data in dictionary namely dict from the opened binary file?
(a) dict=pk.read(fr)
(b) dict=pickle.load(fr)
(c) pickle.load(dict,fr)
(d) none of these

Answer

B

Question. Help Zack to import the module to perform binary file operation in statement 1.
(a) csv
(b) random
(c) pickle
(d) file

Answer

C

Question. Which statement is used from the following for statement 2 to open the binary file in write mode?
(a) open(“employee.dat”,’w’)
(b) open(“employee.dat”,’wb’)
(c) open(“employee.dat”,’w+’)
(d) open(“employee.dat”,’r’)

Answer

B

Now Mr. Zack has given the following code to modify the records of employees from employee.dat used in above code. He has to increase Rs. 2000 in the salary of those who are getting less than 15000. Mr. Zack has to find the records and change the salary in place. His teacher gave him partial code. Help him to complete the code.
import pickle as pk
found=False
emp={}
fin = ___________ #1 statement : open file both in read write mode
# read from file try:
while true:
pos= _______ #2 store file pointer position before reading record
emp=_______ #3 to read the record in emp dictionary
if emp[‘salary’]<15000:
emp[‘salary’]+=10000
_________ #4 place file pointer at exact location of record
pickle.dump(emp,fin)
found=True
except EOFError:
if found==False:
print(“record not found”)
else:
print(“successfully updated”)
fin.close()

Question. Choose the appropriate statement to complete #3 statement to read record in emp dictionary.
(a) pk.read(fin)
(b) pickle.load(fin,emp)
(c) pk.dump(emp)
(d) pk.load(fin)

Answer

D

Question. Choose the appropriate statement to complete #4 statement to place file pointer at exact location of record
(a) fin.seek(pos)
(b) pos=fin.seek()
(c) fin.position()
(d) none of the above

Answer

B

Question. In #1 statement open the file in read and write mode. Which statement is used out of the followings?
(a) open(“employee.dat”,’rb+’)
(b) open(“employee.dat”,’r+’)
(c) open(“employee.dat”,’a’)
(d) open(“employee.dat”,’rb’)

Answer

A

Question. Choose the appropriate statement to complete #2 statement to store file pointer position before reading record.
(a) pk.seek(pos)
(b) fin.tell()
(c) pk.position()
(d) pk.tell() 

Answer

B

Important Questions Data Handling Class 11 Computer Science