Contact Us
A 101-103 Siddhivinayak Towers, Off S.G. Highway, Ahmedabad, Gujarat 380051

Python Interview Questions Part 1

by Attune World Wide / /

1. Who is the author of python? When was Python conceived?

  • Guido van Rossum. Late 1980s

2. What are the features of python? Why python is popular?

  • Features or advantages of python
    1. Solve complex problems in less time
    2. Python is Interpreted
    3. Dynamically typed or Loosely typed ( No need to specify datatypes )
    4. Object oriented programming
    5. Used for many purposes ( Data Science, Machine Learning, Artificial Intelligence, Web Development, Software Testing, Hacking, etc )
    6. Supports multiple OS or cross platformed

3. Is Python case sensitive?

  • Yes, Python is case sensitive that means we can’t write true or TRUE for True and similarly we can’t write false or FALSE for False.

4. In Python, how important indentation is or What role does indentation plays in Python programming?

  • Indentation is required in Python and is most important. Indentation specifies a block of code in Python. If your code is not properly indented then python interpreter will show errors.
  • Unlike other programming languages, python works on indentation to replace the brackets -{} for defining a block or a scope for a function or a class.

5. How is function defined in Python?

  • To define a python function, a def keyword is used.
  • def MyFunction():
    print(“Hi, Welcome to Python”)
    MyFunction(); #calling the function

6. What is __init__()?

  • __init__() is method or constructor in Python. It gets automatically called when any new instance of a class is created.

7. What is slicing in Python?

  • Selecting the range of item from a sequence is known as slicing mechanism.
    1. List1[1:4]
    2. List1[5:-2]

8. What is the difference between Modules and Packages in Python?

  • Modules :
    1. In Python, module is the way to structure program. Each Python program file is a module, which imports other modules like objects and attributes.
  • Packages :
    1. The folder of Python program is a package of modules. A package can have modules or subfolders.
    2. Generally the package contains file which defines it as a package.

9. What is the difference between break, continue and pass?

  • Break :
    1. Allows loop termination when some condition is met and the control is transferred to the next statement.
  • Continue :
    1. Allows skipping some part of a loop when some specific condition is met and the control is transferred to the beginning of the loop
  • Pass :
    1. Used when you need some block of code syntactically, but you want to skip its execution. This is basically a null operation. Nothing happens when this is executed.

10. What does [::-1] do?

  • [::-1] is used to reverse the order of a sequence. Sequence can be any list, tuple, array, string, etc.

About Attune World Wide

What you can read next

Leave a Reply

Your email address will not be published. Required fields are marked *

7 + 16 =

Recent Posts