NEW
Font size
WorksheetsIntroduction to Python Quiz
Total questions: 50
Worksheet time: 25mins
Who developed Python programming language?
Dennis Ritchie
Guido van Rossum
James Gosling
Bjarne Stroustrup
In which year was Python first released?
1989
1991
1995
2000
Which of the following is a key feature of Python?
Compiled language
Low-level language
Object-oriented
Static typing
Which of the following makes Python easy to learn?
Complex syntax
Simple and readable code
Requires extensive memory management
Requires pre-compilation
Python is an example of which type of programming language?
High-level
Assembly-level
Machine-level
Low-level
Python is a:
Compiled language
Interpreted language
Both compiled and interpreted
None of the above
What type of programming paradigms does Python support?
Procedural
Object-oriented
Functional
All of the above
Which file extension is used for Python files?
.java
.py
.cpp
.pyt
What is the default Python IDE that comes with Python installation?
PyCharm
Jupyter Notebook
IDLE
Eclipse
What is the output of print(2 ** 3)?
5
6
8
9
Which of the following tools is used to create virtual environments in Python?
Anaconda
pip
venv
Jupyter
What is the purpose of Anaconda?
Machine learning only
Data science and machine learning
Web development
Game development
Which command is used to install Jupyter Notebook using pip?
install jupyter
pip install jupyter
jupyter install
python install jupyter
What is the default package manager for Python?
npm
pip
conda
brew
How do you activate a virtual environment in Python (Windows)?
activate
env
source env/bin/activate
. activate
Which of the following is a valid variable name in Python?
1var
_var
@var
var-1
Which of the following is not a Python data type?
int
float
char
list
How do you declare a comment in Python?
//
#
/* */
Which operator is used for floor division in Python?
/
//
%
**
What will type(3.14) return?
int
float
double
decimal
Which keyword is used to start an if statement?
if
when
for
else
What will the following code output? if 5 > 3: print("True") else: print("False")
True
False
Error
None
What is the correct way to write an if-else statement in one line?
if x > y print("Yes") else print("No")
print("Yes") if x > y else print("No")
print("Yes" if x > y else "No")
Both B and C
How many times will the following loop execute? for i in range(5): print(i)
4
5
6
Infinite
Which of the following is true about the while loop?
Executes until the condition becomes true
Executes until the condition becomes false
Executes a fixed number of times
Executes at least once
What will the following code output? x = 10 while x > 5: print(x) x -= 2
10, 8, 6
10, 8, 6, 4
Infinite loop
None
What keyword is used to exit a loop early?
skip
continue
break
exit
Which statement is used to skip the current iteration and move to the next one?
continue
pass
break
skip
What is the purpose of the else block in a loop?
Executes only if the loop condition is false
Executes if the loop runs completely without a break
Executes at the beginning of the loop
None of the above
What is the output of bool([])?
True
False
None
Error
Which function is used to get user input in Python 3?
get()
input()
scan()
read()
What is the output of print(type("5"))?
int
float
str
None
What will happen if you try to use a reserved keyword as a variable name?
The code will work fine
It will raise a syntax error
It will be ignored
It will convert the keyword to a string
How do you convert a string "123" to an integer in Python?
int("123")
string("123")
str("123")
float("123")
What is the correct syntax to define a multi-line string in Python?
"This is a multiline string"
"""This is a multiline string"""
'This is a multiline string'
[[This is a multiline string]]
Which operator is used to concatenate two strings in Python?
+
*
&
&&
What will be the output of print("Python"[::-1])?
Python
Pyt
nohtyP
Error
What is the output of print(bool(""))?
True
False
None
Error
What will the following code output? print(2 == 2.0)
True
False
TypeError
None
What will print(2 / 0) output?
0
Infinity
Error
None
Which of the following is the correct format for a for-loop in Python?
for x in 5:
for x in range(5):
for x <= 5:
for x to 5:
What will the following code output? for i in range(2, 7, 2): print(i)
2, 3, 4, 5, 6
2, 4, 6
2, 3, 5
2, 5, 6
What is the output of the following code? x = 3 while x > 0: x -= 1 print(x)
3, 2, 1
2, 1, 0
1, 0
2, 1
What is the output of the following code? x = 5 if x > 3: pass else: print("Hello")
Hello
No output
Error
None
What is the output of the following code? for i in range(3): if i == 2: break print(i)
0, 1, 2
0, 1
1, 2
0
What is the output of the following code? for i in range(5): if i == 2: continue print(i)
0, 1, 3, 4
0, 1, 2, 3, 4
1, 3, 4
1, 2, 3, 4
What happens if you use else with a for loop?
Executes when the loop is finished without a break
Executes when the loop ends with a break
Executes only when the loop condition is true
Causes an error
What will the following code output? if not 0: print("True") else: print("False")
True
False
None
Error
Which of the following is not a valid comparison operator in Python?
==
!==
<=
>
Which of the following is used to check the identity of two objects in Python?
=
==
is
in
