Categories
Python Programming

Programming Languages

Computer programming languages allow us to give instructions to a computer in a language the computer understands.

The diagram above shows how programming languages hide details from the user.

At the base of the diagram, we have the computer hardware.

The hardware refers to the part of the computer that we can see and touch.

To control a computer, we need to use a machine language. Each computer has it’s own machine language and programmers found it hectic to have to learn because it was in binary.

As time when on, the Assembly Language was developed. Assembly Language provided a symbolic representation of the machine code needed to program a given CPU architecture.

The real breakthrough in computer programming would start with the arrival of high level languages.

High level languages were closer to English and in addition to making the task of computer programming easier, they also opened the field to a lot more people.

The top four from that period in computing history are C, BASIC, FORTRAN and COBOL.

Applications running this languages are still in use today.

We will be learning the Python programming language.

According to the TIOBE Index as at January 2020, the Python programming language is the 3rd most popular programming language in the world.

Each language has it’s strength and weakness but for absolute beginners, I will give my reasons why recommend learning the Python programming language first.

Simplicity

When you are starting out on the journey of learning to code, you don’t want to deal with problems that occur while setting up your computer.

While learning Java at the University, one of the biggest issues we would run into was the setting of classpath.

The issue of classpath would stop many beginners dead in their tracks.

In Python, once you have installed the interpreter, you are ready to start programming.

In addition, the language is simple and readable. The commands in the language look like English.

Versatility

Python is a general purpose language that caters to every use case that you can imagine.

It might not beat a specialized language in its domain but it will allow you get started in any domain.

Large Community

The true secret weapon of the Python programming language is the community.

The versatility of the Python programming language is due to the libraries developed by the community.

Conclusion

As technology become more integrated with everyday life, learning how to program will become important in being a member of the society.

For absolute beginners, the Python programming language is great for starting because it is simple and easy to use.

Learn Python in One Week

If you want a quick and easy introduction to the Python programming language, you should check out my fifth book: Learn Python in One Week on the Amazon store.

Categories
State of the Nation

Turn by Turn Nigeria Ltd

“There are no privileges without duties, no authority without responsibilities, and no responsibilities without burdens”.

Quote by IM

This fact seems to be lost on the President of Nigeria as he would travel out of the country in the same week where the National Grid collapsed.

Joshua Meets Buhari in London

World Heavyweight Champion Anthony Joshua would betray the teeming youth population that were his supporters by seeing the President in London.

Being Yoruba, he went ahead to prostrate for the President betraying his fellow youths in Nigeria.

Next time he fights, don’t expect me to support him.

You can read more about the sorry event here.

Boko Haram Executes another batch of Christian Youths

I am tired of writing about Boko Haram.

Sadly after 10 years of this problem, we have reached a point of apathy.

Now we are no longer saddened by the deaths. If we still care, we simple ask: How many died?

You can read about this story here.

Tarkwa Bay Eviction

It would be the turn of the people of Tarkwa Bay to lose their land to the Government.

The logic behind this move leaves a bitter taste in the mouth.

With the allure of ocean front property, it was just a matter of time before the Government took this route.

Sadly, beyond land grabbing, there is no development plan for the ocean front in Lagos.

The water is polluted and smells of shit.

Berlin Conference 2020

Berlin Conference 1.0

Last week, Berlin Conference 2.0 held.

Like the last one, African nations were also missing from a discussion that would affect the security and economy of their respective nations.

Africans were not privy to the discussions of this one.

I believe that the Libyan cake was shared generously.

Berlin Conference 2.0

This conference proves that Africans are really good at championing causes that have no impact on their future.

Ansaru Militant Group is Back

After a brief hiatus, the Ansaru Militant made a comeback.

Seriously, in a nation where terrorists can be rehabilitated and integrated into the army, why miss out on the fun.

What Are the Top 4 Mobile Money Purchases by African Youth?

It is one thing for your government not to have a plan for you.

It is another for you not to have a plan for yourself.

This report shows the top spending by Africans on mobile money platforms.

It was no surprise that gambling was high on the list.

Top 4 Mobile Money Purchases by African Youth

With the focus on getting rich quick rather than value creation, it is safe to say that Africa doesn’t have a future.

Why do you need to plan when there is a foreign organisation to take care of you.

It’s not like we even own our continent.

Foreign Military Presence in Africa

Market Fire

Proving that we learn nothing from the past, we had another market fire last week.

When you live in a nation of the most prayerful people on earth, why do you need to plan for the future.

Your God will take care of you.

I have no more tears left because we will still be back year later in the year.

Peter Needs a Lifeline

If all I have said is too literal in this digest, please read something more technical.

