Playing as a guest? to earn XP and track your progress.
π Python Revision Tour I Quiz
π Python Revision Tour I
Which of the following is used to define a block of code in Python?
Curly braces {}
Indentation
Parentheses ()
Square brackets []
Python uses indentation instead of braces to define code blocks.
What is the output of print(type(10))?
<class 'float'>
<class 'int'>
<class 'str'>
<class 'bool'>
10 is an integer, so its type is int.
Which of the following is NOT a Python keyword?
while
return
variable
yield
βvariableβ is not a keyword.
Which function is used to take input from the user in Python?
scan()
read()
input()
get()
input() is used to take user input as a string.
Which of the following is an immutable type?
List
Dictionary
String
Set
Strings in Python cannot be changed after creation.
What is the output of print(3 * 'Hi')?
HiHiHi
3Hi
Error
Hi 3
String multiplication repeats the string.
Which operator has the highest precedence?
+
*
**
//
Exponentiation has the highest precedence.
What is the result of 10 // 3?
3.33
3
4
3.0
// performs floor division.
Which of the following is NOT a valid variable name?
total_marks
_name
2nd_value
value2
Variable names cannot begin with a digit.
What is the data type of the value returned by input()?
int
float
bool
str
input() always returns a string.
Which of the following is a Python delimiter?
@
:
$
&
Colon is used in loops and condition blocks.
What will be the output?
x = 5
x += 3
print(x)5
3
8
Error
+= adds and assigns.
What is the output of:
print(type(3.0))<class 'int'>
<class 'float'>
<class 'double'>
<class 'decimal'>
3.0 is a floating-point number.
Which statement is used for decision-making?
for
if
while
break
if is the decision-making statement.
What is the output?
print('A' < 'a')True
False
Error
Depends
ASCII value of 'A' is smaller than 'a'.
Which loop is best suited when the number of iterations is known?
while
for
do-while
repeat
for loop is used when the count is known.
What will be the output?
for i in range(1,4):
print(i)1 2 3
1 2 3 4
0 1 2 3
2 3 4
range(1,4) produces 1,2,3.
Which statement terminates a loop?
stop
break
halt
end
break exits the loop immediately.
Which statement skips the current iteration?
skip
pass
continue
break
continue skips to next iteration.
What does pass do in Python?
Ends the loop
Skips iteration
Does nothing
Raises an error
pass is a null statement.
What is the output?
x = '5'
y = 2
print(x * y)10
55
Error
5 5
String multiplied by 2 repeats twice: '55'.
Which of the following is mutable?
tuple
string
list
int
List elements can be modified.
Which operator checks equality?
=
==
===
!
== compares values.
Which of the following is NOT an arithmetic operator?
+
-
%
and
and is a logical operator.
What is the output of print(10 % 3)?
3
1
0
3.33
% gives remainder.
What is the output?
x = True
y = False
print(x and y)True
False
1
Error
True AND False β False.
What is the return type of range()?
list
tuple
range object
generator
range() returns a range object.
Which of the following will cause an error?
a = 10
1a = 20
_a = 30
a1 = 40
Variables cannot start with digits.
Which one is a logical operator?
%
and
**
//
and, or, not are logical operators.
What is the output?
print(2 ** 3 ** 1)64
8
16
Error
Exponentiation is right associative: 31 = 3; 23 = 8.
Which of these is NOT a token?
Identifier
Keyword
Literal
Program
Program is not a token.
Which function converts string to integer?
str()
int()
float()
input()
int() converts a string to integer.
Which symbol marks a comment?
//
#
/* */
<!-- -->
is used for comments.
What does this print?
print(len('Python'))7
6
5
Error
Python has 6 characters.
Which of the following is a valid string literal?
'Hello World'
Hello World
HelloWorld'
'HelloWorld
Strings must be inside quotes.
Output?
for i in range(3):
print("Hi")Hi
Hi Hi
Hi Hi Hi
Error
Loop runs 3 times.
Which statement is used for looping until a condition becomes false?
for
while
loop
repeat
while runs until condition becomes false.
Which of the following is TRUE?
Strings are mutable
Lists are immutable
Tuples are immutable
Dictionaries are immutable
Tuples cannot be changed.
Output?
x = 5
y = 2
print(x/y)2
2.5
2.0
Error
/ always performs float division.
Which operator is used for logical NOT?
!
~
not
!=
Python uses the word 'not'.
Output?
print('5' + '5')10
55
Error
5 5
String concatenation: '55'.
Which is TRUE about pass?
It stops execution
It skips iteration
It does nothing
It repeats loop
pass is a null statement.
Which method displays output on screen?
console()
display()
print()
show()
print() displays output.
Output?
print(bool(0))True
False
0
Error
0 is treated as False.
Which of the following is a comparison operator?
=
==
+=
&
== checks equality.
Output?
print(type([1,2,3]))<class 'tuple'>
<class 'list'>
<class 'set'>
<class 'dict'>
Square brackets create a list.
Which feature makes Python easy to debug?
It is compiled
It is interpreted
It uses pointers
It has manual memory management
Interpreted languages run code line by line.
Output?
for i in range(1,3):
print(i*i)1 4
1 4 9
0 1 4
Error
11 and 22.
Which of these belongs to flow control?
if
list
tuple
range
if controls decision flow.
Which one is TRUE about Python?
It does not support loops
It uses indentation for blocks
It uses semicolon for every line
It is case-insensitive
Python strictly uses indentation for block structure.