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 the correct syntax to output "Hello World" in python?

a)

p("Hello World")

b)

echo("Hello World")

c)

print("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)

Myvar

b)

my-var

c)

_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)

.py

b)

.pyt

c)

.pyth

6.

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

a)

Both the other answers are correct.

b)

x = 2.8

c)

x = float(2.8)

7.

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

a)

print(type(x))

b)

print(typeOf(x))

c)

print(typeof(x))

8.

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

a)

function myfunction():

b)

create myFunction():

c)

def 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)

toUpperCase()

b)

uppercase()

c)

upper()