The efficient way to rotate a list in python is to use a collections.deque it is used for pulling and pushing on both ends. This method includes another method called rotate() method. from collections import deque items = deque([1, 2]) items.append(3) items.rotate(1) items.rotate(-1) item = items.popleft()
Python
Answered Apr 14, 2021
·
1.6K Views
Read answer →
Java
Answered Apr 10, 2021
·
1.2K Views
Read answer →
Simply make a word reference with your boundaries to be encoded in the urlencode function of urrlib module. e.g: For python 2: import urllib d = {'a': 'b', 'c': 'd'}; urllib.urlencode(d) For Python 3 import urllib d = {'a': 'b', 'c': 'd'}; urllib.parse.urlencode(d)
Python
Answered Mar 3, 2021
·
1.9K Views
Read answer →
Search Engine Optimization is the technique which we can use to increase the traffic or visibility of the website. In our HTML page we can use the meta tags to tell the browser about the page description, keywords, character set, author of template etc. These keywords defined in meta tags optimize the search by…
Python
Answered Jun 1, 2020
·
1.9K Views
Read answer →
AOT stands for Ahead-of-Time. AOT transpire the Angular HTML & Typescript code into efficient JavaScript code during the build process which provides the faster rendering in the browser. JIT is the default compiler in Angular and it compiles the app in the browser during runtime. We need to provide the -- aot option…
Python
Answered Jan 27, 2020
·
2.0K Views
Read answer →
We can create the service with a singleton pattern. So, if you are creating the instance of the service without making it singleton then every time it will use the different memory location and create the new instance but in case of singleton pattern the same instance will be used. We can make the service singleton by…
Python
Answered Jan 25, 2020
·
1.8K Views
Read answer →
We can move the validation errors into a component and pass in the formControl.errors as an input property. That way all the validation messages can be reused. validation-errors.component.ts import { Component, OnInit, Input, ChangeDetectionStrategy } from '@angular/core'; import { FormGroup, ValidationErrors } from…
Python
Answered Jan 19, 2020
·
1.7K Views
Read answer →
We can use ViewChildren to get the QueryList of elements or directives from the view DOM. Any time a child element is added, removed, or moved, the query list will be updated, and the changes observable of the query list will emit a new value. That means that we can create a subscription on our viewRefs.changes event…
Python
Answered Jan 14, 2020
·
4.3K Views
Read answer →
ES6 modules: The ES6 Modules, which also goes by the name JS modules or JavaScript modules or ECMAScript modules are part of the JavaScript Language. The JS Modules are stored in a file. There is exactly one module per file and one file per module. These modules contain small units of independent, reusable code. They…
Python
Answered Jan 13, 2020
·
1.5K Views
Read answer →
Components control views (html). They also communicate with other components and services to bring functionality to your app. Modules consist of one or more components. They do not control any html. Your modules declare which components can be used by components belonging to other modules, which classes will be…
Python
Answered Jan 12, 2020
·
1.9K Views
Read answer →
Allows first take a gander at case of each: //ES5 Function Constructor function Person(name) { this.name = name; } //ES6 Class class Person { constructor(name) { this.name = name; }
Python
Answered Jan 11, 2020
·
1.6K Views
Read answer →
To create the module run this: ng g module foo To create the component inside the foo module folder and have it added to the foo.module.ts's declaration collection run this: ng g component foo/fooList --module=foo.module.ts And the cli will scaffold out the module and component like this:
Python
Answered Jan 11, 2020
·
4.1K Views
Read answer →