Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Definitions

Total questions: 12

Worksheet time: 6mins

Name
Class
Date
1.

What term is used to describe data passed into a definition?

a)

Variable

b)

Loop

c)

Constant

d)

Parameter

2.

How do you correctly call this function definition?

a)

def(1)

b)

x=square( )

c)

defSquare(4)

d)

x=square(5)

3.

Which of the following keywords marks the begining of the function block?

a)

Func

b)

define

c)

def

d)

function

4.

What is a variable defined outside (i.e. in the main code) all the definitions referred to as?

a)

A static variable

b)

A global variable

c)

A local variable

d)

An automatic variable

5.

What is a variable defined inside a definition referred to as?

a)

A static variable

b)

A global variable

c)

A local variable

d)

An automatic variable

6.

What will be PRINTED?

a)

nothing

b)

5

c)

6

d)

an error message

7.

When writing a definition, it must occur before it is called.

a)

true

b)

false

8.

What would the output be from the program shown here? (assuming that the user enters "John" and "Smith")

a)

John

b)

Smith

c)

John Smith

d)

Error

9.

What is the difference between a procedure and a function?

a)

They are the same thing

b)

A procedure passes values back out to the program, a function does not

c)

A function passes values back out to the program, a procedure does not

d)

A function can run without being called

10.

What will be the output of this program if the user enters "Han" and then "Solo"?

a)

there will be an error

b)

HanSolo

c)

first surname

d)

Han Solo

11.

Which of the following statements is NOT true?

a)

Definitions are examples of reusable code

b)

Definitions are always appropriate in programs

c)

Using definitions make it easier to "deconstruct" a problem into smaller pieces

d)

Definitions can make programs easier to read and understand

12.

What would the output be for the following program if the user enters 4 and 6?

a)

10

b)

14

c)

16

d)

there will be an error