Python Technical Questions

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Mention five benefits of using Python?

- Python comprises of a huge standard library for most Internet platforms like Email, HTML, etc. - Python does not require explicit memory management as the interpreter itself allocates the memory to new variables and free them automatically - Provide easy readability due to use of square brackets - Easy-to-learn for beginners - Having the built-in data types saves programming time and effort from declaring variables

In Python what is slicing?

A mechanism to select a range of items from sequence types like list, tuple, strings etc. is known as slicing.

What is unittest in Python?

A unit testing framework in Python is known as unittest. It supports sharing of setups, automation testing, shutdown code for tests, aggregation of tests into collections etc.

What is the difference between list and tuple?

List is mutable while tuple is not. Tuple can be hashed for e.g as a key for dictionaries.

What are Python decorators?

A Python decorator is a specific change that we make in Python syntax to alter functions easily.

What is docstring in Python?

A Python documentation string is known as docstring, it is a way of documenting Python functions, modules and classes.

Why do lambda forms in python not have statements?

A lambda form in python does not have statements as it is used to make new function object and then return them at runtime.

Are arguments passed by value or by reference?

Everything in Python is an object and all variables hold references to the objects. The references values are according to the functions; as a result you cannot change the value of the references. However, you can change the objects if it is mutable.

Explain what is Flask & its benefits?

Flask is a web micro framework for Python based on "Werkzeug, Jinja 2 and good intentions" BSD licensed. Werkzeug and jingja are two of its dependencies. Flask is part of the micro-framework. Which means it will have little to no dependencies on external libraries. It makes the framework light while there is little dependency to update and less security bugs.

What is namespace in Python?

In Python, every name introduced has a place where it lives and can be hooked for. This is known as namespace. It is like a box where a variable name is mapped to the object placed. Whenever the variable is searched out, this box will be searched, to get corresponding object.

In Python what are iterators?

In Python, iterators are used to iterate a group of elements, containers like list.

What is module and package in Python?

In Python, module is the way to structure program. Each Python program file is a module, which imports other modules like objects and attributes. The folder of Python program is a package of modules. A package can have modules or subfolders.

How you can convert a number to a string?

In order to convert a number into a string, use the inbuilt function str(). If you want a octal or hexadecimal representation, use the inbuilt function oct() or hex().

What is the use of // operator in Python?

It is a Floor Divisionoperator , which is used for dividing two operands with the result as quotient showing only digits before the decimal point. For instance, 10//5 = 2 and 10.0//5.0 = 2.0.

What is lambda in Python?

It is a single expression anonymous function often used as inline function.

Mention what are the rules for local and global variables in Python?

Local variables: If a variable is assigned a new value anywhere within the function's body, it's assumed to be local. Global variables: Those variables that are only referenced inside a function are implicitly global.

What are the built-in type python provides?

Mutable: - List - Sets - Dictionaries Immutable: - Strings - Tuples - Numbers

What is PEP 8?

PEP 8 is a coding convention, a set of recommendation, about how to write your Python code more readable.

What is pass in Python?

Pass means, no-operation Python statement, or in other words it is a place holder in compound statement, where there should be a blank left and nothing has to be written there.

What is pickling and unpickling?

Pickle module accepts any Python object and converts it into a byte string representation and dumps it into a file by using dump function, this process is called pickling. The process of retrieving original Python objects from the stored string representation is called unpickling.

What are the tools that help to find bugs or perform static analysis?

Pylint is another tool that verifies whether the module meets the coding standard.

What is Python? What are the benefits of using Python?

Python is a programming language with objects, modules, threads, exceptions and automatic memory management. The benefits of pythons are that it is simple and easy, portable, extensible, build-in data structure and it is an open source.

How Python is interpreted?

Python language is an interpreted language. Python program runs directly from the source code. It converts the source code that is written by the programmer into an intermediate language, which is again translated into machine language that has to be executed.

How memory is managed in Python?

Python memory is managed by Python private heap space. All Python objects and data structures are located in a private heap. The programmer does not have an access to this private heap and interpreter takes care of this Python private heap. The allocation of Python heap space for Python objects is done by Python memory manager. The core API gives access to some tools for the programmer to code. Python also have an inbuilt garbage collector, which recycle all the unused memory and frees the memory and makes it available to the heap space.

What is negative index in Python?

Python sequences can be index in positive and negative numbers. For positive index, 0 is the first index, 1 is the second index and so forth. For negative index, (-1) is the last index and (-2) is the second last index and so forth.

Mention the use of the split function in Python?

The use of the split function in Python is that it breaks a string into shorter strings using the defined separator. It gives a list of all words present in the string.

What are generators in Python?

The way of implementing iterators are known as generators. It is a normal function except that it yields expression in the function.

What are Dict and List comprehensions?

They are syntax constructions to ease the creation of a Dictionary or List based on existing iterable.

What is the difference between Xrange and range?

Xrange returns the xrange object while range returns the list, and uses the same memory and no matter what the range size is.


संबंधित स्टडी सेट्स

Adult Gerontology - Male Genitourinary Problems

View Set

Typescript - Basics (Sections 1-4)

View Set

Chapter 22 (Management of Patients with Upper Respiratory Tract Disorders)

View Set

Bio Chapter 17 - Olfaction & Gustation

View Set

Chapter 10: Baroque Instrumental Music

View Set