code-rag-bench/online-tutorials huggingface dataset:
factor command in Linux with examples

15 May, 2019
The factor command in Linux is used to print the prime factors of the given numbers, either given from command line or read from standard input.
The numbers given through standard input may be delimited by tabs, spaces or newlines.
Syntax:
factor [NUMBER]
Factor 100 (non-prime number):We get the prime factors 2 and 5 that make up 100.
Factor 13 (prime number itself) :
Factor of 221 (product of two primes) :Under the hood, the factor command uses the Pollard-Brent rho algorithm to find out the prime factors.
Under the hood, the factor command uses the Pollard-Brent rho algorithm to find out the prime factors.
factor --help : This command only supports a few numbers of options, that is its help command and version number.
linux-command
Linux-misc-commands
Picked
Technical Scripter 2018
Linux-Unix
Technical Scripter
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
ZIP command in Linux with examples
tar command in Linux with examples
curl command in Linux with Examples
TCP Server-Client implementation in C
Conditional Statements | Shell Script
Tail command in Linux with examples
UDP Server-Client implementation in C
Docker - COPY Instruction
scp command in Linux with Examples
Cat command in Linux with examples
sciPy stats.variation() function | Python

13 Feb, 2019
scipy.stats.variation(arr, axis = None) function computes the coefficient of variation. It is defined as the ratio of standard deviation to mean.
Parameters :arr : [array_like] input array.axis : [int or tuples of int] axis along which we want to calculate the coefficient of variation.-> axis = 0 coefficient of variation along the column.-> axis = 1 coefficient of variation working along the row.
Results : Coefficient of variation of the array with values along specified axis.
Code #1: Use of variation()
from scipy.stats import variation import numpy as np  arr = np.random.randn(5, 5)  print ("array : \n", arr)  # rows: axis = 0, cols: axis = 1  print ("\nVariation at axis = 0: \n", variation(arr, axis = 0))  print ("\nVariation at axis = 1: \n", variation(arr, axis = 1))
array : 
 [[-1.16536706 -1.29744691 -0.39964651  2.14909277 -1.00669835]
 [ 0.79979681  0.91566149 -0.823054    0.9189682  -0.01061181]
 [ 0.9532622   0.38630077 -0.79026789 -0.70154086  0.79087801]
 [ 0.53553389  1.46409899  1.89903817 -0.35360202 -0.14597738]
 [-1.53582875 -0.50077039 -0.23073327  0.32457064 -0.43269088]]

Variation at axis = 0: 
 [-12.73042404   5.10272979 -14.6476392    2.15882202  -3.64031032]

Variation at axis = 1: 
 [-3.73200773  1.90419038  5.77300406  1.29451485 -1.27228112]

 Code #2: How to implement without variation()
import numpy as np  arr = np.random.randn(5, 5)  print ("array : \n", arr)  # this function works similar to variation()cv = lambda x: np.std(x) / np.mean(x)  var1 = np.apply_along_axis(cv, axis = 0, arr = arr)print ("\nVariation at axis = 0: \n", var1)  var2 = np.apply_along_axis(cv, axis = 1, arr = arr)print ("\nVariation at axis = 0: \n", var2)
array : 
 [[ 0.51268414 -1.93697931  0.41573223  2.14911168  0.15036631]
 [-0.50407207  1.51519879 -0.42217231 -1.09609322  1.93184432]
 [-1.07727163  0.27195529 -0.1308108  -1.75406388  0.94046395]
 [ 1.23283059 -0.03112461  0.59725109  0.06671002 -0.97537666]
 [ 1.1233506   0.97658799 -1.10309113 -1.33142901 -0.28470146]]

Variation at axis = 0: 
 [ 3.52845174  7.40891024 -4.74078192 -3.57928544  2.85092056]

Variation at axis = 0: 
 [ 5.04874565  4.22763514 -2.74104828  4.10772935 -8.24126977]

Python scipy-stats-functions
Python-scipy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python IMDbPY – Movie info set - GeeksforGeeks

22 Apr, 2020
IMDb data base have every information of the movie i.e when movie released, rating, locations etc but in order to retrieve them problem occur as there will be lots of web pages which can be both time-and bandwidth-consuming, especially if you’re interested in only a small part of the information.
If we want to fetch only specific information we can fetch it by passing an optional information parameter to the get_movie method. In order to get information set of IMDb data set we will use get_movie_infoset method.
Syntax : imdb_object.get_movie_infoset()
Argument : It takes no argument.
Return : It return list.
Below is the implementation
# importing the moduleimport imdb   # creating instance of IMDbia = imdb.IMDb()   # getting the movie info set of data baseinfo = ia.get_movie_infoset()   # printing the list for element in info:    print(element)
Output :
airing
akas
alternate versions
awards
connections
crazy credits
critic reviews
episodes
external reviews
external sites
faqs
full credits
goofs
keywords
locations
main
misc sites
news
official sites
parents guide
photo sites
plot
quotes
release dates
release info
reviews
sound clips
soundtrack
synopsis
taglines
technical
trivia
tv schedule
video clips
vote details

Python IMDbPY-module
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Python | os.path.join() method
Python | Get unique values from a list
Create a directory in Python
Defaultdict in Python
Python | Pandas dataframe.groupby()
Python | Transpose elements of two dimensional list - GeeksforGeeks

19 Jan, 2021
Given a two-dimensional list of integers, write a Python program to get the transpose of given list of lists.In Python, a matrix can be interpreted as a list of lists. Each element is treated as a row of the matrix. For example m = [[10, 20], [40, 50], [30, 60]] represents a matrix of 3 rows and 2 columns. First element of the list – m[0] and element in first row, first column – m[0][0].
Example: 
Input :  l1 = [[4, 5, 3, 9],
               [7, 1, 8, 2],
               [5, 6, 4, 7]]

