Python Developer
200+ Python Developer Interview Questions and Answers

Asked in Cognizant

Q. Explain the logic of a program to reverse a given string word by word without using any built-in functions.
The logic of the program is to reverse a given string word by word without using any built-in function.
Split the string into an array of words using whitespace as the delimiter.
Iterate through the array of words in reverse order.
Append each word to a new string, separated by a space.

Asked in Cognizant

Q. What is the difference between a variable and an object?
Variables are names given to memory locations while objects are instances of a class with attributes and methods.
Variables are used to store values while objects are used to represent real-world entities.
Variables can be reassigned to different values while objects have a fixed identity.
Variables are created when they are assigned a value while objects are created using constructors.
Variables can be of different data types while objects are instances of a specific class.
Examp...read more
Python Developer Interview Questions and Answers for Freshers

Asked in TCS

Q. 1. Difference between tuple and a list? 2. What are decorators? 3. What is 'to' object? 4. Program to illustrate the difference between pass, break, continue? 5. Find the error in the given program? 6. Explain...
read moreAnswers to interview questions for a Python developer.
1. Tuples are immutable while lists are mutable.
2. Decorators are functions that modify the behavior of other functions.
3. 'to' object is not a standard term in Python, so it's unclear.
4. Pass does nothing, break exits the loop, and continue skips to the next iteration.
5. Need the given program to identify the error.
6. Explain your projects in detail, highlighting your role and achievements.

Asked in Ernst & Young

Q. How do you convert a .txt file to a .csv file using Python?
To convert a .txt file into a .csv file in Python, you can use the csv module.
Import the csv module
Open the .txt file in read mode
Open a new .csv file in write mode
Use csv.reader to read the .txt file line by line
Use csv.writer to write each line to the .csv file

Asked in Accenture

Q. Write a program to print a string in reverse without using built-in methods.
This program reverses a given string without using any built-in methods.
Iterate through the string from the last character to the first character.
Append each character to a new string to reverse the order.
Return the reversed string as the output.

Asked in Genpact

Q. How do you check if a key exists in a dictionary without raising a KeyError?
To check if a key exists in a dictionary without raising a KeyError.
Use the 'in' keyword to check if the key exists in the dictionary.
Use the 'get' method to return a default value if the key does not exist.
Use the 'keys' method to get a list of all keys and check if the key is in the list.
Python Developer Jobs




Asked in Innominds Software

Mutable objects can be changed after creation, while immutable objects cannot be changed.
Mutable objects: lists, dictionaries, sets
Immutable objects: strings, tuples, numbers
Example: list is mutable - can be modified by adding/removing elements
Example: tuple is immutable - cannot be modified once created
Asked in Certainty Infotech

Q. What is the difference between deep and shallow copy?
Deep copy creates a new object and recursively copies all the objects it references, while shallow copy creates a new object and references the same objects as the original.
Deep copy creates a completely independent copy of an object, including all nested objects.
Shallow copy creates a new object, but references the same nested objects as the original.
Deep copy is useful when you want to modify one object without affecting the other.
Shallow copy is useful when you want to cre...read more
Share interview questions and help millions of jobseekers 🌟

Asked in Google

Q. 6.What are local variables and global variables in Python? 7.When to use a tuple vs list vs dictionary in Python? 8.Explain some benefits of Python 9.What is Lambda Functions in Python? 10.What is a Negative In...
read moreLocal variables are variables that are defined within a function and can only be accessed within that function. Global variables are variables that are defined outside of any function and can be accessed throughout the program.
Local variables are created when a function is called and destroyed when the function completes.
Global variables can be accessed and modified by any function in the program.
Using local variables helps in encapsulation and prevents naming conflicts.
Globa...read more

Asked in Innominds Software

SOAP is a protocol, while REST is an architectural style for web services.
SOAP is a protocol that uses XML for message format and relies on a predefined set of standards (WSDL, SOAP, etc.)
REST is an architectural style that uses standard HTTP methods (GET, POST, PUT, DELETE) and supports multiple data formats (JSON, XML, etc.)
SOAP is more rigid and requires more bandwidth due to its XML format, while REST is more flexible and lightweight
SOAP is commonly used in enterprise app...read more

Asked in Mphasis

