PYTHON Interview Questions and Answers
Question - 51 : - How will you convert an integer to octal string in python?
Answer - 51 : - oct(x) − Converts an integer to an octal string.
Question - 52 : - What is the purpose of ** operator?
Answer - 52 : - ** Exponent − Performs exponential (power) calculation on operators. a**b = 10 to the power 20 if a = 10 and b = 20.
Question - 53 : - What is the purpose of // operator?
Answer - 53 : - // Floor Division − The division of operands where the result is the quotient in which the digits after the decimal point are removed.
Question - 54 : - What is the purpose of is operator?
Answer - 54 : - is − Evaluates to true if the variables on either side of the operator point to the same object and false otherwise. x is y, here is results in 1 if id(x) equals id(y).
Question - 55 : - What is the purpose of not in operator?
Answer - 55 : - not in − Evaluates to true if it does not finds a variable in the specified sequence and false otherwise. x not in y, here not in results in a 1 if x is not a member of sequence y.
Question - 56 : - What is the purpose break statement in python?
Answer - 56 : - break statement − Terminates the loop statement and transfers execution to the statement immediately following the loop.
Question - 57 : - What is the purpose continue statement in python?
Answer - 57 : - continue statement − Causes the loop to skip the remainder of its body and immediately retest its condition prior to reiterating.
Question - 58 : - What is the purpose pass statement in python?
Answer - 58 : - pass statement − The pass statement in Python is used when a statement is required syntactically but you do not want any command or code to execute.
Question - 59 : - How can you pick a random item from a list or tuple?
Answer - 59 : - choice(seq) − Returns a random item from a list, tuple, or string.
Question - 60 : - How can you pick a random item from a range?
Answer - 60 : - randrange ([start,] stop [,step]) − returns a randomly selected element from range(start, stop, step).