Fiveable
Fiveable
pep
Fiveable
Fiveable

or

Log in

Find what you need to study


Light

3.13 Developing Procedures

2 min readjanuary 3, 2023

Minna Chow

Minna Chow

Milo Chang

Milo Chang

Minna Chow

Minna Chow

Milo Chang

Milo Chang

Procedural Abstraction

Procedures are an example of abstraction. (In fact, it's part a special form of abstraction known as .) This is because you can call a procedure without knowing how it works. Indeed, you often do: a common built-in procedure in programming languages is the print() procedure.

Procedures allow you to solve a large problem based on the solution to smaller sub-problems. For example, my final Create project was a choose-your-own-adventure story. In order to make this story, I had to figure out how to let players choose what path they were going to take, how to display this path choice, how to track a player's progress in the game so their actions would have consequences... and so on. I solved the larger "problem" of writing a choose-your-own-adventure story by solving all these smaller problems with procedures I then combined.

When you divide a computer program into separate sub-programs, it's known as modularity.

Procedures can also help you simplify your code and improve its readability.

Instead of this:

first_number = 7
second_number = 5
sum_value = first_number + second_number
print (sum_value)

first_number = 8
second_number = 2
sum_value = first_number + second_number
print (sum_value)

first_number = 9
second_number = 3
sum_value = first_number + second_number
print (sum_value)

you get this:

def summing_machine(first_number, second_number):
  sum_value = first_number + second_number
  print (sum_value)

summing_machine(5, 7)
summing_machine(8, 2)
summing_machine(9, 3)

Isn't the second example a lot easier to understand? This is especially important in larger programs, where you might already be looking at hundreds of lines of code.

The beauty of procedures is how they can be reused. Parameters usually represent general categories of data, such as numbers or strings. This means you could use one procedure for a wide range of individual scenarios.

Remember that placing a inside a procedure will cause an immediate return from the procedure back to where the procedure is called. The may appear at any point inside the procedure.

also allows programmers the flexibility to modify or fix procedures without affecting the whole program, as long as the procedure continues to function in the same way. Furthermore, they can make a change or edit once, in the procedure, and it will be implemented everywhere the procedure is called.

Key Terms to Review (2)

Procedural Abstraction

: Procedural abstraction refers to breaking down complex tasks into smaller, more manageable procedures or functions. It helps in organizing code and making it easier to understand and maintain.

Return Statement

: A return statement is used in a function to specify the value that should be returned when the function is called. It allows the function to send a value back to the code that called it.

3.13 Developing Procedures

2 min readjanuary 3, 2023

Minna Chow

Minna Chow

Milo Chang

Milo Chang

Minna Chow

Minna Chow

Milo Chang

Milo Chang

Procedural Abstraction

Procedures are an example of abstraction. (In fact, it's part a special form of abstraction known as .) This is because you can call a procedure without knowing how it works. Indeed, you often do: a common built-in procedure in programming languages is the print() procedure.

Procedures allow you to solve a large problem based on the solution to smaller sub-problems. For example, my final Create project was a choose-your-own-adventure story. In order to make this story, I had to figure out how to let players choose what path they were going to take, how to display this path choice, how to track a player's progress in the game so their actions would have consequences... and so on. I solved the larger "problem" of writing a choose-your-own-adventure story by solving all these smaller problems with procedures I then combined.

When you divide a computer program into separate sub-programs, it's known as modularity.

Procedures can also help you simplify your code and improve its readability.

Instead of this:

first_number = 7
second_number = 5
sum_value = first_number + second_number
print (sum_value)

first_number = 8
second_number = 2
sum_value = first_number + second_number
print (sum_value)

first_number = 9
second_number = 3
sum_value = first_number + second_number
print (sum_value)

you get this:

def summing_machine(first_number, second_number):
  sum_value = first_number + second_number
  print (sum_value)

summing_machine(5, 7)
summing_machine(8, 2)
summing_machine(9, 3)

Isn't the second example a lot easier to understand? This is especially important in larger programs, where you might already be looking at hundreds of lines of code.

The beauty of procedures is how they can be reused. Parameters usually represent general categories of data, such as numbers or strings. This means you could use one procedure for a wide range of individual scenarios.

Remember that placing a inside a procedure will cause an immediate return from the procedure back to where the procedure is called. The may appear at any point inside the procedure.

also allows programmers the flexibility to modify or fix procedures without affecting the whole program, as long as the procedure continues to function in the same way. Furthermore, they can make a change or edit once, in the procedure, and it will be implemented everywhere the procedure is called.

Key Terms to Review (2)

Procedural Abstraction

: Procedural abstraction refers to breaking down complex tasks into smaller, more manageable procedures or functions. It helps in organizing code and making it easier to understand and maintain.

Return Statement

: A return statement is used in a function to specify the value that should be returned when the function is called. It allows the function to send a value back to the code that called it.


© 2024 Fiveable Inc. All rights reserved.

AP® and SAT® are trademarks registered by the College Board, which is not affiliated with, and does not endorse this website.


© 2024 Fiveable Inc. All rights reserved.

AP® and SAT® are trademarks registered by the College Board, which is not affiliated with, and does not endorse this website.