3. What types of errors?¶
Syntax errors: a programming language is formal, different from natural languages, and has a rigid syntax.
Runtime errors
Semantic errors (more difficult to find)
3.1. How to find and handle errors?¶
Syntax: pay close attention and practice
During runtime: exception handling
Semantic: desk testing or simulation
3.2. So, how do you run your code?¶
There are two things to run the guessing game program: an editor and an interpreter
The editor saves the code written in a file on the disk
Computers cannot process text because they only understand binary (zeros and ones)
The interpreter converts the source code into a binary file for the computer
The Python interpreter works in two modes: interactive and editing.
The interactive mode is ideal for testing commands and getting instant responses
- However, the editing mode is the most commonly used for developing programs.
File names usually end with “.py”
If you use another extension, you’ll lose colors…
A program is more than a list of commands.