Output : lt = [[4, 7, 5],
               [5, 1, 6],
               [3, 8, 4],
               [9, 2, 7]]
 Method #1: Using loops 
Python
# Python program to get transpose# elements of two dimension listdef transpose(l1, l2):     # iterate over list l1 to the length of an item    for i in range(len(l1[0])):        # print(i)        row =[]        for item in l1:            # appending to new list with values and index positions            # i contains index position and item contains values            row.append(item[i])        l2.append(row)    return l2 # Driver codel1 = [[4, 5, 3, 9], [7, 1, 8, 2], [5, 6, 4, 7]]l2 = []print(transpose(l1, l2))
[[4, 7, 5], [5, 1, 6], [3, 8, 4], [9, 2, 7]]

 Method #2: Using List comprehensions 
Python
# Python program to get transpose# elements of two dimension listdef transpose(l1, l2):     # we have nested loops in comprehensions    # value of i is assigned using inner loop    # then value of item is directed by row[i]    # and appended to l2    l2 =[[row[i] for row in l1] for i in range(len(l1[0]))]    return l2 # Driver codel1 = [[4, 5, 3, 9], [7, 1, 8, 2], [5, 6, 4, 7]]l2 = []print(transpose(l1, l2))
[[4, 7, 5], [5, 1, 6], [3, 8, 4], [9, 2, 7]]

Method #3: Using numpy 
Python3
# Python program to get transpose# elements of two dimension listimport numpy  l1= [[4, 5, 3, 9], [7, 1, 8, 2], [5, 6, 4, 7]]print(numpy.transpose(l1))
Output:
[[4 7 5]
 [5 1 6]
 [3 8 4]
 [9 2 7]]
Method #4: Using zip function 
Python
# Python program to get transpose# elements of two dimension listdef transpose(l1, l2):     # star operator will first    # unpack the values of 2D list    # and then zip function will    # pack them again in opposite manner    l2 = list(map(list, zip(*l1)))    return l2 # Driver codel1 = [[4, 5, 3, 9], [7, 1, 8, 2], [5, 6, 4, 7]]l2 = []print(transpose(l1, l2)) # code contributed by# chaudhary_19# Mayank Chaudhary# modified by Chirag Shilwant
[[4, 7, 5], [5, 1, 6], [3, 8, 4], [9, 2, 7]]

chaudhary_19
chirags_30
Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Read a file line by line in Python
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Python program to convert a list to string
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Split string into list of characters
Python | Convert a list to dictionary
Python program to print all distinct elements of a given integer array.

Given an integer array. The elements of the array may be duplicate.Our task is to display the distinct values.
Input::A=[1,2,3,4,2,3,5,6]
Output [1,2,3,4,5,6]

Step 1: input Array element.
Step 2:  Then pick all the elements one by one.
Step 3:  then check if the picked element is already displayed or not.
Step 4: use one flag variable which initialized by 0.if the element is displayed earlier flag variable is 1 and if the element is not displayed earlier flag variable is 0.
Step 5: Display distinct elements. 

# Python program to print all distinct
# elements in a given array
def distinctelement(A, n1):
   print("Distinct Elements are ::>")
      for i in range(0, n1):
         c = 0
         for j in range(0, i):
            if (A[i] == A[j]):
               c = 1
               break
         if (c == 0):
            print(A[i])
# Driver code
A=list()
n1=int(input("Enter the size of the List ::"))
print("Enter the Element of List ::")
for i in range(int(n1)):
   k=int(input(""))
   A.append(k)
distinctelement(A, n1)
Enter the size of the List ::4
Enter the Element of List ::
1
2
2
4
Distinct Elements are ::>
1
2
4
What is the JLink tool in Java 9?

JLink is a new linker tool that has been used to create our own customized JRE. Usually, we can run our program using default JRE provided by Oracle. If we need to create our own JRE then use this tool. JLink tool can help to create its own JRE with only the required class to run the application. It can reduce the size of the API developed and the dependency of using full JRE.
In Java 9, we have a new phase between compiling the code and its execution link time. Link time is an optional phase between the phases of compile-time and runtime.
jlink --module-path --add-modules --limit-modules --output
module-path is the path where observable modules have discovered by the linker. It can be modular JAR files, JMOD files, and modules.
add-modules names the modules to add to the run-time image, these modules can, via transitive dependencies, cause additional modules to be added.
limit-modules limits the universe of observable modules.
the output is the directory that contains the resulting run-time image.
jlink --module-path $JAVA_HOME/jmods:mlib --add-modules com.greetings --output greetingsapp
In the above command, the value to module-path is a PATH of directories containing the packaged modules. JAVA_HOME/jmods is a directory containing java.base.jmod, other standards, and JDK modules. The directory mlib on the module path containing the artifact for module com.greetings.
How to print a page using JavaScript?

To print a page in JavaScript, use the print() method. It opens up the standard dialog box, through which you can easily set the printing options like which printer to select for printing.
Here’s an example −
You can try to run the following code to learn how to print a page −
Live Demo
<!DOCTYPE html>
<html>
   <body>
      <button onclick="display()">Click to Print</button>
      <script>
         function display() {
            window.print();
         }
      </script>
   </body>
</html>
GATE CS 2010 - GeeksforGeeks

10 Nov, 2021
    a 
  / | \
 b  c  d
Newton-Raphson method is used to compute a root of the equation x2-13=0 with 3.5 as the initial value. The approximation after one iteration is 
3.607 
3.667 
3.676 
3.575 
In Newton-Raphson's method, We use the following formula to get the next value of f(x). f'(x) is derivative of f(x).  
f(x)  =  x2-13
f'(x) =  2x

