Nowadays, coding is the skill in high demands. Many people have plan to start on coding, but what in the case you don’t know anything about programming and how to start? In this article, I would like to explain how the things work out for people who want to learn how to code.

Photo by Nathan da Silva on Unsplash

1. Choosing the language

There are many programming language out there for you to choose, but the question is what language will suit you? For beginner, I would recommend starting on “HTML” or “Python”. The reason would be these 2 language share the same terms of simplicity and applicability.

Although HTML might not be considered as programming language, it’s the most basic designing language for making a format of a site. Everyone who aims to be web designer should know HTML.

For Python, it has very simple language and very straightforward syntax; thus, making it suit for beginner. It also can be utilized for numerous things including the web administration that serves HTML records.

To choose the language you want to start would depend on what you aiming at. If you aim for front-end or web design, HTML is the way to go. On the other hand, Python would be a good choice in case you keen on general programming. This article will use Python as example for coding.

2. IDE

“IDE” come from the word “Integrated Development Environment”. Now the question is “what is IDE and what is it do?”. While coding can be done anywhere including your Notepad, It can be troublesome for the huge amount of code without any helper. IDE is tool that help you coding easier providing source code editor, build automation tools, debugger. Some of them even provide the compiler and interpreter. All of them combine into a single software suitable for programming.

The IDE that I recommended would be a Visual Studio Code from Microsoft since it’s free and build on open source. It has many extensions and also has build-in Git support. If you want to start coding, Visual Studio Code would be a good choice to start. Alternatively, online editor is also a good choice to start since you don’t have to set up anything.

3. Start with the greeting

Most likely the first thing everyone learn how to code must face, “Hello World”. The most basic thing when you try to learn a new language is getting the program response you something.

Example

print("Hello World")

This line will give you a text “Hello World” back to you when compile on your editor.

4. Knowing the basic

The things that you should know before starting to code:

  • Variable: containers for storing the data that can be changed
  • Data Types: variables can store different of data types which very important since each data type has its own attribute and used differently

Some categories of data types:

Text type: str
Numeric types: int, float
Sequence types: list, range, tuple
Boolean type: bool
Binary types: bytes, memoryview
  • Functions: it is the block of code that run when it is called, can return data as a result

Example

# Check the data type of variable using function type()x = 1       # declare a variable x which value = 1
y = 1.5 # declare a variable y which value = 1.5
print(type(x), type(y))

This will return the class of “x”and ‘y” variables as “int” and “float”

  • If…Else: it’s the decision making tool that supports the usual logical conditions from mathematics by executing the code when condition is fulfilled

Example

x = 1
y = 2
if x > y:
print ("x is greater than y")
else:
print ("y is greater than x")

From the above, it will return “y is greater than x” to you since the condition of x > y did not met. Therefore, it will go to another condition which resulting in “y is greater than x” is printed.

  • Loops: there are 2 types of loop in python which are “while” and “for”

Example

# for loop and while loop have different use
# normally, for loop is used when you know the number of iterations
# otherwise, while loop is usually used when number of iterations is
# undefined or you want to keep the code running while
# conditions is satisfied or true
menu = ["chicken", "pork", "soup", "tomato", "salad", "burger"]for i in menu: # i is represent an element in menu
print (i)

This will return each name of menu from “chicken” to “burger”. It count as one iteration.

Example

menu = ["chicken", "pork", "soup", "tomato", "salad", "burger", "tomato"]   # add one more tomato in menun = 0while n < 3: 
for i in menu:
print(i)
if(i == "tomato"):
n += 1

This one use both of while and for loop together. The code will run for 2 iterations before stopping due to the “while condition” is unsatisfied.

5. Let’s write something

Now come the time you want to put what you’ve learned into practice. Starting with the simple program, calculator is the basic program that almost every devices have whether mobile phone or desktop. Let’s write a very basic calculator.

x = input("Please input your number x: ") 
y = input("Please input your number y: ")
z = input("Please input your operation(+ - * /): ")
if (z == "+"):
print (x + y)
elif (z == "-"):
print (x - y)
elif ( z == "*"):
print (x * y)
else:
print (x / y)

If you try to run this code, you will find it won’t work since the data type did not match.

x = int(input("Please input your number x: "))
y = int(input("Please input your number y: "))
z = input("Please input your operation(+ - * /): ")
if (z == "+"):
print (x + y)
elif (z == "-"):
print (x - y)
elif ( z == "*"):
print (x * y)
else:
print (x / y)

As you can see, the data from input() function will be stored as string type, so it cannot be used on math operators. We have to put int() function in front to cast value of input() function to integer.

6. Conclusion

You might see already that when programming a lot of problems will be encountered. There are many programming languages out there to the point that it’s nearly impossible to master all of them. However, most of them share the same basic, so the thing you need to focus while coding is how the code work rather than a syntax of the language. Lastly, the most important skill you should have in coding is problem solving. It can be used on any programming languages including things outside of programming. I hope this article would be useful for those who considered starting on coding.