Posts Tagged with 'Python'
Why is finalize used?
Finalize method is used for freeing up the unmanaged resources and cleaning up before the garbage collection method is invoked. This helps in performing memory management tasks.
Differentiate between new and override modifiers.
Python | New and Override Modifiers The new modifier is used to instruct the compiler to use the new implementation and not the base class function. The Override modifier is useful for overriding a base class …
What are negative indexes and why are they used?
Negative indexes mean that you count from the right instead of the left. So, list[-1] refers to the last element, list[-2] is the second-last, and so on.
Are access specifiers used in python?
Python | Access Specifiers Python does not make use of access specifiers specifically like private, public, protected, etc. However, it does not derive this from any variables. It has the concept of imitating the behavior of …
Is it possible to call parent class without its instance creation in Python?
Yes, it is possible if the base class is instantiated by other child classes or if the base class is a static method.
What does *args and **kwargs mean?
Python | *args and **kwargs *args is a special syntax used in the function definition to pass variable-length arguments. e.g: myFun(*argv) def func(*args): for i in args: print(i) func(2,3,4) #Output 2 3 4 **kwargs is …
Explain split() and join() method in Python?
Python | split() and join() You can use split() method to split a string based on a delimiter to a list of strings. and join() method is used to join a list of strings based on …
Explain how to delete a file in Python?
Python | Delete a file Using command os.remove(file_name) Use the os module to delete a file, we need to first import it, and then use the remove() function provided by the module to delete the file. It …
What is the use of vars(), dir() and help() functions?
Python | vars(), dir() and help() The vars() function returns the __dict__ attribute of an object. The dir() function returns all properties and methods of the specified object, without the values. The help() function is used to display …
What is PYTHONPATH in Python?
Python | PYTHONPATH PYTHONPATH is an environment variable that you can set to add additional directories where Python will look for modules and packages. This is especially useful in maintaining Python libraries that you do not wish …
What is break, continue and pass in Python?
Python | Break, Continue, and Pass Break: The break statement terminates the loop immediately and the control flows to the statement after the body of the loop. Continue: The continue statement skips the current iteration of the statement, …
What is __init__ in python?
Python | __init__ constructor method __init__ is a constructor method in Python and is automatically called to allocate memory when a new object/instance is created. All classes have a __init__ method associated with them. class Student: …
What is the use of self in Python?
Python | Self Self is used to represent the instance of the class. With this keyword, you can access the attributes and methods of the class in python. It binds the attributes with the given arguments. …
What are global, protected and private attributes in Python?
Python | Global, Protected, and Private Global, Protected, and Private access modifiers in Python. Python does not use these keywords to control access modifications instead single and double underscore ‘_’ symbols are used to specify Protected and Private to determine the access control. …
What is pass in Python?
Python | Pass Statement The pass statement is used as a placeholder for future code. It represents a null operation in Python. It is generally used for the purpose of filling up empty blocks of …