Chapter-wise Important MCQ Computer Science Class 12

MCQ Term 1 Computer Science Class 12

In this article, we are going to discuss important MCQ Computer Science Class 12. If you are looking for MCQ questions for class 12 computer science (python chapter-wise), you are landing on the right page. In this article, you will get all MCQ for class 12 computer science (python chapter-wise). So let’s start!

Chapter-wise Important MCQ Computer Science Class 12

Let us begin chapter-wise important MCQ Computer Science Class 12. We are going to start CBSE class 12 computer science (python chapter-wise MCQs) from chapter 1 Python revision tour Class XI.

MCQs Chapter 1 Python Revision Tour

  1. Python identifiers are case sensitive.
    • True
    • False
    • Depends on Program
    • Depends on the computer system
  2. Which of the following is an invalid identifier?
    • CS_class_XII
    • csclass12
    • _csclass12
    • 12CS
  3. The tiny inidividual unit in python program is known as ___________
    • Expression
    • Statement
    • Token
    • Comment
  4. Which of the following not a token?
    • Comments
    • Identifiers
    • Literals
    • Operators
  5. Which of the following are pre-defined or reserved words that convey a special meaning in programming language?
    • Identifiers
    • Literals
    • Keywords
    • Operators
  6. The different names given to different parts of a program is known as _________
    • Identifiers
    • Literals
    • Keywords
    • Operators
  7. Which of the following literals must terminate in one line?
    • Single line Strings
    • Multi line strings
    • Numeric Literals
    • All of the above
  8. To include non-graphic characters in python, which of the following is used?
    • Special Literals
    • Boolean Literals
    • Escape Character Sequence
    • Special Literal – None
  9. The octal literal and hexadecimal literals start with which of the following symbols resepctively?
    • O0 and X0
    • 0O and 0X
    • Oct0 and Hex0
    • 0o and 0x
  10. Which of the following literal has either True or False value?
    • Special Literals
    • Boolean Literals
    • Numeric Literals
    • String Literals
  11. Which of the following are symbols used for computation or logical comparison in a program?
    • Identifiers
    • Literals
    • Keywords
    • Operators
  12. Which of the following is correct statement to computer square of variable x in python?
    • x * 2
    • x power 2
    • x ** 2
    • x // 2
  13. If you want to display the values without decimal place after division, which of the following symbol is used?
    • /
    • //
    • %
    • **
  14. Which of the is a correct statement?
    • xyz = 10 100 1000
    • x y z = 10 100 1000
    • x, y, z = 10, 100, 1000
    • x y z= 10, 100, 1000
  15. Which of the following are symbols used in programming languages to organize statement structures and inidicate the rythm of the program?
    • Operators
    • Punctuators
    • Functions
    • Literals
  16. In python, the single-line comments starts with _______
    • /
    • //
    • #
    • ”’
  17. In python, the multiline comments starts with ________
    • /
    • //
    • #
    • ”’
  18. _______ are additional readable information to clarify the statement in python.
    • Comments
    • Expressions
    • Tokens
    • Flow of control
  19. Which of the following is a group of statements which are part of another statement or functions?
    • Expression
    • Statement
    • Block
    • Comment
  20. All statements inside a block are inteded at the same level.
    • True
    • False
    • Not necessarily
    • Depends on the user’s choice
  21. By default the input() function returns
    • Integer
    • Float
    • Boolean
    • String
  22. If a function does not return a value then what value will be returned by python in a function?
    • int
    • void
    • bool
    • none
  23. The output of d= a + b % c is _________, if a = 12, b=5 and c=3.
    • 14
    • 2
    • 5
    • 17
  24. Evaluate x % y // x, if x = 5, y = 4
    • 1.0
    • 0.0
    • 0
    • 1
  25. Which of theese arithematic operator will evaluate first?
    • +
    • **
    • %
    • //
  26. Which of these relational operator has highest operator precedence?
    • <
    • >=
    • <=
    • ==
  27. Which of the followiing logical operator will evaluate first?
    • and
    • or
    • not
    • is not
  28. How a>b>c will be interpreted by python?
    • a>b or a>c
    • a>b not a>c
    • a>b and a>c
    • a>b && a>c
  29. Which of the followoing statement is correct for and operator?
    • Python only evaluates the second argument if the first one is False
    • Python only evaluates the second argument if the first one is True
    • Python only evaluates True if any one argument is True
    • Python only evaluates False if any one argument is False
  30. Which of the following forces an expression to be converted into specific type?
    • implicit type casting
    • mutable type casting
    • immutable type casting
    • explicit type casting
  31. _____ are stored as individual characters in contiguous locations, with the two-way index for each location.
    • lists
    • tuples
    • strings
    • dictionaries
  32. What is the output of – “5” + “5” ?
    • 25
    • 55
    • 10
    • error
  33. If n=”Hello” and user wants to assign n[0]=’F’ what will be the result?
    • It will replace the first character
    • It’s not allowed in Python to assign a value to an individual character using index
    • It will replace the entire word Hello into F
    • It will remove H and keep rest of the characters
  34. Which of the following operator can be used as replication operator?
    • +
    • *
    • **
    • /
  35. Which point can be considered as difference between string and list?
    • Length
    • Indexing and Slicing
    • Mutability
    • Accessing inidividual elements
  36. In list slicing, the start and stop can be given beyond limits. If it is then
    • reaise exception IndexError
    • raise exception ValueError
    • return elements falling between specified start and stop values
    • return the entire list
  37. In list slicing negative index -1 refers to
    • first element
    • last element
    • second last element
    • second element
  38. Which of the following operator cannot used with strings?
    • ==
    • +
    • *
    • /
  39. Ms. Hetvee is working on a string program. She wants to display last four characters of a string object named s. Which of the following is statement is true?
    • s[4:]
    • s[:4]
    • s[-4:]
    • s[:-4]
  40. The append() method adds an element at
    • first
    • last
    • specified index
    • at any location
  41. Which of the following statement is true for extend() list method?
    • ads element at last
    • ads multiple elements at last
    • ads element at specified index
    • ads elements at random index
  42. The statement del l[1:3] do which of the following task?
    • deletes elements 2 to 4 elements from the list
    • deletes 2nd and 3rd element from the list
    • deletes 1st and 3rd element from the list
    • deletes 1st, 2nd and 3rd element from the list
  43. If l=[11,22,33,44], then output of print(len(l)) will be
    • 4
    • 3
    • 8
    • 6
  44. Which of the following method is used to delete element from the list?
    • del()
    • delete()
    • pop()
    • All of theese
  45. What will be the output of following code:
