code-rag-bench/online-tutorials huggingface dataset:
\scriptsize - Tex Command

\scriptsize - Used to turn on script size.
{ \scriptsize ... }
\scriptsize command is used to turn on script size.

\rm \scriptsize script \normalsize normal \large large

scriptnormallarge



\rm \scriptsize script \normalsize normal \large large

scriptnormallarge


\rm \scriptsize script \normalsize normal \large large

    14 Lectures 
     52 mins

 Ashraf Said

    11 Lectures 
     1 hours 

 Ashraf Said

    9 Lectures 
     1 hours 

 Emenwa Global, Ejike IfeanyiChukwu

    29 Lectures 
     2.5 hours 

 Mohammad Nauman

    14 Lectures 
     1 hours 

 Daniel Stern

    15 Lectures 
     47 mins

 Nishant Kumar
 Print
 Add Notes
 Bookmark this page
Python - SFTP

SFTP is also known as the SSH File Transfer Protocol. It is a network protocol that provides file access, file transfer, and file management over any reliable data stream. The program is run over a secure channel, such as SSH, that the server has already authenticated the client, and that the identity of the client user is available to the protocol.
The pysftp module is a simple interface to SFTP. The module offers high level abstractions and task based routines to handle the SFTP needs. So we install the module into our python environment with the below command.
pip install pysftp
In the below example we login to a remote server using sftp and then get and put some file in that directory.

import pysftp

with pysftp.Connection('hostname', username='me', password='secret') as sftp:

    with sftp.cd('/allcode'):           # temporarily chdir to allcode
        sftp.put('/pycode/filename')  	# upload file to allcode/pycode on remote
        sftp.get('remote_file')         # get a remote file

When we run the above code we are able to see the list of files present in the allcode directory and also put and get some file in that directory.

    187 Lectures 
     17.5 hours 

 Malhar Lathkar

    55 Lectures 
     8 hours 

 Arnab Chakraborty

    136 Lectures 
     11 hours 

 In28Minutes Official

    75 Lectures 
     13 hours 

 Eduonix Learning Solutions

    70 Lectures 
     8.5 hours 

 Lets Kode It

    63 Lectures 
     6 hours 

 Abhilash Nelson
 Print
 Add Notes
 Bookmark this page
How to change the aspect ratio of an image in JavaFX?

The javafx.scene.image.Image class is used to load an image into a JavaFX application. This supports BMP, GIF, JPEG, and, PNG formats.
JavaFX provides a class named javafx.scene.image.ImageView is a node that is used to display, the loaded image.
The preserveRatio property of the ImageView class (boolean) specifies whether the aspect ratio of an image should be preserved, while displaying it using the current ImageView object. You can set the value to this property using the setPreserveRatio() method.
By default, the value of this property is true, i.e. though you change the width or height of the image, the aspect ratio of the displayed image will be the same as the source.
To change the aspect ratio of an image −
Instantiate the Image class by passing the URL (string) of the required
image as a parameter.
Instantiate the Image class by passing the URL (string) of the required
image as a parameter.
Instantiate the ImageView class.
Instantiate the ImageView class.
Set the image to it by passing above the image object as a parameter to the setImage() method.
Set the image to it by passing above the image object as a parameter to the setImage() method.
Set the preserveRatio property to false using the setPreserveRatio() method.
Set the preserveRatio property to false using the setPreserveRatio() method.
Now, if you change the with or, the height of the image, its aspect ratio will be
tampered.
Now, if you change the with or, the height of the image, its aspect ratio will be
tampered.
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
public class PerspectiveRatioExample extends Application {
   public void start(Stage stage) throws IOException {
      //creating the image object
      InputStream stream = new FileInputStream("D:\\images\\elephant.jpg");
      Image image = new Image(stream);
      //Creating the image view
      ImageView imageView1 = new ImageView(image);
      //Setting the image view parameters
      imageView1.setX(170);
      imageView1.setY(10);
      imageView1.setFitWidth(270);
      imageView1.setPreserveRatio(true);
      //Creating the image view
      ImageView imageView2 = new ImageView(image);
      //Setting the image view parameters
      imageView2.setX(10);
      imageView2.setY(180);
      imageView2.setFitWidth(580);
      imageView2.setFitHeight(160);
      imageView2.setPreserveRatio(false);
      //Setting the Scene object
      Group root = new Group(imageView1, imageView2);
      Scene scene = new Scene(root, 595, 350, Color.BEIGE);
      stage.setTitle("Perspective Ratio Example");
      stage.setScene(scene);
      stage.show();
   }
   public static void main(String args[]) {
      launch(args);
   }
}
Assembly - CMPS Instruction

The CMPS instruction compares two strings. This instruction compares two data items of one byte, word or doubleword, pointed to by the DS:SI and ES:DI registers and sets the flags accordingly. You can also use the conditional jump instructions along with this instruction.
The following example demonstrates comparing two strings using the CMPS instruction −
section	.text
   global _start            ;must be declared for using gcc
	
_start:	;tell linker entry point
   mov esi, s1
   mov edi, s2
   mov ecx, lens2
   cld
   repe  cmpsb
   jecxz  equal             ;jump when ecx is zero

   ;If not equal then the following code
   mov eax, 4
   mov ebx, 1
   mov ecx, msg_neq
   mov edx, len_neq
   int 80h
   jmp exit
	
