WorksheetsPython Revision tour Quiz
Total questions: 180
Worksheet time: 2hrs 33mins
Full Form of IDLE
INDUSTRIAL DEVELOPMENT LEARNING ENVIRONMENT
INTEGRATE DRIVE LEARNING ENVIRONMENT
INTEGRATED DEVELOPMENT LEARNING ENVIRONMENT
INTEGRATED DEVELOPMENT LEARNING ENGINEERING
Python is ...................language
High level language
Low level language
Medium level language
Machine language
Which statement is correct
Python is Upper case sensitive
Python is Case-Sensitive
Python is Lower case sensitive
Python is Case-Insensitive
Which statement is correct
It is free language
It is open source language
It is free and open source language
None of the above
Tick the correct statement to print hello.
print(hello)
print("hello")
Print("hello")
Print(hello)
Python programs are executed by which language processor?
Compiler
Interpreter
Assembler
All of the above
Which of the statement is correct?
Python is not portable and platform independent.
Python is portable and platform dependent.
Python is portable and platform independent.
Python is not portable and platform dependent.
Which of the following is not high level programming language?
JAVA
Visual basic
Python
Machine language
Which of the following is not compiler based programming language.
Python
C
C++
JAVA
Find the output of the following program A=0 print(a)
A.A
a
0
error
What is a program?
A set of rules.
A set of ordered instructions.
A set consist of 0 and 1.
A set of unordered instructions.
Computer understands a low level language. A low level language consist of a set of digits
(1,2,3,4)
(0,1,2,3,4,5,6,7,8,9)
(0,1)
(0,1,2,3,4,5,6,7)
Which function can be used to display the output in python
show()
print()
display()
output()
Tick the correct statement to print Hello World.
print(hello)(world)
Print("hello world")
Print(hello world)
print("Hello World ")
Find the output of the following program A=0 print(A)
A.A
a
0
1
Python uses____to convert its instructions into machine language.
Interpreter
Compiler
Both of the above
None of the above
Which of the following is not the feature of python language?
Python is proprietary software.
Python is not case-sensitive.
Python uses brackets for blocks and nested blocks.
All of the above
By default, the Python scripts are saved with____________extension.
.pyp
.pys
.py
None of the above
Which of the following is String literal?
"ABC"
"123"
Both of the above
None of the above
print("I" + "am" + "in" + "school") display
I am in school
I Am In School
Iaminschool
iaminschool
print("I" , "am" , "in" , "school") display
I am in school
I Am In School
Iaminschool
iaminschool
Which of the following is parameter of print( ) function?
sep
end
Both of the above
None of the above
The process of removing errors from programs is called __
Programming
Documentation
Debugging
None of the above
IDLE stands for__________
Integrated Development LEarning
Integrated Development Learning Environment
Intelligent Development Learning Environment
None of the above
Which of the following statement is correct syntactically?
print("Hello" , sep == '@' , end = ' ')
print("Hello" , sep = '@' , end = ' ')
Print("Hello" , sep = '@' , end = ' ')
print("Hello" , sep = '@' , end = ' '
Who developed the Python language?
Zim Den
Wick van Rossum
Guido Van Rossum
NieneStom
In which year was the Python language developed?
1990
1989
1971
1975
Which of the following is an escape sequence for a newline character?
\a
\t
\n
\b
Which of the following functions print the output to the console?
Output( )
Print( )
Echo( )
print( )
The default separator character of print( ) is ..........
tab
space
newline
dot
Which of the following is correct about python?
Python is an open source language.
Python is not based on ABC language.
Python is not a case sensitive
All of the above
Which two languages contributed to Python as a Programming Language?
C++ and ABC language
BASIC and Modula 3
ABC language and Modula 3
None of the Above
When was Python released?
Python was released in September 1991.
Python was released in February 1991.
Python was released in February 1990.
Python was released in March 1991
Python code can run on a variety of platforms, it means Python is a .......... language.
Graphical
Cross-platform
Independent
All of these
Python uses a/an .......... to convert source code to object code.
Interpreter
Compiler
Combination of Interpreter and compiler
Special virtual engine
The interpreter is also called ........................
Python Editor
Python Kernel
Python shell.
None of the Above
In the Python prompt, which symbol indicates that the interpreter is ready to take instructions.
>>
>>>
<<>
>>>>
What is the output after executing the following code: Print("Hello World!")
>>>Hello World!
Hello World
Hello World!
Error
What is the result after executing the following: >>>print(20/4 *5+8-10)
1
23
23.0
24
What will be the output of the following code ? print("150+300")
450
150300
150+300
300
What do we use to define a block of code in Python language?
Key
Brackets
Indentation
None of these
Python interpreter executes............................statement (Command) at a time.
Two
Three
One
All command
Which one is not the feature of Python?
Cross-platform
Interpreted
Free and Open source
Not a case-sensitive
A program written in a high-level language is called ..................
Compile code
Object code
Source code
Binary Code
IDLE stands for
Integrated Development or Learning Environment
Integrated Development and Learning Environment
Integrate Development and Learning Environment
Integrated Development and Learned Environment
What is the maximum possible length of an identifier in python?
16
32
64
None of these
Which of the following is not a keyword in python?
eval
assert
nonlocal
pass
All keywords in python except TRUE and FALSE are in ________?
Lower case
Upper case
Capitalized
None of the above
In which year was the python language developed?
1995
1972
1989
1981
Which one of the following is the correct extension of the python file?
.py
.p
.python
.pyt
Which of the characters is used in python to make a single line comment?
/
//
#
!
Which of the following is not a core data type in python?
List
Dictionary
Tuple
Class
What data type is the object listed below? L=[1,3,"Hello",5]
List
Tuple
Class
Dictionary
Which one of these is the floor division operator?
/
//
%
*
Which of the following has the highest precedence in python?
Exponential
Addition
Parenthesis
Division
What will be the output of the following statement? >>>a+bc
a
b
ab
abc
What is math.factorial(4.0)?
20
24
16
64
Which of the following belongs to integer datatype
-12
4.0
3+4J
-2.05
Which of the following belongs to float datatype
-12
-14.0
3+4J
4
Which of the following belongs to complex datatype
-12
4.0
3+4J
-2.05
An ordered collection of items, where each item is indexed by an integer is called:
MAPPING
SEQUENCES
SETS
NUMBERS
_______ is a sequence of items separated by commas and the items are enclosed in square brackets [ ]
LIST
DICTIONARY
STRING
TUPLE
_______ is a sequence of items separated by commas and the items are enclosed in parenthesis ()
LIST
DICTIONARY
STRING
TUPLE
_______ holds data items in key-value pairs.
LIST
DICTIONARY
STRING
TUPLE
None is a special datatype with a single value. It is used to signify the absence of value in a situation
TRUE
FALSE
NONE
NULL
Datatype conversion can happen :
ONLY EXPLICITLY
ONLY IMPLICITLY
BOTH EXPLICITLY AND IMPLICITLY
NONE OF THE ABOVE
Which of the following is mutable datatype:
INTEGER
FLOAT
STRING
LIST
Which of the following is immutable
LIST
DICTIONARY
STRING
NONE OF THE ABOVE
A list can contain the following:
ONLY NUMBERS
ONLY STRINGS
BOTH NUMBERS AND STRING
ONLY INTEGERS
String is a group of characters. These characters may be
ALPHABETS,
DIGITS
SPECIAL CHARACTERS INCLUDING SPACES.
ALL OF THE ABOVE
Numbers = [ 4, 8, 9, 2.6, 5 ] is a type of which data type in python?
List
Tuple
Set
None of these
If x=3.123, then int(x) will give ?
3.1
0
1
3
Which of the following is not a data type in python?
List
Tuple
Dictionary
Book
Which one of the following is False regarding data types in Python?
In python, explicit data type conversion is possible
Mutable data types are those that can be changed.
Immutable data types are those that cannot be changed.
None of the above
Which of the following function is used to know the data type of a variable in Python?
datatype()
typeof()
type()
vartype()
If we change one datatype to another, then it called
Type Casting
Type Conversion
Both of the above
None of the above
Consider the following sequence of statements : A=100 B=A Following the execution of above statements, python has created how many objects and how many references?
One object Two reference
One object One reference
Two object Two reference
Two object One reference
What data type is the object below? L = {1:"One",2:"Two"}
list
dictionary
array
tuple
Find Example of sequence datatype.
List
Tuple
Both of them
None of them
Which of these about a dictionary is false?
The values of a dictionary can be accessed using keys
The keys of a dictionary can be accessed using values
Dictionaries aren’t ordered
Dictionaries are mutable
Can tuple be used as dictionary key in python?
True
False
Tuple is not used in python
None of the above
Which statement is correct?
List is immutable && Tuple is mutable
List is mutable && Tuple is immutable
Both are Mutable.
Both are Immutable
Which of the following option is a core data type in the python language?
Dictionary
List
String
All of the above
In order to store values in terms of key and value we use that core data type in python?
List
Class
Dictionary
Tuple
In which data type, indexing is not valid?
List
String
Dictionary
None of the above
Which of the following operator can be classified as unary operator?
+
or
not
and
Which of the following operator has lowest precedence?
()
or
not
and
What is the output of the following code? a,b=8/4/2, 8/(4/2) print(a,b)
Syntax error
1.0,4.0
4.0,4.0
4,4
Predict output for following code v1= True v2=1 print(v1==v2, v1 is v2)
True False
False True
True True
False False
Evaluate the following expression and identify the correct answer. 16 // (4 + 2) * 5 + 2**3 * 4
42
46
18
32
Find output of following given program : str1_ = "Aeiou" str2_ = "Machine learning has no alternative" for i in str1_: if i not in str2_: print(i,end='')
Au
ou
Syntax Error
Value Error
Which of the following operator can not be used with string value
-
is
+
*
Find output for following given program a=10 b=20 c=1 print(a !=b and not c)
10
20
True
False
Find output for following given program : a=2 b=3 print( a*b**2)
18
16
64
12
Observe the presence of operator * in following program and predict the output: list1=[10,20] list2=[2,3] list1= list1*list2[0] print(list1)
Error
[20,40]
[10,10,20,20]
[10, 20, 10, 20]
Find output for following given code a=12 print(not(a>=0 and a<=10))
True
False
0
1
Evaluate expression in following given program and find the output : a=56 b=a//7//4 print(b)
0
2
0.0
2.0
What output following program will produce a=12 b=a%10 c=a%100 print(b,c)
2 12
12 2
0 0
Error
What will be value of diff c1='A' c2='a' diff= ord(c1)-ord(c2) print(diff)
Error : unsupported operator ‘-’
32
-32
0
What output following program will produce v1='1' v2= 1 v3= v1==v2
Type Error
Value Error
True will be assigned to V3
False will be assigned to v3
What will be the value of the expression 13+12%14
14
25
13
27
What will be the value of x? x= int(12.5 + 4/2)
14
15
Error
14.5
Which of the following operators has highest precedence: +,-,/,*,%,<<,>>,( ),**
**
( )
%
-
Which of the following results in an error?
float(‘12’)
int(‘12’)
float(’12.5’)
int(‘12.5’)
Which of the following is an invalid statement?
xyz=1,000,000
x y z = 100 200 300
x,y,z=100,200,300
x=y=z=1,000,000
What is the output of the following statements: A=5 B=6 print(A,B)
5 6
5,6
5 6
none of the above
What is the value of the expression 32% 3.0?
2
2.0
10.6666
10
What is the output of the expression print(4.00/(2.0+2.0))?
1
1.0
Error
1.00
What is the output of the following: print(“Hello\nWorld”)
Hello World
Hello World
Hello World
None of the Above
Which of the following is an example of type casting?
3.2+5.3
2.0+5
int(4.7)+3
all of the above
What is the output of the following? S1=”my” S2=”string” print (int(s1+s2))
my string
mystring
2563859
Error
What is the output of the following? print(“Python “, end= “ “) print(“world”)
Python world
Python world
Python end world
Python end world
Evaluate the expression 6*2/5+5*2
2.4
2
12.4
12
Which of the following defines SyntaxError?
It is raised when the file specified in a program statement cannot be opened.
It is raised when there is an error in the syntax of the Python code.
It is raised when the requested module definition is not found.
It is raised due to incorrect indentation in the program code.
Which of the following defines ValueError?
It is raised when the file specified in a program statement cannot be opened.
It is raised when there is an error in the syntax of the Python code.
It is raised when a built-in method or operation receives an argument that has the right data type but mismatched or inappropriate values.
It is raised due to incorrect indentation in the program code.
Which of the following defines IOError?
It is raised when the file specified in a program statement cannot be opened.
It is raised when there is an error in the syntax of the Python code.
It is raised when a built-in method or operation receives an argument that has the right data type but mismatched or inappropriate values.
It is raised due to incorrect indentation in the program code.
Which of the following defines KeyboardInterrupt?
It is raised when the file specified in a program statement cannot be opened.
It is raised when the user accidentally hits the Delete or Esc key while executing a program due to which the normal flow of the program is interrupted.
It is raised when a built-in method or operation receives an argument that has the right data type but mismatched or inappropriate values.
It is raised due to incorrect indentation in the program code.
Which of the following defines ImportError?
It is raised when the file specified in a program statement cannot be opened.
It is raised when there is an error in the syntax of the Python code.
It is raised when the requested module definition is not found.
It is raised due to incorrect indentation in the program code.
Which of the following defines EOFError?
It is raised when the file specified in a program statement cannot be opened.
It is raised when there is an error in the syntax of the Python code.
It is raised when a built-in method or operation receives an argument that has the right data type but mismatched or inappropriate values.
It is raised when the end of file condition is reached without reading any data by input().
It is raised when the denominator in a division operation is zero.
IndexError
IndentationError
ZeroDivisionError
TypeError
It is raised when the index or subscript in a sequence is out of range.
IndexError
IndentationError
ZeroDivisionError
TypeError
It is raised when a local or global variable name is not defined.
IndexError
IndentationError
ZeroDivisionError
NameError
It is raised due to incorrect indentation in the program code.
IndexError
IndentationError
ZeroDivisionError
NameError
It is raised when an operator is supplied with a value of incorrect data type.
IndexError
TypeError
ZeroDivisionError
NameError
It is raised when the result of a calculation exceeds the maximum limit for numeric data type.
OverFlowError
TypeError
ZeroDivisionError
NameError
ZeroDivisionError is a type of:
SyntaxError
Logical Error
Runtime Error
Other
IndentationError is a type of:
SyntaxError
Logical Error
Runtime Error
Other
KeyboardInterrupt is a type of:
SyntaxError
Logical Error
Runtime Error
Other
Which of following is not a decision-making statement.
if-elif statement
for statement
if -else statement
if statement
In Python, ...................... defines a block of statements.
Block
loop
indentation
{}
if 4+5==10: print(“TRUE”) else: print(“false”) print (“True”)
False True
True True
false
none
Predict the output of the following code: X=3 if x>2 or x<5 and x==6: print(“ok”) else: print(“no output”)
ok
okok
no output
none of above
The for loop in Python is an _____________
Entry Controlled Loop
Exit Controlled Loop
Both of the above
None of the above
The .............statement terminates the execution of the whole loop.
continue
exit
breake
break
An empty /null statement in Python is ................
pass
none
null
none
The ........... operator tests if a given value is contained in a sequence or not.
In:
in
not in
none
The order of statement execution in the form of top to bottom is known as ___________________________ construct.
alternate
sequence
flow of data
flow chart
What will be the output of given Python code? str1="hello" c=0 for x in str1: if(x!="l"): c=c+1 else: pass print(c)
2
0
4
3
State which of the following statement are true . 1.If,elif ,else are not compound statement. 2.Else if can be used in python. 3.Indentation while working with blocks is not necessary in python. 4.A pass statement is a null operation;it does nothing.
1
2,3
3
4
In a Python program, a control structure:
Defines program-specific data structures
Directs the order of execution of the statements in the program
Dictates what happens before the program starts and after it terminates
None of the above
Which of the following is False regarding loops in Python?
Loops are used to perform certain tasks repeatedly.
while loop is used when multiple statements are to executed repeatedly until the given condition becomes true.
while loop is used when multiple statements are to executed repeatedly until the given condition becomes false
for loop can be
Why is iteration important?
It determines the order in which instructions are carried out
It allows multiple paths through a program
It allows code to be simplified by removing repeated steps
It ensures the code works correctly
To access a list which contains ten elements, which of the following uses of range() would produce a list of the desired indexes?
range(1,10)
range(0,9)
range(10)
range(1,11)
Which statement is used to iterate itself over a range of values or a sequence
if
while
do-while
for
What abandons the current iteration of the loop?
continue
break
stop
infinite
Which of the following is not a loop statement in python?
do-while
while
for
all of these
Which of the following is a valid keyword?
IF
if
If
None of them
Symbol used to end the if statement is:
;
:
_
#
A graphical representation of an algorithm to solve a given problem:
Flow chart
Pie Chart
Bar chart
Column Chart
Which of the following is not a decision making statement?
if-elif
for
if-else
if
A loop that never ends is called as
infinite loop
continue
break loop
none of them
Find the output of the following: if True: print(101) else: print(202)
101
202
303
102
Which of the following is false?
oval shape in flowchart shows start or end point.
Rectangle shows process
Arrow shows connection between different parts of the code
diamond shows input/output
Which of the following is used as a dummy statement?
pass
pie
if
else
If and else are____
literals
operators
keywords
none of them
How many statements must be present in a loop body.
at least 2
at least 1
at least 4
no required
Which is a jump statement?
break
commit
reflect
do
____________loop is best when the no of iterations is known
for
if
if else
all of them
In a Python program, a control structure:
Defines program-specific data structures.
Directs the order of execution of the statements in the program
Dictates what happens before the program starts and after it terminates.
None of the above.
Can we write if/else into one line in Python?
No
Yes
if/else not used in Python
None of the above.
What keyword would you use to add an alternative condition to an if statement?
else if
elseif
elif
None of the above
Which one of the following is a valid Python if statement?
if a>=9:
if (a>=9)
if (a=>9)
if a>=9
Which statement will check if a is equal to b?
if a=b:
if a==b:
if a===b:
if a==b
What does the following source code print? if 4+5 == 10: print (“True”) else: print (“False”) print (“True”)
True
True False
False True
True False True
What does the following source code print? x = -100 if x < 100: print (“The negative number”,x,”is not print here”) print (“It is always printed”)
It is always printed
The negative number -100 is not print here It is always printed
The negative number -100 is not print here
It will cause an error.
Given the nested if-else below, what will be the value x when the source code executed successfully: x=0 a=5 b=5 if a>0: if b<0: x=x+5 elif a>5: x=x+4 else: x=x+3 else: x=x+2 print (x)
0
4
2
3
Which code segment will NOT reach its print() function?
if ‘yes’!=’no’: print (“Condition met”)
if ‘yes’ != ‘yes’: print (“Condition met”)
if not ‘yes’ = = ‘no’: print (“Condition met”)
if ‘yes’ = = ‘yes’: print (“Condition met”)
What will be the output of following code fragment: a=input(“Enter a number”) if (a = = 5): print (“Five”) else: print (“Not Five”) If input given is (i) 99 (ii) 5
Not Five
Five
Cause error
None of the above
What does the following Python program display? x=3 if x = = 0: print (“Am I here?”,end=’ ’) elif x = = 3: print (“Or here?”, end=’ ‘) else: pass print(“Or over here?”)
Am I here ?
Am I here ? Or here ?
Or here ? Or over here?
Am I here ? Or over here?
Which of the following is a pictorial representation of an algorithm?
Pseudocode
Program
Flowchart
Algorithm
Terminal symbol in a flowchart indicates:
End
Processing
Input and Output
Decision
In flowchart, diamond shaped symbol is used to represent:
Decision box
Statement box
Error box
if-statement box
Symbol used in flowchart such as rectangle with the horizontal lines on two sides is used for:
Defined statement
Predefined process
Error fix
Variables defined
What is the result of executing the following code? number = 5 while number <= 5: if number < 5: number = number + 1 print(number)
The program will loop indefinitely
The value of number will be printed exactly 1 time
The while loop will never get executed
The value of number will be printed exactly 5 times
What will the following code print? counter = 1 sum = 0 while counter <= 6: sum = sum + counter counter = counter + 2 print(sum)
12
9
7
8
What will be printed by the following code when it executes? sum = 0 values = [1,3,5,7] for number in values: sum = sum + number print(sum)
4
0
7
16
What is the last thing printed when the following code is run? number = 0 while number <= 10: print("Number: ", number) number = number + 1
Number: 10
Number: number
Number: 0
Number: 11
How many asterisks will be printed when the following code executes? for x in [0, 1, 2, 3]: for y in [0, 1, 2, 3, 4]: print('*')
0
4
20
This is an infinite loop, so nothing will be printed
The following code contains an infinite loop. Which is the best explanation for why the loop does not terminate? n = 10 answer = 1 while n > 0: answer = answer + n n = n + 1 print(answer)
n starts at 10 and is incremented by 1 each time through the loop, so it will always be positive.
answer starts at 1 and is incremented by n each time, so it will always be positive.
You cannot compare n to 0 in the while loop. You must compare it to another variable.
In the while loop body, we must set n to False, and this code does not do that.
Which type of loop can be used to perform the following iteration: You choose a positive integer at random and then print the numbers from 1 up to and including the selected integer.
