Q-1: What is Python? What are the
benefits of using Python?
Python is a programming language with objects, modules, threads,
exceptions and automatic memory management. The benefits of pythons are that it
is simple and easy, portable, extensible, build-in data structure and it is an
open source.
Q-2: What is PEP 8?
PEP 8 is a coding convention, a set of recommendation, about how to
write your Python code more readable.
Q-3: What is the full form of PEP?
PEP stands for Python Enhancement Proposal.
Under this, a set of rules and guidelines are published, which guides the
developers to write perfect and readable code.
Q-4: What is the default data type assigned
to variables by Python?
The default data type assigned to a new
variable by Python is "String."
Q-5: How Python is interpreted?
Python language is an interpreted language. Python program runs
directly from the source code. It converts the source code that is written by
the programmer into an intermediate language, which is again translated into
machine language that has to be executed.
Q-6: What is the difference between
list and tuple?
The difference between list and tuple is that list is mutable while
tuple is not. Tuple can be hashed for e.g. as a key for dictionaries.
Q-7: What is Dict and List
comprehensions are?
They are syntax constructions to ease the creation of a Dictionary
or List based on existing iterable.
Q-8: What is namespace in Python?
In Python, every name introduced has a place where it lives and can
be hooked for. This is known as namespace. It is like a box where a variable
name is mapped to the object placed. Whenever the variable is searched
out, this box will be searched, to get corresponding object.
Q-9: In Python what are iterators?
In Python, iterators are used to iterate a group of elements,
containers like list.
Q-10: In Python what is slicing?
A mechanism to select a range of items from sequence types like
list, tuple, strings etc. is known as slicing.
Q-11: What is negative index in
Python?
Python sequences can be index in positive and negative
numbers. For positive index, 0 is the first index, 1 is the second index and
so forth. For negative index, (-1) is the last index and (-2) is the
second last index and so forth.
Q-12: What is module and package in
Python?
In Python, module is the way to structure program. Each Python
program file is a module, which imports other modules like objects and
attributes.
The folder of Python program is a package of modules. A
package can have modules or subfolders.
Q-13: When to use list vs. tuple vs. dictionary vs. set?
List is
like array; it can be used to store homogeneous as well as heterogeneous data
type (It can store same data type as well as different data type). List are
faster compared to array. Individual element of List data can be accessed using
indexing & can be manipulated.
Tuples
are similar to lists, but their data can be changed once created through the
execution of program. Individual element of Tuples can be accessed using
indexing.
Dictionary
are similar to what their name is. In a dictionary, In python, the word is
called a ‘key’, and the definition a ‘value’. Dictionaries consist of pairs of
keys and their corresponding values.
Q-14: Explain the disadvantages of
python.
Disadvantages of Python are:
- Python isn’t the best for memory intensive tasks.
- Python is interpreted language & is slow compared to C/C++ or java.
- Python not a great choice for a high-graphic 3d game that takes up a lot of CPU.
Q-15: Describe Pip in
Python?
Pip is one such package manager of Python.
It contains information about most external dependencies and libraries, whereas
we can install desired libraries through Pip.
0 Comments