Top Python Interview Questions
Mobiprep handbooks are free downloadable placement preparation resources that can help you ace any company placement process. We have curated a list of the 40 most important MCQ questions which are asked in most companies such as Infosys, TCS, Wipro, Accenture, etc. The placement handbooks also have detailed explanations for every question ensuring you revise all the questions with detailed answers and explanations.
Question
37
Explanation
What will be the output of the following program?
a = 2
b = '3.77'
c = -8
str1 = '{0:.4f} {0:3d} {2} {1}'.format(a, b, c)
print(str1)
output:
2.0000 2 -8 3.77
At Index 0, integer a is formatted into a float with 4 decimal points, thus 2.0000. At Index 0, a = 2 is formatted into a integer, thus it remains to 2. Index 2 and 1 values are picked next, which are -8 and 3.77 respectively.
Question
38
Explanation
Write a python program to check whether given two strings are anagrams or not.
def check(a,b):
if(len(a)!=len(b)):
return False
else:
if(sorted(list(a)) == sorted(list(b))):
return True
else:
return False
Question
39
Explanation
What is PEP8?
PEP8 is an official style guide given by the community to improve the readability to the top.
PEP8 enables you to write the python code more effective. Some naming conventions and comments will be helpful to share your code with other people to understand the code better.
PEP8 is a document that provides guidelines and best practices on how to write Python code. It was written in 2001 by Guido van Rossum, Barry Warsaw, and Nick Coghlan.
The primary focus of PEP 8 is to improve the readability and consistency of Python code.
.png)