txt="Term 1"
print(txt*2)

a) Term 1 Term 2

b) Term 1Term 1

c) Term 1 2

d) TTeerrmm 11

46. What will be the output of:

txt="SQP2021"
if txt.isalnum()==True:
   print("Term 1 sample paper is out now")
else:
   print("Term 1 sample paper is not out till now")

a) Term 1 sample paper is not out till now

b) Term 1 sample paper is out now

c) SQP2021

d) Error

47. What will be the output of the following statement given:

txt="term 1. sample paper 2021"
print(txt.capitalize())

a) term 1. sample paper 2021

b) Term 1. Sample Saper 2021

c) Term 1. sample paper 2021

d) Term 1. Sample Paper 2021

48. Which of the following statement prints output as ‘B’?

a) char(66)

b) ord(‘B’)

c) char(66)

d) chr(66)

49. Which of the following statement(s) is/are correct?

a) Tuples can have only integer elements.

b) Tuples can have only string elements.

c) Tuples can have various types of elements.

d) Tuples can either integer or string, but not both at once.

50. Which of the following statement creates a tuple?

a) t=[1,,2,3,4]

b) t={1,2,3,4}

c) t=<1,2,3,4>

d) t=(1,2,3,4)

51. Which of the following statement is correct?

a) Tuples are mutable.

b) Tuples are immutable.

c) Tuples and lists are same.

d) All of these are correct.

52. What will be the output of the following code:

t=(4,5,6)
t1=t*2
print(t1)

a) (4,5,6,4,5,6)

b) (4,4,5,5,6,6)

c) (8,10,12)

d) None of the above

53. What will be the output of :

t=(4,5,6)
del t[1]
print(t)

a) (4,6)

b) ([4,6])

c) [4,6]

d) Error

54. Which of the following operation is supported in python with respect to tuple t?

a) t[1]=33

b) t.append(33)

c) t=t+t

d) t.sum()

55. Which of the following statements prints the output (4,5)?

  • print(t[:-1]) , print(t[0:2])
  • print(t[3]), print(t[:-3])
  • print(t[2:3]), print(3:2)
  • print(t[0,2]), print[2,3]

