Python Online Test - TutorialPoints - 1
Python Online Test - TutorialPoints - 1
This Python Online Test simulates a real online certification exams. You will be presented
Multiple Choice Questions (MCQs) based on Python Concepts, where you will be given four
options. You will select the best suitable answer for the question and then proceed to the next
question without wasting given time. You will get your online test score after finishing the
complete test.
Total Questions: 47, Attempted: 48, Correct: 21, Time Taken: 16.19 Min
Q - Name the error that doesn’t cause program to stop/end, but the output is not the
desired result or is incorrect.
A - Syntax error
B - Runtime error
C - Logical error
Answer : C
Explanation
logical error doesn’t cause the program to stop/end, but the output is not the desired result or
is incorrect.
https://www.tutorialspoint.com/python/python_online_test.htm 1/24
05/11/2021, 13:43 Python Online Test
Show Answer
Q - Find the missing code in the following program for the following output −
for i in range(5):
Missing code
Output −
01234
A - print(i)
B - print(i, \t)
Answer : C
Show Answer
Q - What is the output of print list[1:3] if list = [ 'abcd', 786 , 2.23, 'john', 70.2 ]?
B - abcd
C - [786, 2.23]
Answer : C
Explanation
It will print elements starting from 2nd till 3rd. Output would be [786, 2.23].
Show Answer
https://www.tutorialspoint.com/python/python_online_test.htm 2/24
05/11/2021, 13:43 Python Online Test
B - Turtle.circle(''green'')
C - Turtle.dot(20 , ''green'')
D - Turtle.dot(''green'')
Answer : C
Show Answer
A - isupper()
B - join(seq)
C - len(string)
D - ljust(width[, fillchar])
Answer : B
Explanation
Show Answer
print('hijk'.partition('ab'))
B - ('hijk')
D - Name error
Answer : C
Explanation
Since there are no separators in the given string so the output is the same string.
Show Answer
C - It uses English keywords frequently where as other languages use punctuation, and it has
Answer : D
Explanation
Show Answer
A - set(x)
https://www.tutorialspoint.com/python/python_online_test.htm 4/24
05/11/2021, 13:43 Python Online Test
B - dict(d)
C - frozenset(s)
D - chr(x)
Answer : D
Explanation
Show Answer
~~~~~19
A - 20
B - -20
C - -19
D - 19
Answer : B
Explanation
Show Answer
A - Tuple(''abc'')
B - List(''abc'')
C - Set(''abac'')
https://www.tutorialspoint.com/python/python_online_test.htm 5/24
05/11/2021, 13:43 Python Online Test
Answer : D
Explanation
Set does not allow the repetitive values in it and it separated each value present under a
string.
Show Answer
A - unichr(x)
B - ord(x)
C - hex(x)
D - oct(x)
Answer : D
Explanation
Show Answer
A - [‘hat’,’mat’,’rat’,’rhyme’]
B - ‘hatmatratrhyme’
D - ‘hatrhymematrhyme rat’
https://www.tutorialspoint.com/python/python_online_test.htm 6/24
05/11/2021, 13:43 Python Online Test
Answer : D
Explanation
The method join() takes list of string as input and returns string as output. It removes ‘,’ and
add the given string with join to the list.
Show Answer
A - Len(s)
B - Sum(s)
C - Print(s[3])
D - Max(s)
Answer : C
Explanation
Show Answer
A - True
B - False
C - Error
D - Prints '19'.
Answer : B
Show Answer
https://www.tutorialspoint.com/python/python_online_test.htm 7/24
05/11/2021, 13:43 Python Online Test
class Count:
self.__count=count
a=Count(2)
b=Count(2)
c= ''hello''
d= ''hello''
print(id(c)==id(d))
A - True False
B - False True
C - False False
D - True True
Answer : B
Explanation
The objects with same contents share the same object in the python library but this is not
true for custom-defined immutable classes.
Show Answer
A - 1abc
B - $12a
C - _xy1
D - @python
Answer : C
Explanation
https://www.tutorialspoint.com/python/python_online_test.htm 8/24
05/11/2021, 13:43 Python Online Test
Show Answer
A - Index error.
B-''
C - 'Tutorials Point'
D - Syntax error
Answer : B
Explanation
Slicing will never give us an error even if we give it too large of an index for the string. It will
just return the widest matching slice it can.
Show Answer
A - {}
B - ()
C - []
D - set()
Answer : D
Explanation
https://www.tutorialspoint.com/python/python_online_test.htm 9/24
05/11/2021, 13:43 Python Online Test
Show Answer
Q - Which of the following statement terminates the loop statement and transfers
execution to the statement immediately following the loop?
A - break
B - continue
C - pass
Answer : A
Explanation
break statement − Terminates the loop statement and transfers execution to the statement
immediately following the loop.
Show Answer
A-e
C-w
Answer : B
Explanation
Show Answer
https://www.tutorialspoint.com/python/python_online_test.htm 10/24
05/11/2021, 13:43 Python Online Test
A - int(144)==144
B - int('144')==144
C - int(144.0)==144
Answer : D
Explanation
The built-in int() type constructor converts string and floating value to integer.
Show Answer
A - Numbers
B - String
C - List
D - Slice
Answer : D
Explanation
Show Answer
Q - Which module is used to sleep the python shell for the desired time? And what is
the code to do the same?
A - os, os.sleep()
https://www.tutorialspoint.com/python/python_online_test.htm 11/24
05/11/2021, 13:43 Python Online Test
B - os, os.time()
C - time, time.sleep()
D - time, time.os()
Answer : C
Show Answer
Q - Which of the following function changes case for all letters in string?
B - strip([chars])
C - swapcase()
D - title()
Answer : C
Explanation
Show Answer
A - repr(x)
B - eval(str)
C - tuple(s)
D - list(s)
Answer : D
https://www.tutorialspoint.com/python/python_online_test.htm 12/24
05/11/2021, 13:43 Python Online Test
Explanation
Show Answer
A - [19,21]
B - [11,15]
C - [11,15,19]
D - [13,17,21]
Answer : C
Explanation
Show Answer
for i in ''.join(string.split()):
Answer : C
https://www.tutorialspoint.com/python/python_online_test.htm 13/24
05/11/2021, 13:43 Python Online Test
Show Answer
Q - What is the output of print list[0] if list = [ 'abcd', 786 , 2.23, 'john', 70.2 ]?
B - abcd
C - Error
Answer : B
Explanation
Show Answer
A - Hello World!
B - Error
C - str
Answer : A
Explanation
Show Answer
https://www.tutorialspoint.com/python/python_online_test.htm 14/24
05/11/2021, 13:43 Python Online Test
x = Circle()
Answer : B
Explanation
Show Answer
A - Canvas.showinfo(''showinfo'', ''Programming'')
B - Tkinter.showinfo(''showinfo'' , ''Programming'')
C - Tkinter.messagebox.showinfo(''Programming'')
D - Tkinter.messagebox.showinfo(''showinfo'' , ''Programming'')
Answer : D
Show Answer
https://www.tutorialspoint.com/python/python_online_test.htm 15/24
05/11/2021, 13:43 Python Online Test
Q - Using the pack manager, how you can you put the components in a container in the
same row?
A - Component.pack(side= ''LEFT'')
B - Component.pack(''Left '')
C - Component.pack(side=LEFT)
D - Component.pack(Left-side)
Answer : C
Explanation
Show Answer
s = ''\t\t\t\n\nTutorialsPoint\n\n\n\t\t\t''
s.strip()
A - '\n\nTutorialsPoint\n\n\n'
B - '\t\t\tTutorialsPoint\t\t\t'
C - 'TutorialsPoint'
Answer : C
Explanation
Strip method is used to remove all the newline and tab spaces code in the string.
Show Answer
Q - Suppose we are given with two sets(s1&s2) then what is the output of the code −
https://www.tutorialspoint.com/python/python_online_test.htm 16/24
05/11/2021, 13:43 Python Online Test
S1 + S2
C - It is an illegal command.
Answer : C
Explanation
Show Answer
B - strip([chars])
C - swapcase()
D - title()
Answer : D
Explanation
title() − Returns "titlecased" version of string, that is, all words begin with uppercase and the
rest are lowercase.
Show Answer
Q - Which of the following environment variable for Python tells the Python interpreter
where to locate the module files imported into a program?
A - PYTHONPATH
https://www.tutorialspoint.com/python/python_online_test.htm 17/24
05/11/2021, 13:43 Python Online Test
B - PYTHONSTARTUP
C - PYTHONCASEOK
D - PYTHONHOME
Answer : A
Explanation
PYTHONPATH − It has a role similar to PATH. This variable tells the Python interpreter
where to locate the module files imported into a program. It should include the Python
source library directory and the directories containing Python source code. PYTHONPATH is
sometimes preset by the Python installer.
Show Answer
2 * 2 **3
A - 12
B - 64
C - 16
D - 36
Answer : C
Explanation
2**3 gives 2*2*2 i.e. 8, then 2*8 gives 16, since order of precedence is ** then*. ** implies ‘‘
raise to power’’.
Show Answer
A - set(x)
https://www.tutorialspoint.com/python/python_online_test.htm 18/24
05/11/2021, 13:43 Python Online Test
B - dict(d)
C - frozenset(s)
D - chr(x)
Answer : B
Explanation
Show Answer
Q - Which of the following function convert a single character to its integer value in
python?
A - unichr(x)
B - ord(x)
C - hex(x)
D - oct(x)
Answer : B
Explanation
Show Answer
Q - What is the output of print list[2:] if list = [ 'abcd', 786 , 2.23, 'john', 70.2 ]?
B - abcd
C - [786, 2.23]
https://www.tutorialspoint.com/python/python_online_test.htm 19/24
05/11/2021, 13:43 Python Online Test
Answer : D
Explanation
It will print elements starting from 3rd element. Output would be [2.23, 'john', 70.2].
Show Answer
Q - Which of the following function checks in a string that all characters are
alphanumeric?
A - shuffle(lst)
B - capitalize()
C - isalnum()
D - isdigit()
Answer : C
Explanation
isalnum() − Returns true if string has at least 1 character and all characters are
alphanumeric and false otherwise.
Show Answer
https://www.tutorialspoint.com/python/python_online_test.htm 20/24
05/11/2021, 13:43 Python Online Test
Answer : B
Explanation
Show Answer
return(x+y, x-y)
print(x, y)
A - 300 -100
B - 200 0
C - 200 100
D - 0 300
Answer : A
Explanation
In variable y functions runs and gives the output of x + y and x - y i.e 300 and -100
respectively. Then assignment operator is used to assign the value of x and y.
Show Answer
A - random.uniform ()
B - random.randint()
C - random.random()
https://www.tutorialspoint.com/python/python_online_test.htm 21/24
05/11/2021, 13:43 Python Online Test
Answer : D
Explanation
To generate random numbers we import random module and in that module we have these
methods/functions.
uniform(x,y) returns a floating number in the range [x,y] random() returns a floating point
number in the range [0, 1].
randint(x,y) returns a random integer number in the range [x, y].
Show Answer
Q - In the following options which are python libraries which are used for data analysis
and scientific computations
A - Numpy
B - Scipy
C - Pandas
Answer : D
Explanation
Numpy,Scipy,pandas are few libraries in python which are used for data analysis and
scientific computations.
Show Answer
A - isupper()
B - join(seq)
C - len(string)
D - ljust(width[, fillchar])
https://www.tutorialspoint.com/python/python_online_test.htm 22/24
05/11/2021, 13:43 Python Online Test
Answer : C
Explanation
Show Answer
A-$
B - //
C - /*.... */
D-#
Answer : D
Show Answer
A - true
B - false
C - Error
Answer : A
Explanation
true
Show Answer
https://www.tutorialspoint.com/python/python_online_test.htm 23/24
05/11/2021, 13:43 Python Online Test
New Test
https://www.tutorialspoint.com/python/python_online_test.htm 24/24