Python: Become a programmer and build real-world -traditional or decentralized applications on Platforms (such Algorand Blockchain) with Python Programming Language.

in #python5 years ago

Hello World!, Its Bob.

About the Author


image.png

Pixabay

In mid 2019, circling up to 2 years in the blockchain/cryptocurrency Industry,and being unable to contribute positively to the world, made me felt like I wasn't existing. I love blockchain and I have a great deal of passion for it, so I have always been on the go for anything that has to do with the digital trend involving blockchain. This period was a turning point for me when I picked up a course on Java programming language.
Being a complete rookie and no strong foundational knowledge of computer science exposed me to a very tough time catching up with Java (as most would tag it a complex PL). But I had loved to be known with Python development. I was faced with challenges one of which is "knowing which of the programming languages to learn first" With my experience, I would tell anyone aiming to become either a front-end or back-end developer to know the basics first before diving into core aspect.

Introduction


This is my first blog post on "becoming a developer". You will learn the best practice of "writing a good and understandable code" even if you do not have any background knowledge of programming, I will break it down in pieces to a concise form that is understandable even by a layman. So, I will minimize vocabularies to the barest. Please note that it will come in series so as not to bore you with too much words.


What Basics Should I learn First?


Back-end

If you do not have a "pre" knowledge of computer science, you should endeavor to get hold of material (s) to help you get started. I took several courses on Udemy one of which is computer 101. Also having gone through so many computer science materials and Youtube videos, I struggled to write a line of code until I uncover the right learning pattern ideal for my nature. Maybe because I am a slow learner but, utmostly, it depends on which category you fall in. As soon as you are able to figure out your strength and weaknesses when it comes to learning, it becomes easier finding the right way to learn. Be wary that we have different capacity regarding intelligent quotient and adaptation.

Being a back-end developer connotes that you will be dealing much in what is controlling the visual - Graphical User interface - GUI(i.e the brain) aspect of computing. This is where most logic are performed and account for the software/application's functionalities. Here, you tell computer what to do. Errors at the back-end can be costly if not identified before deployment but can be minor at the front-end. As a back-end developer, you should also know how to use HyperText Markup Language (HTML) as a great resources, Cascading Style Sheet (CSS) and Javasscript. Although, CSS is not a must but an added advantage. To begin with, I recommend starting with Python (which is why I have put up this post as the start my blog series on Python programming language) of numerous programming languages such as Java, C++, C#, C, Solidity, Kotlin, Mocha, etc.


Front-end

While you love to be at the front-end, you are concerned with managing user experience. However, this isn't limited to front-end alone. A back-end developer must ensure his code is optimized as much as possible to call for desired experience on all sides(back-end, front-end production and users). Front-end can include but not limited to web design, UI/UX design and all that is connected to what the users see. Html, Css and Javascript are prerequisites for this discipline. Several frameworks you want to choose from includes: AngularJs, VueJs, ReactJs etc, And for UI/UX design, consider any or all of the following tools: Adobe XD, Sketch3, FIgma others.


I am considering writing on Solidity as well which is the core and widely used programming language for smart contract on Ethereum and several other blockchain such as Cypherium but this series is basically on python. Without further, ado, let's get to the deal of the day.


PYTHON PROGRAMMING LANGUAGE

image.png src

A quick definition of Python states that it is an object-oriented, interpreted, high-level programming language that uses dynamic semantics. Python is simple and easy to learn. Its syntax enables readability which in turn reduces the cost of program maintenance. It also supports modules and packages, which helps developers to modularize their code and reuse them. There are couple of things you can use Python for such as "a server to create web applications", "software development", "system scripting" etc. Find out what you can use Python for.


Python is very popular and has been around for a while and its syntax is similar to English Language. In fact, all programming languages syntax have meaning in English. In Blockchain development, Python can be very useful. Ethereum network supports using it as Smart contract programming language(Vyper) but still in the development phase while Solidity is the major official language for now hence many developer of traditional applications would need to learn Solidity to be able to build deployable decentralized applications. A major setback in blockchain/cryptocurrency mainstream adoption could be attributed to this as a problem. Meanwhile Algorand blockchain saw the need to bridge this gap and made it possible to write Smart Contract using existing programming languages - Java, Python, Go and JavaScript. Therefore, learning Python would be advantageous.


.... to write a good program, you should be able to interpret a line of code.

In any programming language, or no matter how much tutorial you may have watched, if, yet you are unable to interpret what a line of code does, you may not be able to write a good program. This article assumes that you already have Python and code editor installed on your computer. I recommend Visual Studio Code (VSCode) since it will be one used throughout this series. If you don't already have one, download Python (version 3.0 or later) and [watch this video] to download and set up Visual Studio Code. Please leave comment below wherever you are confused of encounter difficulty.


