wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Week 7 - User Functions

Total questions: 54

Worksheet time: 27mins

Name
Class
Date
1.

A .................... is a named block of code that is used to perform a task and will return one or more values (called the 'return value’).

a)

Procedure

b)

Argument

c)

Function

d)

Call

2.

Parameter is ......

a)

The variable that information is passed to in a function

b)

The data that is passed to a function

c)

Data is sent back to be used by the main program after a function has been run.

3.

An argument is ......

a)

The variable that information is passed to in a function

b)

The data that is passed to a function

c)

Data is sent back to be used by the main program after a function has been run.

4.

What term is used to describe data passed into/out of a program?

a)

Variable

b)

Loop

c)

Constant

d)

Parameter

5.

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

a)

An error

b)

Nothing

c)

first surname

d)

Han Solo

6.

Variables allow us to:

a)

Name different parts of our programs

b)

Use English words to communicate with Tracy

c)

Store information to use in our programs

d)

Change the words Tracy recognizes

7.

How many parameters can we use in each function?

a)

1

b)

2

c)

3

d)

As many as we need

8.

Which keyword is used for function?*

a)

define

b)

fun

c)

def

d)

function

9.

Which of the following function headers is correct?*

a)

def fun(a = 2, b = 3, c)

b)

def fun(a = 2, b, c = 3)

c)

def fun(a, b = 2, c = 3)

d)

def fun(a, b, c = 3, d)

10.

How is a function declared in Python?*

a)

def function function_name():

b)

declare function function_name():

c)

def function_name():

d)

declare function_name():

11.

Which one of the following is the correct way of calling a function?

a)

function_name()

b)

call function_name()

c)

ret function_name()

d)

function function_name()

12.
a)

a=10

b)

a=20

c)

syntax error

d)

value error

13.

Leo wants to create a function that will roll a dice. Which is the correct function definition header?

a)

def dice roll ():

b)

def diceroll ()

c)

def diceroll ():

d)

def diceroll []:

14.

__________ is the built-in function to know the type of a variable or function.

a)

id()

b)

type()

c)

data_type()

d)

none of the above

15.

times is ________________ type of argument.

a)

default arguments

b)

keyword arguments

c)

positional arguments

d)

arbitrary positional arguments

e)

arbitrary keyword arguments

16.

Do you call or define a function first?

a)

call

b)

define

17.

What is the purpose of a function?

a)

They are reusable pieces of programs.

b)

They are required by the Python

c)

They allow us to compile our program

d)

They make the program larger

18.

What are the two main types of functions?

a)

Custom function

b)

Built-in function & User defined function

c)

User function

d)

System function

19.

Which of the statements below is true about indentation in Python?

a)

Indentation only matters in for loops.

b)

Indentation never matters in Python.

c)

Indentation always matters in Python.

d)

Indentation only matters in functions.

20.

4. The suite of a function always comes after a _______.

a)

;

b)

:

c)

'

d)

#

21.

Which of the following are advantages of using function in program?

a)

It increases readability of program.

b)

It increases reusability.

c)

It makes debugging easier.

d)

All of the above

22.

Function defined to achieve some task as per the programmer’s requirement is called a ______________

a)

user defined function

b)

library function

c)

built in functions

d)

All of the above.

23.
The correct way to write a variable in Python?
a)
myVariable = 10
b)
my Variable = 10
c)
myVariable is 10
d)
myVariable: 10
24.

What term is used to describe data passed into/out of a program?

a)

Variable

b)

Loop

c)

Constant

d)

Parameter

25.

The output of the code above is

a)

40

b)

30

c)

syntax error

26.

What is a parameter?

a)

Parameters are the values that are passed into a function.

b)

Parameters are the names of the information that is used in a function.

c)

A parameter is a small section of program

27.

What is an argument?

a)

An argument is a value that is passed into a function.

b)

An argument is a small section of program

c)

An argument is the name of the information that is used in a function.

28.

