en
Feedback
Python Questions

Python Questions

Open in Telegram

Tasks for Beginners, Interview Questions, Regular expressions, simple coding problems, Quiz etc. Useful Resources — »»» @python_resources_iGnani Projects for Practice — »»» @python_projects_repository Discussion Forum — »»» @python_programmers_club

Show more
The country is not specifiedThe category is not specified
5 285
Subscribers
No data24 hours
No data7 days
No data30 days
Posts Archive
x=56.236 print("%.2f"%x) What is the result of these statements?
Anonymous voting

x='{0}, {1}, and {2}' x.format('hello', 'Python Club', 'members') # What is the output of this code.
Anonymous voting

x = bin((3**9) -1) == '{}'.format(bin((3**9) -1)) What is the value of x? Explain?
Anonymous voting

Which of the following is a valid statement and runs without error?
Anonymous voting

x = - - -5 #What is the value of x
Anonymous voting

'{} was created by {1} and first released in {2}'.format('Python','Guido van Rossum','1991') #What is the output of the code shown above?
Anonymous voting

What is the maximum length allowed for an identifier in Python 3?
Anonymous voting

x = 5,000,000.00 type(x) # What is the datatype of x? Explain Why?
Anonymous voting

x = (round(4.5) - - round(-4.5)) # What is the value of x? Explain Why?
Anonymous voting

Which of these in not a core datatype in Python 3?
Anonymous voting

Which of the following is an invalid statement?
Anonymous voting

All keywords in Python are in?
Anonymous voting

x = 5,000.00 #What is the value of x. Explain Why?
Anonymous voting

print('abcefd'.replace('cd', '12')) #What is the output of the above code?
Anonymous voting

Which of the following programming styles does Python support?
Anonymous voting

x = [3,1,2] What is the output of x [1:-1]? Explain Why?
Anonymous voting

#interviewQuestions : 0013 What are python modules?
Python modules are files containing Python code.

A module can define functions, classes and variables. A module can also include runnable code. Grouping related code into a module makes the code easier to understand and use.

#interviewQuestions : 0012 What is PYTHONPATH?
PYTHONPATH is an environment variable can be set, to add additional directories where python will look for modules and packages.

Whenever a module is imported, PYTHONPATH is also looked up to check for the presence of the imported modules in various directories. The interpreter uses it to determine which module to load.

For most installations, you should not set these variables since they are not needed for Python to run. Python knows where to find its standard library.

The only reason to set PYTHONPATH is to maintain directories of custom Python libraries that you do not want to install in the global default location (i.e., the site-packages directory).

#interviewQuestions : 0011 Q: Explain the following assignment?
x, y, z = 5, 10, 15
a = b = c = 0

a = x - z
x -= z

b = y - y + z 
y -= (y + z)
print(b, y)

15 -15 Notice the result in the here, it should be 15 and 15, but the value of y is -15. Do you know why?
When the statements are evaluated, the statements are evaluated from left to right. But before that, anything within the braces are executed first.

So, in the first statement, since there is no curly braces, it first executes y - y and the result + z, this becomes 15
In the second statement, the expression within curly braces is executed, which is y + z, which comes to 25 and then now the expression becomes y -= 25, which is same as y = y- 25, hence the result -15.

min("abCD123!") # What is the output and WHY?
Anonymous voting