0% found this document useful (0 votes)
2 views

Python Mcq

The document contains a series of questions and answers related to Python programming, covering topics such as file extensions, comments, data types, control structures, and error handling. Each question is followed by multiple-choice options, with the correct answer indicated. It serves as a quiz or test format to assess knowledge of Python programming concepts.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Python Mcq

The document contains a series of questions and answers related to Python programming, covering topics such as file extensions, comments, data types, control structures, and error handling. Each question is followed by multiple-choice options, with the correct answer indicated. It serves as a quiz or test format to assess knowledge of Python programming concepts.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Option 1 Option 2 Option 3 Correct

Sr. No Question Option 4 D


A B C Answer
1 What is the extension of python file? .p .py .python .pyt .py
By the use of which character, single line
2 * $ # ! #
is made comment in Python?
Which of the following is incorrect
3 variable1 1variable _variable 1variable
variable name in Python? variable_1
List is
List is
List is mutable
mutable
immutable && Tuple Both are Both are
4 Which statement is correct? && Tuple
&& Tuple is Mutable. Immutable
is
is mutable immutabl
immutable
e
How to get last element of list in python?
5 arr[0] arr[5] arr[last] arr[-1] arr[-1]
Suppose we have list with name arr
Which of the following is not used as loop while do-while None of the do-while
6 for loop
in Python? loop loop above loop
How many times will the loop run?

i=2
7 2 3 1 0 2
while(i>0):

i=i-1
Which one of the following is a valid if (a >=
8 if a>=2 : if (a => 22) if a >= 22 if a>=2 :
Python if statement : 2)
9 Which keyword is use for function? define fun def function def
What will be the output of following min
Python code? function
cannot be
10 c C++ C C
list1=["Python","Java","c","C","C++"] used on
string
print(min(list1)) elements
11 The identity operators are ___________ is is not is , is not in, not in is , is not
Python _______________ are written
dictionarie tuples and dictionarie
12 with curly brackets, and they have keys tuples list
s list s
and values.
In dictionary value does not exist without
13 number Key string data Key
____________ and vice versa.
The ____________ parameter is a
reference to the current instance of the
14 self this dot current self
class, and is used to access variables
that belongs to the class.
_________________ is the class that
Virtual Parent Base Child
15 inherits from another class, also called Child Class
Class Class Class Class
derived class.
A variable created inside a function and
Local Global Static Dummy Local
16 can only be used inside that function is
Variable Variable Variable Variable Variable
called as ____________________
__________ function can be used to find
17 high() max() large() maximum() max()
the highest value.
To write to an existing file, you must add "
________" parameter to
18 r a w c a
the open() function.

The __________ block lets you test a


19 block of code for errors. except finally try raise try

The_____________ block gets executed


20 no matter if the try block raises any errors final catch for finally finally
or not.
sleep () suspends the execution of thread milisecond milisecond
21 minute hrs seconds
by ______________. s s
_____________ is the standard GUI
22 Jpython Tkkinter Tkinter pgui Tkinter
library for Python.
The _____________ widget is used to
draw shapes, such as lines, ovals,
23 Canvas textbook frame menu Canvas
polygons and rectangles, in your
application.
The ________________ widget is used to
24 add scrolling capability to various widgets, frame Scrollbar Window canvas Scrollbar
such as list boxes.
______________________ is a Regular Regular
searching(
25 sequence of characters that forms a Expressio spin( ) matching( ) Expressio
)
search pattern. n n
______________arranges the widgets in
LayoutMa LayoutMan
26 the window at proper place for better tkinter place pack
nager ager
display.
Layout managers are also known as Geometry Geometry
27 place pack girds
________________________ managers managers
We can use ____________without any
LayoutMana
28 option, so that it can decide which way to place girds pack() pack()
ger
arrange widgets.
It is container widget that can contain any
LabelFra PanedWi Radiobutto PanedWin
29 number of panes, arranged horizontally or frames
me ndow ns dow
vertically.
____________________ can be used to
30 select from a fixed number of values. Spinbox spin( ) box() range() Spinbox

The _____________ is a rectangular area


31 GUI Panel Canvas Pane Canvas
intended for drawing pictures
Regular Regular
_______________, is a sequence of
32 Expressio String char[] tuples Expressio
characters that forms a search pattern.
n n
______________ suspends the execution
33 wait() sleep() halt() hold() sleep()
of thread by miliseconds.
_____________ displays the name of
currentThr displayThre currentThr
34 currently executing thread. current() now()
ead() ad() ead()
35 A ____________ is a part of process. program function() thread object thread
A program is consist of multiple functions,
36 Thread method() process object Thread
a function is a ____________.
heavywei
37 A thread is ____________________. lightweight normal midweight lightweight
ght
same different same
Context Switch is easier and not costly in
38 objects address address classes address
____________________
space space space
When one process goes in waiting mode
the CPU starts executing another process multitaskin multithre multiple multiproces multiproce
39
to save time. This is know as g ading execution sing ssing
_______________________.
The _____________________ time
consuming , costly , difficult, limited
multitaskin multiproc multiple multiproces multiproce
40 because the processes address space is
g essing execution sing ssing
different.

__________________________
random.ra random.r random.ra random.ran random.ra
41 Generates a random float number
ndint() andfl() ndom() df() ndom()
between 0.0 to 1.0
______________________ Returns a
random integer between the specified random.ra random.r random.ra random.ran random.ra
42
integers. ndint() andfl() ndom() df() ndint()

In import mygreet as mg , mg is known as


