code-rag-bench/online-tutorials huggingface dataset:
QlikView - Cross Tables

While analyzing data, we come across situations where we desire columns to become rows and vice-versa. It is not just about transposing, it also involves rolling up many columns together or repeating many values in a row many times to achieve the desired column and row layout in the table.
Consider the following input data, which shows region wise sales of a certain product for each quarter. We create a delimited file (CSV) with the below given data.
Quarter,Region1,Region2,Region 3
Q1,124,421,471
Q2,415,214,584
Q3,417,321,582
Q4,751,256,95

We load the above input data using the script editor, which is invoked by pressing Control+E. Choose the option Table Files and browse for the Input file. After choosing the options as shown below, click Next.
In the next window (File Wizard → Options), click on the Crosstable button. It highlights
the columns in different colors. The pink color shows the qualifier field, which is going to be repeated across many rows for each value of in the Attribute Field. The cell values under the Attribute fields are taken as the data. Click OK.
The transformed data appears in which all the Region fields are clubbed to one column but with values repeating for each quarter.
The Load script for the crosstable transformations shows the commands given below.
On creating a Table Box sheet object using the menu Layout → New Sheet Objects → Table Box, we get the following output.

    70 Lectures 
     5 hours 

 Arthur Fong
 Print
 Add Notes
 Bookmark this page
Concatenate Two Maps in Scala - GeeksforGeeks

13 Aug, 2019
The concatenation of Scala map is obtained by utilizing ++ operator.Syntax :
def ++(xs: Map[(A, B)]): Map[A, B]

Return Type:It returns a single map by concatenating two maps but it separates the identical keys.Example #1:
// Scala program of concatenating// two maps  // Creating objectobject GfG{       // Main method    def main(args:Array[String])    {              // Creating the first map        val m1 = Map("Nidhi" -> 23, "Rahul" -> 18)                   // Creating the second map        val m2 = Map("Geeta" -> 22, "Rahul" -> 18)                   // Applying ++ operator        val result = m1.++(m2)                  // Displays output        println(result)          }}
Map(Nidhi -> 23, Rahul -> 18, Geeta -> 22)

As we can see in above example, we joined two maps by using ++ operator.Example #2:
// Scala program of concatenating// two maps  // Creating objectobject GfG{       // Main method    def main(args:Array[String])    {              // Creating the first map        val m1 = Map("geeks" -> 5, "for" -> 3)                   // Creating the second map        val m2 = Map("geeks" -> 5, "cs" -> 2)                   // Applying ++ operator        val result = m1.++(m2)                  // Displays output        println(result)          }}
Map(geeks -> 5, for -> 3, cs -> 2)

Scala
Scala-Map
Scala
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Type Casting in Scala
Scala Lists
Scala Tutorial – Learn Scala with Step By Step Guide
Class and Object in Scala
Operators in Scala
Hello World in Scala
Inheritance in Scala
Lambda Expression in Scala
Scala Constructors
Scala String substring() method with example
Python | Pandas dataframe.pct_change() - GeeksforGeeks

22 Nov, 2018
Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier.
Pandas dataframe.pct_change() function calculates the percentage change between the current and a prior element. This function by default calculates the percentage change from the immediately previous row.
Note : This function is mostly useful in the time-series data.
Syntax: DataFrame.pct_change(periods=1, fill_method=’pad’, limit=None, freq=None, **kwargs)
Parameters :periods : Periods to shift for forming percent change.fill_method : How to handle NAs before computing percent changes.limit : The number of consecutive NAs to fill before stoppingfreq : Increment to use from time series API (e.g. ‘M’ or BDay()).**kwargs : Additional keyword arguments are passed into DataFrame.shift or Series.shift.
Returns : The same type as the calling object.
Example #1: Use pct_change() function to find the percentage change in the time-series data.
# importing pandas as pdimport pandas as pd  # Creating the time-series indexind = pd.date_range('01/01/2000', periods = 6, freq ='W')  # Creating the dataframe df = pd.DataFrame({"A":[14, 4, 5, 4, 1, 55],                   "B":[5, 2, 54, 3, 2, 32],                    "C":[20, 20, 7, 21, 8, 5],                   "D":[14, 3, 6, 2, 6, 4]}, index = ind)  # Print the dataframedf
Let’s use the dataframe.pct_change() function to find the percent change in the data.
# find the percentage change with the previous rowdf.pct_change()
Output :The first row contains NaN values, as there is no previous row from which we can calculate the change. Example #2: Use pct_change() function to find the percentage change in the data which is also having NaN values.
# importing pandas as pdimport pandas as pd  # Creating the time-series indexind = pd.date_range('01/01/2000', periods = 6, freq ='W')  # Creating the dataframe df = pd.DataFrame({"A":[14, 4, 5, 4, 1, 55],                   "B":[5, 2, None, 3, 2, 32],                    "C":[20, 20, 7, 21, 8, None],                   "D":[14, None, 6, 2, 6, 4]}, index = ind)  # apply the pct_change() method# we use the forward fill method to# fill the missing values in the dataframedf.pct_change(fill_method ='ffill')
Output :
The first row contains NaN values, as there is no previous row from which we can calculate the change. All the NaN values in the dataframe has been filled using ffill method.
Python pandas-dataFrame
Python pandas-dataFrame-methods
Python-pandas
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
*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
How to drop one or multiple columns in Pandas Dataframe
getent - Unix, Linux Command

