code-rag-bench/online-tutorials huggingface dataset:
Find out if a varchar contains a percent sign in MySQL?

To find out a varchar contains a percent sign in MySQL, you can use LIKE operator. The syntax is as follows −
SELECT * FROM yourTableName WHERE yourColumnName like '%|%%' escape '|';
To understand the above syntax, let us create a table. The query to create a table is as follows −
mysql> create table FindPercentInVarcharDemo
   -> (
   -> Id int NOT NULL AUTO_INCREMENT,
   -> Words varchar(30),
   -> PRIMARY KEY(Id)
   -> );
Query OK, 0 rows affected (0.51 sec)
Insert some records with % sign using insert command. The query is as follows −
mysql> insert into FindPercentInVarcharDemo(Words) values('This is a My%SQL Program');
Query OK, 1 row affected (0.19 sec)

mysql> insert into FindPercentInVarcharDemo(Words) values('Java is an object oriented');
Query OK, 1 row affected (0.19 sec)

mysql> insert into FindPercentInVarcharDemo(Words) values('C# is also an object%oriented');
Query OK, 1 row affected (0.57 sec)
Display all records from the table using select statement. The query is as follows −
mysql> select *from FindPercentInVarcharDemo;
The following is the output −
+----+-------------------------------+
| Id | Words                         |
+----+-------------------------------+
| 1  | This is a My%SQL Program      |
| 2  | Java is an object oriented    |
| 4  | C# is also an object%oriented |
+----+-------------------------------+
3 rows in set (0.00 sec)
The following is the query to find out varchar contains % sign. The query is as follows −
mysql> select *from FindPercentInVarcharDemo where Words like '%|%%' escape '|';
The following is the output displaying only the values with a % sign −
+----+-------------------------------+
| Id | Words                         |
+----+-------------------------------+
| 1 | This is a My%SQL Program       |
| 4 | C# is also an object%oriented  |
+----+-------------------------------+
2 rows in set (0.00 sec)
How can we check if a JSON object is empty or not in Java?


A JSON is a lightweight data-interchange format and the format of JSON is a key with value pair. The JSONObject can parse a text from a String to produce a map-like object and supports java.util.Map interface. 
We can check whether the JSON object is empty or not in the below example
import java.util.*;
import org.json.*;
public class JSONObjectTest {
   public static void main(String[] args) {
      JSONObject jsonObj = new JSONObject(
         "{" +
            "Name : Jai," +
            "Age : 25, " +
            "Salary: 25000.00 " +
         "}"
      );
      if(jsonObj.isEmpty()) {
         System.out.println("JSON is empty");
      } else {
         System.out.println("JSON is not empty");
      }
   }
}
JSON is not empty
Can HTML be embedded inside PHP “if” statement?

Yes, HTML can be embedded inside an ‘if’ statement with the help of PHP. Below are a few methods.
Using the if condition −
<?php if($condition) : ?>
   <a href="website_name.com">it is displayed iff $condition is met</a>
<?php endif; ?>
Using the if and else if conditions −
<?php if($condition) : ?>
   <a href=" website_name.com "> it is displayed iff $condition is met </a>
<?php elseif($another_condition) : ?>
   HTML TAG HERE
<?php else : ?>
   HTML TAG HERE
<?php endif; ?>
Embedding HTML inside PHP −
<?php
   if ( $condition met ) {
      ?> HTML TAG HERE
<?php;
}
?>
Implementation of Perceptron Algorithm for NOR Logic Gate with 2-bit Binary Input - GeeksforGeeks

08 Jul, 2020
In the field of Machine Learning, the Perceptron is a Supervised Learning Algorithm for binary classifiers. The Perceptron Model implements the following function:
    
For a particular choice of the weight vector  and bias parameter , the model predicts output  for the corresponding input vector .
NOR logical function truth table for 2-bit binary variables, i.e, the input vector  and the corresponding output  –
We can observe that, Now for the corresponding weight vector  of the input vector  to the OR node, the associated Perceptron Function can be defined as:
    
Later on, the output of OR node  is the input to the NOT node with weight . Then the corresponding output  is the final output of the NOR logic function and the associated Perceptron Function can be defined as:
    
For the implementation, considered weight parameters are  and the bias parameters are .
Python Implementation:
# importing Python libraryimport numpy as np  # define Unit Step Functiondef unitStep(v):    if v >= 0:        return 1    else:        return 0  # design Perceptron Modeldef perceptronModel(x, w, b):    v = np.dot(w, x) + b    y = unitStep(v)    return y  # NOT Logic Function# wNOT = -1, bNOT = 0.5def NOT_logicFunction(x):    wNOT = -1    bNOT = 0.5    return perceptronModel(x, wNOT, bNOT)  # OR Logic Function# w1 = 1, w2 = 1, bOR = -0.5def OR_logicFunction(x):    w = np.array([1, 1])    bOR = -0.5    return perceptronModel(x, w, bOR)  # NOR Logic Function# with OR and NOT  # function calls in sequencedef NOR_logicFunction(x):    output_OR = OR_logicFunction(x)    output_NOT = NOT_logicFunction(output_OR)    return output_NOT  # testing the Perceptron Modeltest1 = np.array([0, 1])test2 = np.array([1, 1])test3 = np.array([0, 0])test4 = np.array([1, 0])  print("NOR({}, {}) = {}".format(0, 1, NOR_logicFunction(test1)))print("NOR({}, {}) = {}".format(1, 1, NOR_logicFunction(test2)))print("NOR({}, {}) = {}".format(0, 0, NOR_logicFunction(test3)))print("NOR({}, {}) = {}".format(1, 0, NOR_logicFunction(test4)))
NOR(0, 1) = 0
NOR(1, 1) = 0
NOR(0, 0) = 1
NOR(1, 0) = 0

