PRACTICE PYTHON
What does a built-in function type do in the context of classes?
a) Determines the object name of any value b) Determines the class name of any value c) Determines class description of any value d) Determines the file name of any value Answer b) Determines the
Which function is used to write a list of string in a file?
a) writeline() b) writelines() c) writestatement() d) writefullline() Answer a) writeline() Explanation With the writeline() function you can write a list of strings to a file!
What arithmetic operators cannot be used with strings?
a) + b) * c) – d) All of the mentioned Answer: c) – Explanation: Arithmetic operators are, operators which are used to perform arithmetic operations which mainly includes addition(+), multiplication(*), subtraction(-) and division(/). We
What will be the output of the following Python code? print (r”\nhello”)
a) a new line and hello b) \nhello c) the letter r and then hello d) error Answer: b) \nhello Explanation: When prefixed with the letter ‘r’ or ‘R’, a string literal becomes a raw
Which of the following statements is false about recursion?
(a) Every recursive function must have a base case (b) Infinite recursion can occur if the base case isn’t properly mentioned (c) A recursive function makes the code easier to understand (d) Every recursive function
To return the length of string s what command do we execute?
a) s.__len__() b) len(s) c) size(s) d) s.size() Answer: a) s.__len__() Explanation: We usually use len(s) to print the length of the string. It works by calling an __len__ method behind the scene, thus a

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?