×

Top 30 Python Interview Questions for 2024

1) What is Python?

Python is a high level, interpreted and object-oriented programming language. It is easy to learn and supports multiple programming patterns. It is also known as powerful and versatile scripting language.

2) What are the features of Python?

The features of Python are:
  • Easy to use.
  • Object oriented language.
  • Extensible.
  • Integrated.
  • Interpreted language.
  • Cross platform language.
  • Expressive language.

3) What are the types of applications developed by Python?

Application developed by python is:
    • Audio or Video based applications.
Example: TimPlayer etc.
    • Console based applications.
Example: IPython.
    • Web applications.
Example: Pocoo, PythonWikiEngines etc.
    • Application for images.
Example: Gogh, imgSeek etc.
    • Enterprise applications.
Example: OpenErp, Picalo etc.

4) What are the types of tokens used in Python?

There are following types of tokens used in Python are:
  • Keywords.
  • Identifiers.
  • Literals.
  • Operators.

5) Write a simple program in Python to print “PYHTON EXPERT”?

Example of Python program:
a= "PYTHON EXPERT"    
print a

6) What are the types of keywords used in Python?

The types of keywords used in Python are:
finally True False None
and is for as
asset def else not
return lambda or if
elif class import try

7) What are the types of String supported in Python?

There are two types of String supported in Python are:
  • Single line String.
  • Multi line String.

8) What will be the output of the following code snippet?

x=100    
y=200  
list=[100,200,300,400,500];    
if (x in list):    
    print "x is in given list"    
else:    
    print "x is not in given list"    
if(y not in list):    
    print "y is not given in list"    
else:    
    print "y is given in list"
OUTPUT:
x is in given list
y is given in list

9) What will be the output of the following code snippet?

x=9>4 and 4>2    
print x    
y=2>4 or 1<2    
print y    
z=not(8>4)    
print z
OUTPUT:
True  
True
False

10) What are the types of “Python Operators”?

Types of operator are:
  • Arithmetic Operators.
  • Assignment Operators.
  • Membership Operators.
  • Bitwise Operators.
  • Relational Operators.
  • Logical Operators.
  • Identity Operators.

11) What are the types of comments in Python?

There are two types of comment in Python:
    • Single line comment.
Example: # Single Line Comment.
    • Multiple line comment.
Example: '''Multiple Line Comment.'''

12) What will be the output of the following code snippet?

for i in [10,20,30,40,50]:    
 if i==30:    
 pass    
 print "Pass when value is", i    
 print i,
OUTPUT:
10 20 Pass when value is 30
30 40 50


13) Write a program in Python to swap two variables?

Example of swapping:
x = input('Enter value of x: ')    
y = input('Enter value of y: ')  
temp = x    
x = y    
y = temp    
print('The value of x after swapping: {}'.format(x))    
print('The value of y after swapping: {}'.format(y))

14) Write a program in Python to check the number is odd or even?

Example of odd or even number:
num = int(input("Enter a number: "))    
if (num % 2) == 0:    
   print("{0} is Even number".format(num))    
else:    
   print("{0} is Odd number".format(num))

15) Write a program in Python to check the number is positive, negative or zero?

Example:
num = float(input("Enter a number: "))    
  if num > 0:    
 print("{0} is a positive number".format(num))    
 elif num == 0:    
 print("{0} is zero".format(num))     
 else:    
 print("{0} is negative number".format(num))

16) Who is the developer of Python?

Guido van Rossum is the developer of Python.

17) What is dictionary in Python?

Dictionary: It is the collection of components. The components of dictionary are keys and values. Here the values are retrieved by square bracket.

18) How to create a dictionary in Python?

Example:
>>> dictionary={'name':'Atul Jaiswal','id':7014,'dept':'CSE'}

19) Write the following commands used in dictionary?

The following commands used in dictionary are:
    • Used to create dictionary
dictionary= {'variable':'value'}
    • Used to check the available key and value pairs in dictionary
dictionary
    • Used to check the keys available in dictionary
dictionary.keys()
    • Used to check the values available in dictionary
dictionary.values()

20) What are Tuples?

Tuples: It is the form of collection where the data can be stored. It is also similar to list where data is separated by commas. Tuples are enclosed in parenthesis.

21) How to assign single value to multiple variables in Python?

Example:
a=b=c=7014    
print a    
print b    
print c

22) What are the types of literals available in Python?

The types of literals available in Python are:
  • String literals
  • Numeric literals
  • Boolean literals
  • Special literals
  • Literal Collections

23) What are the types of Numeric literals available in Pyhton?

Numeric literals are of four types:
  • Int(signed integers)
  • Long(long integers)
  • float(floating point)
  • Complex(complex)

24) What is the difference between Object-oriented and Procedure-oriented programming languages?

The difference between Object-oriented and Procedure-oriented programming languages are:
Object-oriented Programming Procedural Programming
The computation is done by using objects. It uses a list of instructions to do computation step by step.
Simulates the real world entity. Doesn’t simulate the real world.
Makes maintenance and development easier. Not easy to maintain the codes when project becomes lengthy.
Example: C++, C#, Java. Example: C, Fortran, Pascal.

25) Which command is used to delete a file in Python?

Command used to delete a file in Pyhton is: os.remove (filename)

