DXC TECHNOLOGY – Python Interview Questions
Here is the list of Python Interview Questions which are recently asked in DXT Technology company. These questions are included for both Freshers and Experienced professionals. Our Python Training has Answered all the below Questions.
There are total four rounds for recruitment process:
- Written Test (Aptitude, Verbal, Technical)
- Communication round
- Technical round
- HR round
1. What type of a language is python? Interpreted or Compiled?
Python is an “interpreted” language. This means it uses an interpreter. An interpreter is very different from the compiler. An interpreter executes the statements of code “one-by-one” whereas the compiler executes the code entirely and lists all possible errors at a time.
2. What do you mean by python being an “interpreted language”?
Python is called an interpreted language because it goes through an interpreter, which turns code you write into the language understood by your computer's processor. ... Python is an “interpreted” language. This means it uses an interpreter. An interpreter is very different from the compiler
3. Is python statically typed or dynamically typed?
Python is dynamic typed and strong typed; Java is static typed and strong typed; PHP is dynamic typed and weak typed; C is static typed and weak typed (owing to its casting ability).
4. Is python strongly typed or weakly typed language?
Python is both a strongly typed and a dynamically typed language. Strong typing means that variables do have a type and that the type matters when performing operations on a variable.
Dynamic typing means that the type of the variable is determined only during runtime.
5. What is the python syntax for switch case statements?
Compiler generates a jump table for switch case statement.The switch variable/expression is evaluated once. Switch statement looks up the evaluated variable/expression in the jump table and directly decides which code block to execute.
If no match is found, then the code under default case is executed.
6. What is a lambda statement? Provide an example.A Lambda Function in Python programming is an anonymous function or a function having no name. It is a small and restricted function having no more than one line.
Example: adder = lambda x, y: x + y print (adder (1, 2)) Output: 3
7. What are the rules for local and global variables in Python?Rules for local and global variables in python
- In python, the variables referenced inside a function are global.
- When a variable is assigned new value anywhere in the body of a function then it is assumed as local.
- In a function, if a variable ever assigned new value then the variable is implicitly local and explicitly it should be declared as global.
8. What are generators in Python?
A Python generator is a function that produces a sequence of results. It works by maintaining its local state, so that the function can resume again exactly where it left off when called subsequent times. Thus, you can think of a generator as something like a powerful iterator.
9. How memory management is done in Python?
The Python memory manager manages chunks of memory called “Blocks”. A collection of blocks of the same size makes up the “Pool”. Pools are created on Arenas, chunks of 256kB memory allocated on heap=64 pools. If the objects get destroyed, the memory manager fills this space with a new object of the same size.
10. What are the global and local variables in Python?
There are two types of variables: global variables and local variables. The scope of global variables is the entire program whereas the scope of local variable is limited to the function where it is defined
11. What can you use Python generator functions for?
Uses of generators in Python
Python provides a generator to create your own iterator function. A generator is a special type of function which does not return a single value, instead, it returns an iterator object with a sequence of values. In a generator function, a yield statement is used rather than a return statement.
12. When is not a good time to use python generators?
In general, don't use a generator when you need list operations, like len(), reversed(), and so on. There may also be times when you don't want lazy evaluation (e.g. to do all the calculation up front so you can release a resource). In that case, a list expression might be better.
13. What is the difference between range and xrange functions?
As range() returns the list, all the operations that can be applied on the list can be used on it. On the other hand, as xrange() returns the xrange object, operations associated to list cannot be applied on them, hence a disadvantage.
14. What is PEP8?
Python provides a coding style known as PEP 8. PEP refers to Python Enhancement Proposals and is one of the most readable and eye-pleasing coding styles. Since it is used by many projects all across the world, programmers should familiarize themselves with it.
15. Explain how to copy an object in Python.?
In Python, we use = operator to create a copy of an object. You may think that this creates a new object; it doesn't. It only creates a new variable that shares the reference of the original object. Let's take an example where we create a list named old_list and pass an object reference to new_list using = operator.
16. Python How to create a multidimensional list?Lists are a very widely use data structure in python. They contain a list of elements separated by comma. But sometimes lists can also contain lists within them. These are called nested lists or multidimensional lists.
Example: multlist = [[0 for columns in range(4)] for rows in range(3) print(multlist) Output: [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]
17. Explain the disadvantages of python
Python is not a good choice for memory intensive tasks. Due to the flexibility of the data-types, Python's memory consumption is also high. Python has limitations with database access
18. Explain how to make Forms in python.
- form.name: The name of the field, if specified.
- filename: If an FTP transaction, the client-side filename.
- value: The value of the field as a string.
- file: file object from which data can be read.
- type: The content type, if applicable
19. Write a program in Python to produce Star triangle?
# Function to demonstrate printing pattern def pypart(n): # outer loop to handle number of rows # n in this case for i in range(0, n): # inner loop to handle number of columns # values changing acc. to outer loop for j in range(0, i+1) # printing stars print("* ",end="") # ending line after each row print("\r") # Driver Code n = 5 pypart(n)
20. Write Python code to check the given sequence is a palindrome or not?
Python program to check the sequence is a palindrome or not # function to check string is # palindrome or not def isPalindrome(str) # Run loop from 0 to len/2 for i in range(0, int(len(str)/2)): if str[i] != str[len(str)-i-1]: return False return True # main function s = "malayalam" ans = isPalindrome(s) if (ans): print("Yes") else: print("No")
21. Differentiate between SciPy and NumPy?
NumPy stands for Numerical Python while SciPy stands for scientific python. Both NumPy and SciPy are modules of Python, and they are used for various operations of the data. Coming to NumPy first, it is used for efficient operation on homogeneous data that are stored in arrays
22. List the common security issues that can be avoided by using Django?
- Cross site scripting (XSS) protection.
- Cross site request forgery (CSRF) protection.
- SQL injection protection.
- Clickjacking protection.
- Host header validation.
- Referrer policy.
- Session security.
TOP MNC's PYTHON INTERVIEW QUESTIONS & ANSWERS
Here we listed all Python Interview Questions and Answers which are asked in Top MNCs. Periodically we update this page with recently asked Questions, please do visit our page often and be updated in Python.
To become a Python Certified professional and join in your dream company, Enroll now for our Best Python Training. We help you to crack any level of Python Interviews and We offering Python Training with 100% Placements.