$ getent services 22
ssh                   22/tcp
$ getent services 21
ftp                   21/tcp
$ getent services 25
smtp                  25/tcp mail

$ getent passwd `whoami`
root:x:0:0:root:/root:/bin/bash

$ getent hosts myhost.mydomain.com
15.77.3.40       myhost.mydomain.com myhost


    129 Lectures 
     23 hours 

 Eduonix Learning Solutions

    5 Lectures 
     4.5 hours 

 Frahaan Hussain

    35 Lectures 
     2 hours 

 Pradeep D

    41 Lectures 
     2.5 hours 

 Musab Zayadneh

    46 Lectures 
     4 hours 

 GUHARAJANM

    6 Lectures 
     4 hours 

 Uplatz
 Print
 Add Notes
 Bookmark this page
How to Calculate Point-Biserial Correlation in R? - GeeksforGeeks

24 Dec, 2021
In this article, we will discuss how to calculate Point Biserial correlation in R Programming Language.
Correlation measures the relationship between two variables. we can say the correlation is positive if the value is 1, the correlation is negative if the value is -1, else 0. Point biserial correlation returns the correlated value that exists between a binary variable and a continuous variable. we can calculate the point biserial correlation using the cor.test() function.
Syntax:
cor.test(data1,data2)
Parameters:
data: Vectors of points
Example 1:
In this example, we will be using the cor.test() function with two vectors containing different data points to get the correlation between them in the R language.
R
# create two vectorsdata1=c(1:20) data2=c(23:42) # get correlationprint(cor.test(data1,data2))
Output:
    Pearson's product-moment correlation

data:  data1 and data2
t = Inf, df = 18, p-value < 2.2e-16
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
 1 1
sample estimates:
cor 
  1 
Example 2: 
In this example, we will be using the cor.test() function with the different columns of the given data frame get the correlation between them in the R language.
R
# create  dataframe with two columnsdata=data.frame(col1=c(1,34,56,32,23),                col2=c(21,34,56,32,34)) # get correlationprint(cor.test(data$col1,data$col2))
Output:
    Pearson's product-moment correlation

data:  data$col1 and data$col2
t = 4.7383, df = 3, p-value = 0.01782
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
 0.3323372 0.9960865
sample estimates:
      cor 
0.9392161
anikakapoor
Picked
R-Statistics
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 Change Axis Scales in R Plots?
How to Split Column Into Multiple Columns in R DataFrame?
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?
Plot mean and standard deviation using ggplot2 in R
How to import an Excel File into R ?
String in Switch Case in Java

A switch statement allows a variable to be tested for equality against a list of values. Each value is called a case, and the variable being switched on is checked for each case.
 Live Demo
public class Test {
   public static void main(String args[]) {
      // char grade = args[0].charAt(0);
      char grade = 'C';
      switch(grade) {
         case 'A' :
            System.out.println("Excellent!");
            break;
         case 'B' :
         case 'C' :
            System.out.println("Well done");
            break;
         case 'D' :
            System.out.println("You passed");
         case 'F' :
            System.out.println("Better try again");
            break;
         default :
            System.out.println("Invalid grade");
      }
      System.out.println("Your grade is " + grade);
   }
}
Well done
Your grade is C
How to assign multiple values to same variable in C#?


To set multiple values to same variable, use arrays in C#. Let’s say instead of taking 5 variables, set these 5 variables using arrays in a single variable.
The following is an example to set three values to a single variable with a string array −
string[] arr = new string[3];
Let us now initialize it −
string[] arr = new string[3] {"one", "two", "three"};
The following is the complete example −
 Live Demo
using System;

public class Demo {
   static void Main(string[] args) {

      string[] arr = new string[3] {"one", "two", "three"};

      for (int i = 0; i < arr.Length; i++) {
         Console.WriteLine("Values: " + arr[i]);
      }

      Console.ReadKey();
   }

}
Values: one
Values: two
Values: three
Adding borders to the images using Python - OpenCV - GeeksforGeeks

07 Oct, 2021
Image processing is an interesting field in today’s era of Artificial Intelligence and Machine Learning. We can see the applications of image processing in our day-to-day life, like whenever we apply filter over any image (selfie) or when we want to apply some effect like blurring the image, etc. 
In this article, we will discuss how to add borders to an image using Python. Python provides a module called OpenCV that can be used for the same. So before adding borders let’s see a small introduction about OpenCV.
OpenCV (Open Source Computer Vision Library)
It is an open-source library.
Designed to solve Computer Vision problems.
It makes use of a highly optimized library for numerical operations which is Numpy along with MATLAB style syntax.
To add borders to the images OpenCV has a package copyMakeBorder which helps to make a border around the image.
Syntax: cv2.copyMakeBorder()
Parameters of copyMakeBorder:
inputImage
topBorderWidth
bottomBorderWidth
leftBorderWidth
rightBorderWidth
cv2.BORDER_CONSTANT
value=color of border
Input Image:
Example:
Python3
# importing required packages import cv2 # reading the imagevirat_img = cv2.imread('geek.jpg') # making border around image using copyMakeBorderborderoutput = cv2.copyMakeBorder(    virat_img, 20, 20, 20, 20, cv2.BORDER_CONSTANT, value=[255, 255, 0]) # showing the image with bordercv2.imwrite('output.png', borderoutput)
Output:
rajeev0719singh
Picked
Python-OpenCV
Technical Scripter 2020
Python
Technical Scripter
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Install PIP on Windows ?
How to drop one or multiple columns in Pandas Dataframe
Selecting rows in pandas DataFrame based on conditions
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | os.path.join() method
Python | Get unique values from a list
Create a directory in Python
Defaultdict in Python
Python | Pandas dataframe.groupby()
Tryit Editor v3.7

