Category Archives: Techbeamers

Python Programming Quiz Top 20 Questions Part-1

Hello Dear Readers, we have powered this Python programming quiz with most relevant and frequently asked Python programming interview questions for testers and Programmers. Hope you all will enjoy attempting this amazing Python programming quiz.

Note: Answers to all the questions of Python programming quiz will be given at the end of quiz. To learn more about Python, go to on-line Python documentation.

Python programming quiz

Time limit: 0

Quiz-summary

0 of 20 questions completed

Questions:

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20

Information

For your information, please note that this Python programming quiz has only single choice questions. We suggest to please carefully attempt all the questions. Press the below Start quiz button to go ahead.
Python programming quiz

Python programming quiz


Please continue.

You have already completed the quiz before. Hence you can not start it again.

read more

LoadRunner Interview Questions with Answers Part-1

This article will focus on the most important and commonly asked LoadRunner interview questions and answers. It is designed to help you be successful in performance testing interview using LoadRunner. We’ll cover the LoadRunner interview questions in two parts. First part will focus on the theoretical knowledge about LoadRunner. And the second one will cover the configuration and usage of the application.

The reasons we came up with this unique set of LoadRunner interview questions are as follows.

read more

Python Programming Interview Questions with Answers Part-1

Today we are going to present you Part-1 of top 20 Python programming interview questions. We’ve selected these questions after exhaustive research. The criteria of selection was to add questions feasible for both test engineers and developers. Next it is certainly possible that you may already know some of these questions. But we are also sure that you would still find them useful. Because the answers are brisk and pertinent.

The another perspective is that you can not continue reading tutorial by tutorial. You get dried up reading same thing again and needs refreshment. This series of Python programming interview questions is designed to test your Python skills and make you feel refreshed.

Lets now enter into the Python programming interview questions series Part-1.

Python programming interview questions Part-1

Python programming interview questions Part-1.

Python programming interview questions Part-1.

Q: Identify some of the core default modules included in Python?
Ans.

  • email – used to parse, handle, and generate email messages.
  • string – an index of types of strings, such as all capital or lowercase letters.
  • sqlite3 – used to deal with the SQLite database.
  • xml – provides XML support.
  • logging – creates logging classes to log system details.
  • traceback – allows you to extract and print stack trace details.

Q: Why is __init__.py used for?
Ans.
The __init__.py files are required to make Python interpret directories as containing packages.
It is mainly to prevent directories with common name being treated as packages. This permits the programmer control which directories are packages and which are not.
Moreover, __init__.py can just be an empty file too. But it can also execute initialization code for the package or set the __all__variable.

Q: What is a negative index in Python?
Ans.
Python arrays & list items can be accessed with positive or negative numbers (aka index). A negative index accesses the list elements from the end counting backwards.

>>> import array
>>> a= [1, 2, 3]
>>> print a[-3]
1
>>> print a[-2]
2
>>> print a[-1]
3

Q: What is pickling and what is unpickling?
Ans.
Pickling is a process by which a Python object is converted into a string representation by a pickle module. It is then placed into a file with the dump() function. Whereas unpickling refers to the reverse process, in which the stored string is retrieved and turned back into an object.

Q: What is slicing in Python?
Ans.
Slicing in Python is a mechanism to select a range of items from Sequence types like strings, list, tuple, etc.

>>> l=[1,2,3,4,5]
>>> l[1:3]
[2, 3]
>>> l[1:-2]
[2, 3]
>>> l[-3:-1]      # negative indexes in slicing
[3, 4]

>>> s="Hello World"
>>> s[1:3]
'el'
>>> s[:-5]
'Hello '
>>> s[-5:]
'World'

Q: Point out few ways to generate a random number in Python.
Ans.
random() – this command returns a floating point number, between 0 and 1.
uniform(x,y) – this command returns a floating point number between the values given for x and y.
randint(x,y) – this command returns a random integer between the values given for x and y.

Q: Why is “pass” used for in Python?
Ans.
“pass” is no-operation Python statement. It indicates nothing is to be done. It is just a place holder used in compound statements as they cannot be left blank.

>>> if x==0:
        pass
    else:
        print "x!=0"

Q: What are iterators in Python?
Ans.
Iterators in Python are used to iterate over a group of elements, containers, like list. For a container to support iterator, it must provide __iter__().

container.__iter__() :
# This returns an iterator object.

read more