Here, the model predicted output () for each of the test inputs are exactly matched with the NOR logic gate conventional output () according to the truth table for 2-bit binary input.Hence, it is verified that the perceptron algorithm for NOR logic gate is correctly implemented.
Akanksha_Rai
Neural Network
Machine Learning
Python
Machine Learning
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Introduction to Recurrent Neural Network
Support Vector Machine Algorithm
Intuition of Adam Optimizer
CNN | Introduction to Pooling Layer
Convolutional Neural Network (CNN) in Machine Learning
Read JSON file using Python
Adding new column to existing DataFrame in Pandas
Python map() function
How to get column names in Pandas dataframe
Python Dictionary to find mirror characters in a string - GeeksforGeeks

26 May, 2021
Given a string and a number N, we need to mirror the characters from the N-th position up to the length of the string in alphabetical order. In mirror operation, we change ‘a’ to ‘z’, ‘b’ to ‘y’, and so on.Examples:  
Input : N = 3
        paradox
Output : paizwlc
We mirror characters from position 3 to end.

Input : N = 6
        pneumonia
Output : pneumlmrz
 
We have an existing solution for this problem please refer to Mirror characters of a string link. We can solve this problem in Python using Dictionary Data Structure. The mirror value of ‘a’ is ‘z’,’b’ is ‘y’, etc, so we create a dictionary data structure and one-to-one map reverse sequence of alphabets onto the original sequence of alphabets. Now traverse characters from length k in given string and change characters into their mirror value using a dictionary. 
Python3
# function to mirror characters of a string def mirrorChars(input,k):     # create dictionary    original = 'abcdefghijklmnopqrstuvwxyz'    reverse = 'zyxwvutsrqponmlkjihgfedcba'    dictChars = dict(zip(original,reverse))     # separate out string after length k to change    # characters in mirror    prefix = input[0:k-1]    suffix = input[k-1:]    mirror = ''     # change into mirror    for i in range(0,len(suffix)):         mirror = mirror + dictChars[suffix[i]]     # concat prefix and mirrored part    print (prefix+mirror)          # Driver programif __name__ == "__main__":    input = 'paradox'    k = 3    mirrorChars(input,k)
Output:  
paizwlc
 
rvpooja
Python dictionary-programs
python-dict
Python
Strings
python-dict
Strings
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Read a file line by line in Python
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Write a program to reverse an array or string
Reverse a string in Java
Write a program to print all permutations of a given string
C++ Data Types
Longest Common Subsequence | DP-4
How to make text bold, italic and underline using jQuery

To make text bold, italic and underline using jQuery, use the jQuery css() method with the CSS properties font-style, font-weight and text-decoration. You can try to run the following code to learn how to make text bold, italic and underline using jQuery −
Live Demo
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("p").on({
        mouseenter: function(){
        $(this).css({"font-style": "italic", "font-weight": "bold","text-decoration": "underline"});
        }
    });    
});
</script>
</head>
<body>
<p>Move the mouse pointer on the text to make text bold, italic and underline.</p>
</body>
</html>
How to set the size of the browser window in Selenium?

We can set the size of the browser window by the following methods −
getSize() method
getSize() method
Javascript executor
Javascript executor
With setSize() method.
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import java.util.concurrent.TimeUnit;
import java.util.List;
public class BrowserDimension {
   public static void main(String[] args) {
      System.setProperty("webdriver.chrome.driver", "C:\\Users\\ghs6kor\\Desktop\\Java\\chromedriver.exe");
      WebDriver driver = new ChromeDriver();
      String url = "https://www.tutorialspoint.com/index.htm";
      driver.get(url);
      // maximize the browser
      driver.manage().timeouts().implicitlyWait(12, TimeUnit.SECONDS);
      // fetching the current window size with getSize()
      System.out.println(driver.manage().window().getSize());
      //Create object of Dimensions class
      Dimension dm = new Dimension(450,630);
      //Setting the current window to that dimension
      driver.manage().window().setSize(dm);
      driver.close();
      }
}
With Javascript executor.
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.JavascriptExecutor;
public class BrowserDimensionJS {
   public static void main(String[] args) {
      System.setProperty("webdriver.chrome.driver", "C:\\Users\\ghs6kor\\Desktop\\Java\\chromedriver.exe");
      WebDriver driver = new ChromeDriver();
      String url = "https://www.tutorialspoint.com/index.htm";
      driver.get(url);
      // maximize the browser
      driver.manage().timeouts().implicitlyWait(12, TimeUnit.SECONDS);
      JavascriptExecutor js = (JavascriptExecutor) driver;
      // set size with window.resizeTo() method
      js.executeScript("window.resizeTo(450,630);");
      driver.close();
   }
}
TreeMap descendingKeySet() Method in Java with Examples - GeeksforGeeks

27 Aug, 2020
The descendingKeySet() method of TreeMap class returns a reverse order NavigableSet view of the keys contained within the map. The iterator of the set returns the keys in descending order. 
Note: The set is backed by the map, so changes to the map are reflected within the set, and vice-versa.
Syntax:
public NavigableSet<K> descendingKeySet()