equal:
   mov eax, 4
   mov ebx, 1
   mov ecx, msg_eq
   mov edx, len_eq
   int 80h
	
exit:
   mov eax, 1
   mov ebx, 0
   int 80h
	
section	.data
s1 db 'Hello, world!',0      ;our first string
lens1 equ $-s1

s2 db 'Hello, there!', 0     ;our second string
lens2 equ $-s2

msg_eq db 'Strings are equal!', 0xa
len_eq  equ $-msg_eq

msg_neq db 'Strings are not equal!'
len_neq equ $-msg_neq
When the above code is compiled and executed, it produces the following result −
Strings are not equal!


    46 Lectures 
     2 hours 

 Frahaan Hussain

    23 Lectures 
     12 hours 

 Uplatz
 Print
 Add Notes
 Bookmark this page
Java - String equalsIgnoreCase() Method

This method compares this String to another String, ignoring case considerations. Two strings are considered equal ignoring case, if they are of the same length, and corresponding characters in the two strings are equal ignoring case.
Here is the syntax of this method −
public boolean equalsIgnoreCase(String anotherString)

Here is the detail of parameters −
anotherString − the String to compare this String against.
anotherString − the String to compare this String against.
This method returns true if the argument is not null and the Strings are equal, ignoring case; false otherwise.
This method returns true if the argument is not null and the Strings are equal, ignoring case; false otherwise.
public class Test {

   public static void main(String args[]) {
      String Str1 = new String("This is really not immutable!!");
      String Str2 = Str1;
      String Str3 = new String("This is really not immutable!!");
      String Str4 = new String("This IS REALLY NOT IMMUTABLE!!");
      boolean retVal;

      retVal = Str1.equals( Str2 );
      System.out.println("Returned Value = " + retVal );

      retVal = Str1.equals( Str3 );
      System.out.println("Returned Value = " + retVal );

      retVal = Str1.equalsIgnoreCase( Str4 );
      System.out.println("Returned Value = " + retVal );
   }
}
This will produce the following result −
Returned Value = true
Returned Value = true
Returned Value = true


    16 Lectures 
     2 hours 

 Malhar Lathkar

    19 Lectures 
     5 hours 

 Malhar Lathkar

    25 Lectures 
     2.5 hours 

 Anadi Sharma

    126 Lectures 
     7 hours 

  Tushar Kale

    119 Lectures 
     17.5 hours 

 Monica Mittal

    76 Lectures 
     7 hours 

 Arnab Chakraborty
 Print
 Add Notes
 Bookmark this page
Online JSON Minifier

Editable JSON Code
12345678910111213141516{"Company": {"Employee": {"FirstName": "Tanmay","LastName": "Patil","ContactNo": "1234567890","Email": "tanmaypatil@xyz.com","Address": {"City": "Bangalore","State": "Karnataka","Zip": "560212"}}}}X
Privacy Policy
Cookies Policy
Terms of Use
How to choose between `window.URL.createObjectURL()` and `window.webkitURL.createObjectURL()` based on browser?

To choose, you need to define a wrapper function −
function display ( file ) {
   if ( window.webkitURL ) {
      return window.webkitURL.createObjectURL( file );
   } else if ( window.URL && window.URL.createObjectURL ) {
      return window.URL.display( file );
   } else {
   return null;
   }
}
After that set it for cross-browser −
var url = display( file );
Types of Pop up boxes available in JavaScript

There are 3 types of pop up boxes available in JavaScript. These are −
1. Alert − The Window.alert() method displays an alert dialog with the optional specified content and an OK button.
For example, if you execute the following script, it'll open an alert box with the content: "This is an alert" with a confirmation button.
 Live Demo
<script>
   alert("This is a alert");
</script>
Note that the alert dialog should be used for messages which do not require any response on the part of the user, other than the acknowledgement of the message.
2. Confirm − The Window.confirm() method displays a modal dialog with an optional message and two buttons: OK and Cancel.
For example, if you execute the following script, it'll open a confirmation box with the content: "Please confirm this action" with a confirmation button and cancellation button. This returns a boolean depending on the input provided by the user.
 Live Demo
<script>
   let bool = confirm("Please confirm this action");
   console.log(bool);
</script>
If you click confirm, it'll return true. If you click cancel, it'll return false.
Note that Dialog boxes are modal windows — they prevent the user from accessing the rest of the program's interface until the dialog box is closed.
3. Prompt − The Window.prompt() displays a dialog with an optional message prompting the user to input some text.
For example, if you execute the following script, it'll open a propmt box with the content: "Please enter your name" with a confirmation button and cancellation button. This returns a String provided by the user.
 Live Demo
<script>
   let name = prompt("Please enter your name");
   console.log(name);
</script>
When you give it some input in the prompt, it'll log your name to the console.
Check if element exists in list of lists in Python

Lists can be nested, means the elements of a list are themselves lists. In this article we will see how to find out if a given element is present in the sublist which are themselves elements in the bigger list.
We first search if an element is present in the sublist and if the sublist is present in the list. If anyof this is true we can say that the element is present in the list.
 Live Demo
listA = [[-9, -1, 3], [11, -8],[-4,434,0]]
search_element = -8

# Given list
print("Given List :\n", listA)

print("Element to Search: ",search_element)

# Using in
if any(search_element in sublist for sublist in listA):
   print("Present")
else:
   print("Not Present")
