PRACTICE PYTHON
To insert 5 to the third position in list1, we use which command?
a) list1.insert(3, 5) b) list1.insert(2, 5) c) list1.add(3, 5) d) list1.append(3, 5) Answer: b) list1.insert(2, 5) Explanation: The syntax and working of the insert function in python are shown below: Output: [1, 2, 5, 3,
To read two characters from a file object infile, we use _
a) infile.read(2) b) infile.read() c) infile.readline() d) infile.readlines() Answer: a) infile.read(2) Explanation: The read(2) method reads exactly 2 characters from a local file into a python object.
Which of the following commands will create a list?
a) list1 = list() b) list1 = [] c) list1 = list([1, 2, 3]) d) all of the mentioned Answer: d) all of the mentioned Explanation: <class ‘list’><class ‘list’><class ‘list’> So all methods mentioned above
Which of the following is a feature of DocString?
a) Provide a convenient way of associating documentation with Python modules, functions, classes, and methods b) All functions should have a docstring c) Docstrings can be accessed by the __doc__ attribute on objects d) All
Which type of Programming does Python support?
a) object-oriented programming b) structured programming c) functional programming d) all of the mentioned Answer: d) all of the mentioned Explanation: Structured programming is a program written with only the three constructions sequence, decision (if..

Aniket Malik
CERTIFIED TUTOR/TRAINER WITH 300+ REVIEWS
My students are the presents from God to me
Do you want to learn
Programming?
Hey, I’m Aniket. I’m determined to make you one of the best developers in the history of Information technology.
My only question is, are you ready?