Parameters: The method does not take any parameters.
Return Value: The method returns a navigable set view of the values contained in the map.
Exception: The method does not throw any exceptions.
Example 1:  
Java
// Java Program to show the working// of descendingKeySet() Methodimport java.io.*;import java.util.*;public class GFG {    public static void main(String[] args)    {          // creating tree map of Integer and String        TreeMap<Integer, String> treemap            = new TreeMap<Integer, String>();          // populating tree map using put()        treemap.put(3, "three");        treemap.put(1, "one");        treemap.put(2, "two");        treemap.put(0, "zero");        treemap.put(7, "seven");        treemap.put(6, "six");          // putting values in navigable set        // use of descendingKeySet        NavigableSet set1 = treemap.descendingKeySet();          System.out.println("Navigable set values are: "                           + set1);    }}
Output: 
Navigable set values are: [7, 6, 3, 2, 1, 0]

Example 2:  
Java
// Java Program to show the working// of descendingKeySet() Methodimport java.io.*;import java.util.*;public class GFG {    public static void main(String[] args)    {          // creating tree map of Integer and String        TreeMap<Integer, String> geeks            = new TreeMap<Integer, String>();          // putting values in navigable set        geeks.put(1, "Guru");        geeks.put(2, "Ayush");        geeks.put(3, "Devesh");        geeks.put(4, "Kashish");          System.out.println("TreeMap values :- " + geeks);          // use of descendingKeySet        NavigableSet nevigableSet            = geeks.descendingKeySet();          System.out.println("Reverse key values:- "                           + nevigableSet);    }}
Output:  
TreeMap values :- {1=Guru, 2=Ayush, 3=Devesh, 4=Kashish}
Reverse key values:- [4, 3, 2, 1]

 
Java-Collections
java-treeset
java-treeset-functions
Picked
Java
Java
Java-Collections
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Functional Interfaces in Java
Stream In Java
Constructors in Java
Different ways of Reading a text file in Java
Exceptions in Java
Generics in Java
Comparator Interface in Java with Examples
Strings in Java
Difference between Abstract Class and Interface in Java
How to remove an element from ArrayList in Java?
A single query to get the sum of count from different tables in MySQL?

