Qu'est-ce que LessonUp
Rechercher
Canaux
Connectez-vous
S'inscrire
‹
Revenir à la recherche
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
suivant
Slide 1:
Diapositive
Programming
Higher Education (degree)
Cette leçon contient
21 diapositives
, avec
diapositives de texte
.
Commencer la leçon
Partager
Imprimer la leçon
Éléments de cette leçon
Welcome
Procedural Programming and Control Structures in Python
Week 2
Module Lecturer: Dr Raghav Kovvuri
Email: raghav.kovvuri@ieg.ac.uk
Slide 1 - Diapositive
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 - Diapositive
Example: Flow Chart
Slide 3 - Diapositive
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 - Diapositive
Example: Pseudocode
Slide 5 - Diapositive
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 - Diapositive
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 - Diapositive
Python Functions
Basics and Parameters
Defining Functions:
Slide 8 - Diapositive
Function Parameters
Positional arguments:
Order matters
Keyword arguments:
Order doesn't matters
Default parameters:
Slide 9 - Diapositive
Return Values
Single return value:
Multiple return value:
Slide 10 - Diapositive
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 - Diapositive
Lifetime of Variables (2)
The
global
keyword: Used to modify global variables within a function
Slide 12 - Diapositive
Control Structures
Conditional Statements
If Statements:
If-Else Statements:
Slide 13 - Diapositive
Conditional Statements (2)
Nested If Statements
If-Elif-Else Statements
Slide 14 - Diapositive
Conditional Statements(3)
Ternary Operator:
Slide 15 - Diapositive
Control Structures
Loops (1)
'For'
Loop:
Iterating over a range:
Iterating over a list:
Slide 16 - Diapositive
Loops (2)
'While'
Loop
Nested Loops
Slide 17 - Diapositive
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 - Diapositive
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 - Diapositive
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 - Diapositive
Slide 21 - Diapositive
Plus de leçons comme celle-ci
Revision
Mai 2024
- Leçon avec
37 diapositives
Computer Science
Secondary Education
Y8 Python
Juin 2022
- Leçon avec
38 diapositives
Computing
Lower Secondary (Key Stage 3)
01_9B1_Introduction_Minecraft
Septembre 2022
- Leçon avec
12 diapositives
Computing
Lower Secondary (Key Stage 3)
Introduction to PHP: Building the Basics
Juillet 2024
- Leçon avec
16 diapositives
Lesson 4
Mai 2023
- Leçon avec
17 diapositives
Code.org SCITT Lesson 1
Octobre 2022
- Leçon avec
17 diapositives
Computing
Lower Secondary (Key Stage 3)
Introduction to Programming Constructs: Creating a Computer Game with Python
Août 2024
- Leçon avec
23 diapositives
Mathematics
Further Education (Key Stage 5)
Y8 Python - Low Ability - If Elif JM
Juin 2023
- Leçon avec
40 diapositives
Computing
Lower Secondary (Key Stage 3)