Name the variable in this code:

name = "Daffy"

print("Hi", name)

a)

Daffy

b)

Print

c)

Hi

d)

Name

29.

How many individual variables are in this code?

name = "Goofy"

age = "21"

holiday = "Disney"

print("Hi", name, "I see you are", age, "would you like to go to" holiday, "?")

a)

1

b)

2

c)

3

d)

4

30.

Variables can be changed

True or False?

a)

True

b)

False

31.

What is the output?

a)

more than 7

b)

more than 23

c)

spam

d)

7

32.

Which symbol means "not equal to"?

a)

==

b)

<=

c)

>=

d)

!=

33.

Which character must be at the end of the line for if?

a)

:

b)

;

c)

.

d)

{

34.

What does the = = symbol mean in Python?

a)

Equal to or shows equality

b)

Not Equal

c)

Code that will be skipped

d)

End of clause

35.
What will be printed to the screen?
a)
Nothing
b)
Success
c)
Failure
d)
Success
 Failure
36.

A named blocks of code that are designed to do one specific job is called as________

a)

Loop

b)

Function

c)

Block

d)

Branching

37.

While defining a function which of the

following symbol is used.

a)

;(semi colon)

b)

.(dot)

c)

$(dollar)

d)

:(colon)

38.

Which of the following is used, if you don’t need to type all the python code for the same task again and again?

a)

Statement

b)

Scope

c)

Control Structure

d)

Function

39.

Which two (2) lines of code will print when this function is called?

4 lines
40.

What is the name of the function?

4 lines
41.

When defining a function, the definition must occur before it is called.

a)

true

b)

false

42.

Consider the line of code:

Label('Go Team', 200, 100)

What is the Label?

a)

argument

b)

parameter

c)

function name

43.

How do you identify the statements that belong to the body of a function?

a)

Indent those statement the same amount underneath the function "def" statement

b)

Add opening and closing curly braces { and } to mark the start and stop of the function body

c)

Add the "def" keyword to the beginning of each statement

d)

Add the same comment (#) to the right of each statement within the body

44.

If a function named "mystery" is defined as taking no parameters, how would you call that function from your code?

a)

#mystery

b)

mystery[]

c)

mystery()

d)

mystery

45.

Which of the following statements correctly defines a function named "haunted" that takes a parameter named "apple"?

a)

haunted(apple)

b)

haunted

c)

def haunted(apple):

d)

apple

46.

. Which of the following definitions for the "haunted" function will correctly set the default value for the "surprise" parameter equal to the number 1?

a)

haunted(fear, surprise) = 1

b)

def haunted(fear, surprise=1):

c)

def haunted(fear, surprise "1")

d)

def haunted[fear, surprise=1]

47.

The Four Types of data we are learning about are:

a)

Integers, Decimals, Words, Boolean

b)

Numbers, Fractions, Words, Boolean

c)

Integer, Float, String, Boolean

d)

1, 2, 3, 4

48.

What data type would store the value: True

a)

Boolean

b)

String

c)

Integer

d)

Float

49.

What data value would store the value: -9?

a)

Float

b)

Integer

c)

String

d)

Boolean

50.

What data type would store the value: Oranges

a)

String

b)

Float

c)

Boolean

d)

Integer

51.

What data type would store the value: -0.04?

a)

String

b)

List

c)

Boolean

d)

Float

52.

What is the correct code to ask the user their favorite color?

a)

input("What is your favorite color?")

b)

question("What is your favorite color?")

c)

print("What is your favorite color?")

d)

ask("What is your favorite color?")

53.

What is the difference between an input statement & a print statement?

a)

They are the same code.

b)

input displays answers.

print displays questions.

c)

input displays an output on the console.

print accepts input from a user.

d)

input accepts input from a user.

print displays an output on the console.

54.

G Smasha

a)

on the track

b)

is Dillen's favorite rapper

c)

has Drake call him for advice

d)

Best Rapper Alive