'Hello World'
Day by day, month by month - Automation, Machine learning, artificial intelligence, data science, etc is creeping into our life more and more. Tech companies were one of the first groups to take the most advantage of the emerging field. Looking at the impact and rewards of data analysis and machine learning, everyone wants to get into the race.
I have been doing process automation in my organization and as a part of the next step - I am preparing myself to get into Machine learning. I have many of my colleagues coming up to me asking about how to get started with coding. There are different answers I keep giving, depending on who is asking and their past history with coding. This post is for someone the no (or very minimal) coding experience. I'll list down the major areas to look into and provide a roadmap to get started with any language.
It's a good option to start with the motivation to learn to code. This can help answer which language to learn and how much to learn. Much commercial software comes up with GUI to make machine learning models and train the same. You don't need to learn to code for that. Read on if you still want to learn to code. This can be used for automation or training your own models with custom datasets. You can start off with as little as 7 hours a week. Let's get started with the pointers -
1. Choosing a Language -
If you haven't decided which language you want to learn - pick Python. I use javascript and Matlab, for automation at work. So, if you already have a tool you wish to work on, better pick the language it supports. Python is my current choice - open-source, many resources available online to solve the issues related to Python. Once you learn the basics of one language, it is easy to transfer it to another.
Extra reading - Find out which languages topped the annual popularity charts for the past 10 years.
2. First code - "Hello World" -
Congratulations on selecting your language - the next step is to get the installation done and write the first code. Once the installation is done the first task should be to print "Hello World". This makes sure that the installation is correctly done and you will also learn about the interface. You will understand the console, where to write the code, how to execute, and where to see the output.
You can improvise the above code by asking the user to input a text from a user and print out the same.
Extra Reading - Explore the history behind "Hello World" in the programming language.
3. Data Types -
This is an important step. All the data stored in the program is stored in different buckets or data types. Example - Integers, Float, Strings, etc. Now, why is this important? Simple example - If you read text from a document, even the numbers are read as a string. You cannot compare that directly with another number. You need to convert the type before proceeding. Many mathematical operations are also dependent on the data type of a variable. Second is multi-dimensional data - like arrays - this is my personal favorites.
In this section, you should focus on mathematical operations like - how to add a string and a float/double.
What happens if you divide integer with a float/double.
How to index array and modify the values.
If you are in Python - then read about Lists, tuples, dictionary.
4. Control statements -
As the name suggests, this controls the flow of your program. Based on a certain condition you can decide to execute a block of code or skip it. You can iterate over multiple items using control statements. You should be focusing on following major types -
1. If - elseif - else
2. Switch statements
3. While - for iterations
4. for - for iterations
Example problem - take a string input from the user -
if the string length is less than 4 - Output - 'String too short'
else if the string length is greater than 4 and less than 6 - Output - 'Perfect Length'
else - Output - 'String too long'
Advance example problem - Write a code to convert decimal number to binary equivalent.
5. Functions -
These help you to repeat a task. In code, if you want to compute compound interest at 5 different places then you can reduce your code length by using functions. You create a function that will compute the compound interest. Then just make a call to a function whenever you need compound interest. Compound interest requires - Principal amount, interest rate, and time period - this will be input arguments to the function. The compound interest at the end of the tenure will be the return value of the function.
What you need to focus on -
1. How to pass arguments like string, array, etc
2. How to return a string, array, multiple values
3. How to call a function within that function - recurring function - One of the concepts I like the most in this heading. I haven't used this much in my live codes, but I like the concept.
Example problem to be solved - Write a recurring function to calculate the Fibonacci series. The number of terms required as the output of the series - must be input to the function.
There you go - You are ready to start automating your daily tasks or learn advanced concepts. Debugging - that is a skill I guess and an essential one. Now, remember - your code won't compile or run in the first go and that is fine. The process of looking through the code for errors and rectifying is part of debugging. At times the code will run without error but the output won't match with the desired output and again you will get your debugging skills out. Don't worry now, the more you code the better you will be at debugging.
My next post will be on writing code to generate the Fibonacci series in Python. I will also write a code to convert a decimal number to a binary equivalent.
Drop-in your experience, feedback, and comments. Also, write about the topics that you want to learn more about and I'll write a post for the same.