VJC Chapter 3 Control flow
Uploaded by cheesemuffin · 10 December 2025
Preview
VJC/H2Computing/9569 Chapter 3: Control Flow Contents 1 What is control flow? 1.1 Algorithm 1.2 Pseudo code 1.3 Flow chart 2 Control flow statements 2.1 If 2.1.1 Short hand if 2.1.2 Short hand if-else 2.1.3 Evaluating non-zero numerical values 2.1.4 Evaluating non-empty strings 2.1.5 Built-in bool() method 2.2 While 2.3 For 2.3.1 The range() function 2.3.2 Iterating by Sequence Index 2.4 Break, continue and pass 2.4.1 Break 2.4.2 Continue 2.4.3 Pass 3 Decision table Syllabus Learning Outcomes 1.1 Algorithmic Representation Write algorithms in pseudo-code and flowchart for given problems. 1.1.1 Use appropriate techniques or tools such as pseudo-code and flowchart to show program flow. 1.1.2 Use standard flowchart symbols. 1.1.3 Use a combination of various control structures. 1.1.4 Use decision tables to explore the actions for combinations of different input conditions. Note: up to three conditions 2.2 Programming Elements and Constructs Use programming language elements and constructs to write recursive and non-recursive programs to solve a variety of problems. 2.2.3 Apply the fundamental programming constructs to control the flow of program execution: – Sequence – Selection – Iteration 1
VJC/H2Computing/9569 1 What is control flow? In the examples that we have seen till now, there has always been a series of statements faithfully executed by Python in exact top-down order. What if you wanted to change the flow of how it works? For example, you want the program to take some decisions and do different things depending on different situations, such as printing 'Good Morning' or 'Good Evening' depending on the time of the day? As you might have guessed, this is achieved using control flow statements. There are three control flow statements in Python - if, for and while. 1.1 Algorithm An algorithm is a step-by-step procedure (well-defined instructions) to solve a given problem. For instance, the algorithm to find the sum of two numbers is 1. Take two numbers 2. Add the numbers 3. Display the result Or the algorithm to log in to VJC portal 1. Go to https://portal.vjc.sg/ 2. Enter vjc email and password 3. Click on Sign in button 4. Enter OTP 5. Click on Submit button Sometimes there might be different steps depending on some other conditions. For example, if the day is a weekday, you will wake up at 6:00 am, else you will wake up at 10:00 am. Many problems have more than one solution. Sometimes it is a personal preference
Content continues in the PDF.
Related notes
- VJC Chapter 21 SQLite with PythonNotes/Practices · 2025
- VJC Chapter 23 Web Applications PrinciplesNotes/Practices · 2025
- VJC Chapter 10 RecursionNotes/Practices · 2025
- VJC Chapter 20 SQLNotes/Practices · 2025
- VJC Chapter 16 Hash TableNotes/Practices · 2025
- VJC Chapter 22 NoSQLNotes/Practices · 2025