56. What will be the output of the following code:

t=(4,5,6,7,8,9,3,2,1)
print(t[5:-1])

a) (8,9,3,2,1)

b) (9,3,2)

c) (4,5,6,7)

d) (2,3,9)

Now next questions for MCQ Term 1 Computer Science Class 12 are based on dictionary topics.

57. Dictionaries are also known as ________.

a) mappings

b) hashes

c) associative arrays

d) all of the above

58. Dictionaries are _________ type of python.

a) Mutable

b) Immutable

c) simple

d) complex

59. Mr Subodh is working with a dictionary in python for his project. He wants to display the key, and value pair but confuse by these statements, choose the correct statement for him:

a) dict.values()

b) disct.keys()

c) dict.keysvalues()

d) dict.items()

60. The fromkeys() method assigns ________ value to key in dictionary by default.

a) 0

b) None

c) Empty

d) Blank

61. Which one of the following is the correct statement for creating a dictionary for assigning a day number to weekdays using short names?

a) d ={1:Mon,2:Tue,3:Wed,4:Thur}

b) d ={1:’Mon’,2:’Tue’,3:’Wed’,4:’Thur’}

c) d ={1;’Mon’,2;’Tue’,3;’Wed’,4;’Thur’}

d) d ={1-‘Mon’,2-‘Tue’,3-‘Wed’,4-‘Thur’}

62. Om is learning the concept of a dictionary in python. He read something about a dictionary related to a set of elements. But he forgot the term which type of set of elements, suggest from the below-given options:

a) sorted

b) ordered

c) unordered

d) random

63. Eshika is trying to delete an element from the dictionary, but she is getting an error – “the given key is not found in the dictionary”. Which of the following command she has used in the python

a) del dict[key]

b) dict.pop(key)

c) dict.popitem(key)

d) remove dict[key]

64. Which of the following is the correct statement for checking the presence of a key in the dictionary?

a) <key> in <dictionary_object>

a) <key> not in <dictionary_object>

c) <key> found in <dictionary_object>

d) a) <key> exists in <dictionary_object>

65. What will be the output of the following dictionary?

d={'South Africa':'Faf Du Plesis','India':'Virat Kohli','Pakistan':'Babar Azam','Australia':'Steve Smith'}
print(d['Virat Kohli'])

a) India

b) India-Virat Kohli

c) Virat Kohli

d) KeyError

66. What will be the output of the following code?



d={'South Africa':'Faf Du Plesis','India':'Virat Kohli','Pakistan':'Babar Azam','Australia':'Steve Smith'}
print("india" in d)

a) True

b) False

c) Error

d) None

67. Predict the correct output for the following code:

dict={'Manthan':34,'Vishwa':45,'Mayank':50}
print(dict[0])

a) Manthan:34

b) 34

c)Manthan

d) Error

68. Marks in the above-created dictionary are changed after rechecking, where Vishwa got 48 marks and Mayank got 49 marks. Choose the correct statement for the same:

a) dict.change({‘Vishva’:48,’Mayank’:49})

b) dict.alter({‘Vishva’:48,’Mayank’:49})

c) dict.update({‘Vishva’:48,’Mayank’:49})

d) dict.loc({‘Vishva’:48,’Mayank’:49})

69. What happens when the following statement will be written for the same dictionary created in Que. No. 67?

dict.update({'Sameer':44})

a) It will raise an error – KeyError

b) It will add a new key and value at the end of the dictionary

c) It will replace the last key and value with the given key and value

d) It will add a new key and value at the beginning of the dictionary

70. Which of the following code will print output as 3 for the dictionary created in Que. No. 67?

a) print(dict.size)

b) print(size(dict))

c) print(length(dict))

d) print(len(dict))

71. What will be the output of the following code?

dict={'x':11,'y':13,'z':15}
s=""
for i in dict:
   s=s+str(dict[i])+" "
   s1=s[:-1]
print(s1[::-1])

a) 15 13 11

b) 11 13 15

c) 51 31 11

d) 10 13 14

In the next section of MCQ Term 1 Computer Science Class 12, you will get the term 1 MCQ questions based on working with functions.

Term 1 MCQ – Working with functions Computer Science Class 12

1. Aman wants to write a function in python. But he doesn’t know how to start with it! Select the keyword used to start a function out of the following:

a) function

b) start

c) def

d) fun

2. Which of the following is a valid function name?