Running the above code gives us the following result −
('Given List :\n', [[-9, -1, 3], [11, -8], [-4, 434, 0]])
('Element to Search: ', -8)
Present
In this approach we make a simple search using the in operator. If the item is part of sublist which is also a part of the outer list, then we accept the element as present. We make two checks one to check the presence and another to check the absence.
 Live Demo
listA = [[-9, -1, 3], [11, -8],[-4,434,0]]
search_element = -8

# Given list
print("Given List :\n", listA)

print("Element to Search: ",search_element)

# Using in
if search_element in (item for sublist in listA for item in sublist):
   print("Present")
else:
   print("Not Present")

search_element = 13
print("New Element to Search: ",search_element)

# Using in
if search_element in (item for sublist in listA for item in sublist):
   print("Present")
else:
   print("Not Present")
Running the above code gives us the following result −
Given List :
[[-9, -1, 3], [11, -8], [-4, 434, 0]]
Element to Search: -8
Present
New Element to Search: 13
Not Present
With the chain method from itertools module we can expand the lists of sublists and keep checking for the presence of an element using the in menthod.
 Live Demo
from itertools import chain

listA = [[-9, -1, 3], [11, -8],[-4,434,0]]
search_element = -8

# Given list
print("Given List :\n", listA)

print("Element to Search: ",search_element)

# Using in
if search_element in chain(*listA):
   print("Present")
else:
   print("Not Present")

search_element = 13
print("New Element to Search: ",search_element)

# Using in
if search_element in chain(*listA):
   print("Present")
else:
   print("Not Present")
Running the above code gives us the following result −
Given List :
[[-9, -1, 3], [11, -8], [-4, 434, 0]]
Element to Search: -8
Present
New Element to Search: 13
Not Present
Small input field with Bootstrap

Use the .input-sm class to set small input field in Bootstrap.
You can try to run the following code to implement .input-sm class:
Live Demo
<!DOCTYPE html>
<html lang="en">
   <head>
      <title>Bootstrap Example</title>
      <meta charset = "utf-8">
      <meta name = "viewport" content = "width=device-width, initial-scale = 1">
      <link rel = "stylesheet" href = "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
      <script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
      <script src = "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
   </head>
   <body>
      <div class = "container">
         <h2>Candidate Profile</h2>
         <form>
            <div class="form-group">
               <label for="sel2">What is your job profile?</label>
               <select class="form-control input-lg" id="sel2">
                  <option>Programmer</option>
                  <option>Web Developer</option>
                  <option>DBA</option>
                  <option>Support Engineer</option>
               </select>
            </div>
            <div class="form-group">
               <label for="sel3">Educational Qualification</label>
               <select class="form-control input-sm" id="sel3">
                  <option>Undergraduate</option>
                  <option>Graduate</option>
                  <option>Post-Graduate</option>
               </select>
            </div>
         </form>
      </div>
   </body>
</html>
How to Calculate Percentiles in R? - GeeksforGeeks

19 Dec, 2021
In this article, we will discuss how to calculate percentiles in the R programming language. 
Percentiles are measures of central tendency, which depict that out of the total data about certain percent data lies below it. In R, we can use quantile() function to get the job done.
Syntax: quantile( data, probs)
Parameter: 
data: data whose percentiles are to be calculated
probs: percentile value
To calculate the percentile we simply pass the data and the value of the required percentile.
R
x<-c(2,13,5,36,12,50)  res<-quantile(x,probs=0.5)  res
Output:
 50%  
12.5
We can calculate multiple percentiles at once. For that, we have to pass the vector of percentiles instead of a single value to probs parameter.
R
x<-c(2,13,5,36,12,50)  res<-quantile(x,probs=c(0.5,0.75))  res
Output:
 50%   75%  
12.50 30.25 
Sometimes requirement asks for calculating percentiles for a dataframe column in that case the entire process remains same only you have to pass the column name in place of data along with the percentile value to be calculated.
R
df<-data.frame(x=c(2,13,5,36,12,50),y=c('a','b','c','c','c','b'))  res<-quantile(df$x,probs=c(0.35,0.7))  res
Output:
 35%   70%  
10.25 24.50 
We can also find percentiles of several dataframe columns at once. This can also be applied to find the percentiles of all numeric columns of dataframe. For this we use apply() function, within this we will pass the dataframe with just numeric columns and the quantile function that has to be applied on all columns.
Syntax: apply( dataframe, function)
R
df<-data.frame(x=c(2,13,5,36,12,50),y=c('a','b','c','c','c','b'),z=c(2.1,6,3.8,4.8,2.2,1.1))  sub_df<-df[,c('x','z')]  res<-apply(sub_df, 2, function(x) quantile(x,probs=0.5))  res
Output:
   x    z  
