Python Questions
Ir al canal en 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
Mostrar másEl país no está especificadoLa categoría no está especificada
5 285
Suscriptores
Sin datos24 horas
Sin datos7 días
Sin datos30 días
Archivo de publicaciones
5 285
x=56.236
print("%.2f"%x)
What is the result of these statements?
5 285
x='{0}, {1}, and {2}'
x.format('hello', 'Python Club', 'members')
# What is the output of this code.
5 285
x = bin((3**9) -1) == '{}'.format(bin((3**9) -1))
What is the value of x? Explain?
5 285
Which of the following is a valid statement and runs without error?
5 285
'{} was created by {1} and first released in {2}'.format('Python','Guido van Rossum','1991')
#What is the output of the code shown above?
5 285
What is the maximum length allowed for an identifier in Python 3?
5 285
x = 5,000,000.00
type(x)
# What is the datatype of x? Explain Why?
5 285
x = (round(4.5) - - round(-4.5))
# What is the value of x? Explain Why?
5 285
print('abcefd'.replace('cd', '12'))
#What is the output of the above code?
5 285
#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.
5 285
#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).
5 285
#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.
