CORE-PYTHON

1.   Which creates virtual environment?
(A)   py virt
(B)   python venv
(C)   python -m venv
(D)   create venv
Answer:    (C)
2.   Which throws exception manually?
(A)   throw
(B)   raise
(C)   except
(D)   error
Answer:    (B)
3.   Which indicates block of code?
(A)   {}
(B)   ()
(C)   indent
(D)   semicolon
Answer:    (C)
4.   Which is a function of math module?
(A)   math.sum()
(B)   math.add()
(C)   math.factorial()
(D)   math.total()
Answer:    (C)
5.   Which keyword prevents inheritance?
(A)   final
(B)   stop
(C)   sealed
(D)   no such keyword
Answer:    (D)
6.   Which displays documentation?
(A)   doc()
(B)   help()
(C)   info()
(D)   show()
Answer:    (B)
7.   Which creates an array?
(A)   arr()
(B)   array()
(C)   numpy.array()
(D)   list()
Answer:    (C)
8.   Which operator is XOR?
(A)   ^
(B)   ^^
(C)   xor
(D)   !
Answer:    (A)
9.   Which loop executes zero or more times?
(A)   do-while
(B)   for
(C)   while
(D)   both 2 and 3
Answer:    (D)
10.   Which defines constant values?
(A)   const
(B)   final
(C)   none
(D)   no constant in Python
Answer:    (D)
11.   Which writes JSON?
(A)   json.write()
(B)   json.dump()
(C)   dump.json()
(D)   js.dump()
Answer:    (B)
12.   Which loads JSON data?
(A)   json.load()
(B)   load.json()
(C)   json.read()
(D)   js.load()
Answer:    (A)
13.   Which module handles OS functions?
(A)   sys
(B)   os
(C)   file
(D)   machine
Answer:    (B)
14.   Which is not numeric?
(A)   int
(B)   float
(C)   complex
(D)   text
Answer:    (D)
15.   Which removes item by index?
(A)   pop()
(B)   remove()
(C)   delete()
(D)   discard()
Answer:    (A)
16.   Which sorts without changing original?
(A)   sort()
(B)   arrange()
(C)   sorted()
(D)   order()
Answer:    (C)
17.   Which gives random integer?
(A)   random()
(B)   randint()
(C)   intrand()
(D)   ran()
Answer:    (B)
18.   Which module gives system info?
(A)   sys
(B)   system
(C)   os
(D)   pc
Answer:    (A)
19.   Which operator swaps bits?
(A)   <<
(B)   >>
(C)   ~
(D)   None
Answer:    (C)
20.   Which checks multiple conditions?
(A)   if only
(B)   if-else
(C)   if-elif-else
(D)   only elif
Answer:    (C)
21.   Which removes key from dict?
(A)   del
(B)   remove()
(C)   delete()
(D)   pop()
Answer:    (A)
22.   Which casts to float?
(A)   float()
(B)   tofloat()
(C)   cast()
(D)   double()
Answer:    (A)
23.   Which creates empty tuple?
(A)   ()
(B)   (,)
(C)   empty()
(D)   tuple{}
Answer:    (A)
24.   Which is a loop keyword?
(A)   for
(B)   while
(C)   break
(D)   both 1 and 2
Answer:    (D)
25.   Which command installs libraries?
(A)   pip install
(B)   install pip
(C)   pip add
(D)   pip create
Answer:    (A)
26.   Which function reads all lines?
(A)   read()
(B)   readlines()
(C)   readline()
(D)   get()
Answer:    (B)
27.   Which error means bad syntax?
(A)   SyntaxError
(B)   NameError
(C)   TypeError
(D)   IndexError
Answer:    (A)
28.   Which keyword is used for multiple inheritance?
(A)   extends
(B)   inherits
(C)   def
(D)   class A(B,C)
Answer:    (D)
29.   Which function prints all locally defined variables?
(A)   local()
(B)   vars()
(C)   getvars()
(D)   show()
Answer:    (B)
30.   Which method copies list?
(A)   duplicate()
(B)   copy()
(C)   clone()
(D)   replicate()
Answer:    (B)
31.   Which module handles dates?
(A)   time
(B)   dt
(C)   datetime
(D)   clock
Answer:    (C)
32.   Which is immutable?
(A)   list
(B)   dict
(C)   set
(D)   tuple
Answer:    (D)
33.   Which data type stores key-value?
(A)   list
(B)   tuple
(C)   dict
(D)   set
Answer:    (C)
34.   Which operator is bitwise AND?
(A)   &&
(B)   &
(C)   and
(D)   +
Answer:    (B)
35.   Which is NOT an OOP concept?
(A)   inheritance
(B)   encapsulation
(C)   polymorphism
(D)   duplication
Answer:    (D)
36.   Which restarts loop?
(A)   continue
(B)   break
(C)   reset
(D)   pass
Answer:    (A)
37.   Which returns square root?
(A)   root()
(B)   sqrt()
(C)   square()
(D)   mathroot()
Answer:    (B)
38.   Which creates list quickly?
(A)   LC
(B)   LC()
(C)   list comp
(D)   list comprehension
Answer:    (D)
39.   Which data type is sequential?
(A)   list
(B)   set
(C)   dict
(D)   none
Answer:    (A)
40.   Which is used to check type?
(A)   type()
(B)   check()
(C)   datatype()
(D)   inspect()
Answer:    (A)
41.   Which keyword defines object creation?
(A)   create
(B)   new
(C)   object
(D)   none
Answer:    (D)
42.   Which method is used in classes?
(A)   define()
(B)   method()
(C)   def
(D)   classdef
Answer:    (C)
43.   Which operator compares values?
(A)   =
(B)   ==
(C)   ===
(D)   <= >
Answer:    (B)
44.   Which represents empty list?
(A)   {}
(B)   []
(C)   ()
(D)   None
Answer:    (B)
45.   Which is a valid string method?
(A)   uppercase()
(B)   upper()
(C)   makeupper()
(D)   high()
Answer:    (B)
46.   Which represents NOT?
(A)   ~
(B)   not
(C)   !
(D)   ^
Answer:    (B)
47.   Which converts float to int?
(A)   float()
(B)   int()
(C)   convert()
(D)   num()
Answer:    (B)
48.   Which function rounds numbers?
(A)   around()
(B)   round()
(C)   approx()
(D)   fit()
Answer:    (B)
49.   Which joins strings?
(A)   join()
(B)   glue()
(C)   stick()
(D)   concat()
Answer:    (A)
50.   Which package manages libraries?
(A)   pip
(B)   pkg
(C)   manage
(D)   install
Answer:    (A)
51.   Which method adds at specific index?
(A)   add()
(B)   place()
(C)   insert()
(D)   set()
Answer:    (C)
52.   What is output of True==1?
(A)   True
(B)   False
(C)   None
(D)   Error
Answer:    (A)
53.   Which error occurs for wrong index?
(A)   KeyError
(B)   TypeError
(C)   IndexError
(D)   ValueError
Answer:    (C)
54.   Which returns remainder?
(A)   /
(B)   //
(C)   %
(D)   **
Answer:    (C)
55.   Which accesses dictionary value?
(A)   d(0)
(B)   d[0]
(C)   d->0
(D)   d.get()
Answer:    (D)
56.   Which data type is ordered?
(A)   set
(B)   list
(C)   dict (old)
(D)   none
Answer:    (B)
57.   Which function creates a sequence?
(A)   seq()
(B)   range()
(C)   order()
(D)   series()
Answer:    (B)
58.   Which method sorts a list?
(A)   soft()
(B)   sort()
(C)   order()
(D)   arrange()
Answer:    (B)
59.   Which keyword creates a module?
(A)   include
(B)   import
(C)   module
(D)   require
Answer:    (B)
60.   Python supports—
(A)   OOP
(B)   POP
(C)   Both
(D)   None
Answer:    (C)
61.   Which is a valid variable name?
(A)   2name
(B)   name2
(C)   n@me
(D)   my-name
Answer:    (B)
62.   Which method finds index?
(A)   findex()
(B)   index()
(C)   pos()
(D)   find()
Answer:    (B)
63.   Which removes whitespace?
(A)   strip()
(B)   trim()
(C)   clean()
(D)   rstrip()
Answer:    (A)
64.   Which function returns power?
(A)   pow()
(B)   power()
(C)   exp()
(D)   raise()
Answer:    (A)
65.   Which is a mutable type?
(A)   string
(B)   tuple
(C)   list
(D)   int
Answer:    (C)
66.   Which returns length of an object?
(A)   len()
(B)   size()
(C)   count()
(D)   length()
Answer:    (A)
67.   What is the output of 2==‘2’?
(A)   True
(B)   False
(C)   Error
(D)   None
Answer:    (B)
68.   Which converts to dictionary?
(A)   dict()
(B)   todict()
(C)   dct()
(D)   map()
Answer:    (A)
69.   Which is a Boolean value?
(A)   yes
(B)   True
(C)   1
(D)   false
Answer:    (B)
70.   Which method removes duplicates?
(A)   set()
(B)   unique()
(C)   nodup()
(D)   remove()
Answer:    (A)
71.   Which returns minimum value?
(A)   min()
(B)   minimum()
(C)   low()
(D)   small()
Answer:    (A)
72.   Which creates an infinite loop?
(A)   while True
(B)   for True
(C)   while 1==0
(D)   for infinite
Answer:    (A)
73.   Which keyword handles exceptions?
(A)   try
(B)   except
(C)   catch
(D)   both 1 and 2
Answer:    (D)
74.   Which is used to open a file?
(A)   write()
(B)   open()
(C)   file()
(D)   get()
Answer:    (B)
75.   Which converts ASCII to character?
(A)   ord()
(B)   char()
(C)   chr()
(D)   ascii()
Answer:    (C)
76.   Which converts character to ASCII?
(A)   ascii()
(B)   ord()
(C)   char()
(D)   code()
Answer:    (B)
77.   What is the output of True + True?
(A)   True
(B)   2
(C)   False
(D)   1
Answer:    (B)
78.   Which keyword creates a generator?
(A)   gen
(B)   yield
(C)   return
(D)   produce
Answer:    (B)
79.   Which method removes last list item?
(A)   end()
(B)   delete()
(C)   pop()
(D)   shift()
Answer:    (C)
80.   Which operator concatenates strings?
(A)   *
(B)   +
(C)   ^
(D)   &
Answer:    (B)
81.   Which function returns absolute value?
(A)   abs()
(B)   fabs()
(C)   absolute()
(D)   val()
Answer:    (A)
82.   Which keyword defines a class?
(A)   define
(B)   object
(C)   class
(D)   type
Answer:    (C)
83.   Which converts to tuple?
(A)   tuple()
(B)   totuple()
(C)   convert()
(D)   pack()
Answer:    (A)
84.   Which function prints output?
(A)   show()
(B)   print()
(C)   echo()
(D)   write()
Answer:    (B)
85.   Which operator is used for inequality?
(A)   !=
(B)   =
(C)   ==
(D)   <>
Answer:    (A)
86.   What is the output of 10==10?
(A)   True
(B)   False
(C)   None
(D)   Error
Answer:    (A)
87.   Which is used for comments?
(A)   /* */
(B)  
(C)   #
(D)   $$
Answer:    (C)
88.   Which statement ends a function?
(A)   exit
(B)   return
(C)   stop
(D)   break
Answer:    (B)
89.   Which creates a new line?
(A)   \t
(B)   \n
(C)   \
(D)   \r
Answer:    (B)
90.   What is the type of False?
(A)   int
(B)   bool
(C)   string
(D)   binary
Answer:    (B)
91.   Which is used to convert to string?
(A)   string()
(B)   tostr()
(C)   str()
(D)   cast()
Answer:    (C)
92.   Which is not a Python loop?
(A)   for
(B)   while
(C)   do-while
(D)   None
Answer:    (C)
93.   What is the output of 7 % 4?
(A)   1
(B)   2
(C)   3
(D)   0.0
Answer:    (C)
94.   Which keyword defines a loop?
(A)   loop
(B)   cycle
(C)   for
(D)   repeat
Answer:    (C)
95.   Which type of language is Python?
(A)   compiled
(B)   interpreted
(C)   assembly
(D)   machine
Answer:    (B)
96.   What is the output of len([])?
(A)   1
(B)   0.0
(C)   None
(D)   error
Answer:    (B)
97.   Which module is used for random numbers?
(A)   rnd
(B)   random
(C)   rand
(D)   math
Answer:    (B)
98.   Which converts data to a list?
(A)   list()
(B)   tolist()
(C)   convert()
(D)   array()
Answer:    (A)
99.   What is the output of 32?**
(A)   6
(B)   9
(C)   3
(D)   8
Answer:    (B)
100.   Which operator checks membership?
(A)   is
(B)   ==
(C)   in
(D)   not
Answer:    (C)
101.   Which statement creates an empty set?
(A)   {}
(B)   set()
(C)   []
(D)   empty()
Answer:    (B)
102.   Which is used to define anonymous functions?
(A)   def
(B)   lambda
(C)   fun
(D)   define
Answer:    (B)
103.   Which is not a data type?
(A)   float
(B)   boolean
(C)   real
(D)   string
Answer:    (C)
104.   Which of the following is a tuple?
(A)   []
(B)   {}
(C)   ()
(D)   <>
Answer:    (C)
105.   What does list.pop() return?
(A)   first element
(B)   last element
(C)   None
(D)   all elements
Answer:    (B)
106.   Which converts string to integer?
(A)   int()
(B)   str()
(C)   float()
(D)   eval()
Answer:    (A)
107.   Which operator is used for floor division?
(A)   /
(B)   %
(C)   //
(D)   **
Answer:    (C)
108.   Which data type is returned by input()?
(A)   int
(B)   string
(C)   float
(D)   bool
Answer:    (B)
109.   Which module is used for math operations?
(A)   math
(B)   calc
(C)   numbers
(D)   arithmetic
Answer:    (A)
110.   What is the output of 2'A'?*
(A)   error
(B)   A
(C)   AA
(D)   AAAA
Answer:    (C)
111.   Which function is used to find type?
(A)   typeof()
(B)   type()
(C)   datatype()
(D)   isinstance()
Answer:    (B)
112.   What is the return value of print()?
(A)   None
(B)   True
(C)   0.0
(D)   'print'
Answer:    (A)
113.   Which function closes a file?
(A)   stop()
(B)   exit()
(C)   close()
(D)   end()
Answer:    (C)
114.   Which opens a file for reading?
(A)   open(f,'r')
(B)   open(f,'w')
(C)   open(f,'a')
(D)   open(f,'x')
Answer:    (A)
115.   Which statement is used to skip iteration?
(A)   continue
(B)   break
(C)   skip
(D)   pass
Answer:    (A)
116.   What is the result of 10 % 3?
(A)   1
(B)   3
(C)   0.0
(D)   10
Answer:    (A)
117.   Which is a mutable data type?
(A)   tuple
(B)   string
(C)   list
(D)   int
Answer:    (C)
118.   Which function shows all methods of an object?
(A)   show()
(B)   methods()
(C)   dir()
(D)   info()
Answer:    (C)
119.   Which operator checks identity?
(A)   ==
(B)   =
(C)   is
(D)   in
Answer:    (C)
120.   Python was created by—
(A)   Dennis Ritchie
(B)   James Gosling
(C)   Guido van Rossum
(D)   Bjarne Stroustrup
Answer:    (C)
121.   Which keyword is used to inherit a class?
(A)   uses
(B)   inherits
(C)   extends
(D)   class Child(Parent)
Answer:    (D)
122.   What is the output of bool(0)?
(A)   True
(B)   False
(C)   None
(D)   error
Answer:    (B)
123.   Which keyword is used with loops?
(A)   stop
(B)   end
(C)   break
(D)   quit
Answer:    (C)
124.   Which collection is unordered?
(A)   list
(B)   tuple
(C)   set
(D)   string
Answer:    (C)
125.   Which method removes an item by value?
(A)   pop()
(B)   delete()
(C)   remove()
(D)   discard()
Answer:    (C)
126.   What is the base of Python indexing?
(A)   1
(B)   2
(C)   0.0
(D)   -1.0
Answer:    (C)
127.   Which is used to handle exceptions?
(A)   try
(B)   catch
(C)   except
(D)   both 1 and 3
Answer:    (D)
128.   Which loop is entry-controlled?
(A)   while
(B)   for
(C)   do-while
(D)   All
Answer:    (B)
129.   What does range(5) generate?
(A)   1–5
(B)   0–4
(C)   1–4
(D)   0–5
Answer:    (B)
130.   Which function converts to float?
(A)   float()
(B)   double()
(C)   tofloat()
(D)   convert()
Answer:    (A)
131.   Which method adds an element to a list?
(A)   insert()
(B)   add()
(C)   append()
(D)   push()
Answer:    (C)
132.   Which symbol represents logical AND?
(A)   &&
(B)   and
(C)   &
(D)   &&&
Answer:    (B)
133.   What type does input() return?
(A)   int
(B)   str
(C)   float
(D)   bool
Answer:    (B)
134.   What is the output of 'A' < 'B'?
(A)   error
(B)   True
(C)   False
(D)   None
Answer:    (B)
135.   Which function returns the maximum value?
(A)   big()
(B)   max()
(C)   maximum()
(D)   large()
Answer:    (B)
136.   What does int('10') return?
(A)   '10'
(B)   10
(C)   error
(D)   None
Answer:    (B)
137.   Which of the following is NOT a Python keyword?
(A)   pass
(B)   exec
(C)   repeat
(D)   lambda
Answer:    (C)
138.   Which is the correct way to create a dictionary?
(A)   {}
(B)   []
(C)   ()
(D)   <>
Answer:    (A)
139.   Which keyword is used to create a class?
(A)   class
(B)   obj
(C)   struct
(D)   type
Answer:    (A)
140.   What is the output of 5//2?
(A)   2
(B)   2.5
(C)   3
(D)   1
Answer:    (A)
141.   Which operator is used for exponentiation?
(A)   ^
(B)   **
(C)   *
(D)   ^^
Answer:    (B)
142.   Which of the following is a Python list?
(A)   (1,2,3)
(B)   {1,2,3}
(C)   [1,2,3]
(D)  
Answer:    (C)
143.   What is the output of len('Python')?
(A)   5
(B)   6
(C)   7
(D)   8
Answer:    (B)
144.   Which function is used to get input from the user?
(A)   scan()
(B)   take()
(C)   input()
(D)   enter()
Answer:    (C)
145.   What is the output of type(10)?
(A)   float
(B)   int
(C)   str
(D)   bool
Answer:    (B)
146.   Which symbol is used for comments in Python?
(A)   //
(B)   #
(C)   /* */
(D)  
Answer:    (B)
147.   Which data type is immutable in Python?
(A)   list
(B)   dict
(C)   set
(D)   tuple
Answer:    (D)
148.   What is the correct file extension for Python files?
(A)   .pyth
(B)   .pt
(C)   .py
(D)   .pyt
Answer:    (C)
149.   Which keyword is used to define a function in Python?
(A)   def
(B)   func
(C)   define
(D)   function
Answer:    (A)