12.5  3.0 
We can also group values together and find the percentile with respect to each group. For this, we use groupby() function, and then within summarize() we will apply the quantile function.
R
library(dplyr)  df<-data.frame(x=c(2,13,5,36,12,50),                y=c('a','b','c','c','c','b'))  df %>% group_by(y) %>%   summarize(res=quantile(x,probs=0.5))
Output:
A tibble: 3 x 2
y       res
<chr> <dbl>
a       2  
b      31.5
c      12 
Visualizing percentiles can make it better to understand. 
R
df<-data.frame(x=c(2,13,5,36,12,50),y=c('a','b','c','c','c','b'),z=c(2.1,6,3.8,4.8,2.2,1.1))  n<-length(df$x)  plot((1:n-1)/(n-1), sort(df$x.Length), type='h',     xlab = "Percentile",  ylab = "Value")
Output:
Picked
R-Mathematics
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Change Color of Bars in Barchart using ggplot2 in R
Group by function in R using Dplyr
How to Split Column Into Multiple Columns in R DataFrame?
How to Change Axis Scales in R Plots?
Replace Specific Characters in String in R
How to filter R DataFrame by values in a column?
R - if statement
How to filter R dataframe by multiple conditions?
How to import an Excel File into R ?
Time Series Analysis in R
How to display Y-axis labels with more decimal places in R?

To display Y-axis labels with more decimal places, we would need to round the values of the vector or column for which we want to create the plot to the appropriate number of decimal places.
After that axis function will be used for creating the graph. Before doing all this, the graph of original values should be created without axes.
Check out the below example to understand how it works.
Following snippet creates a sample data frame −
x<-rnorm(10)
x
The following dataframe is created −
[1] -0.3002845 -0.6121883 1.9147725 -2.1135920 0.6575177 0.3540003
[7] -0.4564178 1.3474739 -0.6195008 -0.7050753
To display Y-axis labels with more decimal places in R, add the following code to the above snippet −
x<-rnorm(10)
plot(x)
If you execute all the above given snippets as a single program, it generates the following output −
To display Y-axis labels with more decimal places in R, add the following code to the above snippet −
x<-rnorm(10)
plot(x,axes=FALSE,frame.plot=TRUE)
If you execute all the above given snippets as a single program, it generates the following output −
To display Y-axis labels with more decimal places in R, add the following code to the above snippet −
x<-rnorm(10)
plot(x,axes=FALSE,frame.plot=TRUE)
Labels<-round(x,3)
axis(2,at=Labels,labels=Labels)
If you execute all the above given snippets as a single program, it generates the following output −
Java program to find the 2nd largest number in an array

To find the second largest element of the given array, first of all, sort the array.
Compare the first two elements of the array
If the first element is greater than the second swap them.
Then, compare 2nd and 3rd elements if the second element is greater than the 3rd swap them.
Repeat this till the end of the array.
After sorting an array print the second element from the end of the array.
Live Demo
public class ThirdLargestNumberInAnArray {
   public static void main(String args[]){
      int temp, size;
      int array[] = {10, 20, 25, 63, 96, 57};
      size = array.length;

      for(int i = 0; i<size; i++ ){
         for(int j = i+1; j<size; j++){

            if(array[i]>array[j]){
               temp = array[i];
               array[i] = array[j];
               array[j] = temp;
            }
         }
      }
      System.out.println("Third second largest number is:: "+array[size-2]);
   }
}
Third second largest number is:: 63
You can also sort the elements of the given array using the sort method of the java.util.Arrays class then, print the second element from the end of the array.
Live Demo
import java.util.Arrays;
public class LargestNumberSample {
   public static void main(String args[]){
      int array[] = {10, 20, 25, 63, 96, 57};
      int size = array.length;
      Arrays.sort(array);
      System.out.println("sorted Array ::"+Arrays.toString(array));
      int res = array[size-2];
      System.out.println("2nd largest element is ::"+res);
   }
}
sorted Array ::[10, 20, 25, 57, 63, 96]
2nd largest element is ::63
How to switch axes in Matplotlib?

To switch axes in matplotlib, we can create a figure and add two subplots using subplots() method. Plot curves, extract x and y data, and set these data in a second plotted curve.
Create x and y data points using numpy.
Create x and y data points using numpy.
Create a figure and add a set of two subplots.
Create a figure and add a set of two subplots.
Set the title of the plot on both the axes.
Set the title of the plot on both the axes.
Plot x and y data points using plot() method.
Plot x and y data points using plot() method.
Extract the x and y data points using get_xdata and get_ydata.
Extract the x and y data points using get_xdata and get_ydata.
To switch the axes of the plot, set x_data and y_data of the axis 1 curve to axis 2 curve.
To switch the axes of the plot, set x_data and y_data of the axis 1 curve to axis 2 curve.
Adjust the padding between and around the subplots.
Adjust the padding between and around the subplots.
To display the figure, use show() method.
To display the figure, use show() method.
import numpy as np
from matplotlib import pyplot as plt
plt.rcParams["figure.figsize"] = [7.00, 3.50]
plt.rcParams["figure.autolayout"] = True
x = np.linspace(-2, 2, 50)
y = np.sin(x)
f, axes = plt.subplots(2)
axes[0].set_title("First plot on axis")
curve, = axes[0].plot(x, y, c='r')
newx = curve.get_xdata()
newy = curve.get_ydata()
axes[1].set_title("Switch of first plot")
curve2, = axes[1].plot(x, y, c='r')
curve2.set_xdata(newy)
curve2.set_ydata(newx)
plt.show()
How to extract initial, last, or middle characters from a string in R?

