• +91 9971497814
  • info@interviewmaterial.com

Computer Interview Questions Answers

PYTHON Interview Questions Answers

Question - 1 : - What is the purpose of PYTHONSTARTUP environment variable?

Answer - 1 : - PYTHONSTARTUP - It contains the path of an initialization file containing Python source code. It is executed every time you start the interpreter. It is named as .pythonrc.py in Unix and it contains commands that load utilities or modify PYTHONPATH.

Question - 2 : - What is the output of print str + "TEST" if str = 'Hello World!'?

Answer - 2 : - It will print concatenated string. Output would be Hello World!TEST.

Question - 3 : - How will you get the max alphabetical character from the string?

Answer - 3 : - max(str) − Returns the max alphabetical character from the string str.

Question - 4 : - How will you convert a string to a float in python?

Answer - 4 : - float(x) − Converts x to a floating-point number.

Question - 5 : - How will you create a dictionary in python?

Answer - 5 : - Dictionaries are enclosed by curly braces ({ }) and values can be assigned and accessed using square braces ([ ]). dict = {} dict['one'] = "This is one" dict[2]     = "This is two" tinydict = {'name': 'john','code':6734, 'dept': 'sales'}

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

Answer - 6 : - Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4 Pass means, no-operation Python statement, or in other words it is a place holder in compound statement, where there should be a blank left and nothing has to be written there. /* 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 - 7 : - How will you capitalizes first letter of string?

Answer - 7 : - capitalize() − Capitalizes first letter of string.

Question - 8 : - What is Python?

Answer - 8 : - Python is a high-level, interpreted, interactive and object-oriented scripting language. Python is designed to be highly readable. It uses English keywords frequently where as other languages use punctuation, and it has fewer syntactical constructions than other languages.

Question - 9 : - What is PEP 8?

Answer - 9 : - 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 - 10 : - What is the purpose of PYTHONPATH environment variables?

Answer - 10 : - PYTHONPATH - It has a role similar to PATH. This variable tells the Python interpreter where to locate the module files imported into a program. It should include the Python source library directory and the directories containing Python source code. PYTHONPATH is sometimes preset by the Python installer.

Computer Contributors

krishan
Rajeev Katiyar
Yes Baroda

Share your email for latest updates

Name:
Email:

Our partners