a) start_game()

b) start game()

c) start-game()

d) All of the above

3. Which of the following is not a part of the python function?

a) function header

b) return statement

c) parameter list

d) function keyword

4. If the return statement is not used in the function then which type of value will be returned by the function?

a) int

b) str

c) float

d) None

5. The function header contains

a) function name and parameters only

b) def keyword along with function name and parameters

c) return statement only

d) parameter list only

6. The subprogram that acts on data and returns the value sometimes is known as

a) Function

b) Module

c) Class

d) Package

7. Read the statements:

Statement (A) : A function can perform certain functionality

Statement (B) : A function must return a result value

a) Statement A is correct

b) Statement B is correct

c) Statement A is correct but Statement B is not correct

d) Both are incorrect

8. Richa is working with a program where she gave some values to the function. She doesn’t know the term to relate these values. Help her by selecting the correct option.

a) function value

b) arguments or parameters

c) return values

d) function call

9. Mohini wants to know that the symbol : (colon) must be required with which of the following function part?

a) function header

d) function body

c) return statement

d) parameters

10. Which of the function part contains the instructions for the tasks to be done in the function?

a) function header

d) function body

c) return statement

d) parameters

11. Ananya is trying to understand the features of python functions. She is not understanding the feature that distributes the work in small parts. Select the appropriate term for her out of the following:

a) Modularity

b) Reusability

c) Simplicity

d) Abstraction

12. Which of the following is not a feature supported by python functions

a) Modularity

b) Reusability

c) Simplicity

d) Data Hiding

13. Divya wants to print the identity of the object used in the function. Which of the following function is used to print the same?

a) identity()

b) ide()

c) id()

d) idy()

14. Rashmin is learning the python functions He read the topic types of python functions. He read that functions already available in the python library is called ___________. Fill appropriate word in this blank :

a) UDF (User Defined Function)

b) Built-in Functions

c) Modules

d) Reusable Function

15. Which of the following sentence is not correct for the python function?

a) Python function must have arguments

b) Python function can take an unlimited number of arguments

c) Python function can return multiple values

d) To return value you need to write the return statement

16. Pranjal wants to write a function to compute the square of a given number. But he missed one statement in the function. Select the statement for the following code:

def sq(n):
     ____________ 
print(sq(3))

a) return square of n

b) return n**2

c) return n

d) print(“n**n”)

17. Select the proper order of execution for the following code:

A.	def diff(a,b):
B.	        c=a-b
C.	        print(“The Difference is :”,c)
D.	x,y =7,3
E.	diff(x,y)
F.	print(“Finished”) 

a) A -> B -> C -> D -> E -> F

 b) D -> E -> F -> A -> B -> C

c) D -> E -> A -> B -> C -> F

d) E -> B -> C -> D -> A -> F

18. What is the maximum and minimum value of c in the following code snippet?

import random 
a = random.randint(3,5) 
b = random.randint(2,3) 
c = a + b
print(c) 

a) 3 , 5    

b) 5, 8

c) 2, 3

d) 3, 3

19. By default python names the segment with top-level statement as __________________

a) def main()

b) main()

c) __main__

d) _main

20. The order of executing statements in a function is called

a) flow of execution

b) order of execution

c) sequence of execution

d) process of execution

21. In python function, the function calling another function is known as ________________ and the function being called is known _________

a) main, keyword

b) caller, called

c) called, caller

d) executer, execute

22. Archi is confused between arguments and parameters. Select the fact about argument and parameter and solve her doubt

a) arguments are those values being passed and parameters are those values received

b) parameters are those values being passed and arguments are those values received

c) arguments appear in the function header and parameters appear in the function call

d) arguments can have same name and parameters can have value type

23. The value is passed through a function call statement is called _________ and the values being received in the definition is known as __________

a) formal parameter, actual parameter

b) actual parameter, formal parameter

c) passed parameter, received parameter

d) value parameter, constant parameter

24. The positional parameters are also known as

a) required arguments

b) mandatory arguments

c) Both a and b

d) None of them

25. Which of the following is true about the default argument

a) default values are provided in the function call

b) default values are provided in the function body

c) default values are provided with the return statement

d) default values are provided in the function header

26. The default valued parameter specified in the function header becomes optional in the function calling statement.

a) Yes

b) No

c) Not Sure

d) May be

27. Which of the following function header is correct :

a) def discount(rate=7,qty,dis=5)

