Top 100+ Python Interview Questions and Answers in 2019

Best Software training institutes in Hyderabad - Ojango.org

Top 100+ Python Interview Questions and Answers in 2019

January 25, 2019 Interviews 3
latest python interview questions and answers , top 50 interview questions and answers for python

Basic Python Interview Questions

1.What is python?
Ans:
Python is an interpreted, high-level, general-purpose programming language. Created by Guido van Rossum in 1989
and it was first released in 1991.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.

2.What is the main use of Python?
Ans:
Python is a general purpose programming language. Hence, you can use the programming language
for developing both desktop and web applications. Also, you can use Python for developing complex scientific and numeric applications.
Python is designed with features to facilitate data analysis and visualization.
Python is a scripting language like PHP, Perl, Ruby and so much more. It can be used for web programming
(django, Zope, Google App Engine, and much more). But it also can be used for desktop applications (Blender 3D, or even for games pygame).
Python can also be translated into binary code like java.

3.Name some of the features of Python?
Ans:
a)Simple and easy to learn:
Python is simple and easy to learn, read and write. It is developer-friendly and high level programming language.
The syntax isn’t too annoying compared to other languages, and you can import a bunch of modules which can often make your code much shorter.
There are excellent, straightforward tools to work with python code, especially the interactive interpreter ; you don’t need to learn a build system,
IDE, special text editor, or anything else to start using python.
*All you need only a command prompt and the interactive editor.
*The syntaxes of python language are very simple. Anybody can remember the python language syntaxes, rules and regulations very easily.
*The elegant syntaxes of the python language makes the people to learn python in easiest manner.
*With out having any other programming languages knowledge, we can learn python directly.
*The simple and powerful syntax of python language makes the programmers to express their business logic in less lines of code.

b)Interpreted Language:
*Like PHP, Python is also interpreted language i.e. interpreter executes the code line by line at a time. This makes debugging easy and thus suitable for beginners.
*When you use an interpreted language like Python, there is no separate compilation and execution steps.
You just run the program from the source code. This makes debugging easy and thus suitable for beginners
*Python applications does not require explicit compilation so that compiler is not require for python software.
*Python interpreter is responsible for execution of python applications.
When ever we run a python application, the python interpreter checks for the syntax errors. If there is no syntax errors found in our
code then the interpreter converts the code into intermediate code in the form of low level format and executes it.
*The intermediate code of the python applications is known as byte code.
*The extension of the byte code file is .pye (Python Compile Code).

c)Cross-Platform Language:
Python can run equally on different platforms such as Windows, Linux, Unix , Macintosh etc.
A Python program written on a Macintosh computer will run on a Linux system and vice versa. Thus, we can say that Python is a portable language.

d) Free and Open Source & Redistribution:
*Python is an example of a FLOSS (Free/Libre and Open Source Software).In simple terms, you can freely distribute copies of this software,
read the software’s source code, make changes to it.
*Python is a open source language, so that anyone can use the python software without purchasing licence.
*Anyone can read the python source code and can able to do the modification in the source code and also we can redistribute that code to others.
*Python language is freely available at offical web address.The source-code is also available. Therefore it is open source.

e)Object-Oriented Language:
*Python supports object oriented features and concepts of classes and objects come into existence.
*Python language supports both Procedural Oriented Programming and Object Oriented Programming features.
We can implement OOPs features like Encapsulation, polymorphic, inheritance and abstraction in python programming language.

f)Extensive Libraries :
*Python language is proving huge built in libraries. Developers can use the built in libraries for their applications.
*By making use of these built in libraries, development will become faster.
*We can easily add and use the third party libraries in Python applications.

g)Integrated:
Python can be easily integrated with languages like C, C++, JAVA etc.

h)portability:
*The python applications or portable. The applications which are developed by python on one platform are
going to execute any platform with out making any changes (re-compiling is not required).
*To achieve the portability feature with respect to the every operating system a separate python software is developed for every version of python.

