100 Python Interview Questions
100 Python Interview Questions
4. What is pep 8?
PEP in Python stands for Python Enhancement
Proposal. It is a set of rules that specify how to write
and design Python code for maximum readability.
7. What is PYTHONPATH?
PYTHONPATH has a role similar to PATH. This variable
tells 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 Python Installer.
29. What are negative indexes and why are they used?
To access an element from ordered sequences, we
simply use the index of the element, which is the
position number of that particular element. The index
usually starts from 0, i.e., the first element has index 0,
the second has 1, and so on.
65. How will you remove the last object from a list in
Python?
list.pop(obj=list[-1]):
Here, −1 represents the last element of the list. Hence,
the pop() function removes the last object (obj) from
the list.
89. How do you split the data in train and test dataset
in python?
This can be achieved by using the scikit machine
learning library and importing train_test_split function
in python as shown below:
Import sklearn.model_selection.train_test_split
ar = np.array([1, 3, 2, 4, 5, 6])
print(ar.argsort()[-3:][::-1])