43 duplicate alternate mygreet alias alias
_______________
_______________________ block gets
44 executed no matter if the try block raises finally catch raise else finally
any errors or not.
The ______________ block lets you test
50 except catch try finally try
a block of code for errors.
The _________________ block lets you
51 except catch try finally except
handle the error.
The ______________ block lets you raise
52 raise catch try finally raise
/ throw / generate exception.
_____________________ mode add new
55 contents to the previous data without read append write add append
deleting it.
______________ mode add new
56 contents to the file by deleting previous read append write add write
contents.
It is a good practice to always close the
security
file when you are done with it for security
57 safety and privacy consistancy
_________________. and safety.
safety.
The open() function takes
filename filename
58 _________________________parameter filename mode number
and mode and mode
s.
_______________________ module mathema
59 cal math summary math
extends the list of mathematical functions. tics
A variable created inside a function
60 belongs to the _____________ scope of Local Global private public Local
that function.
The ________________ method
61 removes any whitespace from the remove() concate() strip() trunc() strip()
beginning or the end of string.
62 ____________________ finds the length. len() length() long() num() len()
______________________ allows us to
define a class that inherits all the
golbal
63 methods and properties from another scope threading Inheritance Inheritance
scope
class.

________________ is the class being


Parent derived default Parent
64 inherited from, also called base class. child class
class class class class
____________________ class is the
Parent derived default
65 class that inherits from another class, child class child class
class class class
also called derived class.
The ____________ parameter is a
reference to the current instance of the
66 class, and is used to access variables global self local private self
that belongs to the class.

________________ is a special type of Construct destructo Construct


67 class int()
function that is used to initialize the object. or r or
The name of constructor is always the
68 _init___() init() const() __init__()
same as _______________. __init__()
_________________ are only available default protected private public private
69
inside the class and not outside of class. variables variables variables variables variables
_________________ inverts the case for swapcase( swapcase(
70 swap() case() inverted()
all letters ) )
________________ converts all letters in
71 upper() up() capital() cap() upper()
upper case.
72 _______________returns cosine of x. cos() tan() sin() ceil() cos()
_________________________ returns
73 cos() tan() sin() ceil() tan()
the tangent of x.
_____________________ returns sine of
74 cos() tan() sin() ceil() sin()
x
_______________ returns the square sqareroot(
75 sqroot() root() sqrt() sqrt()
root of x. )
76 ____________________ returns e**x. pow() expon() ex() exp() exp()
The __________________ function calls
77 global local iterative recursive recursive
itself one or more times in its own body.
The result of _____________ functions is
78 private Boolean init float Boolean
always true or false.
_______________ function is used to
79 enter() read() input() insert() input()
take input from user.
fibonacci series is 01123 1 1 2 3 5 2 2 4 6 10 1 2 3 5 8 011235
80
_______________________ 5 8 13…. 8 13…. 16…. 13 …. 8 13….
membership operators are
81 in not in is , is not in, not in in, not in
______________
The ____________ statement is null
82 pass delete break continue pass
operation.
The ____________ statement is used to
83 pass delete break continue break
terminate the loop.
The _____________ statement is used to
84 pass delete break continue continue
skip part of loop.
______________ function is used to
85 generate() range() count() increment() range()
generate sequence of numbers.
What data type is the object below ? L = Dictionar
86 List Tuple Arrays List
[1, 23, ‘hello’, 1] y
Syntax Runtime Semantic
87 Following is not type of error in python Time error Time error
errors errors errors

which of the following function convert a long(x


88 int(x[,base float(x) str(x) float(x)
string to a float in python? [,base] )
])
Python allows string slicing. What is the
cppbuzz cppbuzz
89 output of below code s='cppbuzz pbuzz buzzc bu
chicago chicago
chicago'print(s[:])
what is the output for name="Hello World" Hello hello <class <class
90 str
print(type(name)) World World 'str'> 'str'>
Which of the following data type is used
91 Class List Tuple Dictionary Dictionary
to store values in Key & Value format?
which is the following is the conditional
92 Break Pass continues If-else If-else
statement
Which of the following statements are
true
1.Python is high level language
2 all
high level languages are portable
93 1,2,3,4 1,3,4. 1,3 1,2,3 1,2,3
3. Python is
interpreted programming language
4. Low leve
lprograms can run on any kind of
computer
What is the process of tracking down the Debuggin Error-
94 Bugging Syntaxing Debugging
bugs called? g proning
Which error is caused because of Missing
95 Runtime Syntax Semantic exceptional Syntax
parenthese in expression?
Trying to divide by zero during the
96 Logical Semantic Syntax Runtime Runtime
program will cause following error.
Experiment
In python what error will it give if you write Syntax Runtime Semantic Syntax
97 al
(2+2 and forget to close the paranthesis. errors errors errors errors
debugging
Which of the following statements are
true for Pass statement in python
1)The pass statement is a null operation;
nothing happens when it executes.
2)It is used when a statement is required
98 1 1,2 1,3 1,2,3 1,2,3
syntactically but you do not want any
command or code to execute.
3)The pass is also useful in places where
your code will eventually go, but has not
been written yet.
Which of the following statements are true
1)Python is platform independent
language.
99 2)Python supports object oriented 1 1,2 1,2,3 1,2,3,4 1,2,3,4
programming concept.
3) The python file has .py extension.
4)Python is an open source language.
Choose the correct option for the 5 is of 5 is of 5 is of
following code: type 5 is of type 5 is of type type
100
a=5 <class type <> <class <'int'> <class
print(a, "is of type", type(a)) 'int'> +int+> 'int'>

You might also like