i)High Level Language :
*Python is a high level language.
*While developing python applications, developers no need to bother about memory management.

j)Dynamically Typed Language :
*Python is a dynamically typed language. I mean, in python there is no need to declare type of a variable.
*Whenever we assign a value to the variable, based on the value the type will be allocated automatically.

k)Python is Embeddable :
*We can embed the python code into other languages such as C,C++, Java and Etc..
*In order to provide the scripting capabilities to other languages we can use the python code in it.

l)GUI Programming Support:
*Graphical user interfaces can be developed using Python.
*We can develop the GUI based applications using Python Languages.
*We can also develop the Web applications using Python Language.

4)What can Python do?
*Python can be used on a server to create web applications.
*Python can be used alongside software to create workflows.
*Python can connect to database systems. It can also read and modify files.
*Python can be used to handle big data and perform complex mathematics.
*Python can be used for rapid prototyping, or for production-ready software development.

5)Who is python used?
Ans:
*The popular youtube video sharing is used service is largely writtn in python.
*Google makes extensive use of python in its web serach systems.
*Dropbox storage service codes both its server and desktop client software primarily in python.
*The Raspberry pi is a singleboard computer promotes a python as its educational language.
*BitTorrent peer-to-peer file sharing is began its life as a python program.
*NASA,Los Alamos,Fermilab,JPL and others use python for scientific programming task.
*The NASA uses python for cryptography and intellgence analysis.
*Netflix and Yelp have both documented the role of python in their software infrastructures.

6)Where is python used?
Ans:Python is used in:
*Network Programming:Python provides access to network services.
*Machine Learning:Python can be used to develop multiple programs for computers that can access data.
*Game Developement:Python is good language of rapid developement of Game prototyping.
*Web and Internet Developement:Python can be used to build server-side web applications.

7)What is scripting?
Ans:
*As we use python to handle other software system in a specific environment, the scripts should be written in IDE and get executed
*A scripting language is a programming language designed for integrating and communicating with other programming languages.
*Scripts are basically, programs written for run-time environment which automates the xection of tasks.
Example:When the program starts to execute, line-by-line execution is done as per script.

8)Why is python called a scripting language?
Ans:
Many people only knows that python is a programming language, but python is also used as scripting language.
Scripting language:
Scripting language or script is a programming language that supports scripts.
In Scripting:
-The code is written in the form of scripts and gets executed.
-Machine reads and interprets the code.
-Error checking is done at runetime.
-Once the code is checked it can be used several times.

9)What is python interpreter?
Ans:
*Python interpreter is a program that reads and executes the code.
*This includes source code,pre-compiled code and scripts.
Example:help(‘for’)
-When we execute this command,all the information regarding to this syntax ,where can be used this command will be displayed on the interpreter screen.
-This will help us to use specific command to perform specific operation.

10)What is the best python interpreter?
Ans:
PyCharm: PyCharm is a powerful, cross-platform, highly customizable and pluggable Python IDE, which integrates all developments tools in one place.
some other IDE’s are:
Wing Python IDE. …
Eric Python IDE. …
PyDev For Eclipse. …
Spyders Scientific PYthon IDE. …
Pyzo Python IDE. …
GNU Emacs For Python Programming. …
Vim Editor.

11. What is the difference between list and tuples?

List:

Lists are mutable i.e they can be edited.

Lists are slower than tuples.

Syntax:list_1=[10,’chelsa’, 20]

Tuples:

Tuples are immutable(tuples are lists which cannot be edited)

Tuples are faster than lists.

Syntax:typle_1(10,’chelsa’,20)

12. What are the key features of Python?

1.Python is an interpreted language. That means that, unlike languages like C and its variants,

Python does not need to be compiled before it is run.

Other interpreted languages include PHP and Ruby.

2.Python is dynamically typed, this means that you don’t

 need to state the types of variables when you declare them or anything like that.

 You can do things like x=111 and then x=”I’m a string” without error

3.Python is well suited to object orientated programming in

