Q. Explain the use of with statement and its syntax?
A. In Python, using the ‘with’ statement, we can open a file and close it as soon as the block of code, where ‘with’ is used, exits, without having to use the close() method.
with open("filename", "mode") as file_var:
Q. Write a code to display the contents of a file in reverse?
A. for line in reversed(list(open(filename.txt))):
print(line.rstrip()).
Q. What do you understand by Tkinter?
A. Tkinter is an inbuilt Python module that is used to create GUI applications. It’s Python’s standard toolkit for GUI development. Tkinter comes with Python, so there is no installation needed. We can start using it by importing it in our script.
Q. What is self-keyword in Python?
A. Self-keyword is used as the first parameter of a function inside a class that represents the instance of the class. The object or the instance of the class is automatically passed to the method that it belongs to and is received in the ‘self-keyword’.
Will catch you soon updated Interview Questions and Answers on next Series
for Top SQL Server Interview Questions and Answers