Day 2 - The Interpreter

Published on Sep 11, 2024 at 08:57 PM

The Python interpreter is a program that reads and executes Python code. When you write Python code, the interpreter converts the code into a form that the computer's hardware can execute. Python is an interpreted language, meaning that it does not need to be compiled into machine code before execution; instead, the interpreter processes the code line by line. >CPython: This is the default and most widely used Python interpreter. CPython is written in C and compiles Python code into bytecode, which it then interprets.
Few other python implimentations are:
PyPy: An alternative Python interpreter with a Just-In-Time (JIT) compiler, which can make
Jython: A Python interpreter for running Python on the Java platform.
IronPython: An implementation that runs Python programs on the .NET framework.
REPL (Read-Eval-Print Loop), in interactive mode, the Python interpreter functions as a REPL, where it reads the user’s input, evaluates the expression, prints the result, and loops back for more input. Python interpreter is generally installed at /usr/local/bin/python in Linux or Unix. In Windows, python is usually installed in C:\Python27
By default, Python source files are treated as encoded in ASCII. To use custom encodings, we have to add a comment at the beginning of the file.
Syntax: # -*- coding: encoding -*-
For example, to declare that Windows-1252 encoding, first like of the code should have: 
# -*- coding: cp1252 -*-
If the source code starts with a UNIX “shebang” line, then encoding declaration should be added at the second line: 
#!/usr/bin/env python
# -*- coding: cp1252 -*-
#Python #Challange