Python Interview Questions

Summary

The Ultimate Reference & Learning Guide for Python Developers!

In depth and current overview of common challenges with Python

Extensively used by big names such as Google and BitTorrent, fluency with Python can be essential for a career as a developer, however, a user-friendly and thorough resource can be difficult to locate. From helping you to assess your current skill level to preparing for an interview, this guide will tell you the details of what you really need to know. Set yourself apart from other candidates and show that you have what it takes to land the job. More than just a rehash of documentation and sales presentations, each section is based on project knowledge and experience gained on successful high-profile Python implementations.

Python

Python combines remarkable power with very clear syntax. It has interfaces to many system, calls and libraries, as well as to various window systems. It is extensible in C or C++.

You can use it as an extension language for applications that needs a programmable interface.

Finally, Python is portable. It runs on many UNIX variants, on the Mac, and on PCs under MS-DOS, Windows, Windows NT, and OS/2.

Question 2: Python is installed on my machine

Why is Python installed on my machine?

A: If you find Python installed on your system but don't remember installing it, there are several possible ways it could have gotten there.

Perhaps another user on the computer wanted to learn programming and installed it; you'll have to figure out who's been using the machine and might have installed it.

A third-party application installed on the machine might have been written in Python and included a Python installation. For a home computer, the most common such application is PySol, a solitaire game that includes over 200 different games and variations.

Some Windows machines also have Python installed. As of this writing we're aware of computers from Hewlett-Packard and Compaq that include Python. Apparently some of HP/Compaq's administrative tools are written in Python.

All Apple computers running Mac OS X have Python installed; it's included in the base installation.

Question 3: Delete Python

Can I delete Python?

A: It depends where Python came from. If it was installed deliberately, you can remove it without hurting anything.

On Windows, use Add/Remove Programs icon in the Control Panel.

If Python was installed by a third-party application, you can also remove it but that application will no longer work. You should probably use that application's uninstaller rather than removing Python directly.

If Python came with your operating system, removing it is not recommended.

If you remove it, whatever tools were written in Python will no longer run.

Question 4: Using GUI in Python

How to use GUI that comes with Python to test your code?

A: That is just an editor and a graphical version of the interactive shell. You write or load code and run it, or type it into the shell.

There is no automated testing.

Question 5: Creation of Python

Why was Python created?

A: I had extensive experience with implementing an interpreted language in the ABC group at CWI, and from working with this group I had learned a lot about language design. This is the origin of many Python features, including the use of indentation for statement grouping and the inclusion of very-high-level data types (although the details are all different in Python).

I had a number of gripes about the ABC language, but also liked many of its features. It was impossible to extend the ABC language or its implementation to remedy my complaints. In fact its lack of extensibility was one of its biggest problems. I had some experience with using Modula-2+ and talked with the designers of Modula-3 and read the Modula-3 report. Modula-3 is the origin of the syntax and semantics used for exceptions, and some other Python features.

I was working in the Amoeba distributed operating system group at CWI. We needed a better way to do system administration than by writing either C programs or Bourne shell scripts, since Amoeba had its own system call interface which wasn't easily accessible from the Bourne shell. My experience with error handling in Amoeba made me acutely aware of the importance of exceptions as a programming language feature.

It occurred to me that a scripting language with syntax like ABC but with access to the Amoeba system calls would fill the need. I realized that it would be foolish to write an Amoeba-specific language, so I decided that I needed a language that was generally extensible.

During the 1989 Christmas holidays, I had a lot of time on my hand, so I decided to give it a try. During the next year, while still mostly working on it in my own time, Python was used in the Amoeba project with increasing success, and the feedback from colleagues made me add many early improvements. In February 1991, after just over a year of development, I decided to post to USENET. The rest is in the Misc/HISTORY file.

(Note: Response quoted from developer of Python)

Question 6: Use of Python

What is Python good for?

A: Python is a high-level general-purpose programming language that can be applied to many different classes of problems.

Question 7: Restrictions in Using Python

A: You can do anything you want with the source, as long as you leave the copyrights in and display those copyrights in any documentation about Python that you produce.

If you honor the copyright rules, it's ok to use Python for commercial use, to sell copies of Python in source or binary form (modified or unmodified), or to sell products that incorporate Python in some form.