Dear readers, these Python Programming Language Interview Questions have been
designed specially to get you acquainted with the nature of questions you may encounter during
your interview for the subject of Python Programming Language. As per my experience good
interviewers hardly plan to ask any particular question during your interview, normally questions
start with some basic concept of the subject and later they continue based on further discussion
and what you answer −
What is Python?
Python is a high-level, interpreted, interactive and object-oriented scripting language. Python is
designed to be highly readable. It uses English keywords frequently where as other languages use
punctuation, and it has fewer syntactical constructions than other languages.
Name some of the features of Python.
Following are some of the salient features of python −
It supports functional and structured programming methods as well as OOP.
It can be used as a scripting language or can be compiled to byte-code for building large
applications.
It provides very high-level dynamic data types and supports dynamic type checking.
It supports automatic garbage collection.
It can be easily integrated with C, C++, COM, ActiveX, CORBA, and Java.
What is the purpose of PYTHONPATH environment variable?
PYTHONPATH - It has a role similar to PATH. This variable tells the Python interpreter where to
locate the module files imported into a program. It should include the Python source library
directory and the directories containing Python source code. PYTHONPATH is sometimes preset by
the Python installer.
What is the purpose of PYTHONSTARTUP environment variable?
PYTHONSTARTUP - It contains the path of an initialization file containing Python source code. It is
executed every time you start the interpreter. It is named as .pythonrc.py in Unix and it contains
commands that load utilities or modify PYTHONPATH.
What is the purpose of PYTHONCASEOK environment variable?
PYTHONCASEOK − It is used in Windows to instruct Python to find the first case-insensitive match in
an import statement. Set this variable to any value to activate it.
What is the purpose of PYTHONHOME environment variable?
PYTHONHOME − It is an alternative module search path. It is usually embedded in the
PYTHONSTARTUP or PYTHONPATH directories to make switching module libraries easy.
Is python a case sensitive language?
Yes! Python is a case sensitive programming language.
What are the supported data types in Python?
Python has five standard data types −
Numbers
String
, List
Tuple
Dictionary
What is the output of print str if str = 'Hello World!'?
It will print complete string. Output would be Hello World!.
What is the output of print str[0] if str = 'Hello World!'?
It will print first character of the string. Output would be H.
What is the output of print str[2:5] if str = 'Hello World!'?
It will print characters starting from 3rd to 5th. Output would be llo.
What is the output of print str[2:] if str = 'Hello World!'?
It will print characters starting from 3rd character. Output would be llo World!.
What is the output of print str * 2 if str = 'Hello World!'?
It will print string two times. Output would be Hello World!Hello World!.
What is the output of print str + "TEST" if str = 'Hello World!'?
It will print concatenated string. Output would be Hello World!TEST.
What is the output of print list if list = [ 'abcd', 786 , 2.23, 'john', 70.2 ]?
It will print complete list. Output would be ['abcd', 786, 2.23, 'john', 70.200000000000003].
What is the output of print list[0] if list = [ 'abcd', 786 , 2.23, 'john', 70.2 ]?
It will print first element of the list. Output would be abcd.
What is the output of print list[1:3] if list = [ 'abcd', 786 , 2.23, 'john', 70.2 ]?
It will print elements starting from 2nd till 3rd. Output would be [786, 2.23].
What is the output of print list[2:] if list = [ 'abcd', 786 , 2.23, 'john', 70.2 ]?
It will print elements starting from 3rd element. Output would be [2.23, 'john',
70.200000000000003].
What is the output of print tinylist * 2 if tinylist = [123, 'john']?
It will print list two times. Output would be [123, 'john', 123, 'john'].
What is the output of print list + tinylist * 2 if list = [ 'abcd', 786 , 2.23, 'john', 70.2 ] and tinylist =
[123, 'john']?
It will print concatenated lists. Output would be ['abcd', 786, 2.23, 'john', 70.200000000000003,
123, 'john'].
What are tuples in Python?
A tuple is another sequence data type that is similar to the list. A tuple consists of a number of
values separated by commas. Unlike lists, however, tuples are enclosed within parentheses.
What is the difference between tuples and lists in Python?
The main differences between lists and tuples are − Lists are enclosed in brackets [] and their
elements and size can be changed, while tuples are enclosed in parentheses ( ) and cannot be
updated. Tuples can be thought of as read-only lists.
What is the output of print tuple if tuple = ′ abcd ′ , 786, 2.23, ′ john ′ , 70.2?
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller endashaan. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $7.99. You're not tied to anything after your purchase.