b) def discount(rate=7,qty,dis)

c) def discount(rate,qty,dis=5)

d) def discount(qty,rate=7,dis)

28. Read the following statements and then select the answer:

Statement A: Default arguments can be used to add new parameters to the existing functions

Statement B: Default arguments can be used to combine similar functions into one

a) Statement A is correct

b) Statement B is correct

c) Both are correct

d) Both are incorrect

29. What will be the output of the following code?

def fun(x=10, y=20):
       x+=5
       y = y - 3
       return x*y
print(fun(5),fun())

a) 20, 200

b) 170, 255

c) 85, 200

d) 300, 500

30. What will be the output of the following code?

v = 80
def display(n):
  global v
  v = 15
  if n%4==0:
    v += n
  else:
    v -= n
print(v, end="#")
display(20)
print(v)

a) 80#80

b) 80#100

c) 80#35

d 80#20

Watch this video for an explanation:

31. Observe the following lines written for the calling statement and select the appropriate answer:

ele_bill(past_reading=200,rate=6,current_reading=345)
ele_bill(current_reading=345,rate=6,past_reading=200)
ele_bill(rate=6,past_reading=200,current_reading=345)

a) all lines have errors

b) Only line 1 will execute and the rest will raise an error

c) All lines are correct and no errors

d) only line 3 is correct

[32] What will be the output of the following:

def Val(m,n):
    for i in range(n):
      if m[i]<30:
        m[i]//=5
      elif m[i]%5 == 0:
        m[i]//=3
      else:
        m[i]//=2
l = [25,8,75,12]
Val(l,4)
for i in l:
  print(i,end="$")

a) 1$1$2$25$2$

b) 5$1$25$2$

c) 1$4$25$3$

d) 5$2$15$2$

[33] What will be the output of the following code:

def or_cap_update(pl,r,i):
  pl['Runs']+=r
  pl['Innings']+=i

pl1={'S.No':1,'Name':'K L Rahul','Runs':528,'Innings':12}
pl2={'S.No':2,'Name':'Rituraj Gaikwad','Runs':521,'Innings':13}
or_cap_update(pl1,35,1)
or_cap_update(pl2,35,1)
print(pl1)
print(pl2)

a)

{‘S.No’: 1, ‘Name’: ‘K L Rahul’, ‘Runs’: 35, ‘Innings’: 1}
{‘S.No’: 2, ‘Name’: ‘Rituraj Gaikwad’, ‘Runs’: 35, ‘Innings’: 1}

b)

{‘S.No’: 1, ‘Name’: ‘K L Rahul’, ‘Runs’: 563, ‘Innings’: 13}
{‘S.No’: 2, ‘Name’: ‘Rituraj Gaikwad’, ‘Runs’: 556, ‘Innings’: 14}

c)

{‘S.No’: 1, ‘Name’: ‘K L Rahul’, ‘Runs’: 528, ‘Innings’: 12}
{‘S.No’: 2, ‘Name’: ‘Rituraj Gaikwad’, ‘Runs’: 521, ‘Innings’: 13}

d)

{‘S.No’: 1, ‘Name’: ‘K L Rahul’, ‘Runs’: 528, ‘Innings’: 1}
{‘S.No’: 2, ‘Name’: ‘Rituraj Gaikwad’, ‘Runs’: 521, ‘Innings’: 1}

[34] Which of the following variable is defined outside the function?

a) local

b) global

c) enclosed

d) All of these

[35] Observe the following code and select appropriate answers for the given questions:

total = 1
def multiply(l):#Line 1
    for x in l:
        _______ total   #Line2
        total *= x
    
    return _______ #Line3 - Reutrn varibale 