26) What is the use of split function in Python?

split function: This function is used to divide a string into shorter strings by using the defined separator. It also gives the list of words present in the string.

27) What is capitalize() function?

capitalize(): This function is used to capitalize the first character of String.

28) How can you copy an object in Python?

You can copy an object in Python by using: copy.copy() or copy.deepcopy()

29) What is docstring in Python?

docstring stands for documentation string. It is a way of documenting functions, modules and classes.

30) What are the types of membership operator used in Python?

The types of membership operator are:
  • in operator
  • not in operator

Related Topics

Top 24 Clojure Interview Questions for 2024

1) What is Clojure? Clojure is a dynamic, general-purpose programming language. It is simple, coherent and powerful tool. It is based on Lisp Programming language. 2) Which platform is used to run...

4 minutes read.

Top 28 LISP Interview Questions for 2024

1) What is LISP? LISP is the high-level programming language after Fortran. LISP is stands for List Processing. This programming language was invented by John McCarthy in 1958 at the Massachusetts Institute of...

3 minutes read.

W3.CSS Interview Questions

1) What is W3.CSS? W3.CSS stands for Cascading Style Sheet. It is developed by w3schools.com. It is used to create faster, beautiful and responsive websites. 2) What are the features of W3.CSS? W3.CSS...

3 minutes read.

Top 43 React Native Interview Questions for 2024

1. What is React Native? React native is an open-source JavaScript framework designed by Facebook for native mobile applications development. It is based on a JavaScript library-React. React Native saves your development...

11 minutes read.

Top 15 Java Collections Interview Questions for 2024

1) What is Collections in Java? It is a framework which is used to store and manipulate the group of objects. 2) What are the commonly used methods of Collection interface in...

2 minutes read.

Top 18 Blockchain Interview Questions and Answers for 2024

Top 20 Commonly Asked Blockchain Interview Questions and Answers 1. What do you understand by Blockchain? Blockchain is a chain of blocks made up of digital pieces of information or can be defined as...

6 minutes read.

Top 30 VB Script Interview Questions for 2024

1) What is VB Script? VBScript stands for Visual Basic Scripting Language. It is a light version of Microsoft Visual Basic. It is a client side scripting Language. 2) What is the...

5 minutes read.

Top 13 SAS Interview Questions for 2024

1. What is SAS and its functions? SAS (Statistical Analysis System) is statistical software designed by SAS Institute in 1960 for data inspection and report writing. SAS runs on Windows, UNIX...

5 minutes read.

Top 15 JSP Interview Questions for 2024

1) What is JSP? It is a technology which is used to create web application like Servlet technology. It provides more functionality than Servlet. It consists of HTML and JSP tags. 2) What are...

3 minutes read.

Top 30 Web2py Framework Interview Questions for 2024

1) What is Web2py Framework? Web2py is an open source web application framework. It is written in the Python programming language. It allows web developers to design and develop dynamic web...

7 minutes read.

Top 20 Java Programming Coding Interview Questions for 2024

Coding is an integral part of any programming language. It is the most important phase of an interview. Interviewee checks the capability of thinking of any particular. I think one...

13 minutes read.

Top 12 Docker Interview Questions for 2024

Most frequently asked Docker Interview Questions and Answers for Fresher 1. What is Docker? Docker is a new form of Software Containerization in the field of IT. It is an open-source container...

4 minutes read.

Top 30 Zend Framework Interview Questions for 2024

1) What is Zend Framework? Zend is an open source, object-oriented web application framework. It is implemented in PHP 5. It was developed in 3 March 2006. 2) What is the use...

6 minutes read.

Top 15 Erlang Interview Questions for 2024

1) What is Erlang÷ Erlang is an open source programming language. It is used to build massively scalable soft real-time systems. It has runtime environment. It supports concurrency, fault tolerance and...

2 minutes read.

Top 15 Java BeanUtils Interview Questions for 2024

1) What is Java BeanUtils? Java BeanUtils is a design pattern component of the Apache Commons. It facilitates architecture for Java language which is derived from JavaAPI. It helps to set...

3 minutes read.

Top 15 C Interview Questions for 2024

1) What are different storage class specifiers in C? Register,auto, static, extern are the storage class specifiers in C. 2) What is scope of a variable? How are variables scoped in C? Scope...

3 minutes read.

Top 15 CSS Buttons Interview Questions for 2024

1) What is CSS buttons? CSS buttons is used to create awesome button. It provides huge collection of CSS library files. 2) What are the CSS libraries to create buttons? There are following...

5 minutes read.

Top 22 MariaDB Interview Question for 2024

1) What is MariaDB? It is a community based database devoloped by MySQL Devolopers. It provides same features as MySQL also, can be said that it is a replacement of MySQL. 2)...

3 minutes read.

Top 16 OpenStack Interview Questions for 2024

Most Frequently Asked OpenStack Interview Questions and Answers for Freshers 1. Describe OpenStack. OpenStack is designed as the future of cloud computing and developed as free and open-source software that facilitates a...

8 minutes read.

Top 30 Less Interview Questions for 2024

1) What is Less? Less is a dynamic style sheet language that can be compiled in to CSS (Cascading style Sheet). It runs on client side and server side. It is...

4 minutes read.