In Text analysis, we might want to extract characters from a single string or from a vector of strings. This extraction might be required to create a new string with some specific words required for further analysis. We can do this with the help of str_sub function of stringr package.
Consider the below string −
> x1<-"Removing harmful things from the road is an act of charity"
Loading the stringr package −
> library(stringr)
> str_sub(x1,1,8)
[1] "Removing"
> str_sub(x1,1,23)
[1] "Removing harmful things"
> str_sub(x1,29,37)
[1] " the road"
> str_sub(x1,30,37)
[1] "the road"
> str_sub(x1,-58,-51)
[1] "Removing"
> str_sub(x1,-58,-1)
[1] "Removing harmful things from the road is an act of charity"
> str_sub(x1,-7,-1)
[1] "charity"
> str_sub(x1,-14,-1)
[1] "act of charity"
> str_sub(x1,-17,-1)
[1] "an act of charity"
Let’s have a look at extraction of number of characters for a vector of strings −
> x1<-c("Removing", "harmful", "things", "from", "the", "road", "is", "an", "act", "of", "charity")
> str_sub(x1,1,2)
[1] "Re"  "ha"  "th"  "fr"  "th"  "ro"  "is"  "an"  "ac"  "of"  "ch"
> str_sub(x1,1,3)
[1] "Rem" "har" "thi" "fro" "the" "roa" "is" "an" "act" "of" "cha"
> str_sub(x1,1,10)
[1] "Removing" "harmful" "things" "from" "the" "road"
[7] "is"  "an"   "act"    "of"    "charity"
> str_sub(x1,-7,-2)
[1] "emovin" "harmfu" "thing" "fro" "th" "roa" "i" "a"
[9] "ac" "o" "charit"
> str_sub(x1,-7,-1)
[1] "emoving" "harmful" "things" "from" "the" "road" "is"
[8] "an" "act" "of"     "charity"
> str_sub(x1,-10,-1)
[1] "Removing" "harmful" "things" "from" "the" "road"
[7] "is" "an" "act" "of" "charity"
How to get the sum of a specific column of a dataframe in Pandas Python?

Sometimes, it may be required to get the sum of a specific column. This is where the ‘sum’ function can be used.
The column whose sum needs to be computed can be passed as a value to the sum function. The index of the column can also be passed to find the sum.
Let us see a demonstration of the same −
 Live Demo
import pandas as pd
my_data = {'Name':pd.Series(['Tom','Jane','Vin','Eve','Will']),'Age':pd.Series([45, 67, 89, 12, 23]),'value':pd.Series([8.79,23.24,31.98,78.56,90.20])
}
print("The dataframe is :")
my_df = pd.DataFrame(my_data)
print(my_df)
print("The sum of 'age' column is :")
print(my_df.sum(1))
The dataframe is :
    Name  Age value
0   Tom   45   8.79
1   Jane  67   23.24
2   Vin   89   31.98
3   Eve   12   78.56
4   Will   23  90.20
The sum of 'age' column is :
0  53.79
1  90.24
2  120.98
3  90.56
4  113.20
dtype: float64
The required libraries are imported, and given alias names for ease of use.
The required libraries are imported, and given alias names for ease of use.
Dictionary of series consisting of key and value is created, wherein a value is actually a series data structure.
Dictionary of series consisting of key and value is created, wherein a value is actually a series data structure.
This dictionary is later passed as a parameter to the ‘Dataframe’ function present in the ‘pandas’ library
This dictionary is later passed as a parameter to the ‘Dataframe’ function present in the ‘pandas’ library
The dataframe is printed on the console.
The dataframe is printed on the console.
We are looking at computing the sum of the ‘Age’ column.
We are looking at computing the sum of the ‘Age’ column.
The name of the column whose sum needs to be computed is passed as a parameter to the ‘sum’ function.
The name of the column whose sum needs to be computed is passed as a parameter to the ‘sum’ function.
The sum is printed on the console.
The sum is printed on the console.
How can I import modules for a Python Azure Function?

As of writing this, Python support for Azure Functions is experimental. So right now there is no way to directly get a module from a package manager to be installed on your instance. You'll need to bring your own modules with code. No modules are available by default on Azure Functions. You can add them by uploading it via the portal UX or kudu (which is handy for lots of files).
If you don't mind using virtualenv, there is an alternative.
Create your python script on Azure Functions.
Create your python script on Azure Functions.
Open a Kudu console and cd to your script location.
Open a Kudu console and cd to your script location.
Create a virtualenv in this folder (python -m virtualenv myvenv)
Create a virtualenv in this folder (python -m virtualenv myvenv)
Load this venv (cd myvenv/Scripts and call activate.bat). Now your shell should be prefixed by (myvenv).
Load this venv (cd myvenv/Scripts and call activate.bat). Now your shell should be prefixed by (myvenv).
Update pip (python -m pip install -U pip)
Update pip (python -m pip install -U pip)
Install your dependencies using pip. (python -m pip install django)
Install your dependencies using pip. (python -m pip install django)
Now wherever you need to import scripts, append the sys.path variable with this env. For example,
import sys, os.path
sys.path.append(os.path.abspath(os.path.join(os.path.dirname( __file__ ), 'myvenv/Lib/site-packages')))
Mahotas - Haralick features - GeeksforGeeks