Applying the above formula, we get
Next x = 3.5 - (3.5*3.5 - 13)/2*3.5
Next x = 3.607
 
What is the possible number of reflexive relations on a set of 5 elements? 
225 
220 
215 
210 
Number of reflexive relations is 2n2-n which is 220 for n = 5 
What is the value of Limn->∞(1-1/n)2n ? 
e-1/2 
1 
e-2 
0 
= PQ + QR’ + PR’ 
= PQ(R+R’) + (P+P’)QR’ + P(Q+Q’)R’
= PQR + PQR’ +PQR’ +P’QR’ + PQR’ + PQ’R’ 
= PQR(m7) + PQR'(m6)+P’QR'(m2) +PQ’R'(m4) 
= m2 + m4 + m6 + m7 
P is a 16-bit signed integer. The 2's complement representation of P is (F87B)16.The 2's complement representation of 8*P 
(C3D8)16 
(187B)16 
(F878)16 
(987B)16 
P = (F87B)16 is -1111 1000 0111 1011 in binary Note that most significant bit in the binary representation is 1, which implies that the number is negative. To get the value of the number performs the 2's complement of the number. We get P as -1925 and 8P as -15400 Since 8P is also negative, we need to find 2's complement of it (-15400) Binary of 15400 = 0011 1100 0010 1000 2's Complement = 1100 0011 1101 1000 = (C3D8)16 
What does the following program print? 
C
2 2 
2 1 
0 1 
0 2  
See below comments for explanation.  
/* p points to i and q points to j */
void f(int *p, int *q)
{
  p = q;    /* p also points to j now */
 *p = 2;   /* Value of j is changed to 2 now */
}
 
Writing code in comment? Please use ide.geeksforgeeks.org, generate link and share the link here.
Must Do Coding Questions for Product Based Companies
Difference Between Skewness and Kurtosis
How to Replace Values in Column Based on Condition in Pandas?
C Program to read contents of Whole File
How to Download and Install Spring Tool Suite (Spring Tools 4 for Eclipse) IDE?
How to Replace Values in a List in Python?
How to Select Data Between Two Dates and Times in SQL Server?
Spring - REST Controller
Difference between Information Retrieval and Information Extraction
How to Read Text Files with Pandas?
Cypress - Mouse Actions

Cypress can handle hidden elements. There are occasions when submenus get displayed only on hovering over the main menu. These submenus are initially made hidden with the CSS property display:none.
For handling hidden elements, Cypress takes the help of the jQuery method show. It has to be invoked with the help of the Cypress command (invoke['show']).
For example, on hovering over the Mouse Hover button, the Top and Reload buttons get displayed, as shown below −
On moving the mouse out of the Mouse Hover button, the Top and Reload buttons get hidden, as shown below −
Given below is the implementation with jQuery show method in Cypress −
describe('Tutorialspoint Test', function () {
   // test case
   it('Scenario 1', function (){
      // launch URL
      cy.visit("https://learn.letskodeit.com/p/practice");
      // show hidden element with invoke
      cy.get('div.mouse-hover-content').invoke('show');
      //click hidden element
      cy.contains('Top').click();
   });
});
Execution Results
The output is as follows −
The execution logs show the hidden element – Top button represented by an icon at the right of the steps.

    73 Lectures 
     12 hours 

 Rahul Shetty
 Print
 Add Notes
 Bookmark this page
How to Install Go Project Dependencies? - GeeksforGeeks

22 Nov, 2021
We all know that project management is the most essential key for the setup of any project and in the same way, installing dependencies is also one of the important parts of project management.
For installing the go project dependencies, we use go get command, which automatically updates the go.mod file. You can also install go project dependencies by following a few steps, but remember as the package is still not used anywhere in the project it will be marked as indirect. And once you have configured the project for the use of go modules then you can introduce some more new dependencies into your codebase.
Below are all the steps that one needs to follow in order to install go dependencies.
 First of all, we are going to create a workspace for the project, which will involve the below-mentioned steps:
 Firstly we need to create a workspace or project folder and then inside that workspace, we need to create three subdirectories.
mkdir myproject
cd myproject
Names of the three subdirectories will be BIN, SRC, and PKG respectively.
mkdir bin
mkdir src
mkdir pkg
Now after doing all this the structure of our workspace is ready and now next we need to export the location of this workspace so that we can use the Go path variable.
pwd
export GOPATH=$HOME/golang_tutor/myproject
Now we need to export the BIN directory which we created inside the workspace so that we can use the path variable.
export PATH=$GOPATH/bin:$PATH
Now our workspace is ready to work and here are some simple steps to install go project dependencies into your workspace.
Step 2: Choose the package you want to install using the go get command. Suppose, you are installing one package named mux from github.com using the go get command. You can also use any other package from any other medium also.
go get github.com/gorilla/mux
ls
Now in your workspace, you can see your source file inside src folder and inside pkg folder you can see the package object. And the bin directory is empty.
ls src/
ls pkg/
ls bin/
So this is all that it takes to install a dependency in a go project using go get command.
how-to-install
Picked
How To
Installation Guide
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Install FFmpeg on Windows?
How to Set Git Username and Password in GitBash?
How to Add External JAR File to an IntelliJ IDEA Project?
How to Create and Setup Spring Boot Project in Eclipse IDE?
How to Install Jupyter Notebook on MacOS?
Installation of Node.js on Linux
How to Install FFmpeg on Windows?
How to Install Pygame on Windows ?
How to Add External JAR File to an IntelliJ IDEA Project?
How to Install Jupyter Notebook on MacOS?
Instruction type INR R in 8085 Microprocessor

In 8085 Instruction set, INR is a mnemonic that stands for ‘INcRement’ and ‘R’ stands for any of the following registers or memory location M pointed by HL pair.
R = A, B, C, D, E, H, L, or M

