Q. What are control flow statements in Python?
A. Control flow statements are used to manipulate or change the execution flow of a program. Generally, the flow of execution of a program runs from top to bottom, but certain statements in Python can break this top to bottom order of execution. Control flow statements include decision-making, looping, and more.
Q. What is module and package in Python?
A. In Python, module is the way to structure program. Each Python program file is a module, which imports other modules like objects and attributes.
The folder of Python program is a package of modules. A package can have modules or subfolders.
Q. What is the difference between append() and extend() methods?
A. Both append() and extend() methods are methods used for lists. These methods are used to add elements at the end of a list.
append(element): Adds the given element at the end of the list which called this method
extend(another-list): Adds the elements of another-list at the end of the list which called the extend method.
Q. What are loop interruption statements in Python?
A. There are two types of loop interruption statements in Python that let users terminate a loop iteration prematurely, i.e., without letting the loop run its full iterations.
Following are the two loop interruption statements:
Python break statement: This statement immediately terminates the loop entirely, and the control flow of the program is shifted directly to the outside of the loop.
Python continue statement: Continue statement terminates the current loop iteration and moves the control flow of the program to the next iteration of the loop, letting the user skip only the current iteration.
Q. What is docstring in Python?
A. Python lets the user include a description or quick notes for their methods using documentation strings or docstrings. Docstrings are different from regular comments in Python as rather than being completely ignored by Python Interpreter like in the case of comments Python strings can actually be accessed at the run time using the dot operator when docstring is the first statement in a method or function.
for Top SQL Server Interview Questions and Answers