30 Jun, 2021
In this article we will see how we can get the haralick features of image in mahotas. Haralick texture features are calculated from a Gray Level Co-occurrence Matrix, (GLCM), a matrix that counts the co-occurrence of neighboring gray levels in the image. The GLCM is a square matrix that has the dimension of the number of gray levels N in the region of interest (ROI). For this we are going to use the fluorescent microscopy image from a nuclear segmentation benchmark. We can get the image with the help of command given below 
mahotas.demos.nuclear_image()
Below is the nuclear_image  
In order to do this we will use mahotas.features.haralick method  
Syntax : mahotas.features.haralick(img)Argument : It takes image object as argumentReturn : It returns numpy.ndarray  
Note : The input of the this should should be the filtered image or loaded as greyIn order to filter the image we will take the image object which is numpy.ndarray and filter it with the help of indexing, below is the command to do this  
image = image[:, :, 0]
Example 1 :  
Python3
# importing various librariesimport mahotasimport mahotas.demosimport mahotas as mhimport numpy as npfrom pylab import imshow, show # loading nuclear imagenuclear = mahotas.demos.nuclear_image() # filtering imagenuclear = nuclear[:, :, 0] # adding gaussian filternuclear = mahotas.gaussian_filter(nuclear, 4) # setting thresholdthreshed = (nuclear > nuclear.mean()) # making is labeled imagelabeled, n = mahotas.label(threshed) # showing imageprint("Labelled Image")imshow(labeled)show() # getting haralick featuresh_feature = mahotas.features.haralick(labelled) # showing the featureprint("Haralick Features")imshow(h_feature)show()
Output :  
Example 2 :  
Python3
# importing required librariesimport numpy as npimport mahotasfrom pylab import imshow, show  # loading imageimg = mahotas.imread('dog_image.png')    # filtering the imageimg = img[:, :, 0]     # setting gaussian filtergaussian = mahotas.gaussian_filter(img, 15)  # setting threshold valuegaussian = (gaussian > gaussian.mean())  # making is labelled imagelabeled, n = mahotas.label(gaussian) # showing imageprint("Labelled Image")imshow(labelled)show() # getting haralick featuresh_feature = mahotas.features.haralick(labelled) # showing the featureprint("Haralick Features")imshow(h_feature)show()
Output :  
 
arorakashish0911
simranarora5sos
Python-Mahotas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Python String | replace()
*args and **kwargs in Python
Create a Pandas DataFrame from Lists
How To Convert Python Dictionary To JSON?
Convert integer to string in Python
Check if element exists in list in Python
Tensorflow.js tf.matMul() Function - GeeksforGeeks

18 May, 2021
Tensorflow.js is an open-source library developed by Google for running machine learning models and deep learning neural networks in the browser or node environment.
The tf.matMul() function is used to compute the dot product of two matrices, A * B.
Syntax:
tf.matMul (a, b, transposeA?, transposeB?)
Parameters: This function accepts a parameter which is illustrated below:
a: This is the first matrix in dot product operation.
b: This is the second matrix in dot product operation.
transposeA: This is optional and if it is set to true, then a is transposed before multiplication.
transposeB: This is optional and if it is set to true, then b is transposed before multiplication.
Return Value: It returns the dot product of two matrices.
Below are the examples that illustrates the use of tf.matMul() function.
Example 1:
Javascript
// Importing the tensorflow.js libraryimport * as tf from "@tensorflow/tfjs"  // Initializing a tensor of some elementslet geek1 = tf.tensor2d([2, 1], [1, 2]);let geek2 = tf.tensor2d([11, 12, 13, 14], [2, 2]);  // Calling the .avgPool3d() function over// the above tensor as its parameter and // printing the result.geek1.matMul(geek2).print();
Output:
Tensor
     [[35, 38],]
Example 2:
Javascript
// Importing the tensorflow.js libraryimport * as tf from "@tensorflow/tfjs"  // Initializing a tensor of some elementslet geek1 = tf.tensor2d([2, 1], [1, 2]);let geek2 = tf.tensor2d([61, 62, 63, 64], [2, 2]);  // Calling the .avgPool3d() function over// the above tensor as its parameter and // printing the result.tf.matMul(geek1, geek2).print();
Output:
Tensor
     [[185, 188],]
Reference:https://js.tensorflow.org/api/latest/#matMul
Picked
Tensorflow
Tensorflow.js
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Remove elements from a JavaScript Array
Difference between var, let and const keywords in JavaScript
Difference Between PUT and PATCH Request
JavaScript | Promises
How to get character array from string in JavaScript?
Remove elements from a JavaScript Array
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
Difference between var, let and const keywords in JavaScript
Difference between #define and const in Arduino

If you've done sufficient Arduino programming, you'd have seen that there are two ways of defining constants.
One way is to use #define, like
#define const_name 3
The other way is to use the const keyword, like
const int var_name = 3;

#define is like a placeholder. The Arduino compiler replaces all mentions of this constant with its value at the compile time. This means that the values defined using #define don't take up any program space.
Variables defined using const, on the other hand, are just normal variables, whose values can't be changed. They take up program memory space, and have a type (which is advantageous in many situations).
In general, it is preferred to use const over #define, for defining constants.
Line Splicing in C/C++ - GeeksforGeeks

