NEW
Font size
WorksheetsPython Basics for Beginners
Total questions: 10
Worksheet time: 5mins
What is the correct file extension for Python files?
.py
.pyth
python.file
.pyt
How do you create a variable in Python?
Create a variable by writing 'value -> variable_name'.
Assign a variable with 'variable_name : value'.
Declare a variable using 'value = variable_name'.
Use the syntax 'variable_name = value' to create a variable.
What keyword is used to define a function in Python?
method
def
function
define
Which of the following is a valid list in Python?
(1, 2, 3)
{1, 2, 3}
[1, 2, 3]
[1; 2; 3]
What is the output of print(2 ** 3)?
4
8
6
9
How do you start a comment in Python?
Start comments using the '/*' symbol.
Use the '#' symbol to start a comment.
Use the '@' symbol to start a comment.
Begin a comment with '//' in Python.
What data type is used to represent text in Python?
str
string
char
text
Which function is used to read input from the user?
read()
getInput()
fetchInput()
input()
What is the purpose of the 'if' statement in Python?
The 'if' statement in Python is for creating loops.
The 'if' statement in Python is meant for importing modules.
The 'if' statement in Python is used to define functions.
The purpose of the 'if' statement in Python is to execute code conditionally based on a boolean expression.
How do you create a loop that runs 5 times in Python?
for i in range(5): pass
while i < 5: pass
repeat 5 times: pass
for i in range(10): pass
