Programming is broken down into 2 skills sets to master (logic and syntax).
Logic is the steps you take to accomplish the goals of your program. In communication, logic is what you say.
Syntax is the way that you write the program. In communication, syntax is the patterns that you use to spell words and combine them in a sentence.
Different programming languages can perform the same function (logic) but in different ways (syntax). Below is an example of different programming languages commands to print to the screen (same logic) but different syntax.
Notice that each language can have very different syntax but the logic above is the same. They will each print “Hello world!” to the screen.
When your program is not working correctly first identify if the problem is syntax, logic or both. If both then separate the syntax part of the problem from the logical part of the problem.
A lot of beginner programmers have trouble with syntax because they are not used to seeing the syntax patterns. Knowing this will help you to focus your attention on understanding and solving these problems quickly. The nice thing about syntax errors are that the system will tell you when you have them. Here is a methodology that will help to find and fix these errors.
When you have a syntax error the system will tell you this in the form of an Error message (see example below). To solve this do the following steps:
Here is a syntax error from python
Notice the red section. The system is telling you there is a syntax problem here. Compare this print statement with the one above. You should notice that the () are in front of the “Hello World” and not surrounding the text.
These can be more complicated to solve. The program is running but not giving you the correct answer or doing the right thing. A set of techniques you can use to solving logic problems are:
Here is a Python logic error:
Notice that this while loop will run forever.
Overall programming is comprised of logic and syntax. Each is needed for a successful program and each has its own set of issues. Learning how to understand and solve syntax and logical issues are vital to getting a correctly working program.
(c) 2019 Copyright Team Mindshift
For many, a visual aid assists in creating a mindset of where you are going. We believe strongly in visual aids being essential to a transformation journey regardless of the industry. This is why we have created a data-driven pyramid.
In this article, we will discuss what goes into making decisions from the data you gather and how you might want to approach your data-driven decision-making as a team.