How To Check If Python Is Installed On Your Computer

On the searchbox, type CMD and click enter. A command line pops up, then type the following command as seen in the image below.

image.png

Window OS

python --version

Linux or Mac OS

python --version

As depicted in the image, you will notice I entered a command python --version and got an output Python 3.7.4 as the latest version of Python I have on my computer.


Now let us write our first program using Visual Studio Code. Follow these steps strictly :

Steps

1. Create a folder on your computer in any directory(Document or Desktop or Download etc ) of your choice. Perhaps, Desktop or Document would be ideal. Give it a name showing your project name. I will call it pythonTutorial which I created inside Document directory.

Screenshot (120).png

2. Now open your VSCode executable (.exe) and launch. The page should look like in the image below.

image.png

At this point, you need to configure your VSCode to get the best of the functionalities. As I mentioned earlier, this article does not cover how to set up VSCode but please refer here for instructions on how to set it up.

3. On the top left-hand corner, click on file, then select open folder. A dialogue box is opened and you should navigate into the folder we earlier created pythonTutorial and select it. then it is opened in VSCode.

Screenshot (121).png

4. Hover over the folder name on the left pane and create a file name it example.py. Ensure it has the python extension py. That way, python knows we want to write python code and when we run it is recognized.

Screenshot (124).png


Oh great, you just did.


Writing Our First Program

Type the following codes in the
example.py file.

userName = input("Please enter your name.")
print("Welcome " + userName)

Done? Oh Yes! That's great. Now, Let me explain what that mean.


  • We created a variable called userName and assigned a value to it. A variable is a reserved memory location to store value(s). It serves as a placeholder for a specific value that we hope to use later in the future.

  • The value is a function of what we expect to get from the user via the input which is a keyword embedded in python.

Note that you cannot use words that are tagged "keyword" as variable created by you since they are reserved words. Example of keywords in python are:

input
function
print
string
int etc.

Refer to python reference document on the Python official website

  • The opening and closing parentheses ( )immediately after the "input" are meant to take inputs or parameters from external objects for use within the function.
    If you do not understand this, don't worry as they may look like gibberish to you but you will grab it better as we proceed.

Anytime you see parentheses in front of a keyword or functions we defined ourselves, it means that such function is expected to collect arguments or parameters to be used as input on which certain computations will bee performed.

  • In this regard, the input() is a function is python module that collects data externally, performed computation internally and return the output of the computation to us. It actually doesn't do much other than getting what we expect from the user and return the result to us. So, in this case we need to get the name of the user.

  • Afterwards, the user entered his name(the expected value), and hit "enter" key, we need a placeholder for this value which is why we have created a variable called userName to hold this value for us.

    userName = input("Please enter your name.")

  • We also printed the value we got from the user to our console using the line o code

print("Welcome " + userName)

The print() is an internal function in python that renders value externally i.e sending the output of a computation or function to users. Remember what I said about parentheses earlier and what it does. Inside the parentheses, We placed a word ("Welcome") within a quote.

  • This type of data is called String virtually in all programming language. So whenever python sees these quotes, it treats anything within it as a string. Even if you place arbitrary amount of numbers between the quotes, python will always treat it as a string.

  • The + sign is used as a way of joining multiple data that are of different types together. Note that the "Welcome" is a string data type and userNamecould be any type either a string or integer which should be specified at the point we asked user for the information. Don't worry if you don't understand what integer is. I will expatiate better in upcoming article.


  • Lastly, you would notice an unusual manner at which I wrote the userName. This is a practice called camelCase. It is used to connect two or more words that we intended to use as a variable. We could have a variable we intend to give name as last digit for instance. Separating the words with space makes python throw an error because it sees it as two different words.

image.png src

To make python smile, we could write it as either 1.last_digit or 2. lastDigit or perhaps as 3.lastdigit. But 1 and 2 are considered good practice. Also, note that adopting convention requires consistency.


I will close my keyboard at this point. you may go over the article as many time as can make you understand. Meanwhile I have designed it to give you the best learning experience if you're the text type. If you find this article useful, be kind enough to give a thumb and leave comment where you seem lost.


What Is Algorand

Algorand is a technology company that built and developed the world’s first open, permissionless, pure proof-of-stake blockchain protocol that, without forking, provides the necessary security, scalability, and decentralization needed for today’s economy. With an award-winning team, we enable traditional finance and decentralized financial businesses to embrace the world of frictionless finance.

Article posted on my blog

Sort:  

As a follower of @followforupvotes this post has been randomly selected and upvoted! Enjoy your upvote and have a great day!

Coin Marketplace

STEEM 0.21
TRX 0.20
JST 0.034
BTC 90479.14
ETH 3094.57
USDT 1.00
SBD 2.93