Categories
Python Programming

Relational Operators

Relational operators check the relationship between two operands. They return true if the comparison or relation is true otherwise it will return false.

There are six comparison operators in the Python programming language. They are:

  1. Equal To
  2. Not Equal To
  3. Greater Than
  4. Less Than
  5. Greater Than or Equal To
  6. Less Than or Equal To

Equal To (==)

The equal to operator is represented by the double equal sign (==) in the Python programming language. The single equal sign (=) is used for assignment in the Python programming language.

The equal to symbol checks if two operands are equal.

Not Equal To (!=)

This is the opposite of the equal to symbol. It checks if the two operands are not equal.

Greater Than (>)

This checks if the left operand is greater than the right operand.

Less Than (<)

The less than operator is the opposite of the greater than operator. It checks if the operand on the left is less than the operand on the right.

Greater Than or Equal To (>=)

Checks if the left hand operand is either greater or equal to the right hand operand.

Less Than or Equal To (<=)

Checks if the left hand operand is either less or equal to the right hand operand.

Relational operators allow the programmer to define conditions in their code based on the relationship between two variables.

Categories
Blockchain Technology

Back to the Stone Age

Every single time you are filled with techno-optimism in Nigeria, there comes a government policy to put a lid on it.

In Nigeria, the prevailing rule is that whatever they cannot own or control, the government will seek to destroy.

Today, the government through the CBN struck another area of the economy by banning the purchase of cryptocurrencies using the banks.

To be honest, it was inevitable as cryptocurrencies where used in funding the EndSARS protests that held in the country last year.

This might slow down adoption of cryptocurrencies but it will not end them. They alternative is to go peer to peer the way it was always intended for cryptocurrencies.

Categories
Python Programming

IF Statements

IF statements are branching statements used for conditional execution of a program in the Python programming language.

IF statements execute when a programmer defined condition is true. The condition allows the IF statement to be used for decision making.

Decision making is required when we want to execute a piece of code if certain conditions are met.

IF Statement

IF Statement Flowchart

The standalone IF statement checks is a condition is true and executes the statements under it.

Standalone IF Statement

The above standalone IF statement makes no provision for when the condition is false.

IF statements can also be placed one after the other to execute in sequence as shown below:

Combined IF Statements

ELIF Statement

ELIF Statement Flowchart

ELIF allows you to chain multiple expressions for True and execute a block of code as soon as one of the conditions evaluates to true.

It is the equivalent of chaining IF statements in sequence. An example of this is show below:

Compound IF Statements

Note that the first IF statement is the IF statement that you are used to. The ELIF statements follows it.

ELSE Statement

ELSE Statement Flowchart

ELSE statements go with the IF statement. They are used for when the conditions that we are testing for fails.

The can be used with the standalone IF statement as shown below:

ELSE Statement

The ELSE statement can also be used with the compound IF statements as shown below:

Compound ELSE Statement

In the above program, we would only get to the ELSE block when the other conditions fail.

Categories
Python Programming

Branching

The default mode of execution of a program is from top to bottom. However in the course of the execution of a program, the Python interpreter comes across some statements that change the default mode of execution.

Such statements are called a branch. A branch is an instruction in a computer program that causes a computer to begin executing a different instruction sequence and thus deviate from its default behaviour of executing instructions in order.

Branching is implemented as a series of control statements in high level programming languages. In the Python programming language, these include:

  • IF Statement
  • WHILE Loop
  • FOR Loop

IF Statement

IF Statement
If-Then-Else flow diagram

The IF Statement works by evaluating a programmer specified boolean condition and checking if it evaluates to true or false.

If the condition evaluates to true, certain actions are carried out. An evaluation to false means that alternate actions are carried out.

WHILE Loop

While loop flow diagram

A loop ensures that code is repeated. However in programming when you want ensure that you loop an infinite number of times, you use a WHILE loop.

The WHILE loop consists of a block of code and a condition/expression. The condition/expression is evaluated, and if the condition/expression is true, the code within all of their following in the block is executed. This repeats until the condition/expression becomes false.

In the Python programming language, the WHILE loop has an ELSE branch just like the IF statement.

FOR Loop

For loop flow diagram

When you want to loop a fixed number of times in the Python programming language, you use a FOR loop.

A FOR loop has two parts: a header specifying the iteration, and a body which is executed once per iteration. The header often declares an explicit loop counter or loop variable, which allows the body to know which iteration is being executed. FOR loops are typically used when the number of iterations is known before entering the loop.

Conclusion

Branching statements allow the flow of execution to jump to a different part of the program.

Mastering them is important in the journey of learning how to program.

Categories
Uncategorized

Twitter Pulse Week 2

Welcome to a new week. The above graph shows the interest in the Canadian Permanent Residence among Nigerians. Take note of the regions where there are spikes in the graph.

The Goodbye Nigeria post led to Nigerians doing the #snowpose on Twitter. Nigerians from countries with winter took pictures of themselves in the snow.

Elegushi Beach

COVID-19 is in Lagos. Disregarding all warnings by the government, Lagosians stormed the beach on the first Sunday of the year. You can view the picture below:

Elegushi Beach

Such as situation is the ideal environment for the Coronavirus to be spread and some of the beach goers have now tested positive.

Elegushi Beach Aftermath

Panti After Party

The government with view to curbing the spread of the dreaded Coronavirus has placed an embargo on clubs, bars and restaurants.

Sadly, Lagosians didn’t heed the warnings and some of them were caught by the Lagos State Taskforce.

Party Goers
Panti After Party

FG to Borrow Dormant Account Balance

Dormant Accounts

As part of measures to shore up the national purse, the Federal Government has started borrowing from dormant accounts.

DNA Testing

After the FCMB Scandal, Twitter NG was buzzing with reasons why men should do DNA Testing.

Most heart-wrenching is the story below:

Family Feud I
Family Feud II
Family Feud III

Code of Conduct

How bad the level of poverty in Nigeria is can be felt by the code of conduct of a supermarket in Port-harcourt.

You can read this below:

Code of Conduct 1
Code of Conduct 2
Code of Conduct 3

As you can see for yourself, this isn’t a code of conduct, it is the terms of slavery.