that it allows the definition of classes along with composition and inheritance.

Python does not have access specifiers (like C++’s public, private), the justification for this point is given as “we are all adults here”

4.In Python, functions are first-class objects. This means that they can be assigned to variables,

returned from other functions and passed into functions.

Classes are also first class objects

5.Writing Python code is quick but running it is often slower than compiled languages.

Fortunately,Python allows the inclusion of C based extensions so bottlenecks can be optimized away and often are.

6.The numpy package is a good example of this, it’s really quite quick because a lot

of the number crunching it does isn’t actually done by Python

Python finds use in many spheres – web applications, automation, scientific modelling,

big data applications and many more. It’s also often used as “glue” code to get other languages and components to play nice.

13. What is the difference between deep and shallow copy?

Ans: Shallow copy is used when a new instance type gets created and it keeps the values that are copied in the new instance.

Shallow copy is used to copy the reference pointers just like it copies the values. These references point to the original objects

and the changes made in any member of the class will also affect the original copy of it.

Shallow copy allows faster execution of the program and it depends on the size of the data that is used.

Deep copy is used to store the values that are already copied. Deep copy doesn’t copy the reference pointers to the objects.

It makes the reference to an object and the new object that is pointed by some other object gets stored.

The changes made in the original copy won’t affect any other copy that uses the object. Deep copy makes execution of the program slower due to

making certain copies for each object that is been called.

14. How is Multithreading achieved in Python?

Ans:

Python has a multi-threading package but if you want to multi-thread to speed your code up,

then it’s usually not a good idea to use it.

Python has a construct called the Global Interpreter Lock (GIL).

The GIL makes sure that only one of your ‘threads’ can execute at any one time.

A thread acquires the GIL, does a little work, then passes the GIL onto the next thread.

This happens very quickly so to the human eye it may seem like your threads are executing in parallel,

but they are really just taking turns using the same CPU core.

All this GIL passing adds overhead to execution. This means that if you want to make your code run faster then using the

threading package often isn’t a good idea.

15. How can the ternary operators be used in python?

Ans: The Ternary operator is the operator that is used to show the conditional statements.

This consists of the true or false values with a statement that has to be evaluated for it.

Syntax:

The Ternary operator will be given as:

[on_true] if [expression] else [on_false]x, y = 25, 50big = x if x < y else y

Example:

The expression gets evaluated like if x<y else y, in this case if x<y is true then the value is returned as big=x and

if it is incorrect then big=y will be sent as a result.

16.How to transform a string to list and list to string in python?
Ans:String to list:
Example:a=’python’
list=list(a)
print(list)
Output:[‘p’, ‘y’, ‘t’, ‘h’, ‘o’, ‘n’]

List to String:While converting from list to string use join metthod and pass the variable to join method.
Example:list=[‘p’, ‘y’, ‘t’, ‘h’, ‘o’, ‘n’]
string=’ ‘.join(list)
print(list)
Output:python

17.What is negative index in python?
Ans:
Negative index is used in python to index starting from the last element of the list, tuple or any other container class
which supports indexing. -1 refers to the last index, -2 refers to the second last index and so on.

For lists :

array = [0,1,2,3,4,5]

array[-1]=5

For strings :

string = “Hello!”

string[-1]=’!’

18.What is the differe ces between python2 and python3?
Ans:
Python2:
*In Python 2, “print” is treated as a statement rather than a function that does not need a parenthasis.
*Python 2 treats numbers that you type without any digits after the decimal point as integers, which can lead to some unexpected
results during division.As a result it will give truncated value.
For example, if you type the expression 3 / 2 in Python 2 code, the result of the evaluation will be 1, not 1.5 as you might expect.
This is because Python 2 assumes that you want the result of your division to be an integer, so it rounds the calculation down to the nearest whole number.
In order to get the result 1.5, you would have to write 3.0 / 2.0 to tell Python that you want it to return a
float, that is, to include digits after the decimal point in the result.
*range() returns lists in python2.
Python3:
*python 3, “print is treated as function and value needs to be written in parenthesis.

  • Python 3 evaluates 3 / 2 as 1.5 by default it gives decimal value, which is more intuitive for new programmers.
    *range() etc return iteretors or genetrators in python3.