l=[2,3,4]
print(multiply(_____),end="") # Line4
print(" , Thank you ")
  1. Identify the part of function in #Line1?
    • Function header
    • Function Calling
    • Return statement
    • Default Argument
  2. Which of the keyword is used to fill in the blank for #Line2 to run the program without error?
    • eval
    • def
    • global
    • return
  3. Which variable is going to be returned in #Line3
    • total
    • x
    • l
    • None
  4. Which variable is required in the #Line4?
    • total
    • x
    • l
    • None
  5. In the line #Line4 the multiply(l) is called __________
    • caller
    • called
    • parameter
    • argument
  6. In function header multiply(l), l refers to ____________
    • caller
    • called
    • parameter
    • argument
  7. In function calling multiply(l), l refers to ___________
    • caller
    • called
    • parameter
    • argument
  8. What will be the output of this code?
    • 2 3 4 , Thank you
    • 234 , Thank You
    • 24 , Thank you
    • Thank You
  9. Which of the following statement indicates the correct staement for the formal paramter passing technique?
    • multiply(l)
    • multiply(l=[23,45,66])
    • multiply([23,45,66])
    • multiply(23,45,66)
  10. Which of the following statement indicates the correct staement for the actual paramter passing technique?
    • multiply(l)
    • multiply(l=[23,45,66])
    • multiply([23,45,66])
    • multiply(23,45,66)
  11. Sonal wants to modify the function with the specification of length of list with default argument statement for the function with the list and 10 elements by default. Which of the following statement is correct?
    • def multiply(n=10,l):
    • def multiply(l,n=10):
    • def multiply(l,10):
    • def myultiply(l=[22,34,56,22,33,12,45,66,7,1])
  12. Diya wants to call the function with default argument value in the function to display the product of list tobject l. Select the correc statement for her to the same.
    • multiply(l)
    • multiply(10)
    • multiply(l,n)
    • multiply(n,l)

Answers function Case study based MCQ

  1. a) Function Header
  2. c) global
  3. a) total
  4. c) l
  5. a) caller
  6. b) argument
  7. c) parameter
  8. c) 24, Thank You
  9. a) multiply(l)
  10. c) multiply([23,45,66])
  11. b) def multiply(l,n=10)
  12. a) multiply(l)

If you are looking for more questions and notes kindly follow the below-given link to access them:

Working with functions in python class 12- Notes

In the next section of chapter-wise MCQ Term 1 Computer Science Class 12, I will cover the topic introduction to files, types of files and relative and absolute paths concepts.

Data File handling MCQs Class 12 – MCQ Term 1 Computer Science Class 12

[1] A ______________ is a bunch of bytes stored on some storage devices like hard-disk, pen-drive etc.

a) Folder

b) File

c) Package

d) Library

[2] The ____________ are the files that store data pertaining to a specific application, for later use.

a) Data File

b) Program File

c) Source Code

d) Program Code

[3] Which of the following format of files can be created programmatically through python program?

a) Data Files

b) Video Files

c) Media Files

d) Binary Files

[4] Suketu is learning the concept of file handling in python. Where he knew that a type of file stores information in ASCII or UNICODE characters and each line is terminated by EOL. But he forgets the file type. Select the appropriate file type for the same.

a) ASCII File

b) Data File

c) Text File

d) Binary File

[5] Supriya doesn’t know about the text file extension. Help her to identify the same out of these:

a) .text

b) .txt

c) .txf

d) .tfx

[6] In python which of the following is the default EOL character?

a) \eol

b) \enter

c) \n

d) \newline

[7] Which of the following statement is correct for binary files?

a) The file content returned to user in raw form

b) Every line needs translation

c) Each line is terminated by EOL

d) It stores ASCII or Unicode characters

[8] Which of the following statement is not correct for text file?

A) Contains the information as same as its held in memory

B) No delimiter for a line

C) read and write faster than binary files

D) Common format for general work

a) A and B only

b) A, B and C

c) A, C and D

d) All of them

[9] Shiv wants to store the data of his customer using the python program. Suggest the best way to store the data?

a) Text Files

b) CSV files

c) Binary Files

d) Module File

[10] A basic approach to share large data among different organizations carried out through

a) text files

b) binary files

c) spreadsheets or database

d) email attachments

[11] A ___________ is a simple flat file in a human-readable format that is used to store data in a spreadsheet or database.

a) text file

b) database file

c) binary file

d) CSV file

[12] Which of the following statement is correct for CSV files?

a) Store data in plain text

b) Stores data in raw form

c) Stores data in ASCII or Unicode encoded form

d) Store data in converted form

[13] The CSV files can be accessed by

a) text editor and spreadsheet software

b) only through python programs

c) Only spreadsheet software

d) Only through database software

[13] Each line in CSV file is known as

a) tuple

b) data/record

c) field

d) format

[14] Read the statements and choose the correct answer:

Statement A: It is very difficult to organize unstructured data

Statement B: CSV helps into organize a huge amount of data in a proper and systematic way

a) Only Statement A is correct

b) Only Statement B is correct

c) A and B both are correct

d) None of them is correct