This instruction is used to add 1 with the contents of R. So the previous value in R will get increased by amount 1 only. The result of increment will be stored in R updating its previous content. All flags, except Cy flag, are affected depending on the result thus produced. In different assembly language core, this instruction is used for looping or as a count. As R can have any of the eight values as mentioned, so there are eight opcodes possible for this type of instruction. It requires only 1-Byte in memory.
Let us consider INR M as a sample instruction of this category. It is a 1-Byte instruction. Let us consider that HL register pair is holding the 16-bit value 4050H as 16-bit address. And 4050H location is holding value 05H. So after execution of the instruction INR M, the current content of location 4050H will become 06H. The tracing table of this instruction is as follows
(HL)
(4050H)
Flag Register (F)
Here is the timing diagram of the execution of the instruction INR M
Summary − So this instruction INR M requires 1-Byte, 3-Machine Cycles (Opcode Fetch, Memory Read, Memory Write) and 10 T-States for execution as shown in the timing diagram.
CSS - Flash Effect

A sudden brief burst of bright light of an element.
@keyframes flash {
   0%, 50%, 100% {
      opacity: 1;
   }
   25%, 75% {
      opacity: 0;
   }
}
Opacity − Opacity applies to an element to make translucence.
Opacity − Opacity applies to an element to make translucence.
<html>
   <head>
      <style>
         .animated {
            background-image: url(/css/images/logo.png);
            background-repeat: no-repeat;
            background-position: left top;
            padding-top:95px;
            margin-bottom:60px;
            -webkit-animation-duration: 1s;
            animation-duration: 1s;
            -webkit-animation-fill-mode: both;
            animation-fill-mode: both;
         }
         
         @keyframes flash {
            0%, 50%, 100% {
               opacity: 1;
            }
            25%, 75% {
               opacity: 0;
            }
         }
         
         .flash {
            animation-name: flash;
         }
      </style>
   </head>

   <body>
   
      <div id = "animated-example" class = "animated flash"></div>
      <button onclick = "myFunction()">Reload page</button>
      
      <script>
         function myFunction() {
            location.reload();
         }
      </script>
      
   </body>
</html>
It will produce the following result −


 Academic Tutorials
 Big Data & Analytics 
 Computer Programming 
 Computer Science 
 Databases 
 DevOps 
 Digital Marketing 
 Engineering Tutorials 
 Exams Syllabus 
 Famous Monuments 
 GATE Exams Tutorials
 Latest Technologies 
 Machine Learning 
 Mainframe Development 
 Management Tutorials 
 Mathematics Tutorials
 Microsoft Technologies 
 Misc tutorials 
 Mobile Development 
 Java Technologies 
 Python Technologies 
 SAP Tutorials 
Programming Scripts 
 Selected Reading 
 Software Quality 
 Soft Skills 
 Telecom Tutorials 
 UPSC IAS Exams 
 Web Development 
 Sports Tutorials 
 XML Technologies 
 Multi-Language
 Interview Questions


 Academic Tutorials
 Big Data & Analytics 
 Computer Programming 
 Computer Science 
 Databases 
 DevOps 
 Digital Marketing 
 Engineering Tutorials 
 Exams Syllabus 
 Famous Monuments 
 GATE Exams Tutorials
 Latest Technologies 
 Machine Learning 
 Mainframe Development 
 Management Tutorials 
 Mathematics Tutorials
 Microsoft Technologies 
 Misc tutorials 
 Mobile Development 
 Java Technologies 
 Python Technologies 
 SAP Tutorials 
Programming Scripts 
 Selected Reading 
 Software Quality 
 Soft Skills 
 Telecom Tutorials 
 UPSC IAS Exams 
 Web Development 
 Sports Tutorials 
 XML Technologies 
 Multi-Language
 Interview Questions
Selected Reading
UPSC IAS Exams Notes
Developer's Best Practices
Questions and Answers
Effective Resume Writing
HR Interview Questions
Computer Glossary
Who is Who
 Print
 Add Notes
 Bookmark this page
Difference between sum of the squares of and square of sum first n natural numbers.

With a given number n, write a program to find the difference between sum of the squares of and square of sum first n natural numbers.
n = 3
Squares of first three numbers
= 3x3 + 2x2 + 1x1
= 9 + 4 + 1
= 14

Squares of sum of first three numbers
= (3 + 2 + 1)x(3 + 2 + 1)
= 6x6
= 36

Difference
= 36 - 14
= 22
 Live Demo
Following is the program in Java to find the required difference.
public class JavaTester {
   public static int difference(int n){
      //sum of squares of n natural numbers
      int sumSquareN = (n * (n + 1) * (2 * n + 1)) / 6;
      //sum of n natural numbers
      int sumN = (n * (n + 1)) / 2;
      //square of sum of n natural numbers
      int squareSumN = sumN * sumN;
      //difference
      return Math.abs(sumSquareN - squareSumN);
   }
   public static void main(String args[]){
      int n = 3;
      System.out.println("Number: " + n);
      System.out.println("Difference: " + difference(n));
   }
}
Number : 3
Difference: 22
Binary list to integer in Python

We can convert a list of 0s and 1s representing a binary number to a decimal number in python using various approaches. In the below examples we use the int() method as well as bitwise left shift operator.
The int() method takes in two arguments and changes the base of the input as per the below syntax.
int(x, base=10)
Return an integer object constructed from a number or string x.
In the below example we use the int() method to take each element of the list as a string and join them to form a final string which gets converted to integer with base 10.
 Live Demo
