All Questions

Python

Follow
Showing 41 - 50 out of 172 Questions
110 Views

What is functional programming? Does Python follow a functional programming style? If yes, list a few methods to implement functionally oriented programming in Python

Nitin Mereddy 24th Oct, 2021

Functional programming is a coding style where the main source of logic in a program comes from functions.


Incorporating functional programming in our codes means writing pure functions.


Pure functions are functions that cause little or no changes outside the scope of the function. These changes are referred to as side effects. To reduce side effects, pure functions are used, which makes the code easy-to-follow, test, or debug.


Python does follow a functional programming style

54 Views

What is slicing in Python programming

Nitin Mereddy 24th Oct, 2021

Slicing is a process used to select a range of elements from sequence data type like list, string and tuple. Slicing is beneficial and easy to extract out the elements. It requires a : (colon) which separates the start index and end index of the field. All the data sequence types List or tuple allows us to use slicing to get the needed elements. Although we can get elements by specifying an index, we get only a single element whereas using slicing we can get a group or appropriate range of needed elements.

58 Views

How is Multithreading achieved in Python?

Nitin Mereddy 24th Oct, 2021

Python has a multi-threading package ,but commonly not considered as good practice to use it as it will result in increased code execution time.


Python has a constructor called the Global Interpreter Lock (GIL). The GIL ensures that only one of your ‘threads’ can execute at one time.The process makes sure that a thread acquires the GIL, does a little work, then passes the GIL onto the next thread.

This happens at a very Quick instance of time and that’s why to the human eye it seems like your threads are executing parallely, but in reality they are executing one by one by just taking turns using the same CPU core.

129 Views

How does Python Flask handle database requests?

Nitin Mereddy 24th Oct, 2021

Flask supports a database-powered application (RDBS). Such a system requires creating a schema, which needs piping the schema.sql file into the sqlite3 command. Python developers need to install the sqlite3 command to create or initiate the database in Flask.


Flask allows to request for a database in three ways:


before_request(): They are called before a request and pass no arguments.

after_request(): They are called after a request and pass the response that will be sent to the client.

teardown_request(): They are called in a situation when an exception is raised and responses are not guaranteed. They are called after the response has been constructed. They are not allowed to modify the request, and their values are ignored.

47 Views

What is self in Python programming language

Nitin Mereddy 24th Oct, 2021

Self is an object or an instance of a class. This is explicitly included as the first parameter in Python. On the other hand, in Java it is optional. It helps differentiate between the methods and attributes of a class with local variables.


The self variable in the init method refers to the newly created object, while in other methods, it refers to the object whose method was called

303 Views

What advantages do NumPy arrays offer over (nested) Python lists?

Nitin Mereddy 24th Oct, 2021

Nested Lists :

  • Python lists are efficient general-purpose containers that support efficient operations like insertion,appending,deletion and concatenation.
  • The limitations of lists are that they don’t support “vectorized” operations like element wise addition and multiplication, and the fact that they can contain objects of differing types mean that Python must store type information for every element, and must execute type dispatching code when operating on each element.
616 Views

Whenever Python exits, why isnt all the memory de-allocated?

Nitin Mereddy 24th Oct, 2021

Whenever Python exits, especially those Python modules which are having circular references to other objects or the objects that are referenced from the global namespaces are not always de-allocated or freed.

It is not possible to de-allocate those portions of memory that are reserved by the C library.

On exit, because of having its own efficient clean up mechanism, Python would try to de-allocate every object.

108 Views

What do file-related modules in Python do? Can you name some file-related modules in Python?

Nitin Mereddy 24th Oct, 2021

Python comes with some file-related modules that have functions to manipulate text files and binary files in a file system. These modules can be used to create text or binary files, update their content, copy, delete, and more.

Some file-related modules are os, os.path, and shutil.os. The os.path module has functions to access the file system, while the shutil.os module can be used to copy or delete files.

36 Views

Is indentation required in Python?

Nitin Mereddy 24th Oct, 2021

Indentation in Python is compulsory and is part of its syntax.

All programming languages have some way of defining the scope and extent of the block of codes. In Python, it is indentation. Indentation provides better readability to the code, which is probably why Python has made it compulsory.

88 Views

What is type conversion in Python

Nitin Mereddy 24th Oct, 2021

Python provides you with a much needed functionality of converting one form of data type into the  needed one and this is known as type conversion.

Type Conversion is classified into types:

1.Implicit Type Conversion: In this form of Type conversion python interpreter helps in automatically converting the data type into another data type without any User involvement.

2.Explicit Type Conversion: In this  form of Type conversion the data  type inn changed into a required type by the user.

The question have been saved in answer later, you can access it from your profile anytime. Access now

Download the Careers360 App on your Android phone

Regular exam updates, QnA, Predictors, College Applications & E-books now on your Mobile

Careers360 App
150M+ Students
30,000+ Colleges
500+ Exams
1500+ E-books