How My Father Died

Uncle Victor Asemota talks about the death of this father in this post.

Let’s be honest with ourselves living in Nigeria is an extreme sports.

All the money in the world couldn’t make Kinect happen

The Microsoft Kinect was one of the product failures of the last decade.

This post reminds us of that moment in time and what it means to be on the cutting edge of technology.

Meet 13 Year Old Nigerian Teenager Who Makes Electronics From Plastic Scraps | Lucky Ekhator

Let’s we end on a Sad Note
Categories
Words on Marble

Let the End Come

Let the end come
There are no safe places left
Nor powers to protect the innocent
Let the end come
If that at the last is inevitable
Let the end come
And bring and end to the tyranny of hope

Categories
Make Money Online

How to Sell Stuff Online in Nigeria

One of the ways to make money online is to sell online.

The entire experience of selling online replicates the process in real life.

In real life, if I wanted to buy something, I would go to the supermarket.

Once there, I would browse the store for products that I wanted and place them in a shopping cart.

At the checkout, I would pay the cashier and collect a receipt and the goods.

To sell anything online, we have to replicate this process.

Selling Online

In order to sell online, you must replicate what happens in the real world.

The first thing we need is a storefront.

This is a place where prospective customers can browse for the items they want

Once they browse the items they want to buy, they then place them in a shopping cart.

Once they have completed the purchase, they checkout and pay for the items.

Once the transaction is completed, they get a receipt.

Depending on the nature of the goods, how they customers receive them is different.

For physical items, the customer will have to wait for delivery.

The main advantage of digital goods is that delivery is instantaneous.

Online Marketplaces

In online marketplaces, the infrastructure to handle everything from storefront to payment is done for you.

All you need to do is sign up and place your products on the online marketplace.

The main benefit of this is leverage.

You can use the reputation and infrastructure of an existing organisation to setup your own.

An example of this is Amazon. Amazon is the global retail giant allowing you to sell anything you can imagine including digital goods.

Some examples of online marketplaces that we have in Nigeria are:

  1. Baya
  2. Konga
  3. Jumia
  4. Olist
  5. OkadaBooks

Going Your Own Way

If you choose to go your own way, you are deciding to be responsible for every aspect of your own online store.

The two popular options for this are:

  1. Shopify
  2. WooCommerce

Shopify is great if you want to quickly get started. There is no need to code.

You can do everything yourself without a developer using Shopify although you must be willing to pay a monthly fee.

WooCommerce although free comes with the challenge of not being for non-developers.

Both of the above tools will allow you get started up quickly with your online stores.

My advice is that you look at the trade-off between time and money and choose carefully based on your own reality.

Conclusion

With the growth of eCommerce in Nigeria in the last decade, there is no reason for anyone not to make money online.

The tools, platforms and infrastructure to make money online are already available all that is missing is you.

Will you take the opportunity or watch from the sidelines?

Categories
Make Money Online

Internet Usage in Nigeria

Before we can talk about how to make money online, we have to first take inventory on how we are currently using the internet in Nigeria.

The featured image for this post is a barchart from Statista that shows the projected number of internet users in Nigeria.

The accuracy of the chart is shown to be acceptable as the data released by the NCC confirms this.

Top Websites in Nigeria

Alexa collates the top websites in Nigeria. Data doesn’t lie.

Google is our number one website in Nigeria which is hardly surprising as it serves as an aggregator.

After that, the websites can be categorized into the following:

  • Gambling
  • Entertainment
  • Social Media
  • Education
  • News
  • eCommerce
  • FinTech

Gambling websites are predominant in this list.

This shouldn’t come as a surprise as Nigeria is the poverty capital of the world.

Notable on this list is the eCommerce and freelancing platforms that have taken hold in Nigeria.

What Does the Future Hold?

No one knows tomorrow.

As the economy worsens and confidence in the current administration declines, Nigerians will continue to seek methods to make money online.

Conclusion

At the end of the last decade, the payments would be our greatest achievement.

This means that the infrastructure necessary to make money online now exists in the country.

Consider how you use the internet and how you can use the internet usage in Nigeria to your advantage.

Categories
Code and Tools

How to Learn a New Tool

If you work in technology, the fast pace of the industry means that you have to keep learning.

When you have to update your knowledge on a new tool, what is the “best” way to go about it.

This article will provide tips on how to learn a new tool.

Have a Strong Reason to Learn

Why do you want to learn this new tool?

Without a strong enough “Why” the “How” doesn’t matter.

You have to have an expected outcome in mind before you can consider learning something new.

Learning is an investment of time, money and effort. So careful consideration must be made like you would do for any investment.

