WorksheetsPython Basics Quiz
Total questions: 11
Worksheet time: 6mins
What is the purpose of using parentheses in a function in Python?
To indicate the start and end of a list
To control an object
To enclose the arguments of the function
To perform a mathematical operation
What does the assignment operator do in Python?
It multiplies two values
It compares two values
It assigns a value to a variable
It subtracts one value from another
What is an infinite loop in Python?
A loop that runs a specific number of times
A loop that never ends
A loop that can only run once
A loop that executes only if a condition is true
How does Python indicate which lines of code are inside a loop?
By using parentheses
By using curly braces
By using a 4-space indent
By using a semicolon
What is a variable in Python?
A function that performs an action
A fixed value that cannot change
A placeholder for text
A holder for a value
What is the value in the given example "enemy1 = 'Kratt'"?
enemy1
Kratt
hero.findNearestEnemy()
hero.attack(enemy1)
Which keyword is used to define a function in Python?
function
def
func
define
What does the 'break' statement do in a loop in Python?
Pauses the loop
Ends the loop
Skips one iteration of the loop
Breaks the program
What is the output of the expression 3 ** 2 in Python?
5
6
9
12
Which of the following is a correct syntax to output 'Hello World' in Python?
echo 'Hello World'
print('Hello World')
console.log('Hello World')
printf('Hello World')
How do you insert COMMENTS in Python code?
/* This is a comment */
// This is a comment
# This is a comment
<!-- This is a comment -->
