wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

python excercise varible

Total questions: 12

Worksheet time: 6mins

Name
Class
Date
1.

What is the correct file extension for Python files?

a)

.pp

b)

.py

c)

.pt

d)

.php

2.

Insert the missing part of the code below to output "Hello World".


(a)   ("Hello world")

3.

Which character is used to define a Python comment:

a)

'

b)

//

c)

#

d)

/*

4.

What is a correct way to declare a Python variable?

a)

var x = 5

b)

#x = 5

c)

$x = 5

d)

x = 5

5.

True or False:
Variable names are not case-sensitive.

a)

TRUE

b)

FALSE

6.

Which is NOT a legal variable name?

a)

my-var = 20

b)

my_var = 20

c)

Myvar = 20

d)

_myvar = 20

7.

Create a variable named "carname" and assign the value "Volvo" to it.

(a)  

8.

Create a variable named x and assign the value 50 to it.

(a)  

9.

If x = 5, what is a correct syntax for printing the data type of the variable x?

a)

print(dtype(x))

b)

print(type(x))

c)

print(x.dtype())

10.

The following code example would print the data type of x, what data type would that be?

a)

int

b)

str

c)

float

11.

The following code example would print the data type of x, what data type would that be?

a)

str

b)

int

c)

string

d)

float

12.

The following code example would print the data type of x, what data type would that be?

a)

str

b)

bool

c)

int

d)

double