13 Apr, 2021
While writing a program, sometimes we give comment about the working of the code in the comment section with the help of single/double comment line. But we had never thought that if at the end of this comment line if we use \(backslash) character then what will happen?The answer of the above question is line Splicing. Lines terminated by a \ are spliced together with the next line very early in the process of translation. §2.2 Phases of translation. Actually whenever at the end of the comment line if we use \(backslash) character then it merges the immediate next line with current line which makes the new line also as a comment for the compiler. To avoid this issue multi-line comment can be used. 
C
// C program to illustrate the concept of Line splicing.#include <stdio.h>int main(){    // Line Splicing\    printf("Hello GFG\n");    printf("welcome\n");    /* Example 2 - both of the below lines will be printed*/ \    printf("Hello\t");    printf("World");    return (0);}
welcome
Hello World
Explanation: In the above program as we can see when we use the \(backslash) character at the end of comment line. Then the next line of code is treated as comment in the program and the output is welcome. When we use multiline comment this issue get solved and both of the below lines of multiline comment will be printed.This article is contributed by Bishal Kumar Dubey. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above. 
souvikr
codergirl321
C Language
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Function Pointer in C
fork() in C
Substring in C++
std::string class in C++
TCP Server-Client implementation in C
Vector in C++ STL
Inheritance in C++
Initialize a vector in C++ (6 different ways)
Map in C++ Standard Template Library (STL)
C++ Classes and Objects
AtomicReference getAndUpdate() method in Java with Examples - GeeksforGeeks

15 Apr, 2021
The getAndUpdate() method of a AtomicReference class is used to atomically updates which updates the current value of the AtomicReference by applying the specified updateFunction operation on the current value. It takes an object of updateFunction interface as its parameter and applies the operation specified in the object to the current value. It returns the previous value.Syntax:  
public final V getAndUpdate(UnaryOperator<V> updateFunction)
Parameters: This method accepts updateFunction which is a side-effect-free function.Return value: This method returns the previous value.Below programs illustrate the getAndUpdate() method: Program 1:  
Java
// Java program to demonstrate// AtomicReference.getAndUpdate() method import java.util.concurrent.atomic.AtomicReference;import java.util.function.UnaryOperator; public class GFG {    public static void main(String args[])    {         // AtomicReference with value        AtomicReference<Integer> ref            = new AtomicReference<>(987654);         // Declaring the updateFunction        // applying function        UnaryOperator twoDigits            = (v)            -> v.toString()                   .substring(0, 2);         // apply getAndUpdate()        int value = ref.getAndUpdate(twoDigits);         // print AtomicReference        System.out.println(            "The AtomicReference previous value: "            + value);        System.out.println(            "The AtomicReference new value: "            + ref.get());    }}
 
Program 2:  
Java
// Java program to demonstrate// AtomicReference.getAndUpdate() method import java.util.concurrent.atomic.*;import java.util.function.UnaryOperator; public class GFG {    public static void main(String args[])    {         // AtomicReference with value        AtomicReference<String> ref            = new AtomicReference<>("welcome");         // Declaring the updateFunction        // applying function        UnaryOperator twoDigits            = (v) -> v + " to gfg";         // apply getAndUpdate()        String value            = ref.getAndUpdate(twoDigits);         // print AtomicReference        System.out.println(            "The AtomicReference previous value: "            + value);        System.out.println(            "The AtomicReference new value: "            + ref.get());    }}
 
References: https://docs.oracle.com/javase/10/docs/api/java/util/concurrent/atomic/AtomicReference.html#getAndUpdate(java.util.function.UnaryOperator) 
arorakashish0911
Java-Functions
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Stream In Java
Different ways of Reading a text file in Java
Constructors in Java
Exceptions in Java
Functional Interfaces in Java
Generics in Java
Comparator Interface in Java with Examples
HashMap get() Method in Java
Introduction to Java
Difference between Abstract Class and Interface in Java
Represent Int32 as a Binary String in C#

To represent Int632as a Binary string in C#, use the ToString() method and set the base as the ToString() method’s second parameter i.e. 2 for Binary.
Int32 represents a 32-bit signed integer.
Firstly, set an Int64 variable −
int val = 30;
Now, convert it to a binary string by including 2 as the second parameter.
Convert.ToString(val, 2)
 Live Demo
using System;
class Demo {
   static void Main() {
      int val = 30;
      Console.WriteLine("Integer: "+val);
      Console.Write("Binary String: "+Convert.ToString(val, 2));
   }
}
Integer: 30
Binary String: 11110
How to rename multiple files recursively using Python?

You can use os.walk to recursively walk through the directory and subsequently use os.rename to rename the files.
import os
def replace(folder_path, old, new):
    for path, subdirs, files in os.walk(folder_path):
        for name in files:
            if(old.lower() in name.lower()):
                file_path = os.path.join(path,name)
                new_name = os.path.join(path,name.lower().replace(old,new))
                os.rename(file_path, new_name)
You can use this function as follows −
replace('my_folder', 'IMG', 'Image')
This will find all files recursively within the folder and its sub-folders and replace IMG with Image in each one of them. You can modify the function as it suits you for a better result suited to your need.
numpy.column_stack() in Python - GeeksforGeeks

06 Jan, 2019
numpy.column_stack() function is used to stack 1-D arrays as columns into a 2-D array.It takes a sequence of 1-D arrays and stack them as columns to make a single 2-D array. 2-D arrays are stacked as-is, just like with hstack function.
Syntax : numpy.column_stack(tup)
Parameters :tup : [sequence of ndarrays] Tuple containing arrays to be stacked. The arrays must have the same first dimension.Return : [stacked 2-D array] The stacked 2-D array of the input arrays.
Code #1 :
# Python program explaining# column_stack() function  import numpy as geek  # input arrayin_arr1 = geek.array(( 1, 2, 3 ))print ("1st Input array : \n", in_arr1)   in_arr2 = geek.array(( 4, 5, 6 ))print ("2nd Input array : \n", in_arr2)   # Stacking the two arrays out_arr = geek.column_stack((in_arr1, in_arr2))print ("Output stacked array:\n ", out_arr)
1st Input array : 
 [1 2 3]