19.What does zip() d0?
Ans:
The purpose of zip() is to map the similar index of multiple containers so that they can be used just using as single entity.In other words,
it will take mutiple lists and transform them into a single list of tuples.Whenever the given lists are of different lengths,zip stops generating tuples
when the first list ends.
Syntax :
zip(*iterators)
Parameters :
Python iterables or containers ( list, string etc )
Return Value :
Returns a single iterator object, having mapped values from all the
containers.
Example:name = [ “Manjeet”, “Nikhil”, “Shambhavi”, “Astha” ]
roll_no = [ 4, 1, 3, 2 ]
marks = [ 40, 50, 60, 70 ]
mapped = zip(name, roll_no, marks)
mapped = set(mapped)
The zipped result is : {(‘Shambhavi’, 3, 60), (‘Astha’, 2, 70),
(‘Manjeet’, 4, 40), (‘Nikhil’, 1, 50)}

Ex2:

list of 4 elements

ist1 = [‘Alpha’, ‘Beta’, ‘Gamma’, ‘Sigma’]

list of 5 elements

list2 = [‘one’, ‘two’, ‘three’, ‘six’, ‘five’]

list of 3 elements

list3 = [1, 2, 3]

test = zip(list1, list2, list3) # zip the values
cnt = 0

print(‘\nPrinting the values of zip’)
for values in test:
print(values) # print each tuples
cnt+=1

print(‘Zip file contains ‘, cnt, ‘elements.’);

Output:
Printing the values of zip
(‘Alpha’, ‘one’, 1)
(‘Beta’, ‘two’, 2)
(‘Gamma’, ‘three’, 3)
Zip file contains 3 elements.

20)Explain the shortest way to open a text file and display its contents?
Ans:
with open(“file-name”, “r”) as fp:
fileData=fp.read()
print(fileData)

21)When are dictonary,list and set used?
Ans:
Dictonary:
A Python dictionary is a mapping of unique keys to values. Dictionaries are mutable, which means they can be changed.
A dictionary is a collection which is unordered, changeable and indexed. In Python dictionaries are written with curly brackets, and they have keys and values.

List:
A list is a collection which is ordered and changeable. In Python lists are written with square brackets.
Lists are just like the arrays, declared in other languages. Lists need not be homogeneous always which makes it a most powerful tool in Python.
A single list may contain DataTypes like Integers, Strings, as well as Objects. Lists are also very useful for implementing stacks and queues.
Lists are mutable, and hence, they can be altered even after their creation.

Set:
A set is an unordered collection of items. Every element is unique (no duplicates) and must be immutable (which cannot be changed).
However, the set itself is mutable. We can add or remove items from it.
Sets can be used to perform mathematical set operations like union, intersection, symmetric difference etc.
A set is created by placing all the items (elements) inside curly braces {}, separated by comma or by using the built-in function set().
It can have any number of items and they may be of different types (integer, float, tuple, string etc.).
But a set cannot have a mutable element, like list, set or dictionary, as its element.

22)How do you create a dictonary which can preserve the order of pairs?
Ans:
Python dictionaries iterate over pairs in an arbitrary order, hence they do not preserve the insertion order of pairs.
We can maintain an order to the elements in our dictionary by using “OrderedDict” from the collections module rather than a standard dictionary.
An “OrderedDict” is a dictonary subclass that remembers the order in which its contents are added.

23)What is PEp8?
Ans:
PEP 8 is Python’s style guide. It’s a set of rules for how to format your Python code to maximize its readability. Writing code to a specification helps to make
large code bases, with lots of writers, more uniform and predictable, too.PEP is actually an acronym that stands for Python Enhancement Proposal.
PEP stands for Python Enhancement Proposal. A PEP is a design document providing information to the Python community, or describing a new
feature for Python or its processes or environment.
The PEP should provide a concise technical specification of the feature and a rationale for the feature.

