• +91 9971497814
  • info@interviewmaterial.com

Computer Interview Questions Answers

PYTHON Interview Questions Answers

Question - 111 : - How will you randomizes the items of a list in place?

Answer - 111 : - shuffle(lst) − Randomizes the items of a list in place. Returns None.

Question - 112 : - How can you pick a random item from a list or tuple?

Answer - 112 : - choice(seq) − Returns a random item from a list, tuple, or string.

Question - 113 : - What is the purpose of ** operator?

Answer - 113 : - ** Exponent − Performs exponential (power) calculation on operators. a**b = 10 to the power 20 if a = 10 and b = 20.

Question - 114 : - How will you convert a string to all lowercase?

Answer - 114 : - lower() − Converts all uppercase letters in string to lowercase.

Question - 115 : - What is the purpose of not in operator?

Answer - 115 : - 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 - 116 : - What is the output of print tinylist * 2 if tinylist = [123, 'john']?

Answer - 116 : - It will print list two times. Output would be [123, 'john', 123, 'john'].

Question - 117 : - Normal 0 false false false EN-US X-NONE X-NONE

Answer - 117 : - Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4 Python program runs directly from the source code. Each type Python programs are executed code is required. Python converts source code written by the programmer into intermediate language which is again translated it into the native language / machine language that is executed. So Python is an Interpreted language. /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin-top:0in; mso-para-margin-right:0in; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0in; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;}

Question - 118 : - How will you convert a string to all uppercase?

Answer - 118 : - upper() − Converts all lowercase letters in string to uppercase.

Question - 119 : - How can you get a random number in python?

Answer - 119 : - random() − returns a random float r, such that 0 is less than or equal to r and r is less than 1.

Question - 120 : - What is the output of print tuple[0] if tuple = ( 'abcd', 786 , 2.23, 'john', 70.2 )?

Answer - 120 : - It will print first element of the tuple. Output would be abcd.

Computer Contributors

krishan
Rajeev Katiyar
Yes Baroda

Share your email for latest updates

Name:
Email:

Our partners