• +91 9971497814
  • info@interviewmaterial.com

Computer Interview Questions Answers

PYTHON Interview Questions Answers

Question - 21 : - How will you merge elements in a sequence?

Answer - 21 : - join(seq) − Merges (concatenates) the string representations of elements in sequence seq into a string, with separator string.

Question - 22 : - How will you change case for all letters in string?

Answer - 22 : - swapcase() − Inverts case for all letters in string.

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

Answer - 23 : - It will print elements starting from 2nd till 3rd. Output would be [786, 2.23].

Question - 24 : - Is python compiled based or interpretive based language?

Answer - 24 : - Python mostly used in scripting, is general purpose programming language which supports OOP Object oriented programming principles as supported by C++, Java, etc. Python programs are written to files with extension .py . These python source code files are compiled to byte code (python specific representation and not binary code), platform independent form stored in .pyc files. These byte code helps in startup speed optimization. These byte code are then subjected to Python Virtual Machine PVM where one by one instructions are read and executed. This is interpreter.

Question - 25 : - How will you remove all leading whitespace in string?

Answer - 25 : - lstrip() − Removes all leading whitespace in string.

Question - 26 : - What is the output of print tuple[1:3] if tuple = ( 'abcd', 786 , 2.23, 'john', 70.2 )?

Answer - 26 : - It will print elements starting from 2nd till 3rd. Output would be (786, 2.23).

Question - 27 : - What is the purpose pass statement in python?

Answer - 27 : - pass statement − The pass statement in Python is used when a statement is required syntactically but you do not want any command or code to execute.

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

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

Question - 29 : - Name some of the features of Python.

Answer - 29 : - 1. It supports functional and structured programming methods as well as OOP. 2. It can be used as a scripting language or can be compiled to byte-code for building large applications. 3. It provides very high-level dynamic data types and supports dynamic type checking. 4.It supports automatic garbage collection. 5. It can be easily integrated with C, C++, COM, ActiveX, CORBA, and Java.

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

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

Computer Contributors

krishan
Rajeev Katiyar
Yes Baroda

Share your email for latest updates

Name:
Email:

Our partners