McMullen ProgwPython 1e Mod27 PowerPoint
McMullen ProgwPython 1e Mod27 PowerPoint
McMullen/Matthews/Parsons, Programming with Python, 1st Edition. © 2023 Cengage. All Rights Reserved.
May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
Module Objectives (1 of 3)
McMullen/Matthews/Parsons, Programming with Python, 1st Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
Module Objectives (2 of 3)
McMullen/Matthews/Parsons, Programming with Python, 1st Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
Module Objectives (3 of 3)
McMullen/Matthews/Parsons, Programming with Python, 1st Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
27.1 Imperative and Declarative Paradigms
McMullen/Matthews/Parsons, Programming with Python, 1st Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
27.2 The Procedural Paradigm (1 of 7)
• Procedural basics
• Procedural paradigm: the traditional approach to programming, which helps you
visualize a program as a step-by-step algorithm
• A procedural program typically consists of instructions that indicate how a computer
should perform a task or solve a problem
• Characteristics of procedural programs
• Order
• Use of variables
• Use of selection control structures
• Use of repetition control structures
• Top-down decomposition
McMullen/Matthews/Parsons, Programming with Python, 1st Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
27.2 The Procedural Paradigm (2 of 7)
McMullen/Matthews/Parsons, Programming with Python, 1st Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
27.2 The Procedural Paradigm (3 of 7)
McMullen/Matthews/Parsons, Programming with Python, 1st Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
27.2 The Procedural Paradigm (4 of 7)
McMullen/Matthews/Parsons, Programming with Python, 1st Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
27.2 The Procedural Paradigm (5 of 7)
McMullen/Matthews/Parsons, Programming with Python, 1st Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
27.2 The Procedural Paradigm (6 of 7)
McMullen/Matthews/Parsons, Programming with Python, 1st Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
27.2 The Procedural Paradigm (7 of 7)
McMullen/Matthews/Parsons, Programming with Python, 1st Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
Activity 27.1: Knowledge Check (1 of 2)
2. The _____ programming category includes approaches that focus on describing the
problem or task.
McMullen/Matthews/Parsons, Programming with Python, 1st Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
Activity 27.1: Knowledge Check (2 of 2)
3. The _____, considered the traditional approach to programming, helps you visualize a
program as a step-by-step algorithm.
4. The division of complex programming tasks into smaller tasks, which can be coded as
linked programs or abstracted into segments of code called subroutines, procedures, or
functions, is known as _____.
McMullen/Matthews/Parsons, Programming with Python, 1st Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
Activity 27.1: Knowledge Check Answers (1 of 2)
2. The _____ programming category includes approaches that focus on describing the
problem or task.
Answer: declarative
McMullen/Matthews/Parsons, Programming with Python, 1st Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
Activity 27.1: Knowledge Check Answers (2 of 2)
3. The _____, considered the traditional approach to programming, helps you visualize a
program as a step-by-step algorithm.
4. The division of complex programming tasks into smaller tasks, which can be coded as
linked programs or abstracted into segments of code called subroutines, procedures, or
functions, is known as _____.
Answer: decomposition
McMullen/Matthews/Parsons, Programming with Python, 1st Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
27.3 The Object-Oriented Paradigm (1 of 4)
McMullen/Matthews/Parsons, Programming with Python, 1st Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
27.3 The Object-Oriented Paradigm (2 of 4)
McMullen/Matthews/Parsons, Programming with Python, 1st Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
27.3 The Object-Oriented Paradigm (3 of 4)
McMullen/Matthews/Parsons, Programming with Python, 1st Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
27.3 The Object-Oriented Paradigm (4 of 4)
McMullen/Matthews/Parsons, Programming with Python, 1st Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
27.4 Declarative Paradigms (1 of 6)
• Declarative basics
• Declarative paradigms approach programming by describing what a program is
supposed to accomplish rather than the steps required to accomplish a task
• Example: logic programming
• Three types of statements: facts that form a database, rules that define the logic, and
queries that trigger processing
• Predicate expression: an expression that specifies a relationship to provide
information in a logic programming fact
• Queries are used to access facts and the results of rules
• Rules are used to perform calculations, display data, etc.
• The sequence of instructions in the code is not important
• Programming languages that support declarative programing handle flow control
internally
McMullen/Matthews/Parsons, Programming with Python, 1st Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
27.4 Declarative Paradigms (2 of 6)
McMullen/Matthews/Parsons, Programming with Python, 1st Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
27.4 Declarative Paradigms (3 of 6)
McMullen/Matthews/Parsons, Programming with Python, 1st Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
27.4 Declarative Paradigms (4 of 6)
McMullen/Matthews/Parsons, Programming with Python, 1st Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
Activity 27.2: Breakout Groups:
A Problem Three Ways
1. Form pairs or small groups.
2. Search online to find a coding problem/challenge that interests you.
3. In writing, outline how a procedural program, an object-oriented program, and a logic
program would each handle this task. Be sure to identify key elements of the program for
each paradigm and, optionally, include sample code or pseudocode.
4. Now, compare the three approaches.
• How are they alike and different?
• Does one paradigm seem more suited to the task than the others?
McMullen/Matthews/Parsons, Programming with Python, 1st Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
27.4 Declarative Paradigms (5 of 6)
McMullen/Matthews/Parsons, Programming with Python, 1st Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
27.4 Declarative Paradigms (6 of 6)
McMullen/Matthews/Parsons, Programming with Python, 1st Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
Activity 27.3: Knowledge Check (1 of 2)
2. Classes are black boxes that _____ data attributes and methods.
McMullen/Matthews/Parsons, Programming with Python, 1st Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
Activity 27.3: Knowledge Check (2 of 2)
3. In logic programming, a fact supplies basic information in the form of a(n) _____.
McMullen/Matthews/Parsons, Programming with Python, 1st Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
Activity 27.3: Knowledge Check Answers (1 of 2)
2. Classes are black boxes that _____ data attributes and methods.
Answer: encapsulate
McMullen/Matthews/Parsons, Programming with Python, 1st Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
Activity 27.3: Knowledge Check Answers (2 of 2)
3. In logic programming, a fact supplies basic information in the form of a(n) _____.
Answer: Functional
McMullen/Matthews/Parsons, Programming with Python, 1st Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
Activity 27.4: Discussion
1. Each programming paradigm discussed in Module 27 has its advocates and its detractors.
Why would each appeal to some programmers in some situations? Support your answer
with the paradigm characteristics described in the module.
2. How might more than one programming approach be used in combination to optimize a
large software project with multiple components? What are the benefits and risks of
utilizing multiple paradigms when creating and maintaining a large project?
3. Recall what you learned in previous modules regarding machine language and assembly
language. Which programming paradigm most closely mirrors the CPU’s operations? What
are the implications of this for the other paradigms?
McMullen/Matthews/Parsons, Programming with Python, 1st Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
Activity 27.5: Breakout Groups:
Python Practice
1. Form pairs or small groups.
2. To continue sharpening your Python skills, design and write out the code for your own
short program related to travel. You could continue the theme of road trips and their costs
from the module or shift to a different form of travel or focus.
3. Test your program to ensure that it works as expected.
4. Which programming paradigm did you use?
McMullen/Matthews/Parsons, Programming with Python, 1st Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
Self-Assessment
1. Which of the three major programming paradigms discussed in Module 27 have you used
most often in writing your own programs? How do you feel about that paradigm?
2. Which of the paradigms do you think you would prefer to use as your “go to” strategy as a
professional programmer? What additional skills would you need to learn to use this
paradigm on the job?
McMullen/Matthews/Parsons, Programming with Python, 1st Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
Summary
McMullen/Matthews/Parsons, Programming with Python, 1st Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.