24)What is *args and **kwargs?
Ans:
Basically, *args kind of means any number of arguments and **kwargs – means any number of arguments with keywords.
The special syntax, *args and *kwargs in function definitions is used to pass a variable number of arguments to a function. The single asterisk form (args) is used to pass a non-keyworded,variable-length argument list, and the double asterisk form is used
to pass a keyworded, variable-length argument list.

25)What is meant by floor division?
Ans:
In Python 3.0, 5 / 2 will return 2.5 and 5 // 2 will return 2 . The former is floating point division, and the latter is floor division,
sometimes also called integer division.

26)What are command line arguments?
Ans:
Python Command line arguments are input parameters passed to the script when executing them. Almost all programming language provide support for command
line arguments.We have command line options to set some specific options for the program.
There are many options to read python command line arguments. The three most common ones are:
1.Python sys.argv
2.Python getopt module
3.Python argparse module

27)How modules are accessed in python?
Ans:
In Python,modules are accessed by using import statement.

28)Why list are slower than tuples?
Tuples are stored in a single block of memory. Tuples are immutalbe so, It doesn’t require extraspace to store new objects.
Lists are allocated in two blocks: the fixed one with all the Python object information and a variable sized block for the data.
It is the reason creating a tuple is faster than List.

29)What is Python What are the benefits of using Python?
Ans:Python is a high-level, interpreted and general-purpose dynamic programming language that focuses on code readability. The syntax in Python helps the programmers to do coding in fewer steps as compared to Java or C++. The language founded in the year 1991 by the developer Guido Van Rossum has the programming easy and fun to do. The Python is widely used in bigger organizations because of its multiple programming paradigms. They usually involve imperative and object-oriented functional programming.
It has a comprehensive and large standard library that has automatic memory management and dynamic features.
Advantages of python:
a.Extensive Support Libraries:
It provides large standard libraries that include the areas like string operations, Internet, web service tools, operating system interfaces and protocols.
Most of the highly used programming tasks are already scripted into it that limits the length of the codes to be written in Python.
Integration Feature:
Python integrates the Enterprise Application Integration that makes it easy to develop Web services by invoking COM or COBRA components.
It has powerful control capabilities as it calls directly through C, C++ or Java via Jython. Python also processes XML and other markup languages as it can run on all modern operating systems through same byte code.
Improved Programmer’s Productivity:
The language has extensive support libraries and clean object-oriented designs that increase two to ten fold of programmer’s productivity while using the languages
like Java, VB, Perl, C, C++ and C#.
Productivity:
With its strong process integration features, unit testing framework and enhanced control capabilities contribute towards the increased speed for most
applications and productivity of applications. It is a great option for building scalable multi-protocol network applications.

Disadvantages of python:
Difficulty in Using Other Languages:
The Python lovers become so accustomed to its features and its extensive libraries, so they face problem in learning or working on other programming languages.
Python experts may see the declaring of cast “values” or variable “types”, syntactic requirements of adding curly braces or semi colons as an onerous task.

Weak in Mobile Computing:
Python has made its presence on many desktop and server platforms, but it is seen as a weak language for mobile computing.
This is the reason very few mobile applications are built in it like Carbonnelle.

Gets Slow in Speed
Python executes with the help of an interpreter instead of the compiler, which causes it to slow down because compilation and execution help it to work normally.
On the other hand, it can be seen that it is fast for many web applications too.

Run-time Errors
The Python language is dynamically typed so it has many design restrictions that are reported by some Python developers.
It is even seen that it requires more testing time, and the errors show up when the applications are finally run.

Underdeveloped Database Access Layers
As compared to the popular technologies like JDBC and ODBC, the Python’s database access layer is found to be bit underdeveloped and primitive. However, it cannot be applied in the enterprises that need smooth interaction of complex legacy data.