Tryit: HTML class attribute
How to create a URL object using JavaScript?

Following is the code to create a URL object using JavaScript −
 Live Demo
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
   body {
      font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
   }
   .result {
      font-size: 18px;
      font-weight: 500;
      color: rebeccapurple;
   }
</style>
</head>
<body>
<h1>Url object in JavaScript</h1>
<div class="result"></div>
<button class="Btn">CLICK HERE</button>
<h3>Click on the above button to create and display a url object</h3>
<script>
   let resEle = document.querySelector(".result");
   let url = new URL("https://google.com/image=23&size=440px");
   document.querySelector(".Btn").addEventListener("click", () => {
      resEle.innerHTML += "url protocol = " + url.protocol + "<br>";
      resEle.innerHTML += "url host = " + url.host + "<br>";
      resEle.innerHTML += "url.pathname = " + url.pathname + "<br>";
   });
</script>
</body>
</html>
The above code will produce the following output −
On clicking the ‘CLICK HERE’ button −
8085 program to find nth power of a number - GeeksforGeeks

07 Sep, 2018
Problem – Write an assembly language code for calculating the nth power of a number using 8085 microprocessor.
Example –
Input : Base=>02H
        Exponent=>03H  
Output :08H 

In 8085 microprocessor, no direct instruction exists to multiply two numbers, so multiplication is done by repeated addition as 4*4 is equivalent to 4+4+4+4(ie 4 times).Load 02H(base) to register B and 03H(exponent) to register C -> set D register to 02H -> Add 02H B(ie 2) times -> D register now contains 04H -> Add 04H B(ie 2) times -> D register now contains 08H -> Output is 08H.
Algorithm –
Load the base into register B and exponent into register C.To start multiplication set D to 01H.Jump to step 7.Decrements C.Jump to step 3 till value of C>0.Take memory pointer to next location and store result.Load E with contents of B and clear accumulator.Repeatedly add contents of D to accumulator E times.Store accumulator content to D.Go to step 4.
Load the base into register B and exponent into register C.
To start multiplication set D to 01H.
Jump to step 7.
Decrements C.
Jump to step 3 till value of C>0.
Take memory pointer to next location and store result.
Load E with contents of B and clear accumulator.
Repeatedly add contents of D to accumulator E times.
Store accumulator content to D.
Go to step 4.
Program –
Explanation –
Set register B with base and register C with exponent.Set register D with base by calling MULTIPLY subroutine one time.Decrement C and add D to itself B times by calling MULTIPLY subroutine.Repeat the above step till C reaches 0 and then exit the program.The result is obtained in D register which is stored in memory
Set register B with base and register C with exponent.
Set register D with base by calling MULTIPLY subroutine one time.
Decrement C and add D to itself B times by calling MULTIPLY subroutine.
Repeat the above step till C reaches 0 and then exit the program.
The result is obtained in D register which is stored in memory
aastha98
microprocessor
system-programming
Computer Organization & Architecture
microprocessor
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Logical and Physical Address in Operating System
Addressing modes in 8085 microprocessor
Computer Organization and Architecture | Pipelining | Set 1 (Execution, Stages and Throughput)
Architecture of 8085 microprocessor
Computer Organization | RISC and CISC
Memory Hierarchy Design and its Characteristics
Pin diagram of 8086 microprocessor
Architecture of 8086
Computer Organization | Booth's Algorithm
C# Interface Types

Interfaces define properties, methods, and events, which are the members of the interface.Interfaces contain only the declaration of the members.
Some of the interface types in C# include.
IEnumerable − Base interface for all generic collections.
IEnumerable − Base interface for all generic collections.
IList − A generic interface implemented by the arrays and the list type.
IList − A generic interface implemented by the arrays and the list type.
IDictionary − A dictionary collection.
IDictionary − A dictionary collection.
IEnumerable is an interface defining a single method GetEnumerator that returns an IEnumerator interface.
This works for readonly access to a collection that implements that IEnumerable can be used with a foreach statement.
The following shows the implementation of IEnumerable interface.
class Demo : IEnumerable, IEnumerator {
   // IEnumerable method GetEnumerator()
   IEnumerator IEnumerable.GetEnumerator() {
      throw new NotImplementedException();
   }
   public object Current {
      get { throw new NotImplementedException(); }
   }
   // IEnumertor method
   public bool MoveNext() {
      throw new NotImplementedException();
   }
   // IEnumertor method
   public void Reset() {
      throw new NotImplementedException();
   }
}
Above you can see the two methods of IEnumerator.
// IEnumerator method
public bool MoveNext() {
   throw new NotImplementedException();
}
// IEnumertor method
public void Reset() {
   throw new NotImplementedException();
}
PHP Boolean Data Type

