×

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 16 Moo Tools Interview Questions for 2024

1) What is Moo Tools? MooTools stands for My Object-Oriented Tools. It is a lightweight and object-oriented JavaScript framework. It is used to create dynamic web page. It is developed by Valerio...

5 minutes read.

Top 15 Haskell Interview Questions for 2024

1) What is Haskell? Haskell is a functional programming language. It is based on mathematical functions. This programming language is more intelligent than other popular programming languages. 2) Who is the developer of...

2 minutes read.

Top 15 PhantomJS Interview Question for 2024

1) What is PhantomJS? PhantomJS is a lightweight headless scripted browser built on WebKit. It is used for automation web page interaction. 2) Why it is called as headless browser? PhantomJS called as...

4 minutes read.

Top 30 Cassandra Interview Questions for 2024

1) Explain. What is Cassandra? Cassandra is an open source data storage system. It was developed at Facebook for inbox search and designed for storing and managing large amount of data. 2)...

5 minutes read.

Top 30 FuelPHP Framework Interview Questions for 2024

1) What is FuelPHPFramework? FuelPHP Framework is an open source web application and written in PHP scripting language. It is based on the HMVC (Hierarchical Model View Controller) design pattern. It was released...

6 minutes read.

Top 30 TypeScript Interview Questions for 2024

1) What is TypeScript? TypeScript is an object-oriented and compiled language. TypeScript is also known as a set of tools. TypeScript is used for application-scale development. 2) What are the features of TypeScript? Features of...

4 minutes read.

Top 15 CherryPy Interview Questions for 2024

1) What is CherryPy? CherryPy is a web framework used for Python. It provides a friendly interface for Http protocol for Python developer. 2) Why we use CherryPy? CherryPy has following strength: Simplicity: It...

3 minutes read.

Top 30 Cobol Interview Questions for 2024

1) What is COBOL? COBOL is a programming language which is used for finance, business and administrative systems for companies. COBOL is stands for Common Business Oriented Language. 2) What are the features...

4 minutes read.

Top 25 MySQL Interview Questions for 2024

1) What is MySQL? MySql is defined as multi-user DBMS which is built and distributed my MySQLab now acquired by Oracle Co. 2) Enlist the features of MySQL. Cross-Platform Support Wide range...

3 minutes read.

Top 30 DBMS Interview Questions for 2024

1) What is DBMS? DBMS (Data Base Management System) is a technology for managing data of database i.e. Create, Update, Delete, Alter. 2) What is a Database System? It is defined as collection...

4 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 15 Cordova Interview Questions for 2024

Top 20 Cordova Interview Questions and Answers for Freshers 1) What is Cordova? Cordova is a mobile application development framework. Cordova allows building mobile application using HTML5, CSS3, and JavaScript. Cordova is...

3 minutes read.

Top 15 Java OOPS Interview Questions for 2024

1) What are the advantages of Java Package? Advantages of Java package are: Provides access protection Removes naming collision Easily maintained 2) What are the types of Access Modifiers in Java? Two types...

4 minutes read.

Top 30 WordPress Interview Questions for 2024

Most Frequently asked WordPress Interview Questions and Answers 2019 1) What is WordPress? WordPress is an open-source CMS (Content Management System) and a blogging tool. It is used to create web sites and...

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 30 Fortran Interview Questions for 2024

1) What is Fortran? Fortran is general purpose, high-level programming language which is used for numeric and scientific computing. 2) What are the features of Fortran programming language? Features of Fortran language are: ...

4 minutes read.

Top 15 ASP.NET MVC Framework Interview Questions for 2024

1) What is ASP.NET MVC Framework? ASP.NET MVC framework is a software architecture pattern for developing web applications. It is used to split the application's implementation logic into three components: models,...

4 minutes read.

Top 30 Perl interview questions for 2024

1) What is Perl? It is a programming language which is used for web development, system administration, GUI development and etc. It is also known as cross-platform programming language. 2) What are the...

4 minutes read.

Top 30 CodeIgniter interview Questions for 2024

1) What is CodeIgniter? CodeIgniter is an open source PHP framework. It is used to develop web applications and websites. It is loosely based on MVC pattern and easy to use...

4 minutes read.

Top 29 Phalcon Framework Interview Questions for 2024

1) What is Phalcon? Phalcon is an open source framework based on the MVC (Model-View-Controller) pattern. It is the combination of PHP and C language. It is developed by Andres Gutierrez...

6 minutes read.