• +91 9971497814
  • info@interviewmaterial.com

PYTHON Interview Questions Answers

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

Answer 1 : Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4 A unit testing framework in Python is known as unittest.  It supports sharing of setups, automation testing, shutdown code for tests, aggregation of tests into collections etc. /* 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 2 : Normal 0 false false false EN-US X-NONE X-NONE

Answer 2 : Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4 A mechanism to select a range of items from sequence types like list, tuple, strings etc. is known as slicing. /* 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 3 : How will you check in a string that all characters are numerics?

Answer 3 : isnumeric() − Returns true if a unicode string contains only numeric characters and false otherwise.

Question 4 : How will you remove all leading and trailing whitespace in string?

Answer 4 : strip([chars]) − Performs both lstrip() and rstrip() on string.

Question 5 : How will you convert an integer to a character in python?

Answer 5 : chr(x) − Converts an integer to a character.

Question 6 : What is the output of print tinylist * 2 if tinylist = [123, 'john']?

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

Question 7 : How will you convert an integer to hexadecimal string in python?

Answer 7 : hex(x) − Converts an integer to a hexadecimal string.

Question 8 : What is the output of print str[2:5] if str = 'Hello World!'?

Answer 8 : It will print characters starting from 3rd to 5th. Output would be llo.

Question 9 : What is the output of print list if list = [ 'abcd', 786 , 2.23, 'john', 70.2 ]?

Answer 9 : It will print complete list. Output would be ['abcd', 786, 2.23, 'john', 70.200000000000003].

Question 10 : How will you check in a string that all characters are decimal?

Answer 10 : isdecimal() − Returns true if a unicode string contains only decimal characters and false otherwise.

PYTHON Contributors

krishan

Share your email for latest updates

Name:
Email:

Our partners