This is one of the scalar data types in PHP. A boolean data can be either TRUE or FALSE. These are predefined constants in PHP. The variable becomes a boolean variable when either TRUE or FALSE is assigned.
<?php
//Literal assignment of boolean value to variable
$var=TRUE;
?>
Result of echoing TRUE value displays 1 while for FALSE it shows nothing. Using var_dump() function displays bool as type with value
Boolean constants are not case sensitive. That means TRUE is equivalent to true and FALSE is similar to False
Logical operators return boolean value
<?php
$gender="Male";
echo ($gender=="Male");
?>
Any data type can be explicitly converted to boolean with the help of casting operator (bool) or (boolean), although, most of the times, conversion is done automatically whenever required.
This description is applicable to all versions of PHP.
Following example shows use of echo and var_dump() to diplay boolean value
 Live Demo
<?php
$var=TRUE;
echo $var . "\n";
var_dump($var);
$var1=false;
echo $var1;
var_dump($var1);
?>
This will produce following result −
1
bool(true)
bool(false)
Example shows boolean result of logical expression
 Live Demo
<?php
$var=10;
var_dump($var>10);
var_dump($var==true);
?>
This will produce following result −
bool(false)
bool(true)
Example shows use of casting operator
 Live Demo
<?php
$var=10;
$var1=(bool)$var;
var_dump($var1);
//0 and -0 return false
$var=0;
$var1=(bool)$var;
var_dump($var1);
//empty string returns false
$var="PHP";
$var1=(bool)$var;
var_dump($var1);
$var="";
$var1=(bool)$var;
var_dump($var1);
//empty array is case to false
$var=array(1,2,3);
$var1=(bool)$var;
var_dump($var1);
$var=array();
$var1=(bool)$var;
var_dump($var1);
?>
This will produce following result −
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
The fork() Function in Perl

Perl provides a fork() function that corresponds to the Unix system call of the same name. On most Unix-like platforms where the fork() system call is available, Perl's fork() simply calls it. On some platforms such as Windows where the fork() system call is not available, Perl can be built to emulate fork() at the interpreter level.
The fork() function is used to clone a current process. This call create a new process running the same program at the same point. It returns the child pid to the parent process, 0 to the child process, or under if the fork is unsuccessful.
You can use exec() function within a process to launch the requested executable, which will be executed in a separate process area and exec() will wait for it to complete before exiting with the same exit status as that process.
 Live Demo
#!/usr/bin/perl
if(!defined($pid = fork())) {
   # fork returned undef, so unsuccessful
   die "Cannot fork a child: $!";
} elsif ($pid == 0) {
   print "Printed by child process\n";
   exec("date") || die "can't exec date: $!";
} else {
   # fork returned 0 nor undef
   # so this branch is parent
   print "Printed by parent process\n";
   $ret = waitpid($pid, 0);
   print "Completed process id: $ret\n";
}
1;
When above code is executed, it produces the following result −
Printed by parent process
Printed by child process
Tue Sep 17 15:41:08 CDT 2013
Completed process id: 17777
The wait() and waitpid() can be passed as a pseudo-process ID returned by fork(). These calls will properly wait for the termination of the pseudo-process and return its status. If you fork without ever waiting on your children using waitpid() function, you will accumulate zombies. On Unix systems, you can avoid this by setting $SIG{CHLD} to "IGNORE" as follows −
 Live Demo
#!/usr/bin/perl
local $SIG{CHLD} = "IGNORE";
if(!defined($pid = fork())) {
   # fork returned undef, so unsuccessful
   die "Cannot fork a child: $!";
} elsif ($pid == 0) {
   print "Printed by child process\n";
   exec("date") || die "can't exec date: $!";
} else {
   # fork returned 0 nor undef
   # so this branch is parent
   print "Printed by parent process\n";
   $ret = waitpid($pid, 0);
   print "Completed process id: $ret\n";
}
1;
When above code is executed, it produces the following result −
Printed by parent process
Printed by child process
Tue Sep 17 15:44:07 CDT 2013
Completed process id: -1
Python | Every Kth element removal in List - GeeksforGeeks

19 Feb, 2020
We generally wish to employ a particular function to all the elements in a list. But sometimes, according to requirement we would wish to remove certain elements of the list, basically to every Kth element in list. Let’s discuss certain ways in which this can be performed.
Method #1 : Using list comprehension + enumerate()The functionality of getting every Kth number of list can be done with the help of list comprehension and enumerate function helps in the iteration of the whole list.
# Python3 code to demonstrate# Every Kth element removal in List# using list comprehension + enumerate()  # initializing list test_list = [1, 4, 5, 6, 7, 8, 9, 12]  # printing the original listprint ("The original list is : " + str(test_list))  # initializing K K = 3  # using list comprehension + enumerate()# Every Kth element removal in List# Remove every third elementres = [i for j, i in enumerate(test_list) if j % K != 0]  # printing resultprint ("The list after removing every Kth element : " + str(res))
The original list is : [1, 4, 5, 6, 7, 8, 9, 12]
The list after removing every kth element : [4, 5, 7, 8, 12]

 
Method #2 : Using list comprehension + list slicingAbove mentioned functions can help to perform these tasks. The list comprehension does the task of iteration in list and list slicing does the extraction of every Kth element.
# Python3 code to demonstrate# Every Kth element removal in List# using list comprehension + list slicing   # initializing list test_list = [1, 4, 5, 6, 7, 8, 9, 12]  # printing the original listprint ("The original list is : " + str(test_list))  # initializing K K = 3  # using list comprehension + list slicing# Every Kth element removal in List# removes every 3rd elementres = [i for i in test_list if i not in test_list[0 :: 3]]  # printing resultprint ("The list after removing every Kth element : " + str(res))
The original list is : [1, 4, 5, 6, 7, 8, 9, 12]
The list after removing every kth element : [4, 5, 7, 8, 12]

Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Install PIP on Windows ?
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | Pandas dataframe.groupby()
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 check whether a number is Prime or not
Perl Bitwise Operators Example

