Python Interview Question Set 1
Categories: Python
What is Python?
Python was created by Guido van Rossum, and released in 1991.
It is a general-purpose computer programming language. It is a high-level, object-oriented language which can run equally on different platforms such as Windows, Linux, UNIX, and Macintosh. Its high-level built-in data structures, combined with dynamic typing and dynamic binding. It is widely used in data science, machine learning and artificial intelligence domain.
It is widely used for:
a) Web development (server-side).
b) Software development.
c) Mathematics.
d) System scripting.
Why Python?
Python is an interpreted, object-oriented, high-level programming language with dynamic semantics.
Python is compatible with different platforms like Windows, Mac, Linux, Raspberry Pi, etc.
Python has a simple syntax as compared to other languages.
Python allows a developer to write programs with fewer lines than some other programming languages.
Python runs on an interpreter system, means that the code can be executed as soon as it is written. It helps to provide a prototype very quickly.
Python can be described as a procedural way, an object-orientated way or a functional way.
What are the applications of Python?
Python is used in various software domains some application areas are given below.
a) Web and Internet Development
b) Games
c) Scientific and computational applications
d) Language development
e) Image processing and graphic design applications
f) Enterprise and business applications development
g) Operating systems
What are the advantages of Python?
Advantages of Python are:
a) Python is Interpreted language
b) Interpreted: Python is an interpreted language. It does not require prior compilation of code and executes instructions directly.
c) It is Free and open source
d) Free and open source: It is an open-source project which is publicly available to reuse. It can be downloaded free of cost.
e) It is Extensible
f) Extensible: It is very flexible and extensible with any module.
Object-oriented
Object-oriented: Python allows to implement the Object-Oriented concepts to build application solution.
It has Built-in data structure
Built-in data structure: Tuple, List, and Dictionary are useful integrated data structures provided by the language.
What is PEP 8?
PEP 8 stands for Python Enhancement Proposal, it can be defined as a document that helps us to provide the guidelines on how to write the Python code. It is basically a set of rules that specify how to format Python code for maximum readability. It was written by Guido van Rossum, Barry Warsaw and Nick Coghlan in 2001.
What do you mean by Python literals?
Literals can be defined as a data which is given in a variable or constant. Python supports the following literals:
String Literals
String literals are formed by enclosing text in the single or double quotes. For example, string literals are string values.
Example:
# in single quotes
single = 'JavaTpoint'
# in double quotes
double = "JavaTpoint"
# multi-line String
multi = '''''Java
T
point'''
print(single)
print(double)
print(multi)
Output:
JavaTpoint
JavaTpoint
Java
T
point
Explain Python Functions?
A function is a section of the program or a block of code that is written once and can be executed whenever required in the program. A function is a block of self-contained statements which has a valid name, parameters list, and body. Functions make programming more functional and modular to perform modular tasks. Python provides several built-in functions to complete tasks and also allows a user to create new functions as well.
There are three types of functions:
Built-In Functions: copy(), len(), count() are the some built-in functions.
User-defined Functions: Functions which are defined by a user known as user-defined functions.
Anonymous functions: These functions are also known as lambda functions because they are not declared with the standard def keyword.