Follow the flow chart with Boolean expressions.

Helenjoy
4 min readMay 30, 2023

--

When you write a program, it’s not just about following instructions one after another like a to-do list. Programming allows you to make decisions based on certain conditions and control the flow of instructions. This means you can choose to skip or repeat certain instructions, or even pick different instructions to run.

Imagine if you had a program that tells you what to do when it’s raining. Instead of going through every line of code from start to finish, the program can decide what actions to take based on whether it’s raining or not. To understand how this works, we can use a flowchart, which is like a diagram that shows the different paths the program can take. In the flowchart, you’ll see symbols and arrows that guide you through the program’s logic.

flow chart for ‘will it rain or not?

So, by using flow control statements in programming, you have the power to determine which instructions to execute and when, depending on specific conditions. It gives your program flexibility and makes it more powerful.

In a flowchart, there are often multiple paths that can lead from the start to the end. The same concept applies to lines of code in a computer program. In flowcharts, these branching points are represented by diamonds, while the other steps are represented by rectangles. The starting and ending steps are represented by rounded rectangles.

Before diving into flow control statements, it’s important to understand how to represent choices with “yes” and “no” options. Additionally, you need to grasp how to write these branching points in Python code. To achieve that, let’s explore Boolean values, comparison operators, and Boolean operators.

Boolean values are like switches that can be either “true” or “false.” They represent the outcome of a comparison or a logical operation. Comparison operators, such as “greater than” (>), “less than” (<), “equal to” (==), and others, allow you to compare values and produce Boolean results.

Boolean operators, such as “and,” “or,” and “not,” help you combine and manipulate Boolean values. With these operators, you can evaluate multiple conditions and make decisions based on their outcomes.

By understanding Boolean values, comparison operators, and Boolean operators, you’ll be equipped to represent choices and create branching points in your Python code.

While the integer, floating-point, and string data types have an unlimited number of possible values, the Boolean data type has only two values: True and False. (Boolean is capitalized because the data type is named after mathematician George Boole.) When entered as Python code, the Boolean values True and False lack the quotes you place around strings, and they always start with a capital T or F, with the rest of the word in lowercase.

Boolean values are commonly used in expressions and can also be stored in variables. However, it’s important to note that the proper case must be used when working with Boolean values. In Python, the correct case is using “True” and “False” (with the first letter capitalized) to represent the Boolean values.

If you mistakenly use the wrong case, such as “true” or “false,” Python will consider them as variable names rather than Boolean values. Similarly, if you try to use “True” or “False” as variable names themselves, Python will generate an error message because these are reserved keywords for Boolean values.

To avoid such errors, make sure to use the correct case when working with Boolean values (i.e., “True” and “False”), and avoid using these reserved keywords as variable names.

Comparison Operators

comparison operators, also called relational operators, compare two values and evaluate down to a single Boolean value

== (equal to) evaluates to True when the values on both sides are the same, and != (not equal to) evaluates to True when the two values are different. The == and != operators can actually work with values of any data type.

Note :

THE DIFFERENCE BET WEEN THE == AND = OPER ATORS

You might have noticed that the == operator (equal to) has two equal signs, while the = operator (assignment) has just one equal sign. It’s easy to confuse these two operators with each other. Just remember these points:

• The == operator (equal to) asks whether two values are the same as each other.

• The = operator (assignment) puts the value on the right into the variable on the left.

To help remember which is which, notice that the == operator (equal to) consists of two characters, just like the != operator (not equal to) consists of two characters

--

--

Helenjoy

Research aspirant in deep learning based video compression