Python Interview Question
Q1: What is the main feature of Python?
Answer: there are several feature of the Python are followed:
- Python is a High level language, the code of Python is short and simple to write.
- There is no need to learn other programming languages to learn Python.
- Python supports Graphical User interface programming such as Pyqt, tkinter etc.
- Python supports automatic memory allocation; we don’t need to manage memory.
- Python is the extensible language.
- Python provides in-built libraries, with the help of this we can write highly productive and efficient code.
Q2 Difference between Interpreter and Compiler?
Answer: Python is also known as the Language translator which works to convert High level language to Machine code and vice versa.
Interpreters convert code line by line but in the case of Compiler it converts whole code at the same time.
Q3 Difference between Type Casting and Type conversion?
Answer: The changing of the current data type into another data type is called the Type casting. This process is done forcely done by the user.
When the compiler or interpreter changes the data type of the variable itself is called the type conversion.
Q4 What is the Pypi?
Answer: Pypi is an online library of the Python where all the modules of the Python have been saved and it is also known as the Cheese Shop. It is the official third party software repository of Python.
Q5 What is the namespace?
Answer: Namespace is the naming system which is used to make a unique name to avoid the ambiguous situation.
Q6 what is the pep?
Answer: pep stands for Python Enhancement Proposal it is the description of the set of the rules and features of the Python Programming Language.
Q7 What is the Python Module, Writes some commonly used In-built Modules.
Answer: Python Module is the nothing it is just code which is defined by the Python Community with help of this module we can write shorter code. The extension file name .py.
Some common used In built Module
Q8 What is the Pretested and Post-tested loop?
Answer: In Pre-tested loop first condition has checked and later loop block has executed example is For and while loop but in the case of the Post tested loop first loop has executed and further condition has checked example is do while loop. Post-tested loop not supported by Python
Q9 Difference between List and Tuple?
Answer: List and Tuple both store hydrogenous data type and same functionality of accessing the data of list and tuple respectively by using the index value.
- List is mutable but Tuple are Immutable.
- List supports the Assignment and Deletion but Tuple does support both of them.
- List is defined by the [ ] bracket but tuple is defined by the ( ) bracket.
- Implication and Iteration in List is time consuming but Tuple is quite fast.
- List has several in-built functions but Tuple does not have more inbuilt functions.
Q10 What is the local and global variable?
Answer: local variables define out of the class or function it can be accessed from anywhere.
Global variables define inside the class and function only a particular class or function can use local variables.
Q11 Is Python case sensitive?
Q12: What is the indentation in Python?
Answer: Python does support the curly braces to define the range of the function, class or keyword. So we have maintained the spacing to keep in range, this space is called the indentation.
Q13 Does List is the array?
Answer: Array is storing the homogeneous data type but the list can store the heterogeneous data type .we can say list is type of array but it is not a complete array.
Q14 What is the Homogeneous and Heterogeneous data type?
Answer: Similar type of the data type is called Homogeneous e.g.( 1, 2,3,43,43,4,35,3)
Different type of the data type is called Heterogeneous e.g. (11, 22.22, True, “hello”)
Q15 what is __init__?
Answer: __init__ is the method or constructor in Python, it will automatically called when it gets the memory.
Q16 What is the lambda function in Python? And also writes the syntax of Lambda function.
Answer: Lambda function is the anonymous function, it is used for making code shorter, it can take a number of the parameters.
Syntax: lambda argument: expression
Q17 Does the functionality of “is” and “==” are the same ?
Answer: Partially is working as the same but here is a major difference between the both.
‘is’ is the type of Membership operators but ‘==’ is the type of comparison operator.
‘is’ is working on the address of any variable or object but ‘==’ is working upon the value of the variable.
Q18 How to connect Mysql database with Python ?
Answer : let understand the procedure step by step:
Step 1 : Download Mysql Community Server from https://www.mysql.com/downloads/ following link.
Step 2 : Install and Configure the mysql server in your local machine
Step 3 : Open Windows shell and type this command :
pip install mysql_connector
Step 4 : Open Python Idle and type following code:
import mysql.connector mydb=mysql.connector.connect(host='localhost',user="yourusername",password="yourpassword") print(mydb)
When you get the connection id ,it means that you have successfully connected with Mysql via Python.
Q19 Write code to get the .pyc file in Python .
Answer : import py_compile
Q20 How many types of inheritance in Python ?
Answer : There are 5 type of inheritance in Python
- Single Inheritance
- Multilevel Inheritance
- Multiple Inheritance
- hierarchical Inheritance
- Hybrid Inheritance
Q21 What is the “eval” in Python ?
Answer : Python eval() is used for evaluation for the specified expression,If the expression is legal in Python.
Q22 What is the difference between Python Module and Python Packages ?
Answer : Module is a specific file which contains a set of Python instructions while the Package consists of the group of modules.
Q23 How to install django in the System ?
Answer : open the command prompt and type cmd after that press enter button.
after the opening of the Windows Command Shell type this following command:
pip install django
for the Install the specific version of the Django try :
pip install django==(version name)
Q24 What is the “createsuperuser” command in Python and Why use ?
Answer : This command is used for the given the username and password to your project the aim of this command is secure to your project to unauthorized used the syntax is following :
python manage.py createsuperuser
Q25 How to create project and app in Django
Answer :django-admin createproject (project_name) for creating the Project
django-admin createapp(app_name) for creating App.
Q26 How to run the project in django ?
Answer : Go to windows shell and typing the following command
python manage.py runserver
python manage.py runserver==(specific version)
Q27 what is the “migrate” command ?
Answer : this command is applied for making tables in the database.
Q28 What is the Google Colaboratory ?
answer : Google colab is sort name of Google Colaboratory its research project of Google its allowed developer and programmer to write the Python code at your web browser.
Q29 Why are Pandas used ?
Answer :Pandas is used for the high performance of merging data,Python pandas is used in many fields like Finance,Statistic,Web Development,Artificial Intelligence and data preprocessing and much more.
Q30 Why are Numpy used ?
Q31 What is a SciPy ?
Answer :The SciPy is the library of Python. It is the open source library used for scientific computing and mathematical problems. SciPy provides optimization, linear algebra, integration, interpolation.
It provides the user friendly numerical integrations.
Q32 What is used for Matplotlib?
answer : Matplotlib is the very provider of the visual library of Python,It is used for the creating high quality of Graph and 3D Graph which makes data in more understable form.
Q33 What is a Python Cleansing ?
Answer :Machine Learning and artificial intelligence ,face recognition systems ,data mining needs accurate and complete data for better prediction,poor quality cause the missing value ,we will focus on the missing value for making the strong mode.
Q34 Why did we use Data Wranglings ?
Answer :It refers to the technique where we process the data and clean the data for further use.as we know that data comes from the various sources and this type of the data is very bulky and incomplete, Python performs the operations to clean the data.
Q35 What is Scikit Learn ?
Answer :Scikit learn is the powerful tool of machine learning.it provides the statistical modelling,classification,regression etc.This library is related to Python and also developed in Python Languages.It is the free library,Scikit also support the functionality of the Numpy and Scipy.
Q36 Used for Web Scraping ?
Answer : this term is used for the extraction of a large amount of the data from a website. There are two ways to retrieve the data .
1- We can use the API to retrieve the data from the web, like facebook API which helps to retrieve data from facebook.
2- We can also use web scraping or we harvesting to retrieve the data from the website.
Q37 What is a Anaconda Distribution ?
Answer : Anaconda is the open source application for using R and Python Programming,Programmer and Developer is used for scientific learning ,data science, machine learning application,processing large amounts of data etc.
Q38 What is aJupyter ?
Answer : Jupyter is a web based application, it is an interactive development environment,it is a very flexible platform to use.
Q39 Writes the syntax for installing Jupyter.
pip install jupyterlab
Q40 Why is Pillow used ?
Answer : Abbreviation as PIL ,Python has a large amount of inbuilt modules to work with more frequently ,PIllow is used for reading the variety of images from the local disk.
Q41 How to read csv files in Data Science ? Give Demonstration.
import pandas as pd #importing pandas library abc = pd.read_csv('path/info.csv') #read info.csv file print (abc) #print abc file