To get the sum of count from different tables, use UNION ALL. Let us first create a table −
mysql> create table DemoTable1
-> (
-> Id int,
-> Name varchar(30)
-> );
Query OK, 0 rows affected (1.55 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1 values(10,'Chris Brown');
Query OK, 1 row affected (0.83 sec)
mysql> insert into DemoTable1 values(20,'David Miller');
Query OK, 1 row affected (0.50 sec)
mysql> insert into DemoTable1 values(30,'John Adam');
Query OK, 1 row affected (0.83 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable1;
+------+--------------+
| Id   | Name         |
+------+--------------+
| 10   | Chris Brown  |
| 20   | David Miller |
| 30   | John Adam    |
+------+--------------+
3 rows in set (0.00 sec)
Following is the query to create second table −
mysql> create table DemoTable2
-> (
-> Amount int
-> );
Query OK, 0 rows affected (1.17 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable2 values(100);
Query OK, 1 row affected (0.30 sec)
mysql> insert into DemoTable2 values(200);
Query OK, 1 row affected (0.14 sec)
mysql> insert into DemoTable2 values(300);
Query OK, 1 row affected (0.54 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable2;
+--------+
| Amount |
+--------+
| 100    |
| 200    |
| 300    |
+--------+
3 rows in set (0.00 sec)
Here is how to get sum of count from different tables in a single query −
mysql> select sum(AllCount) AS Total_Count
-> from
-> (
-> (select count(*) AS AllCount from DemoTable1)
-> union all
-> (select count(*) AS AllCount from DemoTable2)
-> )t;
+-------------+
| Total_Count |
+-------------+
| 6           |
+-------------+
1 row in set (0.03 sec)
C library function - memmove()

The C library function void *memmove(void *str1, const void *str2, size_t n) copies n characters from str2 to str1, but for overlapping memory blocks, memmove() is a safer approach than memcpy().
Following is the declaration for memmove() function.
void *memmove(void *str1, const void *str2, size_t n)
str1 − This is a pointer to the destination array where the content is to be copied, type-casted to a pointer of type void*.
str1 − This is a pointer to the destination array where the content is to be copied, type-casted to a pointer of type void*.
str2 − This is a pointer to the source of data to be copied, type-casted to a pointer of type void*.
str2 − This is a pointer to the source of data to be copied, type-casted to a pointer of type void*.
n − This is the number of bytes to be copied.
n − This is the number of bytes to be copied.
This function returns a pointer to the destination, which is str1.
The following example shows the usage of memmove() function.
#include <stdio.h>
#include <string.h>

int main () {
   char dest[] = "oldstring";
   const char src[]  = "newstring";

   printf("Before memmove dest = %s, src = %s\n", dest, src);
   memmove(dest, src, 9);
   printf("After memmove dest = %s, src = %s\n", dest, src);

   return(0);
}
Let us compile and run the above program that will produce the following result −
Before memmove dest = oldstring, src = newstring
After memmove dest = newstring, src = newstring
TCS Coding Practice Question | Swap two Numbers

07 Jul, 2022
Given two numbers, the task is to swap the two numbers using Command Line Arguments.  Examples:
Input: n1 = 10, n2 = 20
Output: 20 10

Input: n1 = 100, n2 = 101
Output: 101 100
Approach:
Since the numbers are entered as Command line Arguments, there is no need for a dedicated input line
Extract the input numbers from the command line argument
This extracted numbers will be in string type.
Convert these numbers into integer type and store it in variables, say num1 and num2
Get the sum in one of the two given numbers.
The numbers can then be swapped using the sum and subtraction from the sum.
Program: 
C
Java
// C program to swap the two numbers// using command line arguments #include <stdio.h>#include <stdlib.h> /* atoi */ // Function to swap the two numbersvoid swap(int x, int y){    // Code to swap ‘x’ and ‘y’     // x now becomes x+y    x = x + y;     // y becomes x    y = x - y;     // x becomes y    x = x - y;     printf("%d %d\n", x, y);} // Driver codeint main(int argc, char* argv[]){     int num1, num2;     // Check if the length of args array is 1    if (argc == 1)        printf("No command line arguments found.\n");     else {         // Get the command line argument and        // Convert it from string type to integer type        // using function "atoi( argument)"        num1 = atoi(argv[1]);        num2 = atoi(argv[2]);         // Swap the numbers and print it        swap(num1, num2);    }    return 0;}
// Java program to swap the two numbers// using command line arguments class GFG {     // Function to swap the two numbers    static void swap(int x, int y)    {        // Code to swap ‘x’ and ‘y’         // x now becomes x+y        x = x + y;         // y becomes x        y = x - y;         // x becomes y        x = x - y;         System.out.println(x + " " + y);    }     // Driver code    public static void main(String[] args)    {         // Check if length of args array is        // greater than 0        if (args.length > 0) {             // Get the command line argument and            // Convert it from string type to integer type            int num1 = Integer.parseInt(args[0]);            int num2 = Integer.parseInt(args[1]);             // Swap the numbers            swap(num1, num2);        }        else            System.out.println("No command line "                               + "arguments found.");    }}
Output:
In C: 
In Java: 
Time Complexity: O(1)Auxiliary Space: O(1)
jayanth_mkv
TCS
TCS-coding-questions
C++ Programs
Java Programs
Placements
TCS
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Divide each dataframe row by vector in R

17 May, 2021
In this article, we will discuss how to divide each dataframe row by vector in R Programming Language.
The mapply() method can be used to apply a FUN to the dataframe or a matrix, to modify the data. The function specified as the first argument may be any boolean operator, arithmetic, or logical. The operator is then applied taking the dataframe row as one operand and the vector as the other. The result has to be stored in another variable. The time incurred in this operation is equivalent to the number of rows in the dataframe. 
Syntax: mapply(FUN, df , vec)
Example:
R
# declaring dataframedata_frame <- data.frame(col1 = c(2,4,6), col2 = c(4,6,8),                          col3 = c(8,10,12), col4 = c(20,16,14))  print ("Original Dataframe")print (data_frame)  # declaring vectorvec <-  c(1:4)  # dividing each row by vectordiv <- mapply('/', data_frame, vec)  print ("Result of division")print (div)
Output
[1] "Original Dataframe"
 col1 col2 col3 col4
1    2    4    8   20
2    4    6   10   16
3    6    8   12   14
[1] "Result of division"
    col1 col2     col3 col4
[1,]    2    2 2.666667  5.0
[2,]    4    3 3.333333  4.0
[3,]    6    4 4.000000  3.5
This method in R programming language returns an array obtained from an input array by sweeping out a summary statistic. The method is used to compute arithmetic operations on the dataframe over the chosen axis. For, row-wise operation the chosen axis is 2 and the operand becomes the row of the dataframe. The result has to be stored in another variable. The time incurred in this operation is equivalent to the number of rows in the dataframe. The data type of the resultant column is the largest compatible data type. 
Syntax: sweep (df , axis, vec, op)
Parameter :
df – DataFrame
axis – To compute it row-wise, use axis = 1 and for column-wise, use axis = 2 
vec – The vector to apply on the dataframe
op – The operator to apply
Example:
R
# declaring dataframedata_frame <- data.frame(col1 = c(2,4,6), col2 = c(4,6,8),                          col3 = c(8,10,12), col4 = c(20,16,14))  print ("Original Dataframe")print (data_frame)  # declaring vectorvec <-  c(1:4)  # dividing each row by vectordiv <- sweep(data_frame,2,vec,'/')  print ("Result of division")print (div)
Output
[1] "Original Dataframe"
 col1 col2 col3 col4
1    2    4    8   20
2    4    6   10   16
3    6    8   12   14
[1] "Result of division"
 col1 col2     col3 col4
1    2    2 2.666667  5.0
2    4    3 3.333333  4.0
3    6    4 4.000000  3.5 
Picked
R DataFrame-Programs
R-DataFrame
R Language
R Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Determining file format using Python

02 Sep, 2020
The general way of recognizing the type of file is by looking at its extension. But this isn’t generally the case. This type of standard for recognizing file by associating an extension with a file type is enforced by some operating system families (predominantly Windows). Other OS’s such as Linux (and its variants) use the magic number for recognizing file types. A Magic Number is a constant value, used for the identification of a file. This method provides more flexibility in naming a file and does not mandate the presence of an extension.  Magic numbers are good for recognizing files, as sometimes a file may not have the correct file extension (or may not have one at all).
In this article we will learn how to recognize files by their extension, using python. We would be using the Python Magic library to provide such capabilities to our program. To install the library, execute the following command in your operating system’s command interpreter:-
pip install python-magic

For demonstration purpose, we would be using a file name apple.jpg with the following contents:-
Apparent from the contents, the file is an HTML file. But since it is saved with a .jpg extension, the operating system won’t be able to recognize its actual file type. So this file would be befitting for our program. 
Python3
import magic  # printing the human readable type of the fileprint(magic.from_file('apple.jpg'))  # printing the mime type of the fileprint(magic.from_file('apple.jpg', mime = True))
Output:
HTML document, ASCII text, with CRLF line terminators
text/html

Explanation:
Firstly we import the magic library.  Then we use magic.from_file() method to attain the human-readable file type. After which we use the mime=True attribute to attain the mime type of the file. 
Things to consider while using the above code:
The code works on Linux and Mac OS. But there exists an inbuilt terminal command named file on those operating systems, which provide the same functionality as this program, without installing any other library.
File type recognition using extensions also exists in the newer versions of the library.
Since the file type recognition generally happens by fingerprint lookup of the header of the file, it is not mandatory for one to load the whole file for type recognition. Small sections of the files could also be provided as an argument using magic.from_buffer() and passing the initial bytes of the file using open(‘file.ext’, ‘rb’).read(n) (Only recommended if aware of the header format of the file type).
python-utility
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to set font color in HTML?

To set the font color in HTML, use the style attribute. The style attribute specifies an inline style for an element. The attribute is used with the HTML <p> tag, with the CSS property color. HTML5 do not support the <font> tag, so the CSS style is used to add font color. The <font> tag deprecated in HTML5.
Just keep in mind, the usage of style attribute overrides any style set globally. It will override any style set in the HTML <style> tag or external style sheet.
You can try to run the following code to set font color in HTML −
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <title>HTML Font color</title>
   </head>
   <body>
      <h1>Products</h1>
      <p style="color:blue">This is demo content.</p>
   </body>
</html>
automake command in Linux with Examples - GeeksforGeeks

08 Apr, 2019
automake is a tool used for automatically generating Makefile.in files compliant with the set GNU Coding Standards. autoconf is required for the use of automake. automake manual can either be read on-line or downloaded in the PDF format. More formats are also offered for download or on-line reading. It will generate the Makefile.in for configuration from the Makefile.am file.
Syntax:
automake [OPTION]....[Makefile]
Operation Modes:
–help : Prints help and then exits.
–version : Prints the version information and then it exits.
-v or –verbose : Prints the verbosely list of processes.
–no-force : It will only update Makefile.in which are out of date.
-W or –warnings=Category : Reports the warnings falling in that specific category.The different warnings category’s are:
The different warnings category’s are:
Dependency Tracking Options:
-i or –ignore-deps : Disables the dependency tracking code.
–include-deps : Enables the dependency tracking code.
Flavors:
–foreign : It sets the strictness to foreign.
–gnits : It sets the strictness to gnits.
–gnu : It sets the strictness to gnu.
The library files:
-a or –add-missing : Adds the standard missing files to the package.
–libdir = DIRECTORY : Sets the directory storing library files.
-c or –copy : With -a, copies the missing files.
-f or –force-missing : Forces the update of standard files.
linux-command
Linux-misc-commands
Picked
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
TCP Server-Client implementation in C
tar command in Linux with examples
curl command in Linux with Examples
Conditional Statements | Shell Script
Tail command in Linux with examples
UDP Server-Client implementation in C
Cat command in Linux with examples
touch command in Linux with Examples
scp command in Linux with Examples
echo command in Linux with Examples
Implicit initialization of variables with 0 or 1 in C - GeeksforGeeks

19 Jun, 2018
In C programming language, the variables should be declared before a value is assigned to it.For Example:
   // declaration of variable a and 
   // initializing it with 0.
   int a = 0;

   // declaring array arr and initializing 
   // all the values of arr as 0.
   int arr[5] = {0}; 

However, variables can be assigned with 0 or 1 without even declaring them. Let us see an example to see how it can be done:
#include <stdio.h>#include <stdlib.h>  // implicit initialization of variablesa, b, arr[3];  // value of i is initialized to 1int main(i){    printf("a = %d, b = %d\n\n", a, b);      printf("arr[0] = %d, \narr[1] = %d, \narr[2] = %d,"                "\n\n", arr[0], arr[1], arr[2]);      printf("i = %d\n", i);      return 0;}
a = 0, b = 0

arr[0] = 0, 
arr[1] = 0, 
arr[2] = 0, 

i = 1

In an array, if fewer elements are used than the specified size of the array, then the remaining elements will be set by default to 0.Let us see another example to illustrate this.
#include <stdio.h>#include <stdlib.h>  int main(){    // size of the array is 5, but only array[0],    // array[1] and array[2] are initialized    int arr[5] = { 1, 2, 3 };      // printing all the elements of the array    int i;    for (i = 0; i < 5; i++) {        printf("arr[%d] = %d\n", i, arr[i]);    }      return 0;}
arr[0] = 1
arr[1] = 2
arr[2] = 3
arr[3] = 0
arr[4] = 0

C-Variable Declaration and Scope
C Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
TCP Server-Client implementation in C
Exception Handling in C++
'this' pointer in C++
Multithreading in C
Arrow operator -> in C/C++ with Examples
Multiple Inheritance in C++
Smart Pointers in C++ and How to Use Them
Understanding "extern" keyword in C
How to split a string in C/C++, Python and Java?
UDP Server-Client implementation in C
GATE | GATE-CS-2007 | Question 78 - GeeksforGeeks

14 Sep, 2021
Consider the CFG with {S,A,B) as the non-terminal alphabet, {a,b) as the terminal alphabet, S as the start symbol and the following set of production rules
S --> aB        S --> bA
B --> b         A --> a
B --> bS        A --> aS
B --> aBB       A --> bAA
Which of the following strings is generated by the grammar?(A) aaaabb(B) aabbbb(C) aabbab(D) abbbbaAnswer: (C)Explanation: Given below production rules.
S --> aB        S --> bA
B --> b         A --> a
B --> bS        A --> aS
B --> aBB       A --> bAA
We can derive aabbab using below sequence
S  -> aB      [Using S --> aB] 
   -> aaBB    [Using B --> aBB]
   -> aabB    [Using B --> b]
   -> aabbS   [Using B --> bS]
   -> aabbaB  [Using S --> aB]
   -> aabbab  [Using B --> b]
YouTubeGeeksforGeeks GATE Computer Science16.3K subscribersPYQ - Parsing and SDT (Continued) Part 4 with Joyojyoti Acharya | GeeksforGeeks GATEWatch laterShareCopy linkInfoShoppingTap to unmuteIf playback doesn't begin shortly, try restarting your device.You're signed outVideos you watch may be added to the TV's watch history and influence TV recommendations. To avoid this, cancel and sign in to YouTube on your computer.CancelConfirmMore videosMore videosSwitch cameraShareInclude playlistAn error occurred while retrieving sharing information. Please try again later.Watch on0:000:0032:36 / 58:40•Live•<div class="player-unavailable"><h1 class="message">An error occurred.</h1><div class="submessage"><a href="https://www.youtube.com/watch?v=LdMTs93sekg" target="_blank">Try watching this video on www.youtube.com</a>, or enable JavaScript if it is disabled in your browser.</div></div>Quiz of this Question
GATE-CS-2007
GATE-GATE-CS-2007
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | Gate IT 2007 | Question 25
GATE | GATE-CS-2000 | Question 41
GATE | GATE-CS-2001 | Question 39
GATE | GATE-CS-2005 | Question 6
GATE | GATE MOCK 2017 | Question 21
GATE | GATE-CS-2006 | Question 47
GATE | GATE MOCK 2017 | Question 24
GATE | Gate IT 2008 | Question 43
GATE | GATE-CS-2009 | Question 38
GATE | GATE-CS-2003 | Question 90
append() and extend() in Python

The append() and extend() functions are used with the python list to increase its number of elements. But the two have different behaviors as shown below.
Syntax: list_name.append(‘value’)
It takes only one argument.
This function appends the incoming element to the end of the list as a single new element. Even if the incoming element is itself a list, it will increase the count of the original list by only one.
list = ['Mon', 'Tue', 'Wed' ]
print("Existing list\n",list)
# Append an element
list.append('Thu')
print("Appended one element: ",list)

# Append a list
list.append(['Fri','Sat'])
print("Appended a list: ",list)
Running the above code gives us the following result −
Existing list
['Mon', 'Tue', 'Wed']
Appended one element: ['Mon', 'Tue', 'Wed', 'Thu']
Appended a list: ['Mon', 'Tue', 'Wed', 'Thu', ['Fri', 'Sat']]
Extend adds each element to the list as an individual element. The new length of the list is incremented by the number of elements added.
Syntax: list_name.extend(‘value’)
It takes only one argument.
list = ['Mon', 'Tue', 'Wed' ]
print("Existing list\n",list)
# Extend an element
list.extend("Thu")
print("Extended one element: ",list)

# Extend a list
list.extend(['Fri','Sat'])
print("Extended a list: ",list)
Running the above code gives us the following result −
['Mon', 'Tue', 'Wed']
Extended one element: ['Mon', 'Tue', 'Wed', 'T', 'h', 'u']
Extended a list: ['Mon', 'Tue', 'Wed', 'T', 'h', 'u', 'Fri', 'Sat']
What is the basic minimal structure of HTML document?

HTML document is a web page, which helps you in showing content on the website. It consists of tags, which has an opening as well as closing tags. However, some tags do not come in pairs i.e. they do not have a closing tag. The basic minimal structure also has some tags, which you need to add.
doctypeThis is a doctype declaration, which begins the HTML program and gets added as <!DOCTYPE html>. It is added to tell and instruct the browser about the document.<htmlThe first thing after the doctype declaration is the <html> tag. All the other HTML tags comes inside the <html>...</html> tag tells. Every tag inside this tag follows HTML rules.
<head>The <head> tag helps you in adding the title for the HTML document using the <title>...<title> tag.<body>The <body> tag allows you need to content to the HTML Document. You can use the <p>...</p> tag to add content to the document, which is visible on the web page.
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <title>HTML Document</title>
   </head>
   <body>
      <p>This is demo text.</p>
   </body>
</html>
How to Swap a Values in MySQL? - GeeksforGeeks

19 Nov, 2021
The UPDATE statement in SQL is used to update the data of an existing table in the database. We can update single columns as well as multiple columns using the UPDATE statements as per our requirement. Suppose we want to need to write a SQL query to swap all ‘a’ and ‘m’ values (i.e., change all ‘f’ values to ‘m’ and vice versa) with a single update statement and no intermediate temporary tables, then following are the steps:
Step 1: Creating the Database
Use the below SQL statement to create a database called geeks:
Query:
create database geeksforgeeks;
Step 2: Using the Database
Use the below SQL statement to switch the database context to geeks:
Query:
use geeksforgeeks;
Step 3: Table Definition
We have the following Salary table in our geeksforgeeks database.
Query:
create table Salary(id int  , name varchar(20) , sex varchar(1) ,
 salary int);
the table Salary contains information about an employee.
Step 4: Inserting Values in the table
Query:
insert into Salary values(1 , "A" , "m" , 2500);
insert into Salary values(2 , "B" , "f" , 1500);
insert into Salary values(3 , "C" , "m" , 5500);
insert into Salary values(4 , "D" , "f" ,  500);
Step 5: Suppose we want to update a particular value in the table then the query will be as follows
MySQL Query:
update Salary set sex = if(sex='m' , 'f','m');
here in the above query, we are using the IF() function to swap f and m, return f if sex is m, return m otherwise.
Output:
mysql
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Update Multiple Columns in Single Update Statement in SQL?
SQL | Subquery
How to Create a Table With Multiple Foreign Keys in SQL?
What is Temporary Table in SQL?
SQL Query to Find the Name of a Person Whose Name Starts with Specific Letter
SQL Query to Convert VARCHAR to INT
SQL using Python
How to Write a SQL Query For a Specific Date Range and Date Time?
How to Select Data Between Two Dates and Times in SQL Server?
SQL Query to Compare Two Dates
Reduce size of legend area using ggplot in R - GeeksforGeeks

30 May, 2021
In this article, we will are going to see how to change the size of the legend in the plot in the R programming language. We will change legend size of the plot using cex argument of legend() function.
In this approach to change the legend size of the plot, the user needs to use the cex argument of the legend function and specify its value with the user requirement, the values of cex greater than 1 will increase the legend size in the plot and the value of cex less than 1 will decrease the size of the legend in the plot.
cex: This is a number indicating the amount by which plotting text and symbols should be scaled relative to the default. 1=default, 1.5 is 50% larger, 0.5 is 50% smaller, etc.
Example1: In this example, we will be decreasing the size of the legend of the plot using the cex parameter as 0.5 in the legend() function of the R programming language.
R
x1 <- c(1, 8, 5, 3, 8, 7)                y1 <- c(4, 6, 3, 8, 2, 7)  plot(x1, y1, cex = .8, pch = 1,     col = "red")  x2<-c(4, 5, 8, 6, 4)y2<-c(9, 8, 2, 3, 1)x3<-c(2, 1, 6, 7, 4)y3<-c(7, 9, 1, 5, 2)  points(x2, y2, cex = .8, pch = 2, col = "blue")points(x3, y3, cex = .8, pch = 3, col = "green")  legend("topright", c("gfg1", "gfg2", "gfg3"),       cex = 0.5, col = c("red", "blue", "green"),       pch = c(1, 2, 3))
Output:
Example 2: In this example, we will be decreasing the size of the legend of the plot using the cex parameter as 0.5 in the legend() function of the R programming language.
R
gfg_data <- matrix(c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),                    ncol = 5)    colnames(gfg_data) <- paste0("Gfg", 1:5)rownames(gfg_data) <- c('A','B')  gfg_data  barplot(gfg_data,        col = 1 : nrow(gfg_data))  legend("topright",       legend = rownames(gfg_data),       pch = 15,       col = 1 : nrow(gfg_data), cex = 0.5)
Output:
Picked
R-ggplot
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?
How to import an Excel File into R ?
R - if statement
Time Series Analysis in R
How to filter R dataframe by multiple conditions?
Dart - Generics - GeeksforGeeks

12 Mar, 2021
In Dart, by default collections are heterogeneous. However, by the use of generics, we can make a collection to hold homogeneous values. The use of Generics makes the use of a single compulsory data type to be held inside the collection. Such collections are called type-safe collections. By the use of generics, type safety is ensured in the Dart language.
Syntax:
Collection_name <data_type> identifier= new Collection_name<data_type> 
We can use List, Set, Map, and Queue generics to implement type safety in Dart.
In Dart, a List is simply an ordered group of objects. A list is simply an implementation of an array.
Example:
Dart
main() {    List <int> listEx = new List <int>();    listEx.add(341);    listEx.add(1);    listEx.add(23);         // iterating across list listEx    for (int element in listEx) {       print(element);    }  }
Output:
341
1
23
In Dart, a Set represents a collection of objects in which each object can exist only once.
Example:
Dart
main() {    Set <int> SetEx = new Set <int>();    SetEx.add(12);    SetEx.add(3);    SetEx.add(4);       // Already added once, hence wont be added  SetEx.add(3);         // iterating across Set SetEx    for (int element in SetEx) {       print(element);    }  }
Output:
12
3
4
In Dart, Map is a dynamic collection of the key, value pairs.
Example:
Dart
main() {        // Creating a Map with Name and ids of students  Map <String,int> mp={'Ankur':1,'Arnav':002,'Shivam':003};    print('Map :${mp}');  }
Output:
Map :{Ankur: 1, Arnav: 2, Shivam: 3}
A queue is a collection that is used when the data is to be inserted in a FIFO (First in first out) manner. In Dart, a queue can be manipulated at both ends, i.e. at the start as well as the end of the queue.
Example:
Dart
import 'dart:collection';    main() {    Queue<int> q = new Queue<int>();          // Inserting at end of the queue  q.addLast(1);        // Inserting at end of the queue  q.addLast(2);        // Inserting at start of the queue  q.addFirst(3);      // Inserting at end of the queue    q.addLast(4);        // Current Queue order is 3 1 2 4.  // Removing the first element(3) of the queue    q.removeFirst();        // Iterating over the queue  for(int element in q){       print(element);    }  }
Output:
1
2
4
Dart Data-types
Picked
Dart
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Flutter - Custom Bottom Navigation Bar
ListView Class in Flutter
Flutter - Flexible Widget
Flutter - Stack Widget
Flutter - Dialogs
Android Studio Setup for Flutter Development
Flutter - Positioned Widget
Format Dates in Flutter
Flutter - Managing the MediaQuery Object
What is widgets in Flutter?
strconv.Atoi() Function in Golang With Examples - GeeksforGeeks

21 Apr, 2020
Go language provides inbuilt support to implement conversions to and from string representations of basic data types by strconv Package. This package provides an Atoi() function which is equivalent to ParseInt(str string, base int, bitSize int) is used to convert string type into int type. To access Atoi() function you need to import strconv Package in your program.
Syntax:
func Atoi(str string) (int, error)
Here, str is the string.
Example 1:
// Golang program to illustrate// strconv.Atoi() functionpackage main  import (    "fmt"    "strconv")  func main() {      // Using Atoi() function    x := "245"    y, e := strconv.Atoi(x)    if e == nil {        fmt.Printf("%T \n %v", y, y)    }  }
Output:
int 
 245

Example 2:
// Golang program to illustrate// strconv.Atoi() functionpackage main  import (    "fmt"    "strconv")  func main() {      // Using Atoi() function    x1 := "245"    fmt.Println("Before:")    fmt.Printf("Type: %T ", x1)    fmt.Printf("\nValue: %v", x1)    y1, e1 := strconv.Atoi(x1)    if e1 == nil {        fmt.Println("\nAfter:")        fmt.Printf("Type: %T ", y1)        fmt.Printf("\nValue: %v", y1)    }      x2 := "1"    fmt.Println("\n\nBefore:")    fmt.Printf("Type: %T ", x2)    fmt.Printf("\nValue: %v", x2)    y2, e2 := strconv.Atoi(x2)    if e2 == nil {        fmt.Println("\nAfter:")        fmt.Printf("Type: %T ", y2)        fmt.Printf("\nValue: %v", y2)    }  }
Output:
Before:
Type: string 
Value: 245
After:
Type: int 
Value: 245

Before:
Type: string 
Value: 1
After:
Type: int 
Value: 1

Golang-strconv
Go Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
strings.Replace() Function in Golang With Examples
Arrays in Go
fmt.Sprintf() Function in Golang With Examples
How to Split a String in Golang?
6 Best Books to Learn Go Programming Language
Golang Maps
Slices in Golang
Different Ways to Find the Type of Variable in Golang
Inheritance in GoLang
Interfaces in Golang
Calinski-Harabasz Index – Cluster Validity indices | Set 3 - GeeksforGeeks

25 Apr, 2022
Prerequisites: Cluster Validity Index
Clustering validation has been recognized as one of the important factors essential to the success of clustering algorithms. How to effectively and efficiently assess the clustering results of clustering algorithms is the key to the problem. Generally, cluster validity measures are categorized into 3 classes (Internal cluster validation, External cluster validation and Relative cluster validation).
In this article, we focus on an internal cluster validation index i.e. Calinski-Harabasz Index.
Calinski-Harabasz Index:
Calinski-Harabasz (CH) Index (introduced by Calinski and Harabasz in 1974) can be used to evaluate the model when ground truth labels are not known where the validation of how well the clustering has been done is made using quantities and features inherent to the dataset. The CH Index (also known as Variance ratio criterion) is a measure of how similar an object is to its own cluster (cohesion) compared to other clusters (separation). Here cohesion is estimated based on the distances from the data points in a cluster to its cluster centroid and separation is based on the distance of the cluster centroids from the global centroid. CH index has a form of (a . Separation)/(b . Cohesion) , where a and b are weights. 
Calculation of Calinski-Harabasz Index:
The CH index for K number of clusters on a dataset D =[ d1 , d2 , d3 , ... dN ] is defined as,
 
where, nk  and ck  are the no. of points and centroid of the kth cluster respectively, c is the global centroid, N is the total no. of data points.
 
Higher value of CH index means the clusters are dense and well separated, although there is no “acceptable” cut-off value. We need to choose that solution which gives a peak or at least an abrupt elbow on the line plot of CH indices. On the other hand, if the line is smooth (horizontal or ascending or descending) then there is no such reason to prefer one solution over others. 
 
Line-plot of CH values vs No. of clusters for IRIS dataset
 
Below is the Python implementation of the above CH index using the sklearn library :
 
python3
from sklearn import datasetsfrom sklearn.cluster import KMeansfrom sklearn import metricsfrom sklearn.metrics import pairwise_distancesimport numpy as np # loading the datasetX, y = datasets.load_iris(return_X_y=True) # K-Meanskmeans = KMeans(n_clusters=3, random_state=1).fit(X) # we store the cluster labelslabels = kmeans.labels_ print(metrics.calinski_harabasz_score(X, labels))
Output:
561.62
References: 
https://scikit-learn.org/stable/modules/clustering.html#calinski-harabasz-index 
pyshark
Machine Learning
Python
Machine Learning
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Decision Tree
Activation functions in Neural Networks
Introduction to Recurrent Neural Network
Decision Tree Introduction with example
Support Vector Machine Algorithm
Read JSON file using Python
Adding new column to existing DataFrame in Pandas
Python map() function
How to get column names in Pandas dataframe