Q. Can we change the key of dictionary. What are the criteria to select key of dictionary
Yes, the key of a dictionary in Python can be changed. The criteria for selecting a key are immutability and uniqueness.
The key of a dictionary can be any immutable data type such as strings, numbers, or tuples.
The key must be unique within the dictionary, as duplicate keys are not allowed.
Changing the value of a key is allowed, but changing the key itself requires creating a new key-value pair.
Keys that are mutable, such as lists, cannot be used as dictionary keys.

Asked in BigStep Technologies

Q. How do you retrieve the value associated with a key in a dictionary?
To get the value for a key from a dictionary in Python, use the square bracket notation or the get() method.
Use square brackets and the key name to access the value directly: dictionary[key]
Alternatively, use the get() method to retrieve the value: dictionary.get(key)
If the key is not present in the dictionary, using square brackets will raise a KeyError, while get() will return None or a default value if specified

Asked in CGI Group

Q. What is the difference between Python arrays and lists?
Arrays are homogeneous data structures while lists are heterogeneous data structures in Python.
Arrays are fixed in size while lists are dynamic.
Arrays can only contain elements of the same data type while lists can contain elements of different data types.
Arrays are faster and more memory-efficient for numerical operations.
Lists have more built-in functions and are more versatile for general-purpose programming.
Example of array: import array as arr; a = arr.array('i', [1, 2, ...read more

Asked in Innominds Software

Method overriding in Python is when a subclass provides a specific implementation of a method that is already provided by its parent class.
In method overriding, a subclass can provide a specific implementation of a method that is already defined in its parent class.
The method in the subclass should have the same name, parameters, and return type as the method in the parent class to override it.
Method overriding allows for polymorphism, where a subclass can be treated as its p...read more

Asked in TCS

Q. What are the new features added in the latest version of Python?
Python 3.10 added new features like structural pattern matching, improved error messages, and more.
Structural pattern matching allows for more concise and readable code
Improved error messages make debugging easier
New syntax for specifying precise types
Performance improvements in various areas
New modules and libraries added
Examples: match case, improved error messages, improved typing syntax

Asked in Cognizant

Q. Have you worked on any Python-related development projects?
Yes, I have worked on various python projects including web development, data analysis and automation.
Developed a web application using Django framework
Automated data extraction and analysis using pandas library
Created a chatbot using Python and Dialogflow API
Implemented machine learning algorithms for predictive analysis
Integrated Python scripts with other technologies like AWS and Docker

Asked in TCS

Q. What is linked list, what is array, multidimensional array, nested for loop, polymorphism
A brief explanation of linked list, array, multidimensional array, nested for loop, and polymorphism.
Linked list is a data structure where each element points to the next one.
Array is a collection of elements of the same data type stored in contiguous memory locations.
Multidimensional array is an array with more than one dimension.
Nested for loop is a loop inside another loop.
Polymorphism is the ability of an object to take on many forms.

Asked in Cognizant

Q. What is decorator?why we are using decorator? Write a program for decorator?
A decorator is a design pattern in Python that allows modifying the behavior of a function or class without changing its source code.
Decorators are functions that take another function as an argument and return a new function.
They are used to add functionality to an existing function or class.
They can be used to modify the behavior of a function, such as adding logging or timing functionality.
They can also be used to enforce security or access control.
A decorator is denoted b...read more
Asked in Spectromax Technology Solutions

Q. If we decide to change the domain, should we dedicate 3-6 months to learning about the new domain to achieve our goals effectively?
Agree, taking time to learn the new domain is crucial for success.
Learning the new domain will help us understand the business requirements better.
It will also help us identify potential challenges and opportunities.
We can leverage our existing skills and knowledge to build better solutions.
Taking time to learn the new domain will also help us build credibility with stakeholders.
We can use this time to network and build relationships with experts in the new domain.

Asked in MariApps Marine Solutions

Q. define class and functions.why functions are written inside class.what is the role of a class
A class is a blueprint for creating objects that have properties and methods. Functions are written inside a class to define its behavior.
A class is a user-defined data type that encapsulates data and functions that operate on that data.
Functions written inside a class are called methods and are used to define the behavior of the class.
The role of a class is to provide a template for creating objects that share common properties and behavior.
Classes allow for code reusability...read more

Asked in TCS iON

Q. What is the difference between lists and tuples in Python?
Lists are mutable while tuples are immutable in Python.
Lists use square brackets [] while tuples use parentheses ().
Elements in a list can be added, removed, or modified while tuples cannot be modified.
Lists are used for collections of homogeneous items while tuples are used for heterogeneous items.
Lists are generally used for large collections of data while tuples are used for smaller collections or for data that should not be changed.
Lists are slower than tuples in terms of...read more

Asked in 6Sense

Q. Solve a Data Structures and Algorithms (DSA) problem and discuss the approaches over a Zoom call.
Discussing approaches to solve a DSA problem in a Zoom call.
Understand the problem statement and constraints.
Choose an appropriate data structure and algorithm.
Implement the solution and test it with sample inputs.
Optimize the solution if possible.
Discuss the time and space complexity of the solution.

Asked in TCS

Q. What are generators in Python?
Generators in Python are functions that can be paused and resumed, allowing for efficient memory usage and lazy evaluation.
Generators are created using the yield keyword
They are used to create iterators
Generators produce a sequence of values on-the-fly
They are memory efficient as they generate values one at a time
Generators are useful for processing large datasets or infinite sequences
Asked in Audree Infotech

Q. You have two vessels with capacities of 3L and 5L. You have unlimited water. How can you measure out exactly 1L or 4L of water in one of the vessels?
Using 3L and 5L vessels, achieve 1L and 4L of water through filling and pouring methods.
Fill the 3L vessel completely and pour it into the 5L vessel.
Fill the 3L vessel again and pour it into the 5L vessel until it is full, leaving 1L in the 3L vessel.
To achieve 4L in the 5L vessel, fill the 5L vessel completely from the water source.

Asked in Google

Q. 11.What is the namespace in Python? 12.What is a dictionary in Python? 13.What is type conversion in Python? 14.What is the difference between Python Arrays and lists? 15.What are functions in Python?
Answers to common Python interview questions.
Namespace is a container for storing variables and functions.
Dictionary is a collection of key-value pairs.
Type conversion is the process of converting one data type to another.
Arrays are homogeneous while lists are heterogeneous.
Functions are blocks of code that perform a specific task.

Asked in Tech Mahindra

Q. How do you send data to a database using Python?
Data can be sent to the database using SQL queries or an ORM like Django's ORM.
Use SQL queries to insert, update or delete data in the database.
Use an ORM like Django's ORM to interact with the database using Python code.
Ensure that the data being sent is properly formatted and validated to prevent errors or security issues.

Asked in Cognizant

Q. Have you heard about pickling and non-pickling?
Pickling is a way to serialize Python objects, while non-pickling refers to objects that cannot be pickled.
Pickling is used to convert Python objects into a byte stream that can be stored or transmitted.
Non-pickling objects are those that cannot be serialized using the pickle module.
Examples of non-pickling objects include file objects, network sockets, and database connections.
To make an object picklable, it must be able to be reduced to a string of bytes and then reconstruc...read more

Asked in TCS

Q. What is inheritance and what are its types?
Inheritance is a way to create a new class by inheriting properties and methods from an existing class.
It allows code reusability and saves time.
Types of inheritance are single, multiple, multilevel, and hierarchical.
Single inheritance involves inheriting properties and methods from a single parent class.
Multiple inheritance involves inheriting properties and methods from multiple parent classes.
Multilevel inheritance involves inheriting properties and methods from a parent c...read more

Asked in Calsoft

Q. How is memory managed in Python?
Python uses automatic memory management through a garbage collector.
Python uses reference counting to keep track of objects in memory.
When an object's reference count reaches zero, it is automatically deallocated.
Python also employs a garbage collector to handle cyclic references.
The garbage collector identifies and collects objects that are no longer reachable.
Memory management in Python is transparent to the developer.

Asked in All Hands Global

Q. What are collection data types ? What is HTML what is CSS what is object What is array What is thread What is multi threading
Collection data types are data structures that can hold multiple values in Python.
List: ordered, mutable collection
Tuple: ordered, immutable collection
Set: unordered, mutable collection with no duplicate elements
Dictionary: unordered, mutable collection of key-value pairs
Interview Questions of Similar Designations
Interview Experiences of Popular Companies





Top Interview Questions for Python Developer Related Skills



Reviews
Interviews
Salaries
Users