Conclusion

Python is a robust programming language and provides an easy usage of the code lines, maintenance can be handled in a great way,
and debugging can be done easily too. It has gained importance across the globe as computer giant Google has made it one of its official programming languages.

30)What is the use of end in Python?
The print() function inserts a new line at the end, by default. In Python 2, it can be suppressed by putting ‘,’ at the end.
In Python 3, “end =’ ‘” appends space instead of newline.

40)How do I run a Python script from the command line?
Run a Python script under Windows with the Command Prompt. Note that you must use the full path of the Python interpreter.
If you want to simply type python.exe C:\Users\Username\Desktop\my_python_script.py you must add python.exe to your PATH environmental variable.

41)How is Python interpreted?
An interpreted language is any programming language that isn’t already in “machine code” prior to runtime. … so, Python will fall under byte code interpreted. The .py source code is first compiled to byte code as .pyc.
This byte code can be interpreted (official CPython), or JIT compiled (PyPy).

42)Why is C faster than Python?
Python is slower than C because it is an interpreted language. … The difference is that the python code will be interpreted, instead of directly by the CPU.
This makes all the difference in the world, with regard to performance. Python code almost always runs in a virtual machine.

43) Compare Java & Python
Criteria Java Python
Ease of use Good Very Good
Speed of coding Average Excellent
Data types Static typed Dynamically typed
Data Science & machine learning applications Average Very Good

10). What are the supported data types in Python?
Python has five standard data types –

Numbers
String
List
Tuple
Dictionary

43.How is memory managed in Python?
Python memory is managed by Python private heap space. All Python objects and data structures are located in a private heap. The programmer does not have an access to this private heap and interpreter takes care of this Python private heap.
The allocation of Python heap space for Python objects is done by Python memory manager. The core API gives access to some tools for the programmer to code.
Python also have an inbuilt garbage collector, which recycle all the unused memory and frees the memory and makes it available to the heap space.

  1. Explain Inheritance in Python with an example.
    Inheritance allows One class to gain all the members(say attributes and methods) of another class. Inheritance provides code reusability, makes it easier to create and maintain an application. The class from which we are inheriting is called super-class and the class that is inherited is called a derived / child class.
    They are different types of inheritance supported by Python:
    Single Inheritance – where a derived class acquires the members of a single super class.
    Multi-level inheritance – a derived class d1 in inherited from base class base1, and d2 is inherited from base2.
    Hierarchical inheritance – from one base class you can inherit any number of child classes
    Multiple inheritance – a derived class is inherited from more than one base class.

44.What is dictionary in Python?
The built-in datatypes in Python is called dictionary. It defines one-to-one relationship between keys and values. Dictionaries contain pair of keys and their corresponding values. Dictionaries are indexed by keys.

Let’s take an example:

The following example contains some keys. Country, Capital & PM. Their corresponding values are India, Delhi and Modi respectively.

dict={‘Country’:’India’,’Capital’:’Delhi’,’PM’:’Modi’}

print dict[Country]

45)How will you reverse a list?
Ans:
list.reverse() – Reverses objects of list in place.

46)How will you remove last object from a list?
Ans:
list.pop(obj=list[-1]) – Removes and returns last object or obj from list.

47)Is Python object oriented? what is object oriented programming?
Ans:
Yes. Python is Object Oriented Programming language. OOP is the programming paradigm based on classes and instances of those classes called objects. The features of OOP are:
Encapsulation, Data Abstraction, Inheritance, Polymorphism.

48)How is Python executed?
Ans:
Python files are compiled to bytecode. which is then executed by the host.
Alternate Answer:
Type python .pv at the command line.

49.What are control statements or control structures?
Ans:
Control Flow Statements:
A program’s control flow is the order in which the program’s code executes.
The control flow of a Python program is regulated by conditional statements, loops, and function calls. In other words,it defines in which order instruction will be
executed in the program.
There are three types of flow control
a)Decision (or) Conditional statements
b)Sequential (or) Transfer
c)Iterative control

