Python Interview Questions and Answers
- What is Python? What are the benefits of using Python?
- What are the key features of Python?
- What type of language is python? Programming or scripting?
- Is python a case sensitive language?
- Is indentation required in python?
- What is self in Python?
- What is pep 8 in Python?
- Can we take any name in place of self in python?
- What is a function in Python Programming?
- Write the steps to define the function in python
- How to call a function in python?
- What is __init__ in Python?
- What is the difference between self and __init__ methods in python Class?
- What is the return keyword used for in python?
- Is It Mandatory For A Python Function To Return A Value?
- What Is The Return Value Of The Trunc() Function in python?
- What is “Call By Value” in Python?
- What Is “Call By Reference” In Python?
- How are arguments passed by value or by reference in Python?
- What is the output of the below python code?
- What is the output of the below python code?
- What is the output of the below python code?
- How many basic types of functions are available in Python?
- What are the applications of Python?
- What are python modules? Name some commonly used built-in modules in Python?
- What are the benefits of Python?
- What are the Python libraries? Name a few of them
- What is the difference between list and tuples in Python?
- What Does The __ Name __ Do In Python?
- Does Python have a main()method?
- What is the purpose of “end” in Python?
- Is the Python platform independent?
- What are Python packages?
- What are the OOPS concepts available in Python?
- What Is Class In Python?
- How to create a class in Python?
- What is the syntax for creating an instance of a class in Python?
- How to create an empty class in Python?
- Explain Inheritance in Python with an example?
- Does python support multiple inheritances?
- Write a python code that explains the inheritance?
- What is polymorphism in Python?
- Write a python code that explains the Polymorphism?
- Does Python make use of access specifiers?
- Define encapsulation in Python?
- What is data abstraction in Python?
- How do you do data abstraction in Python?
- What is pass in Python?
Answer :
Yes, Indentation is necessary for Python. Most of the programming languages like C, C++, Java use braces { } to define a block of code. Python uses the indentation to mark blocks of code. It is one of the distinctive features of Python is its use of indentation to highlighting the blocks of code. Whitespace is used for indentation in Python. If your code is not indented necessarily, it will not execute accurately and will throw errors as well.
Output:
Hi aticleworld…
Please visit Aticleworld !
Code Explanation,
The lines print(‘Hi aticleworld…’) and print(‘Ohh…’) are two separate code blocks. The two blocks of code in our example if-statement are both indented four spaces. Last print(‘Please visit Aticleworld !’) is not indented, and so it does not belong to the else-block.
need an explanation for this answer? contact us directly to get an explanation for this answer