There are following Bitwise operators supported by Perl language, assume if $a = 60; and $b = 13 −
&
Binary AND Operator copies a bit to the result if it exists in both operands.
Example − ($a & $b) will give 12 which is 0000 1100
|
Binary OR Operator copies a bit if it exists in eather operand.
Example − ($a | $b) will give 61 which is 0011 1101
^
Binary XOR Operator copies the bit if it is set in one operand but not both.
Example − ($a ^ $b) will give 49 which is 0011 0001
~
Binary Ones Complement Operator is unary and has the efect of 'flipping' bits.
Example − (~$a ) will give -61 which is 1100 0011 in 2's complement form due to a signed binary number.
<<
Binary Left Shift Operator. The left operands value is moved left by the number of bits specified by the right operand.
Example − $a << 2 will give 240 which is 1111 0000
>>
Binary Right Shift Operator. The left operands value is moved right by the number of bits specified by the right operand.
Example − $a >> 2 will give 15 which is 0000 1111
Try the following example to understand all the bitwise operators available in Perl. Copy and paste the following Perl program in test.pl file and execute this program.
#!/usr/local/bin/perl

use integer;
 
$a = 60;
$b = 13;

print "Value of \$a = $a and value of \$b = $b\n";

$c = $a & $b;
print "Value of \$a & \$b = $c\n";

$c = $a | $b;
print "Value of \$a | \$b = $c\n";

$c = $a ^ $b;
print "Value of \$a ^ \$b = $c\n";

$c = ~$a;
print "Value of ~\$a = $c\n";

$c = $a << 2;
print "Value of \$a << 2 = $c\n";

$c = $a >> 2;
print "Value of \$a >> 2 = $c\n";
When the above code is executed, it produces the following result −
Value of $a = 60 and value of $b = 13
Value of $a & $b = 12
Value of $a | $b = 61
Value of $a ^ $b = 49
Value of ~$a = -61
Value of $a << 2 = 240
Value of $a >> 2 = 15


    46 Lectures 
     4.5 hours 

 Devi Killada

    11 Lectures 
     1.5 hours 

 Harshit Srivastava

    30 Lectures 
     6 hours 

 TELCOMA Global

    24 Lectures 
     2 hours 

 Mohammad Nauman

    68 Lectures 
     7 hours 

 Stone River ELearning

    58 Lectures 
     6.5 hours 

 Stone River ELearning
 Print
 Add Notes
 Bookmark this page
Write a C program to compare two strings using strncmp library function

Strncmp is a predefined library function present in string.h file, it used to compare two strings and display which string is greater.
This function compares 2 strings. It returns the ASCII difference of the first two non– matching characters in both the strings.
int strcmp (string1, string2);
If the difference is equal to zero, then string1 = string2.
If the difference is equal to zero, then string1 = string2.
If the difference is positive, then string1> string2.
If the difference is positive, then string1> string2.
If the difference is negative, then string1 <string2.
If the difference is negative, then string1 <string2.
This function is used for comparing first ‘n’ characters of 2 strings.
strncmp ( string1, string2,2)
#include<stdio.h>
#include<string.h>
void main(){
   //Declaring two strings//
   char string1[25],string2[25];
   int value;
   //Reading string 1 and String 2//
   printf("Enter String 1: ");
   gets(string1);
   printf("Enter String 2: ");
   gets(string2);
   //Comparing using library function//
   value = strncmp(string1,string2,4);
   //If conditions//
   if(value==0){
      printf("%s is same as %s",string1,string2);
   } else if(value>0) {
      printf("%s is greater than %s",string1,string2);
   } else {
      printf("%s is less than %s",string1,string2);
   }
}
Enter String 1: Tutorials
Enter String 2: Point
Tutorials is greater than Point
Find common elements in three sorted arrays by dictionary intersection in Python

While manipulating data using python we may come across situation where we need to find the elements which are common among the multiple arrays. This can be achieved by converting the arrayd into dictionaries as shown below.
In the below example we take the arrays and apply the Counter container from collections module. It will hold the count of each of the elements present in the container. Then we convert them to a dictionary by applying dict() and using the & operator to identify only the common elements among the arrays. Finally we loop through the items of the newly created dictionary and append the values from the dictionary to get the final result of common values.
from collections import Counter

arrayA = ['Sun', 12, 14, 11, 34]
arrayB = [6, 12, 'Sun', 11]
arrayC = [19, 6, 20, 'Sun', 12, 67, 11]

