Python Introduction

  • - Featured
  • - Table of Contents

What is python?

Python is a programming language which mostly use interpreter but sometimes uses compiler also. Hence it is mixed. Python is interactive, object-oriented and high-level. It was developed and designed by Guido van Rossum. Python is an open source language hence its source code is also accessible.

Python can be used to program to a lower degree in procedural, object-oriented , in functional style, although at heart Python is an object-oriented Language.

Python is designed to be highly readable. It utilizes English keywords, while other languages use punctuation, and python is less syntactic than other languages. The interpreter processes Python at runtime. Before you execute it, you don't have to compile your program.

Do you Know: Python is named after the comedy television show Monty Python’s Flying Circus. It is not named after the Python snake and a handful of later full-length films, still popular today, including Monty Python and the Holy Grail. Python’s original creator was a fan of Monty Python, as are many software developers (indeed, there seems to be a sort of symmetry between the two fields...).

Is Python a “Scripting Language”?

Python is regarded as a scripting language. In fact, Python is not a language of scripting, but a language of programming for general purposes that also works well with scripting.

We can perform all tasks by Python that java could do. During runtime, both the programming languages are viewed, i.e. python and java. Usually the term scripting means writing code to automate a particular process in a particular environment (like browser).

Scripting Language Features:

What Are Python features?

The features of Python is listed below:

  1. It’s Object-Oriented and Functional
    • Python is, from the ground up, an object-oriented language. Its class model supports sophisticated concepts such as polymorphism, overloading of operators and multiple inheritance; however, OOP is extremely easy to apply in the framework of Python's simple syntax and typing.

    • In fact, if you don’t understand these terms, you’ll find they are much easier to Learn about any other OOP language accessible with Python.

  2. It’s Free
    • Python can be used and distributed free of charge.

    • As with other open source software, such as Tcl, Perl, Linux, and Apache, all of Python's source code is available free of charge on the Internet. Copying it, embedding it into your devices or shipping it with your products are not restricted. In reality, if you are willing, you can even sell Python's source code.

  3. It’s Portable
    • Python's normal application is written in mobile ANSI C, compiling and running on nearly every major presently in use platform. Python programs, for instance, operate on everything from PDAs to supercomputers today. Python can be found as a partial list on:

      • Linux and Unix systems

      • Microsoft Windows (all modern flavors)

      • Mac OS (both OS X and Classic)

      • BeOS, OS/2, VMS, and QNX

      • Real-time systems such as VxWorks

      • Cray supercomputers and IBM mainframes

      • PDAs running Palm OS, PocketPC, and Linux

      • Cell phones running Symbian OS, and Windows Mobile

      • Gaming consoles and iPods

      • Tablets and smartphones running Google’s Android and Apple’s iOS

      • And more
  4. It’s Powerful

    • Python is a hybrid programming language. Its toolset positions is between traditional languages of scripting (such as Tcl, Scheme, and Perl) and languages of system growth (such as C, C++, and Java) Python offers a scripting language with all the simplicity and ease of use. Usually discovered in compiled languages, along with more sophisticated software engineering instruments.

    • Dynamic typing: Python tracks the types of objects that your program utilizes when it operates; it doesn’t require complicated type and size declarations in your code. In fact, there is no such thing as a type or variable declaration anywhere in Python. Because Python code does not constrain data types, it is also usually automatically applicable to a whole range of objects.

    • Automatic memory management: When they are no longer used, Python automatically allocates items and reclaims ("trash collects") and most of them can expand and shrink on demand. Python keeps track of memory details at low levels so you don't need to.

    • Programming-in-the-large support:

      Python involves tools such as modules, classes and exceptions for constructing bigger systems. These tools allow you to organize systems into components, reuse and customize code using OOP, and handle incidents and errors graciously. The functional programming tools of Python, described above, provide additional techniques to achieve many of the same goals.

    • Built-in object types: Python offers frequently used data structures such as lists, dictionaries and strings as an inherent part of the language ; as you will see, they are both versatile and simple to use For example, built-in objects may expand and decrease on demand, they may be nested arbitrarily to represent complicated data, and more.

    • Built-in tools: Python comes with strong and standard activities to process all these kinds of objects, including concatenation (joining collections), slicing, sorting, mapping, and more.

    • Library utilities: Python also comes with a big set of pre-coded library instruments to help everything from periodic matching expression to networking for more particular functions. Once you know the language itself, there is much of the application-level action taking place in Python's library instruments.

    • Third-party utilities:Because Python is open source, developers are urged to add pre-coded instruments that help functions beyond those supported by its built-ins; on the Web, COM, image, numeric programming, XML, database access, and much more are available.

  5. It’s Mixable:
    • Python programs can be readily join with a multitude of ways to parts published in other languages.

    • Python's C API, for instance, allows C programs to call and be called flexibly by Python programs. This implies that you can add features as required to the Python scheme and use Python programs in other settings or systems.

    • For example, mixing Python with libraries coded in languages such as C or C++ makes it a user-friendly front language and customization tool. This also makes Python good for fast prototyping— systems can be introduced first in Python to leverage its development velocity and then transferred to C for shipment, one piece at the moment, depending on performance requirements.

  6. It’s Relatively Easy to Use:
    • Compared to options such as C++, Java, and C #, for most observers, programming Python seems amazingly easy.

    • You merely type it and operate it to run a Python program. There are no intermediate steps in compiling and linking, as in languages like C or C++. Python runs programs instantly, which results in an interactive programming experience and quick turnaround after program changes— in many instances, you can witness the impact of a program change almost as quickly as you can type it.

