• +91 9971497814
  • info@interviewmaterial.com

Computer Interview Questions Answers

PYTHON Interview Questions Answers

Question - 121 : - What is the output of print str * 2 if str = 'Hello World!' ?

Answer - 121 : - It will print string two times. Output would be Hello World!Hello World!.

Question - 122 : - How will you create a dictionary using tuples in python?

Answer - 122 : - dict(d) − Creates a dictionary. d must be a sequence of (key,value) tuples.

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

Answer - 123 : - 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 - 124 : - Normal 0 false false false EN-US X-NONE X-NONE

Answer - 124 : - Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4 Decorators allow us to inject or modify code in functions or classes". In other words decorators allow us to wrap a function or class method call and execute some code before or after the execution of the original code. And also we can nest them e.g. to use more than one decorator for a specific function. Usage examples include - logging the calls to specific method, checking for permission(s), checking and/or modifying the arguments passed to the method 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 - 125 : - What is the purpose of // operator?

Answer - 125 : - // Floor Division − The division of operands where the result is the quotient in which the digits after the decimal point are removed.

Question - 126 : - How will you check in a string that all characters are numerics?

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

Question - 127 : - What is the purpose of PYTHONCASEOK environment variable?

Answer - 127 : - PYTHONCASEOK − It is used in Windows to instruct Python to find the first case-insensitive match in an import statement. Set this variable to any value to activate it.

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

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

Question - 129 : - How will you get a space-padded string with the original string left-justified to a total of width columns?

Answer - 129 : - ljust(width[, fillchar]) − Returns a space-padded string with the original string left-justified to a total of width columns.

Question - 130 : - What is the output of print tinytuple * 2 if tinytuple = (123, 'john')?

Answer - 130 : - It will print tuple two times. Output would be (123, 'john', 123, 'john').

Computer Contributors

krishan
Rajeev Katiyar
Yes Baroda

Share your email for latest updates

Name:
Email:

Our partners