Page 127 - PYTHON-12
P. 127
APPENDIX C
VIVA VOCE
1. Who developed Python?
Ans. Guido van Rossum, a Dutch programmer, developed Python in 1991.
2. What is Python and what are its uses?
Ans. Python is a programming language with objects, modules, threads, exceptions and automatic memory
management. The benefits of Python are that it is simple and easy, portable, extensible, has built-in data
structures and is open source.
3. What are the two modes of working in Python?
Ans. Two ways to use the Python interpreter are:
(i) Interactive mode (ii) Script mode
4. How is Python interpreted?
Ans. Python language is an interpreted language. Python program runs directly from the source code. It converts
the source code that is written by the programmer into an intermediate language, which is again translated
into machine language that has to be executed.
5. What is the smallest element of Python coding termed as?
Ans. Tokens in Python
6. Differentiate between call by value and call by reference with a suitable example of each.
Ans. In the event that you pass arguments like whole numbers, strings or tuples to a function, the passing is like
call by value because you cannot change the value of the immutable objects being passed to the function.
Passing mutable objects, however, can be considered as call by reference because when their values are
changed inside the function, it is also reflected outside the function.
7. Identify and write the name of the module to which the following functions belong:
(a) ceil() (b) floor() (c) randint
(d) dump() (e) sqrt()
Ans. (a) math module (b) math module (c) random module
(d) pickle module (e) math module
8. What type of objects can be used as keys in dictionaries?
Ans. Only immutable type objects (i.e., Numbers, Strings, Tuples) can be used as keys in dictionaries.
9. What is pickling and unpickling?
Ans. Pickle module accepts any Python object and converts it into a string representation and dumps it into a file
by using dump function. This process is called pickling. The process of retrieving original Python objects from
the stored string representation is called unpickling.
10. How is memory managed in Python?
Ans. Python memory is managed by Python private heap space. All Python objects and data structures are located
in a private heap. The programmer does not have access to this and the interpreter takes care of this Python
private heap.
• The allocation of Python heap space for Python objects is done by Python memory manager. The core
API gives access to some tools for the programmer to code.
• Python also has an inbuilt garbage collector which recycles all the unused memory, frees up memory and
makes it available to the heap space.
11. What is the difference between list and tuple?
Ans. The difference between list and tuple is that list is mutable while tuple is not. Tuple can be further implemented
as a key to dictionaries.
12. State the use of the split() function in Python.
Ans. split() function breaks a string into shorter strings using a defined separator. It gives a list of all words present
in the string.
13. How do you write comments in Python?
Ans. A comment in Python starts with the hash (#) character and extends to the end of the line.
A.22 Computer Science with Python–XII