Python Interview Questions
1 .
How Python is interpreted?
Python language is an interpreted language. Python program runs directly from the source code. It converts the source code that is written by the programmer into an intermediate language, which is again translated into machine language that has to be executed.
2 .
Mention what is Flask-WTF and what are their features?
Flask-WTF offers simple integration with WTForms. Features include for Flask WTF are Integration with wtforms Secure form with csrf token Global csrf protection Internationalization integration Recaptcha supporting File upload that works with Flask Uploads
3 .
How can I find methods or attributes of an object in Python?
Built­in dir() function of Python ,on an instance shows the instance variables as
well as the methods and class attributes defined by the instance’s class and all its base classes alphabetically. So by any object as argument to dir() we can find all the methods & attributes of the object’s class
4 .
What is the usage of help() and dir() function in Python?
help() and dir() both functions are accessible from the Python interpreter and used for viewing a consolidated dump of built-in functions.
 
Help() function : The help() function is used to display the documentation string and also facilitates you to see the help related to modules, keywords, attributes, etc.

Dir() function : The dir() function is used to display the defined symbols.
5 .
What is Polymorphism in Python?
Polymorphism means the ability to take multiple forms. So, for instance, if the parent class has a method named ABC then the child class also can have a method with the same name ABC having its own parameters and variables. Python allows polymorphism.
6 .
What Is %S In Python?
Python has support for formatting any value into a string. It may contain quite complex expressions.
 
One of the common usages is to push values into a string with the %s format specifier. The formatting operation in Python has the comparable syntax as the C function printf() has.speed
7 .
What Is The Set Object In Python?
Sets are unordered collection objects in Python. They store unique and immutable objects. Python has its implementation derived from mathematics.
8 .
What Is The Difference Between An Iterator And Iterable?
The collection type like a list, tuple, dictionary, and set are all iterable objects whereas they are also iterable containers which return an iterator while traversing.
9 .
How Do You Delete Elements Of A Dictionary In Python?
We can delete a key in a dictionary by using the del() method.
 
>>> site_stats = {'site': 'freetimelearning.com', 'traffic': 10000, "type": "organic"}
>>> del site_stats["type"]
>>> print(site_stats)
{'site': 'google.co.in', 'traffic': 1000000}

Another method, we can use is the pop() function. It accepts the key as the parameter. Also, a second parameter, we can pass a default value if the key doesn’t exist.
 
>>> site_stats = {'site': 'freetimelearning.com', 'traffic': 10000, "type": "organic"}
>>> print(site_stats.pop("type", None))
organic
>>> print(site_stats)
{'site': 'freetimelearning.com', 'traffic': 10000}
10 .
How Do You Write A Conditional Expression In Python?
We can utilize the following single statement as a conditional expression. default_statment if Condition else another_statement
 
>>> no_of_days = 366
>>> is_leap_year = "Yes" if no_of_days == 366 else "No"
>>> print(is_leap_year)
Yes