Q36. What is the method?
Ans: Method is a function only, but it is associated with the object. And can be called using dot notation.
object.method()
Q37. How do you represent file in Python?
Ans: A file is represented using file object. For instance you have a file “c:/hadoopexam.txt” . If you want to read or write in this file you have to use Python file object.
Q38. What is the list in Python?
Ans: In python list is a sequence of values e.g. [“Amit”,”Rakesh”,”Rohit”,”Umesh”] is a list and contains 4 elements. List is represented using [] bracket. And it’s indexing start with 0. So here value at index 0 is “Amit” and value at index 3 is “Umesh” and there is no value at index 4.
Learn Python in Less than 8 Hours sitting at Home/@Desk
Q39. Can a list contain another list?
Ans: Yes, a list can contain another list as below
[“Amit”,”Rakesh”,”Rohit”,”Umesh” , [“Mumbai” , “Delhi” , “Banglore” ,”Chennai”]]
Q40. What is an accumulator?
Ans : Accumulator is a variable, which generally used in the loop to accumulate the values in each iteration. E.g. if you want to add all the values in a list [1,2,3,4] . Then, you will be creating an accumulator which will hold the sum till previous iteration.