List = [0, 1, 0, 1, 0, 1]
print ("The List is : " + str(List))
# binary list to integer conversion
result = int("".join(str(i) for i in List),2)
# result
print ("The value is : " + str(result))
Running the above code gives us the following result −
The List is : [1, 1, 0, 1, 0, 1]
The value is : 53
The bitwise left shift operator converts the given list of digits to an integer after adding to zeros to the binary form. Then bitwise or is used to add to this result. We use a for loop to iterate through each of the digits in the list.
 Live Demo
List = [1, 0, 0, 1, 1, 0]
print ("The values in list is : " + str(List))

# binary list to integer conversion
result = 0
for digits in List:
result = (result << 1) | digits

# result
print ("The value is : " + str(result))
Running the above code gives us the following result −
The values in list is : [1, 0, 0, 1, 1, 0]
The value is : 38
What is the role of IWebHostEnvironment interface in C# ASP.NET Core?

IWebHostEnvironment Provides information about the web hosting environment an
application is running in.
belongs to namespace Microsoft.AspNetCore.Hosting
The IWebHostEnvironment interface need to be injected as dependency in the
Controller and then later used throughout the Controller.
The IWebHostEnvironment interface have two properties.
WebRootPath − Path of the www folder(Gets or sets the absolute path to the directory that contains the web-servable application content files)
ContentRootPath − Path of the root folder which contains all the Application files(Gets or sets an IFileProvider pointing at WebRootPath.)
We need to import namesace
using Microsoft.AspNetCore.Hosting;
In the below example, the IWebHostEnvironment is injected in the Controller and
assigned to the private property Environment and later used to get the WebRootPath
and ContentRootPath.
public class HomeController : Controller{
   private IWebHostEnvironment Environment;
   public HomeController(IWebHostEnvironment _environment){
      Environment = _environment;
   }
   public IActionResult Index(){
      string wwwPath = this.Environment.WebRootPath;
      string contentPath = this.Environment.ContentRootPath;
      return View();
   }
}
wxPython - HTMLWindow Class

wxHTML library contains classes for parsing and displaying HTML content. Although this is not intended to be a full-featured browser, wx.HtmlWindow object is a generic HTML viewer.
HtmlWindow class constructor takes a familiar look −
(Parent, id, pos, size, style)

This class supports the following styles −
wxHW_SCROLLBAR_NEVER
Never display scrollbars, not even when the page is larger than the window
wxHW_SCROLLBAR_AUTO
Display scrollbars only if the page size exceeds window's size
wxHW_NO_SELECTION
Don't allow the user to select text
Following event binders are available for this class −
EVT_HTML_CELL_CLICKED
A wxHtmlCell was clicked
EVT_HTML_CELL_HOVER
The mouse passed over a wxHtmlCell
EVT_HTML_LINK_CLICKED
A wxHtmlCell which contains an hyperlink was clicked
Following member functions of this class are frequently used −
AppendToPage()
Appends HTML fragment to currently displayed text and refreshes the window
HistoryBack()
Goes back to the previously visited page
HistoryForward()
Goes to the next page in history
LoadPage()
Loads a HTML file
OnLinkClicked()
Called when a hyperlink is clicked
SetPage()
Sets text tagged with HTML tags as page contents
The following code displays a simple HTML browser. On running the code, a TextEntry Dialog pops up asking a URL to be entered. LoadPage() method of wx.HtmlWindow class displays the contents in the window.
import  wx 
import  wx.html 
  
class MyHtmlFrame(wx.Frame): 
   def __init__(self, parent, title): 
      wx.Frame.__init__(self, parent, -1, title, size = (600,400)) 
      html = wx.html.HtmlWindow(self) 
		
      if "gtk2" in wx.PlatformInfo: 
         html.SetStandardFonts() 
			
      dlg = wx.TextEntryDialog(self, 'Enter a URL', 'HTMLWindow') 
		
      if dlg.ShowModal() == wx.ID_OK: 
         html.LoadPage(dlg.GetValue()) 
			
app = wx.App()  
frm = MyHtmlFrame(None, "Simple HTML Browser")  
frm.Show()  
app.MainLoop()
 Print
 Add Notes
 Bookmark this page
Extract key value from a nested object in JavaScript?

Let us first create a nested object −
var details = {
   "teacherDetails":
   {
      "teacherName": ["John", "David"]
   },
   "subjectDetails":
   {
      "subjectName": ["MongoDB", "Java"]
   }
}
Let us now extract the keys. Following is the code −
var details = {
   "teacherDetails":
   {
      "teacherName": ["John", "David"]
   },
   "subjectDetails":
   {
      "subjectName": ["MongoDB", "Java"]
   }
}
var objectName, nestedObject;
var name = "Java";
for(var key in details){
   for(var secondKey in details[key]){
      if(details[key][secondKey].includes(name)){
         objectName = key;
         nestedObject = secondKey;
      }
   }
}
console.log(objectName + ', ' + nestedObject);
To run the above program, you need to use the following command −
node fileName.js.
Here, my file name is demo96.js.
This will produce the following output −
PS C:\Users\Amit\JavaScript-code> node demo96.js
subjectDetails, subjectName
Finding two closest elements to a specific number in an array using JavaScript

We are required to write a JavaScript function that takes in an array of sorted integers, arr, as the first argument and a target number, as the second argument.
Our function should return an array of exactly two numbers that exists in the array arr and are closest to target. The output array should also be sorted in increasing order.
For example, if the input to the function is
Input
const arr = [1, 2, 3, 4, 5];
const target = 3;
Output
const output = [2, 3];
Following is the code −
 Live Demo
const arr = [1, 2, 3, 4, 5];
const target = 3;
const findClosest = (arr = [], target = 1) => {
   const size = 2;
   return arr.sort((a, b) => {
      const distanceA = Math.abs(a - target)
      const distanceB = Math.abs(b - target)
      if (distanceA === distanceB) {
         return a - b
      }
      return distanceA - distanceB
   }).slice(0, size)
   .sort((a, b) => a - b);
};
console.log(findClosest(arr, target));
[2, 3]
How to create arrays dynamically in C#?

