wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

python quiz

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

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

a)

print("Hello World")

b)

echo("Hello World");

c)

p("Hello World")

d)

echo"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

d)

This is a comment

3.

Which one is NOT a legal variable name?

a)

my-var

b)

Myvar

c)

my_var

d)

_myvar

4.

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

a)

x = int(5)

b)

x = 5

c)

Both the other answers are correct

5.

What is the correct file extension for Python files?

a)

.py

b)

.pt

c)

.pyt

d)

.pyth

6.

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

a)

x = float(2.8)

b)

x = 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(typeof(x))

c)

print(typeof x)

d)

print(type(x))

8.

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

a)

def myFunction():

b)

function myfunction():

c)

create myFunction():

9.

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

a)

False

b)

True

10.

Which method can be used to remove any whitespace from both the beginning and the end of a string?

a)

trim()

b)

ptrim()

c)

strip()

d)

len()