[15] Which of the following are features of CSV files:

a) easy to read and manage

b) small in size

c) fast to process data

d) All of them

[16] While opening a file for any operation python looks for

a) File in the system folder

b) file in the python installation folder

c) file in the current folder where the .py file is saved

d) file in the downloads folder

[17] The default directory for performing most of the functions is known as

a) active directory

b) current directory

c) working directory

d) open directory

[18] Biswajit wants to working with files and directories through python. Select the python module to help him to do finish his work:

a) os

b) csv

c) pickle

d) sys

[19] Manoj wants to get the name of the current directory. Select appropriate statement for the same:

a) os.getcd()

b) os.getcurrentdirectory()

c) os.getcwd()

d) os.currentdirectory()

[20] Identify the function to read first 5 characters of the file from the beginning out of the following:

a) f.read(5)

b) f.read()=5

c) f.readline()

d) f.readlines(5)

[21] Priya has placed the file pointer at 4th line in the text file. Now she wants to read all remaining lines of a text file. Which function is suitable for her, select the correct one:

a) f.read()

b) f.readlines()

c) f.read(n)

d) f.readlines()

[22] A file customer.txt has been created. Now Which of the following function(s) can be used to open the file in only reading mode?

i) f=open(“customer.txt”,’r’)

ii) f=open(“customer.txt”,’r+’)

iii) f=open(“customer.txt”)

iv) f=open(“customer.txt”,”rb”)

a) i and iii only

b) i, ii and iii

c) ii and iii

d) iv only

[23] In which of the following mode the file offset position is not at the begging of the file?

i) r, rb, r+ or +r, rb+ or +rb

ii) w, wb, wb+ or +wb

iii) a, a+ or +a

a) i, ii and iii

b) i, and ii only

c) iii only

d) ii and iii only

[24] Which of the following statement is correct for opening file for read and write both mode?

a) r

b) rb

c) a

d) r+ or +r

[24] Puru wants to close a file after reading operation for the file object f. Suggest the correct function to him.

a) f.close()

b) f.close

c) f.quit()

d) f.exit()

[25] Statement A: It is always a good practice to close the file when read/write operations done in the file.

Statement B: While closing a file system frees the memory allocated to it.

a) Statement A is Correct

b) Statement B is Correct

c) Statement A and Statement B are correct

d) Statement A and Statement B are incorrect

[26] Disha is looking for a function to write a stream of bytes in the text file. Which of the following function is correct?

a) write()

b) writestream()

c) writestatement()

d) writeline()

[27] Atul wants to know that he has closed the file after performing the tasks. Which of the following function he can used to check whether the file is closed or not?

a) f.close()

b) f.closing()

c) f.closed()

d) There is no such function in python

[28] The access_mode can be retrieved through

a) access_mode

b) process_mode

c) open_mode

d) select_mode

[29] Which of the following statement is correct about the file closing?

a) If the file object is re-assigned to another file, the previous file is automatically closed

b) every time you need to close the file when you want to re-assign file object to another file

c) re-assign file object to another file is not possible in python

d) None of these

[30] _________ clause close the opened file automatically once control comes outside the clause.

a) for clause

b) while clause

c) with clause

d) None of these

[31] The with clause plays an important role in file handling when

a) File is opened for writing

b) File is opened for reading

c) File is closed

d) Exception occurs

[32] Statement A: An existing file is opened in the write mode the previous data will be erased.

Statement B: When the existing file is opened in write mode the file object will be positioned at the end of the file.

a) Statement A is Wrong

b) Statement B is wrong

c) Statement A and B both are wrong

d) Statement A and B both are correct

[33] The ________ mode allows adding data into the existing file at the end of the file.

a) read

b) write

c) binary

d) append

[34] Which of the following function requires a new line character at the end of every sentence to mark the end of line in writing mode?

a) write()

b) writeline()

c) writelines()

d) dump()

[35] The write() function actually

a) writes into permanent location to the file

b) write into the buffer

c) write into the library

d) write into the program

[36] Jenny wants to transfer data into csv from the python console screen. Which of the following is the correct statement to import the module csv in python?

a) import csv as cv

b) import csv_file as cv

c) import CSV as cv

d) import csv.*

[37] To write data into CSV from python console, which of the following function is correct?

a) csv.write(file)

b) csv.writer(file)

c) csv.Write(file)

d) csv.writerow()

[38] Python will raise error FileNotFounderror, if