Before investing your time, you should consider opportunity cost.

Will it be easier to just pay someone to do the job for you?

If the answer is yes, then there is no point learning how to use a new tool.

Search the Web

The web is a trove of information.

With the availability of internet access in Nigeria, you can do research on any task you want to carry out before you start.

This is important because for every task you wish to carry out, there are a plethora of alternative tools.

You may also want to check out the reviews of the alternatives before you make a final decision.

You should consider the entry point for the tool you are planning to use.

Some tools are meant for absolute beginners. Others require a higher level of knowledge to use.

Don’t frustrate yourself before you get started.

Try it Out

At this point, you have decided on the tool to help you get the work done.

If it is meant for offline usage, download and install it. From that point, try to accomplish the task you have in mind.

Online software usually requires a login. Once you do, try to see if you can do what you set out to do.

The goal here is to “Figure it Out”.

Start from Source

Always try to read through the training materials provided by the creators of the tool.

There is always a blind spot you will miss if you don’t follow this approach.

Being Nigerian, I understand why we like to “Terisi”. However, this doesn’t allow for mastery of the tools.

So go through the training provided by the creators of the tool that you are interested in.

Refer to Third Party Tutorials

Only if you have gone through the tutorials provided by the creators of the software that you are interested in should you then look for third party tutorials.

Trust me on this, it is a “rabbit hole”.

You cannot finish all the tutorials out there so make sure that you start with the creator tutorials first.

Conclusion

Tools are not a substitute for work.

Work is hard.

The choice of a good tool makes doing the work easier and quicker.

A good tool is indispensable in improving the productivity of a worker.

This article has looked at the process you should follow in selecting and learning a new tool.

If you have any suggestions, I welcome them in the comments.

Categories
Drawing Adinkra Symbols using Python

Adinkrahene

Adinkrahene is the symbol for leadership and charisma. This symbol is reportedly the inspiration for the design of the other symbols. Its simple yet abstract design, consisting of three concentric circles emphasizes the importance of ideas and abstract concepts.

In the last section, I introduced the grid. The grid will allow us create any symbol we want to because we can analyse and replicate the symbol of our choice.

We will draw a grid of 5 pixel squares on the image of the Adinkra symbol of our choice and replicate that on our grid. The squares on our grid are 10 pixels each. The goal of our program would be to create a grid that is two times the size of the original grid.

Drawing the 5 pixel squares on the Adinkrahene symbol will look as shown below:

Adinkrahene on a Grid
Adinkrahene on a Grid

Analysing the Symbol

The first circle is 8 squares away from the centre of the circle. So multiplying by 5 would give us 40 pixels.

The second circle is 13 pixels away from the centre of the circle. So multiplying by 5 would give us 65 pixels.

The third circle is 18 pixels away from the centre of the circle. So multiplying by 5 would give us 90 pixels.

The outer circle doesn’t touch the edge of the grid. It leaves a space of 1 square. The thickness of the circles are all 10 pixels.

The Plan to Draw the Symbol

To draw the Adinkahene symbol, we have to compensate for scaling up the shape to twice its size.

As a result of this, we shall increase the size of our pen to 20 pixels.

The first circle will have a radius of 80 pixels. We will move the pen to the location (0, -80) and draw a circle of 80 pixels.

The second circle will have a radius of 130 pixels. We will move the pen to the location (0, -130) and draw a circle of 130 pixels.

The third circle will have a radius of 180 pixels. We will move the pen to the location (0, -180) and draw a circle of radius 180 pixels.

Algorithm to Draw the Symbol

The algorithm to draw the Adinkrahene symbol is shown below:

  1. Lift up the pen
  2. Increase the pensize to 20 pixels
  3. Move the turtle to the position (0, -80)
  4. Place the pen down
  5. Draw a circle that is 80 pixels in radius
  6. Lift up the pen
  7. Move the turtle to the position (0, -130)
  8. Place the pen down
  9. Draw a circle that is 130 pixels in radius
  10. Lift up the pen
  11. Move the turtle to the position (0, -180)
  12. Place the pen down
  13. Draw a circle that is 180 pixels in radius

Using Turtle Graphics

We will use the template.py file and rename it to adinkrahene.py.

The first step in drawing the Adinkrahene symbol is to draw the innermost circle and work our way out.

The first task is to lift up the pen. The code to do this is shown below:

turtle.penup()

Next we will increase our pensize to 20. The code to do this is shown below:

turtle.pensize(20)

The origin of the turtle is at (0, 0). To move the turtle to the position (0, -80), we use the command shown below:

turtle.setposition(0, -80)

