Fetch
Decode
Explain
Activities
Flashcards
Exam Questions
Revise
Blog
Contact
Login
Login
Menu
Activities
Flashcards
Exam Questions
Revise
Blog
Contact
Login
Qualifications
OCR GCSE Computer Science
2.2 Programming Fundamentals
Sub Programs
Card
1
of
21
0
got it
0
still learning
Question
Evil question
Tap
Click or press space
to see the answer
Answer
Still learning
Got it
Turn over
Shuffle
0%
Round complete
Go again with the ones I'm still learning
Start the whole set again
Choose another set
All 21 cards in this set
What is meant by a sub program?
A named block of code that carries out one task
Which term describes a sub program that carries out a task but does not return a value?
Procedure
What is meant by a function?
A sub program that returns a value to the caller
What is the name for a variable in the definition of a sub program that receives a value passed in when it is called?
Parameter
What is meant by calling a sub program?
Running a sub program by writing its name and brackets
What is the name for the value that a function sends back to the code that called it?
Return value
A sub program called agePass has no parameters. How is it called?
By writing agePass()
Which line correctly defines a sub program called total that receives one value?
Def total(num):
A program calls a sub program and the sub program runs to its last line. Where does execution continue?
At the line after the call
What is the key difference between a function and a procedure?
A function returns a value, a procedure does not
A sub program only displays the final scores on screen and sends nothing back. Which type of sub program is it?
A procedure
What does this program print?
17
A sub program is defined as def multiply(num1, num2): and is called with multiply(4, 6). Which statement is true?
The parameter num1 receives 4 and num2 receives 6
A function returns True or False, and a call to it is written directly after if as the condition. Why does this work?
The returned value is used as the condition
Which of these is a reason for writing a program as sub programs?
A task used in several places is written once and called each time
A function is given an array of scores and returns a new array holding each score doubled. What is true of the array that was passed in?
It is not changed by the function
A program calls greet() on line 1, but def greet(): is written on line 5. What happens when the program runs?
An error occurs because the definition has not run yet
A sub program is defined as numberAdder but a later line calls NumberAdder(). What happens?
The call fails because the names do not match exactly
A function contains return result followed by a print line. What happens to the print line when the function is called?
It is not run because return ends the function
A function average(scores) uses len(scores) inside a loop. Why does this let the function work for arrays of different sizes?
It gives the number of elements in the array
A function is meant to return a value but it prints the value instead and has no return statement. What problem does this cause?
The calling code has no value to store or use