Dynamic arrays are growable arrays and have an advantage over static arrays. This is because the size of an array is fixed.
To create arrays dynamically in C#, use the ArrayList collection. It represents ordered collection of an object that can be indexed individually. It also allows dynamic memory allocation, adding, searching and sorting items in the list.
The following is an example showing how to create arrays in dynamically in C#.
 Live Demo
using System;
using System.Collections;
namespace CollectionApplication {
   class Program {
      static void Main(string[] args) {
         ArrayList al = new ArrayList();
         al.Add(99);
         al.Add(47);
         al.Add(64);
         Console.WriteLine("Count: {0}", al.Count);
         Console.Write("List: ");
         foreach (int i in al) {
            Console.Write(i + " ");
         }
         Console.WriteLine();
         Console.ReadKey();
      }
   }
}
Count: 3
List: 99 47 64
Python - Itertools.zip_longest() - GeeksforGeeks

27 Feb, 2020
Python’s Itertool is a module that provides various functions that work on iterators to produce complex iterators. This module works as a fast, memory-efficient tool that is used either by themselves or in combination to form iterator algebra.
Iterators in Python is an object that can iterate like sequence data types such as list, tuple, str and so on.
Note: For more information, refer to Python Itertools
This iterator falls under the category of Terminating Iterators. It prints the values of iterables alternatively in sequence. If one of the iterables is printed fully, the remaining values are filled by the values assigned to fillvalue parameter.
Syntax:
zip_longest( iterable1, iterable2, fillval)
Example 1:
# Python code to demonstrate the working of   # zip_longest()            import itertools        # using zip_longest() to combine two iterables.  print ("The combined values of iterables is  : ")  print (*(itertools.zip_longest('GesoGes', 'ekfrek', fillvalue ='_' )))  
Output:
The combined values of iterables is  : 
('G', 'e') ('e', 'k') ('s', 'f') ('o', 'r') ('G', 'e') ('e', 'k') ('s', '_')
Example 2:
from itertools import zip_longest    x =[1, 2, 3, 4, 5, 6, 7]y =[8, 9, 10]z = list(zip_longest(x, y))print(z)
Output:
[(1, 8), (2, 9), (3, 10), (4, None), (5, None), (6, None), (7, None)]
Python-itertools
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Check if element exists in list in Python
Python | os.path.join() method
Selecting rows in pandas DataFrame based on conditions
Defaultdict in Python
Python | Get unique values from a list
Create a directory in Python
Python | Pandas dataframe.groupby()
MySQL command for display current configuration variables?

You can use SHOW VARIABLES command to display current configuration variables. The syntax is as follows −
SHOW VARIABLES;
If you want any specific information, then implement the LIKE operator. The syntax is as follows −
SHOW VARIABLES LIKE ‘%AnySpecificInformation%’;
Now we will implement the above syntax −
mysql> show variables like '%variable%';
The following is the output −
+--------------------------------+------------------------------------------------------------------------------------------+
| Variable_name                  | Value                                                                                    |
+--------------------------------+------------------------------------------------------------------------------------------+
| session_track_system_variables | time_zone,autocommit,character_set_client,character_set_results,character_set_connection |
+--------------------------------+------------------------------------------------------------------------------------------+
1 row in set (0.01 sec)
You can also get the host information. The query is as follows −
mysql> show variables like '%host%';
The following is the output −
+-------------------------------+-----------------+
| Variable_name                 | Value           |
+-------------------------------+-----------------+
| host_cache_size               | 279             |
| hostname                      | DESKTOP-QN2RB3H |
| performance_schema_hosts_size | -1              |
| report_host                   |                 |
+-------------------------------+-----------------+
4 rows in set (0.00 sec)
Batch Script - Remove All Spaces

This is used to remove all spaces in a string via substitution.
@echo off 
set str = This string    has    a  lot  of spaces 
echo %str% 

set str=%str:=% 
echo %str%
The key thing to note about the above program is, the : = operator is used to remove all spaces from a string.
The above command produces the following output.
This string    has    a  lot  of spaces
Thisstringhasalotofspaces

 Print
 Add Notes
 Bookmark this page
Matplotlib.axes.Axes.set_xlabel() in Python

19 Apr, 2020
Matplotlib is a library in Python and it is numerical – mathematical extension for NumPy library. The Axes Class contains most of the figure elements: Axis, Tick, Line2D, Text, Polygon, etc., and sets the coordinate system. And the instances of Axes supports callbacks through a callbacks attribute.
The Axes.set_xlabel() function in axes module of matplotlib library is used to set the label for the x-axis.
Syntax: Axes.set_xlabel(self, xlabel, fontdict=None, labelpad=None, **kwargs)
Parameters: This method accepts the following parameters.
xlabel : This parameter is the label text.
labelpad : This parameter is the spacing in points from the axes bounding box including ticks and tick labels.
Returns:This method does not returns any value.
Below examples illustrate the matplotlib.axes.Axes.set_xlabel() function in matplotlib.axes:
Example 1:
import matplotlib.pyplot as pltimport numpy as np  t = np.arange(0.01, 5.0, 0.01)s = np.exp(-t)  fig, ax = plt.subplots()  ax.plot(t, s)ax.set_xlim(5, 0)ax.set_xlabel('Display X-axis Label',                fontweight ='bold')ax.grid(True)  ax.set_title('matplotlib.axes.Axes.set_xlabel()\ Examples\n', fontsize = 14, fontweight ='bold')plt.show()
Output:
Example 2:
# Implementation of matplotlib functionimport numpy as npimport matplotlib.pyplot as pltimport matplotlib.cbook as cbook  with cbook.get_sample_data('goog.npz') as datafile:    price_data = np.load(datafile)['price_data'].view(np.recarray)      # get the most recent 250# trading daysprice_data = price_data[-250:]    delta1 = np.diff(price_data.adj_close)/price_data.adj_close[:-1]  volume = (25 * price_data.volume[:-2] / price_data.volume[0])**3close = (0.03 * price_data.close[:-2] / 0.03 * price_data.open[:-2])**2  fig, ax = plt.subplots()ax.scatter(delta1[:-1], delta1[1:],           c = close, s = volume,           alpha = 0.5)  ax.set_xlabel(r'X-axis contains $\Delta_i$ values',              fontweight ='bold')ax.grid(True)fig.suptitle('matplotlib.axes.Axes.set_xlabel() Examples\n',             fontsize = 14, fontweight ='bold')  plt.show()
Output:
Python-matplotlib
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Python OOPs Concepts
Iterate over a list in Python
Insert Python Dictionary in PostgreSQL using Psycopg2