a) the file is empty

b) the file is created but not in use

c) the file doesn’t exist

d) the file is opened in read mode

[39] Vansh has created a file names ‘data.txt’. Now he wants to add content as like that data will be added into the file without erasing old data.

Kindly share your views by filling up this feedback form. Select the appropriate code to do so.

a) f=open(“data.txt”, ‘w’)

b) f=open(“data.txt”,’r’)

c) f=open(“data.txt”,’wb’)

d) f=open(“data.txt”,’a’)

[40] The alternative statement of f.close() is

a) f=close()

b) f.exit()

c) f.quit

d) with statement

[41] Using with ensures that

i) all the resources allocated the file objects get deallocated automatically when the user stops using the file

ii) all files will be closed by itself

iii) do not require to close the file in case of exception as well

iv) it makes code more compact and readable

a) i, ii and iii

b) i, iii and iv

c) ii, ii and iv

d) ii, iii and iv

[42] which of the following is the correct statement for with statement?

a) f = open with(‘data’txt’,’w’)

b) with (‘data.txt’,’w’)

c) with open(‘data.txt’,’w’) as f:

d) with open=(‘data.txt’,’w’) as f:

[43] Mr. Alpesh wants to know the standard stream which reads the standard input in python. Select the correct stream from the following:

a) sys.stdin

b) sys.stdinput

c) sys.input

d) sys.standardin

[44] To use the standard streams, which of the following module can be used?

a) pickle

b) system

c) sys

d) standard

[45] Statement A: Data written to sys.stdout appears on screen.

Statement B: Data are written to sys.stdout can be linked to the standard input of another program with a pipe.

a) Statement A is True

b) Statement B is False

c) Statement B is True

d) Both statements A and B are True

[46] Select the correct statements for sys.stderr:

i) It is used to provide error messages.

ii) It is similar as sys.stdout

iii) It does not print only exceptions but prints error messages with debugging comments

iv) Can be linked to the standard input of another program with a pipe symbol

a) ii, iii and iv

b) i, ii and iv

c) i and iv only

d) i, ii and iii

[47] The process of transforming data or an object in RAM to a stream of bytes is _______.

i) Transformation

ii) Pickling

iii) Serialization

iv) Deserialization

a) i and ii

b) ii and iii

c) iii and iv

d) i and iv

[48] Pickling refers to

a) converting the structure to a byte stream before working to the file

b) converting the structure to a file in unicode

c) converting the structure to a file in text file

d) converting the structure to a csv filve

[49] The process of converting the byte stream into its original form back is known as

a) pickling

b) unpickling

c) decomposition

d) composition

[50] The dump method requires _________ minimum no of parameters

a) 1

b) 2

c) 0

d) None of these

[50] Whic of the following parameters required for pickle.dump() method

a) object, fileobject

b) fileobject, object

c) filename, filemode

d) None of these

[51] User need to call load() each time dump() is called.

a) Yes, it must be

b) No, Not necessarily

c) Depends on the file operations

d) All of the above

[52] Which of the following function is used to write steam data from python console to binary file?

a) load()

b) dumps()

c) dump()

d) write()

[53] The pickle.load() function requires minimum _____ number of parameters

a) 0

b) 1

c) 2

d) 3

[54] To read binary files data ___________ function is used.

a) read()

b) readdata()

c) dump()

d) load()

[55] Arrange the following file handling operations in proper order:

A) Close the file

B) Perform operations on file

C) Opening the file

a) C – B – A

b) A – B – C

c) A – C – B

d) C – B – A

[56] Observe the following code:

f=open('story.txt','r')
for i in ____:
   print(i,end="")
f.close()

a) range(f)

b) f

c) len(f)

d) None of these

[57] Rani wants to replace the for loop given in the above question:

a) for i in f.readline():

b) for i in f.read():

c) for i in f.readlines():

d) for i in range(len(f)):

[57] Observe the following code that reads the text file ‘para.txt’, choose the correct line code to count and print those lines end with full stop or comma.

c=0
with open(“para.TXT “,”r”) as f:
        for i in f:
                ______________________    
                   c=c+1
print(“count=”,c)

a) if i[len(i)-2]==’.’ or i[len(i)-2]==’,’ :

b) if i[len(i)]==’.’ or i[len(i)]==’,’:

c) if i==’.’ or i==’,’

d) if ‘.’ in i or ‘,’ in i: