3.2. Syntax RulesΒΆ

At their core, programming languages are collections of rules that allow us to tell a computer what to do. Actions like Repeat ____ 25 times, Prompt the user for a password, or Display text on the screen can be done with any language. However, each one uses different methods to complete the tasks.

Syntax refers to the structure of a language (spoken, programming, or otherwise) and the rules about that structure. For example, in English, a sentence must begin with a capital letter and end with proper punctuation.

Python and other languages can only run a program if it is syntactically correct, and each language is pretty rigid and unforgiving if you make a mistake. While humans are good at overlooking minor grammar and syntax errors, computers cannot do the same.

For example, the following sentence will send English teachers into fits, i believe that Catch 22 demon straights a cleer picture of whirled wor too. Despite being badly written, we can still make some sense out of the words. It might take some re-reading, but eventually we will get the point. Other examples include vanity license plates:

Plate Meaning
KC ROKS Kansas City (or Casey?) Rocks
4EVERL8 All parents who ever needed to get the kids to practice

Computers cannot interpret or overlook mistakes like humans. Any syntax errors, no matter how minor, will prevent the code from running. Instead of trying to work around the issue, the program will immediately crash and generate error messages.