Skip to main content

Posts

Showing posts from July, 2019

Lambda, Map, and Filter in Python

Lambda: Lambda functions are known as the anonymous functions in Python. This kind of functions are declared without any name. Can accept any number of argument.  Restricted to only a single expression.  Used only one-time. Lambda function is used when you need a function for a short period of time.  Basic syntax:  lambda arguments : expression Example: Map: Map is a built-in function that takes a function object and iterable list (list/dictionary) as its parameter. Basic syntax: map (function_object, iterable_1, iterable_2, ... ) Few examples of Map in python: Filter: It works similar way like map. The difference is it makes a new list from the element in the list that satisfy some condition . In case of of parameters, it takes a function and one iterable. Basic syntax: filter (function, iterable) Normally used with lambda functions. Example is given below:

Differences between MVC and MVT framework

MVC (Model-View-Controller) is a software design pattern for developing web applications. It consists of the following parts: Model : It is responsible for managing data of the application. It can be a database, a single object, or some structure of objects etc. It can also have logic to update controller if its data changes. View : View represents the visualization of the data that a model contains. It is responsible for which data should be displayed for a particular request.  Controller : It connects the View with the Model. It controls the data flow and keeps Model and View separate. It is responsible for responding to the user input and perform interactions on the data model objects.  Django - MVT (Model-View-Template ) pattern is slightly different from MVC pattern. The main difference is Django itself take care of the Controller part. In the Template, it's just HTML file mixed with DTL - Django Template Language. 

Python's Web Framework - Django Fundamentals

image source: djangoproject What is  middleware in Django? A middleware is a class with methods that are globally executed  during the request or response phase. For example, Django includes a middleware component called AuthenticationMiddleware which associates users with requests using sessions. See Doc .  What are the models added by the Django authentication framework? Django authentication framework includes the following models: User : A user model with basic fields; the main fields of this model are username , password , email , first_name , last_name , and is_active. Group : A group model to categorize users. Permission : Flags for users or groups to perform certain actions. Which parameters is accepted by the render method? (django.shortcuts -> render)? Render accepts three parameter. (request, template_name, context) For example: return render(request, 'account/login.html', {'form': form}) What is SMTP  and why do we use i...

Database - SQL fundamental concepts

The difference of null, zero and blank space:   They are not the same. The null value is a value which is unavailable, unassigned, unknown or not applicable. Zero is a number and blank space is a character. DDL, DML and DCL commands : DDL(Data Definition Language): CREATE, ALTER, DROP  [CAD] DML(Data Manupulation language): SELECT, INSERT, DELETE, UPDATE [SIDU] DCL (Data Control Langauge):   GRANT, REVOKE Grant and Revoke: Grant gives a privilege to the user and revoke takes back privileges granted from the user. ACID property in a database:    A transaction in a database system must maintain Atomicity, Consistency, Isolation, and Durability − commonly known as ACID properties − in order to ensure accuracy, completeness, and data integrity. A: Atomicity: This property states that a transaction must be treated as an atomic unit, that is, either all of its operations are executed or none. Refers to the transactions which are either comp...