3.2 Subroutines

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/5

flashcard set

Earn XP

Description and Tags

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

6 Terms

1
New cards
Define a subroutine
A set of instructions which execute a commonly used task.
2
New cards
What is the difference between a procedure and a function?
A function returns a value but a procedure does not
3
New cards
How do you write a subroutine in pseudo-code?(add a and b)
SUBROUTINE add(a, b)
result ← a + b
OUTPUT result
ENDSUBROUTINE
#this is a procedure
4
New cards
Write a subroutine with a return value in python. (area)
def area(l, w):
area = l * w
return area
print(area(5, 6)
#prints out 30
5
New cards
How do you call subroutine without a return value? (PC, PY)
add(3, 4) #it is the same for both
6
New cards
How do you call a subroutine with a return value?
answer ← area(l, w)
answer = area(l, w)