Chapter 2
Chapter 2
programming?
P R O G R A M M I N G PA R A D I G M C O N C E P T S
Eleanor Thomas
Senior Data Analytics Engineer
What is procedural programming?
Procedural programming: an imperative programming paradigm in which programs are
built using procedures
Procedure (subroutine): a series of steps that can be referenced and rerun multiple times
print_initial("Marwa")
print_initial("Celia")
print_initial("Raqael")
Output:
"M"
"C"
"R"
Eleanor Thomas
Senior Data Analytics Engineer
Typical applications for procedural programming
Commonly used in general-purpose programming languages
Makes sense when problems naturally break down into steps
Any kind of coding task where the problem can be defined step-by-step and broken up into
subtasks
discount = 0.20
final_price = price_in_dollars * (1 - discount)
print("The final price is: $", final_price)
Convert to dollars
Apply a discount
Benefits modularity, reducing overall Can be less secure than other paradigms
amount of code and saving time due to how data is moved around
Eleanor Thomas
Senior Data Analytics Engineer
What is control flow?
Control flow: set of keywords and processes within a programming language that indicate
how the logic of the code should be stepped through
Combined:
my_height = 63
height_list = [62, 67, 70]
compare_heights(my_height, height_list)
Code this logic in Python with if statements, loops, and Python functions