How Python Runs Programs

  1. Python will be interpreted as byte code. First, py source code is collected as byte codeas.pyc. It is possible to interpret this byte code (formal CPython) or compile JIT (PyPy). Python source code (.py) can be compiled as well as IronPython (.Net) or Jython (JVM) to separate byte code.

  2. An interactive session is a commonly used way of running Python software. To begin an interactive Python session, simply open a command line or terminal, then type python, or python3, depending on your Python setup, and hit Enter.

  3. Here’s an example of how to do this on Linux:

  4. shell $ python3 Python 3.6.7 (default, Jul 19 2019, 11:32:17) [GCC 8.2.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>>
  5. The default prompt for interactive mode is > > >, so you'll understand you're in as quickly as you see these characters. Now, as you want, you can write and operate Python code, with the only drawback being that your code will be gone when you close the session.

  6. When you operate interactively, you instantly evaluate and execute every phrase and declaration you type in:

Print >>> print(TalentXoom!') TalentXoom! >>> 5 + 5 10 >>> print('Welcome to TalentXoom!')


Welcome to TalentXoom!

An interactive session will enable you to test every piece of code you write, making it an amazing development tool and an outstanding location to experiment on the fly with the language and test Python code.

To exit interactive mode, you can use one of the following options: quit() or exit(), which are built-in functions. The Ctrl+Z and Enter key combination on Windows, or just Ctrl+D on Unix-like systems

How do I run python from command line?
  1. Run your script

  2. Open Command line: Start menu -> Run and type cmd.

  3. Type: C:\python27\python.exe Z:\code\hw01\

  4. Or you can drag and drop your script from Explorer to the Command Line window and click enter if your system is configured properly.

Check your knowledge(Quiz).

  1. What is the Python interpreter?

    The Python interpreter is a program that runs the Python programs you write.

  2. What is source code?

    Source code is the statements you write for your program—it consists of text in text files that normally end with a .py extension.

  3. What is byte code?

    Byte code is your program's lower-level type after it is compiled by Python. Python stores byte code in files with a.pyc extension automatically.

  4. What is the PVM?

    The PVM is the Python Virtual Machine—the runtime engine of Python that interprets your compiled byte code.

  5. Name two or more variations on Python’s standard execution model.

    All variations on the execution model are Psyco, Shed Skin, and frozen binaries. Furthermore, Python's alternative implementations named in the next two responses also change the model in some way — by replacing byte code and VMs, or by incorporating instruments and JITs.

  6. How are CPython, Jython, and IronPython different?

    CPython is the language's normal application. Jython and IronPython, respectively, implement Python programs for use in Java and. NET settings ; they are alternative Python compilers.

  7. What are Stackless and PyPy?

    Stackless is an improved version of competition-oriented Python, and PyPy is a speed-oriented re-implementation of Python. PyPy is also Psyco's successor, incorporating the JIT ideas developed by Psyco.