21 Oct, 2021
In this article, we are going to see how to insert a Python dictionary in PostgreSQL using Psycopg2.
We can insert a python dictionary by taking the dictionary keys as column names and values as dictionary values. We import the Psycopg2 package and form a connection to the PostgreSQL database using psycopg2.connect() method. First, let’s create a table and then insert the python dictionary values into it. We create the table by executing the SQL statement using the cursor.execute() method. 
'''CREATE TABLE DETAILS(employee_id int NOT NULL, employee_name char(20),
         employee_email varchar(30), employee_salary float);'''
After creating an empty table, values in the table are taken from the dictionary by using the .values() method.
empty table
We loop through the dictionary values and insert them into the table. The below SQL statement is executed for each insertion.
'''insert into DETAILS(employee_id , employee_name ,
         employee_email , employee_salary) VALUES{};'''
Below is the implementation:
Python3
import psycopg2 # connection establishmentconn = psycopg2.connect(   database="geeks",    user='postgres',    password='root',    host='localhost',    port= '5432')    conn.autocommit = Truecursor = conn.cursor() sql = '''CREATE TABLE DETAILS(employee_id int NOT NULL,\          employee_name char(20),          employee_email varchar(30), employee_salary float);'''  cursor.execute(sql)dictionary ={ 'empl1' : (187643,'sarah',                       'sarahpaul@gmail.com',65000),              'empl2' : (187644,'rahul',                       'rahul101@gmail.com',75000),              'empl3' : (187645,'arjun',                       'arjun234@gmail.com',70000)}columns= dictionary.keys()for i in dictionary.values():    sql2='''insert into DETAILS(employee_id , employee_name ,          employee_email , employee_salary) VALUES{};'''.format(i)     cursor.execute(sql2) sql3='''select * from DETAILS;'''cursor.execute(sql3)for i in cursor.fetchall():    print(i) conn.commit()conn.close()
Output:
(187643, 'sarah               ', 'sarahpaul@gmail.com', 65000.0)
(187644, 'rahul               ', 'rahul101@gmail.com', 75000.0)
(187645, 'arjun               ', 'arjun234@gmail.com', 70000.0)
final table after insertion
isitapol2002
Picked
Python PostgreSQL
Python Pyscopg2
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
scipy stats.erlang() | Python

20 Mar, 2019
scipy.stats.erlang() : is an Erlang continuous random variable that is defined with a standard format and some shape parameters to complete its specification. it is a special case of the Gamma distribution.
Parameters :q : lower and upper tail probabilityx : quantilesloc : [optional] location parameter. Default = 0scale : [optional] scale parameter. Default = 1size : [tuple of ints, optional] shape or random variates.moments : [optional] composed of letters [‘mvsk’]; ‘m’ = mean, ‘v’ = variance, ‘s’ = Fisher’s skew and ‘k’ = Fisher’s kurtosis. (default = ‘mv’).
Results : erlang continuous random variable
Code #1 : Creating erlang continuous random variable
from scipy.stats import erlang   numargs = erlang.numargs[a] = [0.6, ] * numargsrv = erlang(a)  print ("RV : \n", rv) 
Output :
RV : 
 <scipy.stats._distn_infrastructure.rv_frozen object at 0x0000018D544FBC88>

Code #2 : erlang random variates and probability distribution.
import numpy as npquantile = np.arange (0.01, 1, 0.1)   # Random VariatesR = erlang.rvs(a, scale = 2,  size = 10)print ("Random Variates : \n", R)  # PDFR = erlang.pdf(a, quantile, loc = 0, scale = 1)print ("\nProbability Distribution : \n", R)
Output :
Random Variates : 
 [5.65708510e+00 5.16045580e+00 1.02056956e-01 3.64349340e-01
 5.65593073e+00 2.27100280e+00 9.77623414e-04 2.01994399e-01
 8.84331471e-01 2.20817630e+00]

Probability Distribution :
[0.01, 0.11, 0.21, 0.31, 0.41, 0.51, 0.61, 0.71, 0.81, 0.91]
 
Code #3 : Graphical Representation.
import numpy as npimport matplotlib.pyplot as plt  distribution = np.linspace(0, np.minimum(rv.dist.b, 5))print("Distribution : \n", distribution)  plot = plt.plot(distribution, rv.pdf(distribution))
Output :
Distribution : 
Distribution : 
 [0.         0.10204082 0.20408163 0.30612245 0.40816327 0.51020408
 0.6122449  0.71428571 0.81632653 0.91836735 1.02040816 1.12244898
 1.2244898  1.32653061 1.42857143 1.53061224 1.63265306 1.73469388
 1.83673469 1.93877551 2.04081633 2.14285714 2.24489796 2.34693878
 2.44897959 2.55102041 2.65306122 2.75510204 2.85714286 2.95918367
 3.06122449 3.16326531 3.26530612 3.36734694 3.46938776 3.57142857
 3.67346939 3.7755102  3.87755102 3.97959184 4.08163265 4.18367347
 4.28571429 4.3877551  4.48979592 4.59183673 4.69387755 4.79591837
 4.89795918 5.        ]
