Wat is LessonUp
Zoeken
Kanalen
Inloggen
Registreren
‹
Terug naar zoeken
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
volgende
Slide 1:
Tekstslide
Programming
Higher Education (degree)
In deze les zitten
21 slides
, met
tekstslides
.
Start les
Bewaar
Deel
Printen
Onderdelen in deze les
Welcome
Procedural Programming and Control Structures in Python
Week 2
Module Lecturer: Dr Raghav Kovvuri
Email: raghav.kovvuri@ieg.ac.uk
Slide 1 - Tekstslide
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 - Tekstslide
Example: Flow Chart
Slide 3 - Tekstslide
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 - Tekstslide
Example: Pseudocode
Slide 5 - Tekstslide
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 - Tekstslide
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 - Tekstslide
Python Functions
Basics and Parameters
Defining Functions:
Slide 8 - Tekstslide
Function Parameters
Positional arguments:
Order matters
Keyword arguments:
Order doesn't matters
Default parameters:
Slide 9 - Tekstslide
Return Values
Single return value:
Multiple return value:
Slide 10 - Tekstslide
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 - Tekstslide
Lifetime of Variables (2)
The
global
keyword: Used to modify global variables within a function
Slide 12 - Tekstslide
Control Structures
Conditional Statements
If Statements:
If-Else Statements:
Slide 13 - Tekstslide
Conditional Statements (2)
Nested If Statements
If-Elif-Else Statements
Slide 14 - Tekstslide
Conditional Statements(3)
Ternary Operator:
Slide 15 - Tekstslide
Control Structures
Loops (1)
'For'
Loop:
Iterating over a range:
Iterating over a list:
Slide 16 - Tekstslide
Loops (2)
'While'
Loop
Nested Loops
Slide 17 - Tekstslide
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 - Tekstslide
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 - Tekstslide
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 - Tekstslide
Slide 21 - Tekstslide
Meer lessen zoals deze
Revision
Mei 2024
- Les met
37 slides
Computer Science
Secondary Education
Y8 Python
Juni 2022
- Les met
38 slides
Computing
Lower Secondary (Key Stage 3)
Lesson 4
Mei 2023
- Les met
17 slides
01_9B1_Introduction_Minecraft
September 2022
- Les met
12 slides
Computing
Lower Secondary (Key Stage 3)
Code.org SCITT Lesson 1
Oktober 2022
- Les met
17 slides
Computing
Lower Secondary (Key Stage 3)
Introduction to Programming Constructs: Creating a Computer Game with Python
Augustus 2024
- Les met
23 slides
Mathematics
Further Education (Key Stage 5)
Introduction to PHP: Building the Basics
Juli 2024
- Les met
16 slides
Y8 Python - Low Ability - If Elif JM
Juni 2023
- Les met
40 slides
Computing
Lower Secondary (Key Stage 3)