arrayA = Counter(arrayA)
arrayB = Counter(arrayB)
arrayC = Counter(arrayC)

# Intersection
commonDict = dict(arrayA.items() & arrayB.items() & arrayC.items())
res = []

# result
for (key, val) in commonDict.items():
   for i in range(0, val):
      res.append(key)

print("The common values among the arrays are:\n ",res)
Running the above code gives us the following result −
The common values among the arrays are:
['Sun', 11, 12]
MySQL queries to update date records with NULL values

You can use IFNULL() for this. Let us first create a table −
mysql> create table DemoTable
   -> (
   -> added_date date,
   -> updated_date date
   -> );
Query OK, 0 rows affected (0.95 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('2019-01-10','2019-06-01');
Query OK, 1 row affected (0.19 sec)

mysql> insert into DemoTable values('2019-05-19',NULL);
Query OK, 1 row affected (0.14 sec)

mysql> insert into DemoTable values(NULL,'2019-09-05');
Query OK, 1 row affected (0.18 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+------------+--------------+
| added_date | updated_date |
+------------+--------------+
| 2019-01-10 | 2019-06-01   |
| 2019-05-19 | NULL         |
| NULL       | 2019-09-05   |
+------------+--------------+
3 rows in set (0.00 sec)
Case 1 − If you want the result in descending order.
Here is the query to select row with added_date and updated_date.
mysql> select *from DemoTable order by ifnull(updated_date,added_date) desc;
This will produce the following output −
+------------+--------------+
| added_date | updated_date |
+------------+--------------+
| NULL       | 2019-09-05   |
| 2019-01-10 | 2019-06-01   |
| 2019-05-19 | NULL         |
+------------+--------------+
3 rows in set (0.00 sec)
Case 2 − If you want the result in ascending order.
Here is the query to select row with added_date and updated_date −
mysql> select *from DemoTable order by ifnull(updated_date,added_date);
This will produce the following output −
+------------+--------------+
| added_date | updated_date |
+------------+--------------+
| 2019-05-19 | NULL         |
| 2019-01-10 | 2019-06-01   |
| NULL       | 2019-09-05   |
+------------+--------------+
3 rows in set (0.00 sec)
How to print unique elements from two unsorted arrays using JavaScript ? - GeeksforGeeks

14 Sep, 2020
Given two unsorted arrays, the task is to write a JavaScript program to print the unique (uncommon) elements in the two arrays.
Approach:
Create an empty array that would store the unique elements from the two arrays.
Iterate over all elements of array1 using a loop.
Set the initial flag value as 0 for each iteration.
In that loop Iterate over all elements of array2 using another loop and check if array1[element] is present in array2.
If present, remove the element from array2 using splice() method and set the flag to 1.
If array2 has been fully traversed for array1[element] and the flag is still equal to 0, add the array1[element] to the unique elements array.
Repeat steps 4-6 for each element in array1.
Finally, push array2 to the unique elements array since all duplicate elements have been removed from array2 (refer Step 5).
Example: The implementation of the above approach is given below:
Javascript
<script>function unique(arr1,arr2,uniqueArr) {    for(var i=0; i<arr1.length; i++) {        flag = 0;        for(var j=0; j<arr2.length; j++) {            if(arr1[i] === arr2[j]) {                arr2.splice(j,1);                j--;                flag = 1;            }        }          if(flag == 0) {            uniqueArr.push(arr1[i]);        }    }    uniqueArr.push(arr2);    return uniqueArr;}  var arr1 = [54, 71, 58, 95, 20];  var arr2 = [71, 51, 54, 33, 80];  var uniqueArr = [];  console.log("Unique elements in the two arrays are:");console.log(unique(arr1,arr2,uniqueArr).flat());</script>
Output:
javascript-array
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
Difference Between PUT and PATCH Request
Remove elements from a JavaScript Array
How to get character array from string in JavaScript?
How to filter object array based on attributes?
Roadmap to Become a Web Developer in 2022
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?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
What is dynamic binding in C#?

In Dynamic binding, the compiler will not do type checking at compile time. At runtime, the checking is done.
Use it to avoid the restriction of anonymous types to one method. This is only because the type name is visible only to the compiler; therefore, you cannot declare it as the return value of a method.
Let us see an example −
public dynamic GetAnonymousType() {
   return new {
      StudentName = "Jack",
      Subject = "Maths",
   };
}
Above, the method is set to be dynamic, that would mean the compiler won’t do type checking at compile time −
public dynamic GetAnonymousType() {}
Node.js process.uptime() Method - GeeksforGeeks

11 Oct, 2021
The process.uptime() method is an inbuilt application programming interface of the process module which is used to get the number of seconds the Node.js process is running.
Syntax:
process.uptime();
Parameters: This method does not accept any parameter.
Return Value: It returns a floating-point number specifying the number of seconds the Node.js process is running.
Below examples illustrate the use of process.uptime() method in Node.js:
Example 1:
// Node.js program to demonstrate the   // process.uptime() Method  // Allocating process moduleconst process = require('process');  // Printing the number of seconds// the Node.js process is runningconsole.log(process.uptime());
Output:
0.0842063
Example 2:
// Node.js program to demonstrate the   // process.uptime() Method  // Allocating process moduleconst process = require('process');  // Checking whether the method// exists or notif (process.uptime) {      // Printing uptime() value    console.log("The number of seconds the"          + " Node.js process is running: "          + process.uptime() + " seconds");      var i = 1000000;      while(i--);          console.log("The number of seconds the"          + " Node.js process is running: "          + process.uptime() + " seconds");      console.log("In whole seconds: "          + Math.floor(process.uptime())          + " seconds");}
Output:
the number of seconds the Node.js process is running: 0.077 seconds
the number of seconds the Node.js process is running: 0.087 seconds
In whole seconds: 0 seconds

Note: The above program will compile and run by using the node filename.js command.
Reference: https://nodejs.org/api/process.html#process_process_uptime
Node.js-process-module
Node.js
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Node.js fs.readFile() Method
Node.js fs.writeFile() Method
How to install the previous version of node.js and npm ?
Difference between promise and async await in Node.js
How to use an ES6 import in Node.js?
Top 10 Front End Developer Skills That You Need in 2022
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?
Difference between var, let and const keywords in JavaScript
Arduino - Ifâ¦else if â¦else statement

The if statement can be followed by an optional else if...else statement, which is very useful to test various conditions using single if...else if statement.
When using if...else if...else statements, keep in mind −
An if can have zero or one else statement and it must come after any else if's.
An if can have zero or one else statement and it must come after any else if's.
An if can have zero to many else if statements and they must come before the else.
An if can have zero to many else if statements and they must come before the else.
Once an else if succeeds, none of the remaining else if or else statements will be tested.
Once an else if succeeds, none of the remaining else if or else statements will be tested.
if (expression_1) {
   Block of statements;
}

else if(expression_2) {
   Block of statements;
}
.
.
.

else {
   Block of statements;
}

/* Global variable definition */
int A = 5 ;
int B = 9 ;
int c = 15;

Void setup () {

}

Void loop () {
   /* check the boolean condition */
   if (A > B) /* if condition is true then execute the following statement*/ {
      A++;
   }
   /* check the boolean condition */
   else if ((A == B )||( B < c) ) /* if condition is true then 
      execute the following statement*/ {
      C = B* A;
   }else
      c++;
}

    65 Lectures 
     6.5 hours 

 Amit Rana

    43 Lectures 
     3 hours 

 Amit Rana

    20 Lectures 
     2 hours 

 Ashraf Said

    19 Lectures 
     1.5 hours 

 Ashraf Said

    11 Lectures 
     47 mins

 Ashraf Said

    9 Lectures 
     41 mins

 Ashraf Said
 Print
 Add Notes
 Bookmark this page
C# | Uri.CheckHostName(String) Method - GeeksforGeeks

01 May, 2019
Uri.CheckHostName(String) Method is used to determine whether the specified host name is a valid DNS name or not.
Syntax: public static UriHostNameType CheckHostName (string name);Here, it takes the host name to validate. This can be an IPv4 or IPv6 address or an Internet host name.
Return Value: This method returns a UriHostNameType which indicates the type of the host name. If the type of the host name cannot be determined or if the host name is null or a zero-length string, this method returns Unknown.
Below programs illustrate the use of Uri.CheckHostName() Method:
Example 1:
// C# program to demonstrate the// Uri.CheckHostName(string) Methodusing System;using System.Globalization;  class GFG {      // Main Method    public static void Main()    {        // Declaring and initializing uri        string uri = "www.geeksforgeeks.org";          // using CheckHostName() method        UriHostNameType value = Uri.CheckHostName(uri);          // Displaying the result        Console.WriteLine("Host type is: {0}", value);    }}
Host type is: Dns

Example 2:
// C# program to demonstrate the// Uri.CheckHostName(string) Methodusing System;using System.Globalization;  class GFG {      // Main Method    public static void Main()    {        // Declaring and initializing uri        string uri = "http:// localhost:3000";          // using CheckHostName() method        UriHostNameType value = Uri.CheckHostName(uri);          // Displaying the result        Console.WriteLine("Host type is: {0}", value);    }}
Host type is: Unknown

Reference:
https://docs.microsoft.com/en-us/dotnet/api/system.uri.checkhostname?view=netstandard-2.1
CSharp-method
CSharp-Uri-Class
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Top 50 C# Interview Questions & Answers
Extension Method in C#
HashSet in C# with Examples
Partial Classes in C#
C# | Inheritance
Convert String to Character Array in C#
Linked List Implementation in C#
C# | How to insert an element in an Array?
C# | List Class
Difference between Hashtable and Dictionary in C#
What does the interface ICloneable do in C#?

The ICloneable interface creates a copy of the exisiting object i.e a clone.
It only has a single method −
Clone() − The clone() method creates a new object that is a copy of the current instance.
Clone() − The clone() method creates a new object that is a copy of the current instance.
The following is an example showing how to perform cloning using Icloneable interface −
 Live Demo
using System;

class Car : ICloneable {
   int width;

   public Car(int width) {
      this.width = width;
   }

   public object Clone() {
      return new Car(this.width);
   }

   public override string ToString() {
      return string.Format("Width of car = {0}",this.width);
   }
}

class Program {
   static void Main() {
      Car carOne = new Car(1695);
      Car carTwo = carOne.Clone() as Car;

      Console.WriteLine("{0}mm", carOne);
      Console.WriteLine("{0}mm", carTwo);
   }
}
Width of car = 1695mm
Width of car = 1695mm
Construction of the machines to produce residue modulo ‘2’ of binary numbers - GeeksforGeeks

20 Nov, 2019
Prerequisite: Mealy and Moore Machines, Difference between Mealy machine and Moore machineIn this article, we will see some designing of Finite Automata with Output i.e, Moore and Mealy machines.
Problem: Construction of the machines that take the binary number {0, 1} as input and produce residue modulo ‘2’ as output i.e, when the equivalent decimal number of binary input over {0, 1} is divided by 2 then it gives output as it’s remainder.Assume,
Ε = {0, 1} and 
Δ = {0, 1} 
where Ε and Δ are the input and output alphabet respectively.
The required Moore machine is constructed below:
In the above diagram, the initial state ‘X’ on getting ‘0’ as the input it remains in the state of itself and prints ‘0’ as the output and on getting ‘1’ as the input it transmits to a state ‘Y’ and prints ‘1’ as the output so on for the remaining states.
For example, when the input string is ’10’ then above Moore machine produce 0 as the output because the decimal equivalent of binary input ’10’ is 2 and 2 divided by 2 is 0 i.e, the remainder is 0. Thus finally above Moore machine can easily produce residue modulo ‘2’ as output i.e, when the equivalent decimal number of binary input over {0, 1} is divided by 2 then it gives output as it’s remainder.
The required Mealy machine is constructed below:
In the above diagram, the initial state ‘X’ on getting ‘0’ as the input it remains in the state of itself and prints ‘0’ as the output and on getting ‘1’ as the input it transmits to a state ‘Y’ and prints ‘1’ as the output. The state ‘Y’ on getting ‘1’ as the input it remains in the state of itself and prints ‘1’ as the output and on getting ‘0’ as the input it goes back to the initial state ‘X’ and prints ‘0’ as the output.
For example, when the input string is ’10’ then above Mealy machine produce 0 as the output because the decimal equivalent of binary input ’10’ is 2 and 2 divided by 2 is 0 i.e, the remainder is 0. Thus finally above Mealy machine can easily produce residue modulo ‘2’ as output i.e, when the equivalent decimal number of binary input over {0, 1} is divided by 2 then it gives output as it’s remainder.
GATE CS
Theory of Computation & Automata
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Regular Expressions, Regular Grammar and Regular Languages
Phases of a Compiler
Difference between Clustered and Non-clustered index
Preemptive and Non-Preemptive Scheduling
Introduction of Process Synchronization
Regular Expressions, Regular Grammar and Regular Languages
Difference between DFA and NFA
Pumping Lemma in Theory of Computation
Introduction of Finite Automata
Turing Machine in TOC
Control Size of ggplot2 Legend Items in R - GeeksforGeeks

30 May, 2021
In this article, we will see how to control the size of ggplot2 Legend Items in R Programming Language. To create an R plot, we use ggplot() function and for making a scatter plot geom_point() function is added to ggplot() function.
Let us first create a regular plot without any modifications so that the difference is apparent.
Example:
R
# Load Packagelibrary("ggplot2")  # Create a DataFrame data <- data.frame(Xdata = rnorm(10),                                           Ydata = rnorm(10),                   LegendData = c("ld-01", "ld-02", "ld-03",                                  "ld-04", "ld-05", "ld-06",                                  "ld-07", "ld-08", "ld-09",                                   "ld-10"))  # Create a Scatter Plotggplot(data, aes(Xdata, Ydata, color = LegendData)) +     geom_point()
Output:
Scatter Plot with Legend
To change the Size of Legend, we have to add guides() and guide_legend() functions to the geom_point() function. Inside guides() function, we take parameter color, which calls guide_legend() guide function as value. Inside guide_legend() function, we take an argument called override.aes, which has the list specifying aesthetic parameters of legend keys. Inside this list, we specify the size of legend.
Syntax : guides(...)
Parameter :
... : either a string or call to a guide function. here we call guide_legend() guide function.
Return : each scale can be set scale-by-scale
Syntax : guide_legend(override.aes = list())
Parameter :
override.aes : A list specifying aesthetic parameters of legend key. Inside this list, we specify the size of legend to size object.
Return : Legend Guides for various scales
Example:
R
# Load Packagelibrary("ggplot2")  # Create a DataFrame data <- data.frame(Xdata = rnorm(10),                                           Ydata = rnorm(10),                   LegendData = c("ld-01", "ld-02", "ld-03",                                  "ld-04", "ld-05", "ld-06",                                  "ld-07", "ld-08", "ld-09",                                   "ld-10"))  # Create a Scatter Plot and change# the size of legendggplot(data, aes(Xdata, Ydata, color = LegendData)) +     geom_point()+  guides(color = guide_legend(override.aes = list(size = 10)))
Output:
Scatterplot with change size of legend
Picked
R-ggplot
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Group by function in R using Dplyr
Change Color of Bars in Barchart using ggplot2 in R
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?
How to filter R dataframe by multiple conditions?
Time Series Analysis in R
R - if statement
How to import an Excel File into R ?