DELL – Python Interview Questions
Here is the list of Python Interview Questions which are recently asked in DELL company. These questions are included for both Freshers and Experienced professionals. Our Python Training has Answered all the below Questions.
1. Differentiate between lists and tuples.
The most important differences between list and tuple is that list is mutable, whereas a tuple is immutable. This means that lists can be changed, and tuples cannot be changed. So, some operations can work on lists, but not on tuples.
2. Explain the ternary operator in Python.
The ternary operator is a way of writing conditional statements in Python. As the name ternary suggests, this Python operator consists of three operands.
The ternary operator can be thought of as a simplified, one-line version of the if-else statement to test a condition.
3. What are negative indices?
Python programming language supports negative indexing of arrays, something which is not available in arrays in most other programming languages.
This means that the index value of -1 gives the last element, and -2 gives the second last element of an array. The negative indexing starts from where the array ends.
4. Is Python case-sensitive?
Python is a case-sensitive language because it distinguishes between identifiers like Variable and variable. In simple words, we can say it cares about uppercase and lowercase.
5. How long can an identifier be in Python?
an identifier of infinite length. However, the PEP-8 standard sets a rule that you should limit all lines to a maximum of 79 characters.
6. What is the pass statement in Python?
In Python, pass is a null statement. The interpreter does not ignore a pass statement, but nothing happens and the statement results into no operation.
The pass statement is useful when you don't write the implementation of a function but you want to implement it in the future.
7. Explain help() and dir() functions in Python.
Help() and dir(), are the two functions that are reachable from the python interpreter. Both functions are utilized for observing the combine dump of build-in-function.
These created functions in python are truly helpful for the efficient observation of the built-in system.
8. What is slicing?
The slice() function returns a slice object. A slice object is used to specify how to slice a sequence. You can specify where to start the slicing, and where to end. You can also specify the step, which allows you to e.g. slice only every other item
9. What is the difference between list and tuple in Python?
In Python, list and tuple are a class of data structure that can store one or more objects or values. A list is used to store multiple items in one variable and can be created using square brackets.
Similarly, tuples also can store multiple items in a single variable and can be declared using parentheses
10.Write a program to display the Fibonacci sequence in Python?
# Python program to display the Fibonacci sequence def recur_fibo(n): if n <= 1: return n else: return(recur_fibo(n-1) + recur_fibo(n-2)) nterms = 10 # check if the number of terms is valid if nterms <= 0: print("Plese enter a positive integer") else: print("Fibonacci sequence:") for i in range(nterms): print(recur_fibo(i))
11. Explain about Django session?
Django provides full support for anonymous sessions. The session framework lets you store and retrieve arbitrary data on a per-site-visitor basis. It stores data on the server side and abstracts the sending and receiving of cookies.
12. List the ways we add view functions to urls.py?To tell the existence of index() view function in urls.py you need to do two things:
- Add from blog import views towards the end of the import list.
- Create a new URL pattern by adding the following line at the beginning of the urlpatterns list. url(r'^$', views. index),
13. How would you declare a comment in Python?
Comments in Python begin with a hash mark ( # ) and whitespace character and continue to the end of the line. Because comments do not execute, when you run a program you will not see any indication of the comment there.
Comments are in the source code for humans to read, not for computers to execute.
14. How does a function return values?
Return Values: They can be situated anywhere in the function body. A return statement ends the execution of the function call and "returns" the result, i.e. the value of the expression following the return keyword, to the caller.
If the return statement is without an expression, the special value None is returned.
15. What is the Python interpreter prompt?
Python interpreter is in an interactive mode when it reads commands from a tty. When it shows this prompt, it means it prompts the developer for the next command. This is the REPL.
Before it prints the first prompt, Python interpreter prints a welcome message that also states its version number and a copyright notice.
16. How would you define a block in Python?
To indicate a block of code in Python, you must indent each line of the block by the same amount. The two blocks of code in our example if-statement are both indented four spaces, which is a typical amount of indentation for Python.
17. Why do we need break and continue in Python?
The Python break and continue statements modify the behavior of the loop while the loop runs. Consider an example where you are running a loop for a specific period.
At a certain point, you want the loop to end and move to the next statement within your code. At such a point, the break statement works best.
18. What are the built-in type does python provides?
Python uses five numeric types: Booleans, integers, long integers, floating-point numbers, and complex numbers. Except for Booleans, all numeric objects are signed. All numeric types are immutable. Booleans are represented by two values: True and False.
19. What is namespace in Python?
Namespace is a way to implement scope. In Python, each package, module, class, function and method function owns a "namespace" in which variable names are resolved. When a function, module or package is evaluated (that is, starts execution), a namespace is created.
20. What is lambda in Python?
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.
Just like a normal function, a Lambda function can have multiple arguments with one expression.
21. How to create a class in Python?A Class is like an object constructor, or a "blueprint" for creating objects.
- Create a Class. To create a class, use the keyword class
- Create Object. Now we can use the class named MyClass to create objects
- The self-Parameter
- Modify Object Properties
- Delete Object Properties
- Delete Objects
22. Does Python make use of access specifiers
There are three types of access modifiers in Python: public, private, and protected. Variables with the public access modifiers can be accessed anywhere inside or outside the class, the private variables can only be accessed inside the class, while protected variables can be accessed within the same package.
23. Explain the procedure to minimize or lower the outages of Memcached server in your Python development?The procedure to minimize or lower the outages of Memcached server in your Python development.
- Use code to minimize cache stampedes to leave a minimal impact
- Another way on a new machine is to use the lost machines IP address
- Setting timeout value
24. What is the use of manage.py?
manage.py: A command-line utility that lets you interact with this Django project in various ways. You can read all the details about manage.py in django-admin and manage.py. The inner mysite/ directory is the actual Python package for your project.
25. Is Django stable?
Django is committed to API stability and forwards-compatibility. You may need to make minor changes when upgrading the version of Django your project uses: see the “Backwards incompatible changes” section of the release note for the version or versions to which you are upgrading.
26. Write a program to count the number of capital letters in a file?Python Program to count the number of capital letters in a file
def upper(string): upper = 0 for i in range(len(string)): # For upper letters elif (ord(string[i]) >= 65 and ord(string[i]) <= 90): upper += 1 print('Upper case characters = %s' %upper) # Driver Code string = 'God is Great' upper(string)
27. In Python what are iterators?
Iterator is an object which allows a programmer to traverse through all the elements of a collection, regardless of its specific implementation. In Python, an iterator is an object which implements the iterator protocol.
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.