50.What are Python decorators?
Decorators provide a simple syntax for calling higher-order functions. By definition, a decorator is a function that takes another function and extends the
behavior of the latter function without explicitly modifying it.

51.Why do we use decorators in python?
Python Decorators – Key Takeaways. Decorators define reusable building blocks you can apply to a callable to modify its behavior without permanently modifying
the callable itself. The @ syntax is just a shorthand for calling the decorator on an input function.

python interview questions on Strings in Python

52.What is a string in python?
Ans:
A string is a sequence of characters.Strings are immutable. This means that once defined,they cannot be changed.A character is simply a symbol. For example, the English language has 26 characters.
Computers do not deal with characters, they deal with numbers (binary). Even though you may see characters on your screen, internally it is stored and manipulated as a combination of 0’s and 1’s.
This conversion of character to a number is called encoding, and the reverse process is decoding. ASCII and Unicode are some of the popular encoding used.
In Python, string is a sequence of Unicode character. Unicode was introduced to include every character in all languages and bring uniformity in encoding.

53.How to create a string in Python?
Ans:
Strings can be created by enclosing characters inside a single quote or double quotes.
Even triple quotes can be used in Python but generally used to represent multiline strings and docstrings.

54.What is string indexing in python?
Ans:
String Indexing. The beginning character of a string corresponds to index 0 and the last character corresponds to the index (length of string)-1 .
The length of a string is the number of characters it contains, including spaces, punctuation, and control characters.

55.What does Len mean in Python?
In computer programs, len is the name of one of the major string functions. It stands for length, and returns the length of a specific string.
Many common programming languages operate on strings using string functions.

56.How do you comment in Python?
Comments in Python start with the hash character, # , and extend to the end of the physical line. A comment may appear at the start of a line or following whitespace or code, but not within a string literal.
A hash character within a string literal is just a hash character.

57.ow do you append to a list in Python?
Here are some other common list methods.
list.append(elem) — adds a single element to the end of the list. …
list.insert(index, elem) — inserts the element at the given index, shifting elements to the right.
list.extend(list2) adds the elements in list2 to the end of the list.

58.How do you declare a variable in Python?
Declaring a variable means binding it to a data type. Declaration of variables is not required in Python. If there is need of a variable, you think of a name and start using it as a variable.
Another remarkable aspect of Python: Not only the value of a variable may change during program execution but the type as well.

59.What does triple quotes mean in Python?
String literals inside triple quotes, “”” or ”’, can span multiple lines of text.
Python strings are “immutable” which means they cannot be changed after they are created (Java strings also use this immutable style). The len(string) function returns the length of a string.

60.What is string Ascii_lowercase?
Python string. | ascii_lowercase. In Python3, ascii_lowercase is a pre-initialized string used as string constant. In Python, string ascii_lowercase will give the lowercase letters ‘abcdefghijklmnopqrstuvwxyz.

10.What is a format string?
The Format String exploit occurs when the submitted data of an input string is evaluated as a command by the application.
The Format Function is an ANSI C conversion function, like printf, fprintf, which converts a primitive variable of the programming language into a human-readable string representation.

3 Responses

  1. Mahesh says:

    The great stuff I have seen here

  2. Aly Chiman says:

    Hello there,

    My name is Aly and I would like to know if you would have any interest to have your website here at ojango.org promoted as a resource on our blog alychidesign.com ?

    We are in the midst of updating our broken link resources to include current and up to date resources for our readers. Our resource links are manually approved allowing us to mark a link as a do-follow link as well
    .
    If you may be interested please in being included as a resource on our blog, please let me know.

    Thanks,
    Aly

Leave a Reply

Your email address will not be published. Required fields are marked *

RSS
Follow by Email
Facebook
Facebook
Google+
http://ojango.org/top-100-python-interview-questions-and-answers-ojango-org">
Twitter