Basic Terms For Python3
Basic Terms For Python3
Errors: Humans are prone to making mistakes. Humans are also typically in
charge of creating computer programs. To compensate, programming languages
attempt to understand and explain mistakes made in their programs.
Python refers to these mistakes as errors and will point to the location where an
error occurred with a ^ character. When programs throw errors that we didn’t expect
to encounter we call those errors bugs. Programmers call the process of updating
the program so that it no longer produces unexpected errors debugging.
SyntaxError means there is something wrong with the way your program is
written — punctuation that does not belong, a command where it is not
expected, or a missing parenthesis can all trigger a SyntaxError.
A NameError occurs when the Python interpreter sees a word it does not
recognize. Code that contains something that looks like a variable but was
never defined will throw a NameError.
Numbers: Computers can understand much more than just strings of text.
Python has a few numeric data types. It has multiple ways of storing numbers. Which
one you use depends on your intended purpose for the number you are saving.
An integer, or int, is a whole number. It has no decimal point and contains all
counting numbers (1, 2, 3, …) as well as their negative counterparts and the number
0. If you were counting the number of people in a room, the number of jellybeans in
a jar, or the number of keys on a keyboard you would likely use an integer.
Notice that when we perform division, the result has a decimal place. This is
because Python converts all ints to floats before performing division. In older
versions of Python (2.7 and earlier) this conversion did not happen, and integer
division would always round down to the nearest integer.
Division can throw its own special error: ZeroDivisionError. Python will raise this
error when attempting to divide by 0.