At this point, place the pen down and draw a circle of radius 80 pixels. The code to do this is shown below:

turtle.pendown()
turtle.circle(80)

Our Python Turtle window will look like shown below:

Inner concentric circle of Adinkrahene
Inner Concentric Circle

Steps 6 to 9 are the steps for drawing the second circle. The code is similar to what you have already seen before and is shown below:

turtle.penup()
turtle.setposition(0, -130)
turtle.pendown()
turtle.circle(130)

When we run the code, our second circle now appears as shown below:

Middle Circle of Adikrahene
Middle Concentric Circle

Steps 10 to 13 will draw the third circle. The code to do this is similar to what you have already seen before and is shown below:

turtle.penup()
turtle.setposition(0, -180)
turtle.pendown()
turtle.circle(180)

When you run the code, the image is as shown below:

Adinkrahene
Final Image

Complete Code

The code for drawing the symbol is shown below:

"""
Project Name: Drawing Adinkra Symbols using Python
Symbol Name: Adinkrahene
Developer Name: Truston Ailende
Email Address: trustonailende@gmail.com
"""
import turtle
import math

# Square
def drawSquare(length):
    turtle.penup()
    turtle.setposition(-length/2.0, length/2.0)
    turtle.pendown()
    for i in range(0, 4):
        turtle.forward(length)
        turtle.right(90)
    turtle.penup()
    turtle.home()

# Horizontal lines
def drawHorizontalLine(length, division):
    pixelSpace = int(length / division)
    half = int(length / 2)
    for j in range((-half + pixelSpace), half, pixelSpace):
        turtle.penup()
        turtle.setposition(-half, j)
        turtle.pendown()
        turtle.forward(length)
    turtle.penup()
    turtle.home()

# Vertical lines
def drawVerticalLine(length, division):
    pixelSpace = int(length / division)
    half = int(length / 2)
    turtle.right(90)
    for k in range((-half + pixelSpace), half, pixelSpace):
        turtle.penup()
        turtle.setposition(k, half)
        turtle.pendown()
        turtle.forward(length)
    turtle.penup()
    turtle.home()

# Draw the grid
drawSquare(400)
drawHorizontalLine(400, 40)
drawVerticalLine(400, 40)

# Change the colour mode
turtle.colormode(255)

# Change the pencolor to red
turtle.pencolor(255, 0, 0)

# Draw the horizontal centre line
turtle.setposition(-200, 0)
turtle.pendown()
turtle.forward(400)
turtle.penup()

# Draw the vertical centre line
turtle.setposition(0, 200)
turtle.setheading(270)
turtle.pendown()
turtle.forward(400)

# Reset all the properties
turtle.home()
turtle.pencolor(0, 0, 0)

# Place code here
# Lift up the pen
turtle.penup()

# Set the pensize
turtle.pensize(20)

# Draw the first circle
turtle.setposition(0, -80)
turtle.pendown()
turtle.circle(80)

# Draw the second circle
turtle.penup()
turtle.setposition(0, -130)
turtle.pendown()
turtle.circle(130)

# Draw the third circle
turtle.penup()
turtle.setposition(0, -180)
turtle.pendown()
turtle.circle(180)

# End the program
turtle.done()

Where Can It Be Found?

A brief Google search led me to the following places where you can get branded Adinkrahene products:

  1. TShirts, Mugs and Phone Cases on TeePublic
  2. Pendants on Purple Blessing
  3. Socks on Adinkra Republic

Summary

At the end of this post, we have successfully used the Python Turtle environment to draw the Adinkrahene symbol.

The code for this series is available on GitHub. Please feel free to check it out.

Support this Series

Using the Adinkra symbols, I created the Adinkra Notebooks Collection.

You can support this series by buying one of them.

Categories
Python Programming

Why We Program

A computer is a machine that processes information under the control of a program.

By seeing the computer as a machine, you can then come to appreciate it like any device around you.

What however makes the computer special is the fact that you can program it.

What is Programming?

Computer programming is a way of giving computers instructions about what they should do in order to complete a set task.

A computer program will have the ability to take input data from a device such as a keyboard, process calculations, and make decisions based on certain conditions.

The practice of programming is one of teaching the computer to do something.

You must know how to do it yourself before you can teach a computer to do it for you.

Programming Languages

The instructions to execute the task that you want the computer to do for your are given to it in a programming language.

A programming language is a language that the computer understands.

Using a programming language, you are then able to transfer the logic of how you solved a problem to the computer.

To learn a programming language, you should be able to do the following with it:

  1. Take inputs
  2. Produce outputs
  3. Declare variables
  4. Use mathematical expressions
  5. Use conditional statements such as IF/ELSE
  6. Using looping statements such as WHILE
  7. Write functions

