Q76. What zip() function does?
Ans : zip() function will combine multiple lists elements based on their position and create tuple out of this. See below example
l1=[1,2,3] l2=['a','b','c','d'] l3=['hadoop' , 'exam' , 'learning']
zip(l1,l2,l3) Out[11]: [(1, 'a', 'hadoop'), (2, 'b', 'exam'), (3, 'c', 'learning')] |
It will create tuple only the minimum length of the any list.
Q77. What is the Pass by Value and Pass by Reference?
Ans : Whenever arguments passed to the function they are always passed by reference. It means, if you change the value of the function inside the parameter, it will also change the value of the original parameter. However, if you are passing immutable variable then it will be pass by value, hence original copy of the variable will not be changed.
Q78. Is everything object in Python?
Ans : Everything in Python is an object, and almost everything has attributes and methods. All functions have a built-in attribute __doc__, which returns the doc string defined in the function's source code. The sys module is an object which has (among other things) an attribute called path.
Learn Python in Less than 8 Hours sitting at Home/@Desk
Q79. What is an id() function?
Ans : id() unction provide the unique integer value of an object.
Q80. What is the purpose of the __init__ method?
Ans : The __init__ method is run as soon as an object of a class is instantiated. The method is useful to do any initialization you want to do with your object.