Top Python Interview Questions & Answers [ 2023 ]

Python Interview Questions for Freshers
Python Interview Questions for Experienced
Python OOPS Interview Questions
Python Pandas Interview Questions
Numpy Interview Questions
Python Libraries Interview Questions
Python Programming Examples

What is Python? What are the benefits of using Python

Answer

- Python is a high-level, interpreted, general-purpose programming language.
- It was created by Guido van Rossum in 1991 and further developed by the Python Software Foundation.
- It was created by Guido van Rossum in 1991 and further developed by the Python Software Foundation.
- It is widely used in data science, machine learning and artificial intelligence.

Benefits:
- Python is a general-purpose programming language that emphasizes readability and has an easy-to-learn syntax, which lowers the cost of programme maintenance.
- The language also supports third-party packages that promote modularity and code reuse, is fully open-source, and can be scripted.
- Compared to some other programming languages, Python enables developers to write programmes with fewer lines.
- For all popular platforms, the Python interpreter and the extensive standard library are freely distributable and available in source or binary form.
- Portable and Interactive

Python is used for:
- Web application Development
- System Scripting
- Software Development
- Game Development
- Complex Mathematics

Differentiate between List and Tuple?

Answer

- Lists are Mutable datatype. whereas Tuples are Immutable datatype.
- Lists consume more memory, whereas Tuple consume less memory as compared to the list.
- In List, iterations is Time-consuming. Wheras, Iteration implementation in Tuple is faster compared to the list
- Syntax of list: list = [12, ‘computer’, 50], Syntax of tuple: tup_1 = (12, ‘computer’, 50)

What is the Difference Between a Shallow Copy and Deep Copy?

Answer

- Shallow Copy is a bit-wise copy of an object.
- The copied object created has an exact copy of the values in the original object.
- Shallow copy is faster.
- Shallow Copy reflects changes made to the new/copied object in the original object.

Syntax of Shallow copy
copy.copy(x)

- Deep copy stores copies of the object’s value.
- Deep copy is comparatively slower.

Syntax of Deep copy
- Deep copy doesn’t reflect changes made to the new/copied object in the original object.
copy.deepcopy(x)

What does ‘#’ symbol do in Python?

Answer

- The character "#" is used to comment out the line.

How to Write a code to display the current time?

Answer

c_time= time.localtime(time.time())
print (“Current time is”, c_time)

What is the maximum possible length of an identifier?

Answer

Identifiers in Python can be of any length.

What is the maximum possible length of an identifier?

Useful features of python.

Answer

Useful features of python.

What Does the // Operator Do?

Answer

The / operator performs division and returns the quotient in the float.
For example: 7 / 2 returns 3.5
The // operator, on the other hand, returns the quotient in integer.
For example: 7 // 2 returns 3

What Does the // Operator Do?

What are the applications of Python?

Answer

- Image processing applications.
- GUI based desktop applications.
- Prototyping
- Business and Enterprise applications
- Web and web framework applications

What are the built-in types available in Python?

Answer

Integer
Complex numbers
Floating-point numbers
Strings
List
Tuple

What are the built-in types available in Python?

Python is an interpreted language. Explain.

Answer

Any programming language that isn't machine-level code prior to runtime is an interpreted language.

What are namespaces in Python?

Answer

The name that is given to each object in Python is referred to as a namespace. Variables and functions are the objects.

There 4 types of namespace in python-
Built-in namespace : contain all the built-in objects in python and are available whenever python is running.
Global namespace: For all the objects created at the level of the main program.
Enclosing namespaces: the higher level or outer function.
Local namespaces: the local or inner function.

Are Arguments in Python Passed by Value or by Reference?

Answer

Pass : to provide it an argument.
By reference:When you send a function an argument via reference, it means that the argument is a reference to a variable that is already present in memory.
- In Python, arguments are passed using a reference. As a result, all modifications done inside a function are reflected in the original object.
- Passing immutable arguments to a function, such as integers, strings, or tuples, behaves like call by value. If we pass mutable parameters, it is different.

What are Keywords in Python?

Answer

- Keywords in python are reserved words that have special meaning.
- Keywords are used to define type of variables.
- Keywords cannot be used for variable or function names.
- Keywords: And, Or, Not, If, Elif, Else, For, While, Break, As, Def,Lambda, Pass, Return, True, False, Try, With, Assert, Class, Continue, Del, Except, Finally , From, Global, Import, In, Is, None, Nonlocal, Raise, Yield

Post a Comment

0 Comments