wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python XM

Total questions: 22

Worksheet time: 11mins

Name
Class
Date
1.

What is a correct syntax to output "Hello World" in Python?

a)

echo("Hello World");

b)

print("Hello World")

c)

echo "Hello World"

d)

p("Hello World)

2.

How do you insert COMMENTS in Python code?

a)

#This is a comment

b)

//This is a comment

c)

/*This is a comment*/

3.

Which one is NOT a legal variable name?

a)

my_var

b)

my-var

c)

_myvar

d)

Myvar

4.

How do you create a variable with the numeric value 5?

a)

Both the other answers are correct

b)

x = 5

c)

x = int(5)

5.

What is the correct file extension for Python files?

a)

.pyt

b)

.pyth

c)

.py

d)

.pt

6.

How do you create a variable with the floating number 2.8?

a)

x = 2.8

b)

x = float(2.8)

c)

Both the other answers are correct

7.

What is the correct syntax to output the type of a variable or object in Python?

a)

print(typeof x)

b)

print(type(x))

c)

print(typeof(x))

d)

print(typeOf(x))

8.

What is the correct way to create a function in Python?

a)

def myFunction():

b)

create myFunction():

c)

function myfunction():

9.

In Python, 'Hello', is the same as "Hello"

a)

True

b)

False

10.

Which method can be used to return a string in upper case letters?

a)

uppercase()

b)

upperCase()

c)

toUpperCase()

d)

upper()

11.

Which operator is used to multiply numbers?

a)

%

b)

#

c)

x

d)

*

12.

Which operator can be used to compare two values?

a)

==

b)

> <

c)

=

d)

<>

13.

Which of these collections defines a LIST?

a)

["apple", "banana", "cherry"]

b)

("apple", "banana", "cherry")

c)

{"name": "apple", "color": "green"}

d)

{"apple", "banana", "cherry"}

14.

Which of these collections defines a TUPLE?

a)

{"apple", "banana", "cherry"}

b)

["apple", "banana", "cherry"]

c)

("apple", "banana", "cherry")

d)

{"name": "apple", "color": "green"}

15.

Which of these collections defines a SET?

a)

{"apple", "banana", "cherry"}

b)

["apple", "banana", "cherry"]

c)

("apple", "banana", "cherry")

d)

{"name": "apple", "color": "green"}

16.

Which of these collections defines a DICTIONARY?

a)

{"apple", "banana", "cherry"}

b)

["apple", "banana", "cherry"]

c)

("apple", "banana", "cherry")

d)

{"name": "apple", "color": "green"}

17.

Which collection is ordered, changeable, and allows duplicate members?

a)

TUPLE

b)

LIST

c)

DICTIONARY

d)

SET

18.

Which collection does not allow duplicate members?

a)

TUPLE

b)

LIST

c)

SET

19.

How do you start writing an if statement in Python?

a)

if x > y then:

b)

if x > y:

c)

if (x > y)

20.

How do you start writing a while loop in Python?

a)

while (x > y)

b)

while x > y:

c)

while x > y {

d)

x > y while {

21.

How do you start writing a for loop in Python?

a)

for x > y:

b)

for x in y:

c)

for each x in y:

22.

Which statement is used to stop a loop?

a)

stop

b)

break

c)

return

d)

exit