2nd Input array : 
 [4 5 6]
Output stacked array:
  [[1 4]
 [2 5]
 [3 6]]

 Code #2 :
# Python program explaining# column_stack() function  import numpy as geek  # input arrayin_arr1 = geek.array([[ 1, 2, 3], [ -1, -2, -3]] )print ("1st Input array : \n", in_arr1)   in_arr2 = geek.array([[ 4, 5, 6], [ -4, -5, -6]] )print ("2nd Input array : \n", in_arr2)   # Stacking the two arrays out_arr = geek.column_stack((in_arr1, in_arr2))print ("Output stacked array :\n ", out_arr)
1st Input array : 
 [[ 1  2  3]
 [-1 -2 -3]]
2nd Input array : 
 [[ 4  5  6]
 [-4 -5 -6]]
Output stacked array :
  [[ 1  2  3  4  5  6]
 [-1 -2 -3 -4 -5 -6]]

Python numpy-arrayManipulation
Python-numpy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Reading and Writing to text files in Python
*args and **kwargs in Python
Create a Pandas DataFrame from Lists
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Convert integer to string in Python
How to create a TreeView using JavaFX?

A tree provides a view of hierarchical structures, each tree contains a root (highest object) and it contains children. You can create a tree view by instantiating the javafx.scene.control.TreeView class.
The following Example demonstrates the creation of a TreeView.
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.TreeItem;
import javafx.scene.control.TreeView;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
public class TreeViewExample extends Application {
   public void start(Stage stage) {
      //Creating tree items
      TreeItem root1 = new TreeItem("Programming Languages");
      TreeItem item1 = new TreeItem("Java");
      TreeItem item2 = new TreeItem("Python");
      TreeItem item3 = new TreeItem("C++");
      //Adding elements to root1
      root1.getChildren().addAll(item1, item2, item3);
      TreeItem root2 = new TreeItem("NoSQL Databases");
      TreeItem item4 = new TreeItem("Neo4j");
      TreeItem item5 = new TreeItem("HBase");
      TreeItem item6 = new TreeItem("Cassandra");
      //Adding elements to root2
      root2.getChildren().addAll(item4, item5, item6);
      TreeItem root3 = new TreeItem("Bigdata & Analytics");
      TreeItem item7 = new TreeItem("Hadoop");
      TreeItem item8 = new TreeItem("Mahout");
      TreeItem item9 = new TreeItem("Hive");
      //Adding elements to root2
      root3.getChildren().addAll(item7, item8, item9);
      //list View for educational qualification
      TreeItem<String> base = new TreeItem<String>("Technologies");
      base.setExpanded(true);
      base.getChildren().addAll(root1, root2, root3);
      //Creating a TreeView item
      TreeView view = new TreeView(base);
      view.setPrefHeight(300);
      VBox pane = new VBox(10);
      pane.setPadding(new Insets(5, 5, 5, 50));
      pane.getChildren().addAll(view);
      //Setting the stage
      Group node = new Group(pane);
      Scene scene = new Scene(node, 595, 320, Color.BEIGE);
      stage.setTitle("List View Example");
      stage.setScene(scene);
      stage.show();
   }
   public static void main(String args[]){
      launch(args);
   }
}
CSS | z-index Property - GeeksforGeeks

09 Aug, 2019
The z-index property is used to displace elements on the z-axis i.e in or out of the screen. It is used to define the order of elements if they overlap on each other.
Syntax:
z-index: auto|number|initial|inherit;

Property values:
auto: The stack order is equal to that of the parent(default).
number: The stack order depends in the number.
initial: Sets the property to its default value.
inherit: Inherits the property from the parent element.
Example 1:
<!DOCTYPE html><html>  <head>    <title>         z-index Property    </title>    <style>        img {            position: absolute;            left: 0px;            top: 0px;            z-index: -1;        }                  h1,        p {            background-color: green;        }    </style></head>  <body>      <h1>GeeksforGeeks</h1>    <img src="https://media.geeksforgeeks.org/wp-content/uploads/geek.png"          width="400" height="150">    <p>This example shows the use of z-index property.</p></body>  </html>
Output:
Example 2:
<!DOCTYPE html><html>  <head>    <title>         z-index Property    </title>    <style>        img {            position: absolute;            left: 0px;            top: 0px;            z-index: +1;        }                  h1,        p {            background-color: green;        }    </style></head>  <body>      <h1>GeeksforGeeks</h1>    <img src="https://media.geeksforgeeks.org/wp-content/uploads/geek.png"          width="400" height="150">    <p>This example shows the use of z-index property.</p></body>  </html>
Output:
In the Example-1 the z-index is set to -1 therefore, the image appears behind the text but in Example-2 when the z-index is set to +1 the image hides the text.
Supported Browsers: The browser supported by z-index property are listed below:
Google Chrome 1.0
Edge 12.0
Firefox 1.0
Opera 4.0
Apple Safari 1.0
CSS-Properties
Picked
CSS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
How to update Node.js and NPM to next version ?
How to create footer to stay at the bottom of a Web page?
CSS to put icon inside an input element in a form
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?