Code #4 : Varying Positional Arguments
import matplotlib.pyplot as pltimport numpy as np  x = np.linspace(0, 5, 100)  # Varying positional argumentsy1 = erlang.pdf(x, 2, 6)y2 = erlang.pdf(x, 1, 4)plt.plot(x, y1, "*", x, y2, "r--")
Output :
Python scipy-stats-functions
Python-scipy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Matplotlib.axes.Axes.set_facecolor() in Python

19 Apr, 2020
Matplotlib is a library in Python and it is numerical – mathematical extension for NumPy library. The Axes Class contains most of the figure elements: Axis, Tick, Line2D, Text, Polygon, etc., and sets the coordinate system. And the instances of Axes supports callbacks through a callbacks attribute.
The Axes.set_facecolor() function in axes module of matplotlib library is used to set the facecolor of the Axes..
Syntax: Axes.set_facecolor(self, color)
Parameters: This method accept only one parameters.color: This parameter accepts the color for the facecolor of the axes.
Returns:This method does not returns any value.
Below examples illustrate the matplotlib.axes.Axes.set_facecolor() function in matplotlib.axes:
Example 1:
# Implementation of matplotlib functionimport numpy as npimport matplotlib.pyplot as plt     x = np.arange(-5, 5, 0.01)y1 = -3 * x*x + 10 * x + 10y2 = 3 * x*x + x     fig, ax = plt.subplots()ax.plot(x, y1, x, y2, color ='black')ax.fill_between(x, y1, y2, where = y2 >y1,                facecolor ='green', alpha = 0.8)ax.fill_between(x, y1, y2, where = y2 <= y1,               facecolor ='black', alpha = 0.8)   ax.set_facecolor('# eafff5')ax.set_title('matplotlib.axes.Axes.get_facecolor() \Example\n', fontsize = 12, fontweight ='bold')plt.show()
Output:
Example 2:
# Implementation of matplotlib functionimport numpy as npimport matplotlib.pyplot as plt     t = np.linspace(0.0, 2.0, 201)s = np.sin(2 * np.pi * t)  fig, ax = plt.subplots()ax.set_facecolor('# E56B51')ax.set_xlabel('x-axis')ax.set_ylabel('y-axis')ax.plot(t, s, )ax.set_title('matplotlib.axes.Axes.get_facecolor()\ Example\n', fontsize = 12, fontweight ='bold')plt.show()
Output:
Python-matplotlib
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Communication between Parent and Child process using pipe in Python

16 Apr, 2019
Prerequisite – Creating child process in PythonAs there are many processes running simultaneously on the computer so it is very necessary to have proper communication between them as one process may be dependent on other processes.There are various methods to communicate between processes. Here is a simple Python program to demonstrate communication between the parent process and child process using the pipe method.
Library Used –OS Module in Python : The OS module in Python provides a way of using operating system dependent functionality. The functions that the OS module provides allows you to interface with the underlying operating system that Python is running on; be that Windows, Mac or Linux. It can be imported as –
import os

System Call Used –pipe() System call : The method pipe() creates a pipe and returns a pair of file descriptors (r, w) usable for reading and writing, respectively. This method returns a pair of file descriptor.
Syntax – Following is the syntax for pipe() method –
os.pipe()

Note – Pipe is one-way communication only i.e we can use a pipe such that One process write to the pipe, and the other process reads from the pipe.
# Python code to demonstrate communication# between parent and child process using # python.  import os  def communication(child_writes):    # file descriptors r, w for reading and writing    r, w = os.pipe()          #Creating child process using fork    processid = os.fork()    if processid:        # This is the parent process        # Closes file descriptor w        os.close(w)        r = os.fdopen(r)        print ("Parent reading")        str = r.read()        print( "Parent reads =", str)    else:        # This is the child process        os.close(r)        w = os.fdopen(w, 'w')        print ("Child writing")        w.write(child_writes)        print("Child writes = ",child_writes)        w.close()          # Driver code        child_writes = "Hello geeks"communication(child_writes)  # Contributed by "Sharad_Bhardwaj".
Output :
Child writing
Child writes =  Hello geeks
Parent reading
Parent reads = Hello geeks

Akanksha_Rai
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python string | capwords() method

11 Aug, 2021
In Python, string capwords() method is used to capitalize all the words in the string using split() method.  
Syntax: string.capwords(string, sep=None) Return Value: Returns a formatted string after above operations.
Split the argument into words using split, capitalize each word using capitalize, and join the capitalized words using join. If the optional second argument sep is absent or None, runs of whitespace characters are replaced by a single space and leading and trailing whitespace are removed, otherwise sep is used to split and join the words.Code #1: If sep parameter is left None.  
Python3
# imports string moduleimport string sentence = 'Python is one of the best programming languages.' # sep parameter is left Noneformatted = string.capwords(sentence, sep = None) print(formatted)
Python Is One Of The Best Programming Languages.
 
  Code #2: When sep is not None.  
Python3
# imports string moduleimport string sentence = 'Python is one of the best programming languages.' # sep parameter is 'g'formatted = string.capwords(sentence, sep = 'g')print('When sep = "g"', formatted) # sep parameter is 'o'formatted = string.capwords(sentence, sep = 'o')print('When sep = "o"', formatted)
When sep = "g" Python is one of the best progRamming langUagEs.
When sep = "o" PythoN is oNe oF the best proGramming languages.
 
akshaysingh98088
python-string
Python-string-functions
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.