Program→An ordered set of instructions to be executed by a computer to carry out a
specific task
Source code→A program written in a high-level language
Language translators→Tools to convert source code to machine language
Types→Interpreter, compiler
Interpreter
Definition→A language translator that processes statements one-by-one,
translating and then executing.
Error handling→An interpreter processes statements one-by-one until an
error is encountered or the whole program is executed successfully.
Compiler
Definition→A language translator that translates the entire source code as
a whole into object code.
Error handling→After scanning the whole program, a compiler generates error
messages, if any.
Features of Python
Elements→High level, interpreted, easy to understand, case-sensitive, platform
independent, rich library, web dev, indentation
High level→Python is a high level language, and is free and open source.
Interpreted→Python is an interpreted language, because Python programs are
executed by an interpreter.
Easy to understand→Python programs are easy to understand as they have a
clearly defined syntax and relatively simple structure.
Case-sensitive→Python is case-sensitive, e.g., "number" and "NUMBER" are not
the same in Python.
Platform independent→Python is portable and platform independent, means it can
run on various operating systems and hardware platforms.
Rich library→Python has a rich library of predefined functions.
Web dev→Python is helpful in web development. Many popular web apps and
services are built using Python.
Indentation→Python uses indentation for blocks and nested blocks.
Execution Modes→Interactive and Script modes
Interactive Mode
Usage→Interactive mode allows execution of individual statements
instantaneously.
Pros→Working in this mode is convenient for testing a single line of code
for instant execution.
Cons→Statements cannot be saved for future use and have to be retyped to
run them again.
Script Mode
Usage→Script mode allows us to write more than one instruction, in a file
called the Python source code file, that can be executed.
Identifiers→Names used to identify variables, classes, functions or other entities.
Rules
Can only begin with letter or underscore
Can only contain letters, numbers and underscores
Can be of any length
Cannot be a a keyword
Numeric literals
Types→Float, int, complex