Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2 views

Python Interview Questions (3)

The document contains a comprehensive list of Python interview questions and answers covering fundamental concepts such as data types, functions, and programming paradigms. It includes explanations of key features, operators, and constructs in Python, as well as practical programming tasks. Additionally, it addresses topics like encapsulation, abstraction, and the differences between various data structures and functions.

Uploaded by

Keerthivasan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Python Interview Questions (3)

The document contains a comprehensive list of Python interview questions and answers covering fundamental concepts such as data types, functions, and programming paradigms. It includes explanations of key features, operators, and constructs in Python, as well as practical programming tasks. Additionally, it addresses topics like encapsulation, abstraction, and the differences between various data structures and functions.

Uploaded by

Keerthivasan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 58

PYTHON

INTERVIEW QUESTIONS
CONCEPT
1) what is python

• Python is an interpreted and high-level programming language.


• Python supports modules, objects, threads, automatic memory
management, and exception handling.
2. what are the key features of the python programming
language?

• Python is dynamically typed and you don’t need to state the


types of variables when you declare them
• In Python, functions can be assigned to variables
• It is well suited to object-orientated programming
3) why python is an interpreted language?

• An interpreted language is any programming language that is


not in machine-level code before runtime.Therefore, Python is
an interpreted language.
4) what is namespace in python?

• A namespace is just a naming system. It makes sure that all the


names are unique and also prevents naming conflicts.
5)what is a list in python?

• The list is a data structure in python that allows you to store


different types of data in it. Every value inside the list is called
an item. Lists are represented as the values in between the
square bracket.
6) what are local variables and global variables?

• Global Variables are the variables declared outside a function or


in global space are called global variables. A local variable is a
variable that is declared inside a function.
7)what are the functions in python?

• A function is a block of code that is executed only when it is


called.
8) Is indentation required in python?

• Indentation is necessary for Python as it specifies a block of


code. All code within loops, classes, functions, etc. is specified
within an indented block
9) what is the difference between python arrays and lists?

• In Python, Arrays and Lists have the same way of storing data.
Arrays can hold single data type elements and lists can hold any
data type elements.
10) what are the generators?

• Generators are functions that return an iterable set of items.


11) what are python packages?

• Python packages are namespaces containing multiple modules.


12)what is dict in python?

• It is a collection of data that is used to store data values. It is a


built-in function and is also known as associative arrays in other
programming languages.
13) what is a pass in python?

• Pass statement is a null operation and nothing happens when it


is executed. It is used for making the code syntactically correct.
14) what are positive and negative indices?

• When positive indices are applied then the search begins from
left to right whereas when negative indices are applied then the
search begins from right to left
15) what is the use of relational, assignment, and membership
operators in python?

• Relational operators – They are used to compare values


• Assignment operators – They are used to assign value to the
variables
• Membership operators – It validates the membership of a value.
16) what is the index in python?

• Index refers to a position in a list or string. The string is a list of


characters and you access them with the help of an index.
17) what is the lambda function in python?

• You can create an anonymous function with the help of the


lambda function. It can accept any number of arguments but it
can only have one statement.
18) what is self in python?

• Self represents the object of a class. You can differentiate


between attributes and methods of the class with the help of
self.
19) what are decorators in python?

• A Python decorator is a specific modification that we make in


code syntax to alter Python functions easily.
20) what are iterators in python?

• In Python, iterators are used to iterate over iterable objects


such as lists, tuples, dicts, and sets.
21) what is scope in python?

• Every object in python remains relevant in a specific area that is defined to it, which is
called scope.There are different type of scope that are created during code execution in
python and that is,
• Local scope
• Global scope
• Module-level scope
• Outermost scope
22) What is Polymorphism in Python?

• Polymorphism means the ability to take multiple forms. So, for


instance, if the parent class has a method named ABC then the
child class also can have a method with the same name ABC
having its own parameters and variables.
23) what is __init__ in python?

• Equivalent to constructors in OOP terminology, __init__ is a


reserved method in Python classes. The __init__ method is called
automatically whenever a new object is initiated.This method
allocates memory to the new object as soon as it is created. This
method can also be used to initialize variables.
24) what is a map function in python?

• The map() function in Python has two parameters, function and iterable.
• The map() function takes a function as an argument and then applies that
function to all the elements of an iterable, passed to it as another
argument. It returns an object list of results.
25) what does *args and **kwargs mean?

• .*args: It is used to pass multiple arguments in a function.


• **kwargs: It is used to pass multiple keyworded arguments in a
function in python
26) define encapsulation in python?

• encapsulation in Python refers to the process of wrapping up


the variables and different functions into a single entity or
capsule. Python class is the best example of encapsulation in
python.
27) What is Abstraction?

• Abstraction is used to hide the internal functionality of the function


from the users.
• The users only interact with the basic implementation of the
function, but inner working is hidden.
28) What is Abstraction?

• Abstraction is used to hide the internal functionality of the function


from the users.
• The users only interact with the basic implementation of the
function, but inner working is hidden.
29) what is the difference between remove() function and del
statement?

• The remove() function deletes the matching element/object,


• del removes the element at a specific index.
30) why do we use join() function in python?

• The join() work is a string method that profits a string linked


with the components of an iterable.
• This technique gives an adaptable method to connect string.
• It links every component of an iterable, to the string and
afterward restores the connection string.
31) what is swapcase() function in python?

• The string swapcase() strategy changes over every single


capitalized character to lowercase and do the other way
around of the given string, and returns it.
32) what is pip software in the python world?

• PIP is nothing but a package manager (containing all the


records required for a module) or a standard package
management system that is used to install as well as manage
software packages written in Python.
33) how does for loop and while loop differ in python?

• A for loop is used when we know how many times the code
should run.That particular piece of code will iterate “n”
number of times.
• while loop is used in code to repeat some statements, and it
runs until a condition is false. It is almost similar to “if
statement” except that it does not run only once.
34) which databases are supported by python?

• A database is a structured set of data that is held in a


computer and is accessible in numerous ways.
• The two most common databases supported by Python are
PostgreSQL and MySQL.
35) what is the use of assertions in python?

• An assertion checks if the returned boolean value is 0 or 1. For


1, the next code line is executed. For 0, an error message is
shown.
PROGRAMMATIC
1) python program to reverse a number
2) prime number program in python
3) python program to find greatest of three numbers
4) program to check given number representation is in binary
or not
5) swap two variables without using the third variable in
python
6)python program to find the average of numbers
7)python program to remove character from string
8)python code to remove vowels from the string
9) python program to concatenate string using join() method
10) python code to find sum of integers in the string
11) python program to sort string character in descending
order
12) python program to find ascii value of character
13) python program for average of numbers in a list
14) python program to swap two elements in a list
15) how to check if a number is repeated in a list in python
16) find duplicates in a list in python
17) how to compare two lists in python
18) reverse each word of a string in python
19) print only the uppercase letters in the string python
20) remove special characters from list python

You might also like