What is LessonUp
Search
Channels
Log in
Register
‹
Return to search
WK2: Procedural Programming and Control Structures in Python (Session 1)
Welcome
Procedural Programming and Control Structures in Python
Week 2
Module Lecturer: Dr Raghav Kovvuri
Email: raghav.kovvuri@ieg.ac.uk
1 / 21
next
Slide 1:
Slide
Programming
Higher Education (degree)
This lesson contains
21 slides
, with
text slides
.
Start lesson
Save
Share
Print lesson
Items in this lesson
Welcome
Procedural Programming and Control Structures in Python
Week 2
Module Lecturer: Dr Raghav Kovvuri
Email: raghav.kovvuri@ieg.ac.uk
Slide 1 - Slide
Retrospect: Flowcharts
A flowchart is a graphical representation of an algorithm or process
Key components:
Oval: Start/End
Rectangle: Process/Action
Diamond: Decision
Parallelogram: Input/Output
Arrows: Flow direction
Benefits:
Visual clarity of process flow
Easy to understand and communicate
Helpful in identifying bottlenecks
Slide 2 - Slide
Example: Flow Chart
Slide 3 - Slide
Retrospect: Pseudocode Pseudocode
Pseudocode is a informal, high-level description of an algorithm
Key Components
Input/Output statements
Assignment operations
Conditional statements (IF-THEN-ELSE)
Loops (WHILE, FOR)
Function calls
Characteristics
Written in a mixture of natural language and simple programming constructs
Not tied to any specific programming language
Focuses on logic rather than syntax
Slide 4 - Slide
Example: Pseudocode
Slide 5 - Slide
Procedural Programming (1)
Definition:
Programming paradigm based on the concept of procedure calls
Key Characteristics:
Sequence:
Instructions executed in order
Selection:
Decision making (if-else statements)
Iteration:
Repetition of a process (loops)
Modularity:
Breaking code into reusable procedures or functions
Slide 6 - Slide
Comparison with Other Paradigms:
Object-Oriented: Focuses on objects that contain data and code
Functional: Emphasizes the application of functions to solve problems
Procedural Programming (2)
Advantages:
Simplicity and ease of implementation
Code reusability through functions
Straightforward flow of control
Slide 7 - Slide
Python Functions
Basics and Parameters
Defining Functions:
Slide 8 - Slide
Function Parameters
Positional arguments:
Order matters
Keyword arguments:
Order doesn't matters
Default parameters:
Slide 9 - Slide
Return Values
Single return value:
Multiple return value:
Slide 10 - Slide
Scope and Lifetime of Variables (1)
Local variables:
Defined inside a function, only accessible within that function
Global variables:
Defined outside functions, accessible throughout the program
Slide 11 - Slide
Lifetime of Variables (2)
The
global
keyword: Used to modify global variables within a function
Slide 12 - Slide
Control Structures
Conditional Statements
If Statements:
If-Else Statements:
Slide 13 - Slide
Conditional Statements (2)
Nested If Statements
If-Elif-Else Statements
Slide 14 - Slide
Conditional Statements(3)
Ternary Operator:
Slide 15 - Slide
Control Structures
Loops (1)
'For'
Loop:
Iterating over a range:
Iterating over a list:
Slide 16 - Slide
Loops (2)
'While'
Loop
Nested Loops
Slide 17 - Slide
Loops (3)
Loop Control Statements:
break:
Exit the loop prematurely
continue:
Skip the rest of the current iteration
else clause in loops:
Executed when loop completes normally
Slide 18 - Slide
Practical Exercise
Simple Calculator
Task:
Create a simple calculator that can perform basic arithmetic operations.
Download Simple Calculator.py from Canvas and comment and run the code accordingly
Slide 19 - Slide
Key Takeaways
Procedural Programming Fundamentals:
Sequence, Selection, Iteration
Modularity through functions
Python Implementation:
Functions: Definition, parameters, return values, scope
Control Structures: Conditional statements, loops
Importance of Algorithms:
Flowcharts and pseudocode for planning
Translating algorithms into code
Slide 20 - Slide
Slide 21 - Slide
More lessons like this
Revision
May 2024
- Lesson with
37 slides
Computer Science
Secondary Education
Y8 Python
June 2022
- Lesson with
38 slides
Computing
Lower Secondary (Key Stage 3)
01_9B1_Introduction_Minecraft
September 2022
- Lesson with
12 slides
Computing
Lower Secondary (Key Stage 3)
Introduction to PHP: Building the Basics
July 2024
- Lesson with
16 slides
Lesson 4
May 2023
- Lesson with
17 slides
Code.org SCITT Lesson 1
October 2022
- Lesson with
17 slides
Computing
Lower Secondary (Key Stage 3)
Introduction to Programming Constructs: Creating a Computer Game with Python
August 2024
- Lesson with
23 slides
Mathematics
Further Education (Key Stage 5)
Y8 Python - Low Ability - If Elif JM
June 2023
- Lesson with
40 slides
Computing
Lower Secondary (Key Stage 3)