• +91 9971497814
  • info@interviewmaterial.com

Computer Interview Questions Answers

PYTHON Interview Questions Answers

Question - 91 : - What is the output of for x in [1, 2, 3]: print x?

Answer - 91 : - 1 2 3

Question - 92 : - How will you get the length of the string?

Answer - 92 : - len(string) − Returns the length of the string.

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

Answer - 93 : - Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4 Xrange returns the xrange object while range returns the list, and uses the same memory and no matter what the range size is. /* 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 - 94 : - What is the output of print list + tinylist * 2 if list = [ 'abcd', 786 , 2.23, 'john', 70.2 ] and tinylist = [123, 'john']?

Answer - 94 : - It will print concatenated lists. Output would be ['abcd', 786, 2.23, 'john', 70.200000000000003, 123, 'john'].

Question - 95 : - How will you convert a String to an object in python?

Answer - 95 : - eval(str) − Evaluates a string and returns an object.

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

Answer - 96 : - Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4 In Python, iterators are used to iterate a group of elements, containers like list. /* 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 - 97 : - How will you convert a object to a regular expression in python?

Answer - 97 : - repr(x) − Converts object x to an expression string.

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

Answer - 98 : - Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4 list.reverse() − Reverses objects of list in place. /* 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 - 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 There are mutable and Immutable types of Pythons built in types Mutable built-in types     1.List     2.Sets     3.Dictionaries Immutable built-in types     1.Strings     2.Tuples     3.Numbers /* 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 Range returns a list while xrange returns a  xrange object which takes the same memory no matter of the range size. In the first case you have all items already generated(this can take a lot of time and memory) while in the second you get the elements one by one e.g. only one element is generated and available per iteration. Simple example of generator usage can be find in the problem 2 of the "homework" for my presentation Functions in Python. /* 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;}

Computer Contributors

krishan
Rajeev Katiyar
Yes Baroda

Share your email for latest updates

Name:
Email:

Our partners