Basic Syntax: Wait, What is Syntax?

Programming language syntax is associated with the language’s grammar. Imagine you’re learning to write a story in a new language. Just like any language, The story has its own set of rules for putting words and sentences together to make a meaningful story. This set of rules is called “grammar.” You know this.

In a story, you might follow these grammar rules: For example,

• Sentences must start with a capital letter and end with a period.
• Verbs should match the subject..
• Adjectives come before nouns.

Now, let’s relate this to programming and Python syntax:

Programming languages, like Python, also have their own set of rules, just like grammar in languages. These rules are called “syntax.” Syntax tells you how to structure your instructions so the computer can understand and follow them correctly.

For example, in Python, some of the syntax rules similar to the grammar rules mentioned above;

• Instructions must end with a special character like a semicolon (:) or parentheses ().
• Commands like “print” are followed by parentheses () to show what should be printed.
• Variables need to be named correctly.

Let’s give some more examples?

print("Hello World.")

When you write this code in IDE screen, Computer will understand this syntax and will return the sentence “Hello, today is beautiful day.” in the screen.

print(“Hello World.“)

Write the sentence inside the parentheses on the screen.

The computer will understand what you’re saying, and the result will look like the following.

See the similarities? Just like in a story where you follow grammar rules to make a proper sentence, in programming, you follow syntax rules to create a proper instruction that the computer can understand.

If you have any questions about this topic, please don’t hesitate to ask in the comments. I will answer all your questions.

Leave a Comment