The Purpose of Programming

The purpose of programming is to automate processes.

When we have a problem that we want to solve, we list out the steps to solve that problem.

The sequence of steps we create is the algorithm.

The algorithm embodies all the logic we need to solve a problem.

With a well designed algorithm, we are confident that if we follow the steps of the algorithm, the result will always be correct.

We then take this algorithm and express it in a programming language as a program.

Once we have the program, the computer will handle the task for us.

We can then free up the time for our task until something goes wrong or we need to update the program’s logic.

This is the essence of programming.

Conclusion

Programming is a task that deals with the automation of the solution to a problem.

It is difficult hence the need to understand why it is needed before you do it.

Learn Python in One Week

If you want a quick and easy introduction to the Python programming language, you should check out my fifth book: Learn Python in One Week on the Amazon store.

Categories
State of the Nation

Mathemagic

Introduction

Welcome to a new week.

Last week was filled was fast paced. Story upon story. Thankfully, we made it to the end.

This post will look at some of the happenings of last week.

How 4th Became 1st

In an amazing turn of events, the 4th would be come first in Imo state.

You can read all the sordid details of the case here.

Election Results for Imo State

I am short of words at the happenings but not surprised. Nigeria has been synonymous with new lows in recent times.

Every time you think it cannot get any lower, it does.

As an engineer, I thought about how 1st could become 4th.

Haven’t you heard of modulus?

It is represented by the % symbol. It is the whole number remainder when you divide one number by another.

4 % 4 = 0
0 + 1 = 1

The proof above should suffice for the mathematically curious.

Forex Intervention

Last year, we spent close to 17 Billion Naira for the defence of the Naira.

No longer is our exchange rate an indicator of our productivity, it is now a measure of how well we can do Currency Warfare.

Such a regime is unsustainable but in this foolhardy administration, the continuation of foolish policies without recourse to common sense is notable.

The first forex intervention happened last week.

Who gives a damn if our banks cannot hold their water?

Group Economics

It wasn’t all doom and gloom.

I would read a story about a group of women who would combine forces to build a 5 storey building in Kenya.

It points to the fact that in unity, there is power.

Amotekun

Amotekun Logo

We all knew that the killings in the country could not go unanswered.

Although slow in coming, the Governors of the South Western states have decided to unite for the defense of their states.

This move marks the beginning of the end for the union called Nigeria.

It has been criticized by the North. Yet, they are unable to state on what basis makes the Hisbah legal and Amotekun illegal.

Amotekun in the South, Hisbah in the North

What will be left will be for other states to follow.

Amotekun means Cheetah in the Yoruba language.

Grid Collapse

Dark Room

It is only common sense that a nation that plans to go to space should have light on earth.

Last week on Thursday, 16th of January 2020, the national grid collapsed.

It would be the first collapse of the year. Nigeria has refused to apply any metric of wisdom in dealing with this problem.

VAT Increase

As if the suffering of Nigerians under bad government policies is not enough, the government has decided to increase the Value Added Tax (VAT).

You can see the announcement below:

VAT Increase Announcement

Not that it will do much good to the economy as the problem with the country is one of capacity.

What Does the Future Hold?

This article covers a possible future for Nigeria.

The writer brings no original thinking to the article and if you read any “Africa Rising” narratives last decade, it is in the same class.

How it Could All End?

Could Nigeria suffer the same fate as Venezuela?

The article gives a harrowing picture of people leaving a defunct nation.

Jetting Off

Despite all the problems in the country, the President is out of the country for another pointless trip.

This time he didn’t slither off. He met with some of his people.

Conclusion

History Repeats Itself

The above image covers all my feelings about Nigeria this week.

Thankfully, the world has been here before.

Have a great week.

Categories
Python for Financial Mathematics

Simple Interest

The concept of Simple Interest is one of the first things anyone learns in Financial Mathematics.

It isn’t really hard to program.

The formula I am using is given below:

Simple Interest Formula

The code to program this is shown below:

# Print out the purpose of the program
print("This program computes the compound amount using simple interest")
print("Reference: An Undergraduate Introduction to Financial Mathematics (Page 2)\n")

# Ask the user for the initial deposit
principal = float(input("Please enter the initial deposit: "))

# Ask the user for the rate as a percentage
rate = float(input("Please enter the rate: "))

# Ask the user for the number of years
years = float(input("Please enter the number of years: "))

# Compute the compounded amount
rate = rate / 100
compounded_amount = principal * ((1 + rate)**years)
print("\nThe compounded amount is:", round(compounded_amount, 2))

You can also find the code on GitHub.