• +91 9723535972
  • info@interviewmaterial.com

PYTHON Interview Questions and Answers

Related Subjects

PYTHON Interview Questions and Answers

Question - 91 : - What is the output of L[2] if L = [1,2,3]?

Answer - 91 : - 3, Offsets start at zero.

Question - 92 : - What is the output of L[-2] if L = [1,2,3]?

Answer - 92 : - 1, Negative: count from the right.

Question - 93 : - What is the output of L[1:] if L = [1,2,3]?

Answer - 93 : - 2, 3, Slicing fetches sections.

Question - 94 : - How will you compare two lists?

Answer - 94 : - cmp(list1, list2) − Compares elements of both lists.

Question - 95 : - How will you get the length of a list?

Answer - 95 : - len(list) − Gives the total length of the list.

Question - 96 : - How will you get the max valued item of a list?

Answer - 96 : - max(list) − Returns item from the list with max value.

Question - 97 : - How will you get the min valued item of a list?

Answer - 97 : - min(list) − Returns item from the list with min value.

Question - 98 : - What is PEP 8?

Answer - 98 : - PEP 8 is a coding convention(a set of recommendations) how to write your Python code in order to make it more readable and useful for those after you. For more information check PEP 8.

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

Answer - 99 : - Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4 PEP 8 is a coding convention(a set of recommendations) how to write your Python code in order to make it more readable and useful for those after you. For more information check PEP 8. /* 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 - 100 : -
Normal 0 false false false EN-US X-NONE X-NONE

Answer - 100 : - Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4 First list are mutable while tuples are not, and second tuples can be hashed e.g. to be used as keys for dictionaries. As an example of their usage, tuples are used when the order of the elements in the sequence matters e.g. a geographic coordinates, "list" of points in a path or route, or set of actions that should be executed in specific order. Don't forget that you can use them a dictionary keys. For everything else use lists. /* 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;}


NCERT Solutions

 

Share your email for latest updates

Name:
Email:

Our partners