Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Basics Quiz

Total questions: 11

Worksheet time: 6mins

Name
Class
Date
1.

What is the purpose of using parentheses in a function in Python?

a)

To indicate the start and end of a list

b)

To control an object

c)

To enclose the arguments of the function

d)

To perform a mathematical operation

2.

What does the assignment operator do in Python?

a)

It multiplies two values

b)

It compares two values

c)

It assigns a value to a variable

d)

It subtracts one value from another

3.

What is an infinite loop in Python?

a)

A loop that runs a specific number of times

b)

A loop that never ends

c)

A loop that can only run once

d)

A loop that executes only if a condition is true

4.

How does Python indicate which lines of code are inside a loop?

a)

By using parentheses

b)

By using curly braces

c)

By using a 4-space indent

d)

By using a semicolon

5.

What is a variable in Python?

a)

A function that performs an action

b)

A fixed value that cannot change

c)

A placeholder for text

d)

A holder for a value

6.

What is the value in the given example "enemy1 = 'Kratt'"?

a)

enemy1

b)

Kratt

c)

hero.findNearestEnemy()

d)

hero.attack(enemy1)

7.

Which keyword is used to define a function in Python?

a)

function

b)

def

c)

func

d)

define

8.

What does the 'break' statement do in a loop in Python?

a)

Pauses the loop

b)

Ends the loop

c)

Skips one iteration of the loop

d)

Breaks the program

9.

What is the output of the expression 3 ** 2 in Python?

a)

5

b)

6

c)

9

d)

12

10.

Which of the following is a correct syntax to output 'Hello World' in Python?

a)

echo 'Hello World'

b)

print('Hello World')

c)

console.log('Hello World')

d)

printf('Hello World')

11.

How do you insert COMMENTS in Python code?

a)

/* This is a comment */

b)

// This is a comment

c)

# This is a comment

d)

<!-- This is a comment -->