Feb 26, 2020

python questions for interview

Python questions for Interview

This post is all about the Python questions for the interview and python interview questions for freshers and helps you to enhance your Python language and develop your skill a bit more.

1)What is a pass in Python language?
Ans:- The meaning of pass is no operation python statement or we can say it is a place holder in the compound statement , where only blank is left and nothing is written there.

2)What are Generators in python language?
Ans:-The way of putting iterators are called generators. it's just a normal function except that it yields expression in function. 

3)How to Convert Number to String?
Ans:-to convert a number into a string we have to use the function called str(). if we want an octal or hexadecimal representation than we have to use oct() function or hex() function.

4)What are the different build-in types python has?
Ans:-There are two types of Built-in types in python , Mutable and immutable

Mutable types are as follows
  • List
  • Sets
  • Dictionaries
Immutable Types in python are
  • String
  • Tuple data type
  • Numbers
4)What is Spilt function in python and it's used in python?
Ans:-Split function as per its name suggests that it's used to break the string into shorter strings by using the defined separator . and it gives the list of all the words present in that particular string.

5)What is the difference between tuple and list data types?
Ans:-List is mutable which means that the data present in mutable data type can be modified whereas Tuple is immutable which cannot be modified so the data in Tuple cannot be changed or modifies.

6)How to manage memory in python programming language?
Ans:-Python memory is managed by Python private heap space. All the objects and data structures are present in a private heap. The programmer does not have any access to this private heap and the interpreter takes care of this Python private heap.

Python memory manager is responsible for the allocation of python heap space, the core API gives access to some tools for the programmer to code.

Python also has an inbuilt garbage collector , Which recycles all the unused memory and frees the memory and makes it available to the heap space.

7)How to write a comment in Python?
Ans:- To write a comment in python language we have to start the sentence with "#" then the compiler of the python assumes that sentence as the comment.

8)Why the PYTHONPATH variable is used?
Ans:-its function is similar to PATH, this variable tells the python compiler where to find the module files and imported that located files into the program. It should also include the Python source library directory and the directories which contain Python source code. PYTHONPATH is sometimes preset by the python installer which is already there in a python programing language.

9)How to use join() function in Python?
Ans:-Join() function is used to join the two strings into one string, this is very useful for joining the two strings into single string.

10)What is the difference between local and global in python?
Ans:- Global variable is used by any function in the program and local variables are defined inside the particular program and that variable is only accessed by that program only and that variable is been used under that program only.


Popular Blog Posts