code-rag-bench/online-tutorials huggingface dataset:
SQL - UPDATE Query

The SQL UPDATE Query is used to modify the existing records in a table. You can use the WHERE clause with the UPDATE query to update the selected rows, otherwise all the rows would be affected.
The basic syntax of the UPDATE query with a WHERE clause is as follows −
UPDATE table_name
SET column1 = value1, column2 = value2...., columnN = valueN
WHERE [condition];

You can combine N number of conditions using the AND or the OR operators.
Consider the CUSTOMERS table having the following records −
+----+----------+-----+-----------+----------+
| ID | NAME     | AGE | ADDRESS   | SALARY   |
+----+----------+-----+-----------+----------+
|  1 | Ramesh   |  32 | Ahmedabad |  2000.00 |
|  2 | Khilan   |  25 | Delhi     |  1500.00 |
|  3 | kaushik  |  23 | Kota      |  2000.00 |
|  4 | Chaitali |  25 | Mumbai    |  6500.00 |
|  5 | Hardik   |  27 | Bhopal    |  8500.00 |
|  6 | Komal    |  22 | MP        |  4500.00 |
|  7 | Muffy    |  24 | Indore    | 10000.00 |
+----+----------+-----+-----------+----------+
The following query will update the ADDRESS for a customer whose ID number is 6 in the table.
SQL> UPDATE CUSTOMERS
SET ADDRESS = 'Pune'
WHERE ID = 6;
Now, the CUSTOMERS table would have the following records −
+----+----------+-----+-----------+----------+
| ID | NAME     | AGE | ADDRESS   | SALARY   |
+----+----------+-----+-----------+----------+
|  1 | Ramesh   |  32 | Ahmedabad |  2000.00 |
|  2 | Khilan   |  25 | Delhi     |  1500.00 |
|  3 | kaushik  |  23 | Kota      |  2000.00 |
|  4 | Chaitali |  25 | Mumbai    |  6500.00 |
|  5 | Hardik   |  27 | Bhopal    |  8500.00 |
|  6 | Komal    |  22 | Pune      |  4500.00 |
|  7 | Muffy    |  24 | Indore    | 10000.00 |
+----+----------+-----+-----------+----------+

If you want to modify all the ADDRESS and the SALARY column values in the CUSTOMERS table, you do not need to use the WHERE clause as the UPDATE query would be enough as shown in the following code block.
SQL> UPDATE CUSTOMERS
SET ADDRESS = 'Pune', SALARY = 1000.00;
Now, CUSTOMERS table would have the following records −
+----+----------+-----+---------+---------+
| ID | NAME     | AGE | ADDRESS | SALARY  |
+----+----------+-----+---------+---------+
|  1 | Ramesh   |  32 | Pune    | 1000.00 |
|  2 | Khilan   |  25 | Pune    | 1000.00 |
|  3 | kaushik  |  23 | Pune    | 1000.00 |
|  4 | Chaitali |  25 | Pune    | 1000.00 |
|  5 | Hardik   |  27 | Pune    | 1000.00 |
|  6 | Komal    |  22 | Pune    | 1000.00 |
|  7 | Muffy    |  24 | Pune    | 1000.00 |
+----+----------+-----+---------+---------+


    42 Lectures 
     5 hours 

 Anadi Sharma

    14 Lectures 
     2 hours 

 Anadi Sharma

    44 Lectures 
     4.5 hours 

 Anadi Sharma

    94 Lectures 
     7 hours 

 Abhishek And Pukhraj

    80 Lectures 
     6.5 hours 

 Oracle Master Training | 150,000+ Students Worldwide

    31 Lectures 
     6 hours 

 Eduonix Learning Solutions
 Print
 Add Notes
 Bookmark this page
- GeeksforGeeks

26 Dec, 2018
Assume that to spell check a large file, 820,000,000 instructions are needed. The instructions in the program are broken down into 4 different classes, and each class requires N clock cycles to execute. Specific information is given in the table below. (Here, N is the same as in the MIPS multi-cycle datapath discussed in class.)
If the total execution time for this program is found to be 1.57 seconds, what is the clock cycle time of the computer on which it was run?
(A) 1.6 GHz(B) 1.82 GHz(C) 2.16 GHz(D) 3.32 GHzAnswer: (C)Explanation: We can apply the CPU time formula: CPU time = IC x CPIavg x CC Time, and solve for CC Time.820,000,000 * {3*(150,000,000 / 820,000,000) + 4*(185,000,000 / 820,000,000) + 5*(260,000,000 / 820,000,000) + 4*(225,000,000 / 820,000,000)} × N = 1.57s
Thus, the clock cycle time is 4.63 x 10-10s.
Which is equal to,
1 / (4.63 x 10-10) 
= 0.215982721 x 1010
= 2.15982721 x 109 cycle per second
= 2.16 GHz 
This is a 2.16 GHz machine.
So, option (C) is correct.Quiz of this Question
Writing code in comment? Please use ide.geeksforgeeks.org, generate link and share the link here.
Comments
Old Comments
Must Do Coding Questions for Product Based Companies
Microsoft Interview Experience for Internship (Via Engage)
Difference between var, let and const keywords in JavaScript
Array of Objects in C++ with Examples
How to Replace Values in Column Based on Condition in Pandas?
C Program to read contents of Whole File
How to Replace Values in a List in Python?
How to Read Text Files with Pandas?
Infosys DSE Interview Experience | On-Campus 2021
HackWithInfy - A Coding Competition by Infosys
ES6 - Array Method filter()

filter() method creates a new array with all elements that pass the test implemented by the provided function.
array.filter(callback[, thisObject]); 

callback − Function to test for each element.
callback − Function to test for each element.
thisObject − Object to use as this when executing callback.
thisObject − Object to use as this when executing callback.
Returns created array.
function isBigEnough(element, index, array) { 
   return (element >= 10); 
} 
var passed = [12, 5, 8, 130, 44].filter(isBigEnough); 
console.log("Test Value : " + passed );  
Test Value :12,130,44 


    32 Lectures 
     3.5 hours 

 Sharad Kumar

    40 Lectures 
     5 hours 

 Richa Maheshwari

    16 Lectures 
     1 hours 

 Anadi Sharma

    50 Lectures 
     6.5 hours 

 Gowthami Swarna

    14 Lectures 
     1 hours 

 Deepti Trivedi

    31 Lectures 
     1.5 hours 

 Shweta
 Print
 Add Notes
 Bookmark this page
How to sort date in excel using Pandas? - GeeksforGeeks

05 Sep, 2020
In these articles, We will discuss how to import an excel file in a single Dataframe and sort the Date in a given column on. Suppose our Excel file looks like these:
sample_date.xlsx
To get the excel file used click here.
Approach :
Import Pandas module
Make DataFrame from Excel file
sort the date column with DataFrame.sort_value() function
Display the Final DataFrame
Step 1: Importing pandas module and making DataFrame form excel.
Python3
# import moduleimport pandas as pd  # making data frame from excel filedf = pd.read_excel('excel_work\sample_date.xlsx')  print("Original DataFrame")df
Output :
Step 2: Sorting date with DataFrame.sort_value() function.
Python3
# sorting date with sort_value() functionFinal_result = df.sort_values('Joining Date')  print(" Sorted Date DataFrame")Final_result
Output :
Python pandas-dataFrame-methods
Python pandas-io
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Python OOPs Concepts
How to Install PIP on Windows ?
Bar Plot in Matplotlib
Defaultdict in Python
Python Classes and Objects
Deque in Python
Check if element exists in list in Python
How to drop one or multiple columns in Pandas Dataframe
Python - Ways to remove duplicates from list
Class method vs Static method in Python
SQLite - CREATE Database

In SQLite, sqlite3 command is used to create a new SQLite database. You do not need to have any special privilege to create a database.
Following is the basic syntax of sqlite3 command to create a database: −
$sqlite3 DatabaseName.db

Always, database name should be unique within the RDBMS.
If you want to create a new database <testDB.db>, then SQLITE3 statement would be as follows −
$sqlite3 testDB.db
SQLite version 3.7.15.2 2013-01-09 11:53:05
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite>
The above command will create a file testDB.db in the current directory. This file will be used as database by SQLite engine. If you have noticed while creating database, sqlite3 command will provide a sqlite> prompt after creating a database file successfully.
Once a database is created, you can verify it in the list of databases using the following SQLite .databases  command.
sqlite>.databases
seq  name             file
---  ---------------  ----------------------
0    main             /home/sqlite/testDB.db

You will use SQLite .quit command to come out of the sqlite prompt as follows −
sqlite>.quit
$

You can use .dump dot command to export complete database in a text file using the following SQLite command at the command prompt.
$sqlite3 testDB.db .dump > testDB.sql
The above command will convert the entire contents of testDB.db database into SQLite statements and dump it into ASCII text file testDB.sql. You can perform restoration from the generated testDB.sql in a simple way as follows −
$sqlite3 testDB.db < testDB.sql
At this moment your database is empty, so you can try above two procedures once you have few tables and data in your database. For now, let's proceed to the next chapter.

    25 Lectures 
     4.5 hours 

 Sandip Bhattacharya

    17 Lectures 
     1 hours 

 Laurence Svekis

    5 Lectures 
     51 mins

 Vinay Kumar
 Print
 Add Notes
 Bookmark this page
What are local variables and global variables in C++?

A scope is a region of the program and broadly speaking there are three places, where variables can be declared −
 Inside a function or a block which is called local variables,
 In the definition of function parameters which is called formal parameters.
 Outside of all functions which are called global variables.
Local variables can be used only by statements that are inside that function or block of code. Local variables are not known to functions on their own. 
#include <iostream>
using namespace std;
int main () {
   // Local variable declaration:
   int a, b;
   int c;

   // actual initialization
   a = 10;
   b = 20;
   c = a + b;

   cout << c;
   return 0;
}
This will give the output −
30
Global variables are defined outside of all the functions, usually on top of the program. The global variables will hold their value throughout the lifetime of your program. A global variable can be accessed by any function. 
#include <iostream>
using namespace std;
// Global variable declaration:
int g;
int main () {
   // Local variable declaration:
   int a, b;

   // actual initialization
   a = 10;
   b = 20;
   g = a + b;

   cout << g;
   return 0;
}
This will give the output −
30
A program can have the same name for local and global variables but the value of a local variable inside a function will take preference. For accessing the global variable with same rame, you'll have to use the scope resolution operator. 
#include <iostream>
using namespace std;
// Global variable declaration:
int g = 20;
int main () {
   // Local variable declaration:
   int g = 10;

   cout << g;   // Local
   cout << ::g; // Global
   return 0;
}
This will give the output −
10
20
Can we define constructor inside an interface in java?

No, you cannot have a constructor within an interface in Java.
You can have only public, static, final variables and, public, abstract, methods as of Java7.
You can have only public, static, final variables and, public, abstract, methods as of Java7.
From Java8 onwards interfaces allow default methods and static methods.
From Java8 onwards interfaces allow default methods and static methods.
From Java9 onwards interfaces allow private and private static methods.
From Java9 onwards interfaces allow private and private static methods.
Moreover, all the methods you define (except above mentioned) in an interface should be implemented by another class (overridden). But, you cannot override constructors in Java.
Still if you try to define constructors in an interface it generates a compile time error.
In the following Java program, we are trying to define a constructor within an interface.
public interface MyInterface{
   public abstract MyInterface();
   /*{
      System.out.println("This is the constructor of the interface");
   }*/
   public static final int num = 10;
   public abstract void demo();
}
On compiling, the above program generates the following error
MyInterface.java:2: error: expected
   public abstract MyInterface();
^
1 error
In short, it does not accept methods without return type in an interface. If you add return type to the MyInterface() method then it is considered as a normal method and the program gets compiled without errors.
public interface MyInterface {
   public abstract void MyInterface();
   public static final int num = 10;
   public abstract void demo();
}
Matplotlib.axes.Axes.get_legend_handles_labels() in Python - GeeksforGeeks

19 Apr, 2020
Matplotlib is a library in Python and it is numerical – mathematical extension for NumPy library. The Axes Class contains most of the figure elements: Axis, Tick, Line2D, Text, Polygon, etc., and sets the coordinate system. And the instances of Axes supports callbacks through a callbacks attribute.
The Axes.get_legend_handles_labels() function in axes module of matplotlib library is used to return the handles and labels for legend.
Syntax: Axes.get_legend_handles_labels(self)
Parameters: This method does not accepts any parameters.
Return: This function return the handles and labels for legend.
Below examples illustrate the matplotlib.axes.Axes.get_legend_handles_labels() function in matplotlib.axes:
Example 1:
# Implementation of matplotlib function  import matplotlib.pyplot as pltimport numpy as np     fig, ax = plt.subplots()ax.plot([1, 6, 3, 8, 34, 13, 56, 67], color ="green")  h, l = ax.get_legend_handles_labels()# print(h, l)text ="Legend is present"if h ==[]:    text ="No legend present"else:    text+="and labels are : "+str(l)      ax.text(2.5, 60, text, fontweight ="bold")fig.suptitle('matplotlib.axes.Axes.get_legend_handles_labels()\ function Example\n', fontweight ="bold")fig.canvas.draw()plt.show()
Output:
Example 2:
# Implementation of matplotlib functionimport numpy as npnp.random.seed(19680801)import matplotlib.pyplot as plt      fig, ax = plt.subplots()for color in [ 'tab:green', 'tab:blue', 'tab:orange']:    n = 70    x, y = np.random.rand(2, n)    scale = 1000.0 * np.random.rand(n)    ax.scatter(x, y, c = color, s = scale, label = color,               alpha = 0.35)   ax.legend()ax.grid(True)  h, l = ax.get_legend_handles_labels()print(h, l)text ="    Legend is present"if h ==[]:    text ="No legend present"else:    text+=" and labels are : \n"+str(l)      ax.text(0.15, 0.45, text, fontweight ="bold")fig.suptitle('matplotlib.axes.Axes.get_legend_handles_labels()\ function Example\n', fontweight ="bold")fig.canvas.draw()plt.show()
Output:
Python-matplotlib
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python Classes and Objects
How to drop one or multiple columns in Pandas Dataframe
Python | Get unique values from a list
Defaultdict in Python
Python | os.path.join() method
Create a directory in Python
Python | Pandas dataframe.groupby()
random.betavariate() method in Python - GeeksforGeeks

17 May, 2020
betavariate() is an inbuilt method of the random module. It is used to return a random floating point number with beta distribution. The returned value is between 0 and 1.
Syntax : random.betavariate(alpha, beta)
Parameters :alpha : greater than 0beta : greater than 0
Returns : a random beta distribution floating number between 0 and 1
Example 1:
# import the random moduleimport random  # determining the values of the parametersalpha = 5beta = 10  # using the betavariate() methodprint(random.betavariate(alpha, beta))
Output :
0.5148685287422776
Example 2: We can generate the number multiple times and plot a graph to observe the beta distribution.
# import the required librariesimport randomimport matplotlib.pyplot as plt    # store the random numbers in a # listnums = []low = 10high = 100mode = 20  for i in range(100):    temp = random.betavariate(5, 10)    nums.append(temp)      # plotting a graphplt.plot(nums)plt.show()
Output :
Python-random
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
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
Taking input in Python
Read a file line by line in Python
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
PyQt5 - Change state of Radio Button - GeeksforGeeks

22 Apr, 2020
In this article we will see how to change the state of radio button. Although with the help of setChecked method we can we make the radio button checked but when we use this method on the checked radio button there will be no change in the state of radio button.
In order to change the state of radio button when push button is pressed we have to do the following –
1. Create a radio button2. Create a push button3. Connect a method to push button such that when push button get pressed method get called4. In the calling method with the help of nextCheckState method change the state of radio button.
Below is the implement.
# importing librariesfrom PyQt5.QtWidgets import * from PyQt5 import QtCore, QtGuifrom PyQt5.QtGui import * from PyQt5.QtCore import * import sys    class Window(QMainWindow):      def __init__(self):        super().__init__()          # setting title        self.setWindowTitle("Python ")          # setting geometry        self.setGeometry(100, 100, 600, 400)          # calling method        self.UiComponents()          # showing all the widgets        self.show()      # method for widgets    def UiComponents(self):          # creating a radio button        self.radio_button = QRadioButton(self)          # setting geometry of radio button        self.radio_button.setGeometry(200, 150, 120, 40)          # setting text to radio button        self.radio_button.setText("Radio Button")          # creating push button        push = QPushButton("Press", self)          # setting geometry of push button        push.setGeometry(200, 200, 100, 40)          # connect method to push button        push.clicked.connect(self.method)      def method(self):          # changing the state of radio button        self.radio_button.nextCheckState()      # create pyqt5 appApp = QApplication(sys.argv)  # create the instance of our Windowwindow = Window()  # start the appsys.exit(App.exec())
output :
Python-gui
Python-PyQt
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python Classes and Objects
How to drop one or multiple columns in Pandas Dataframe
Defaultdict in Python
Python | Get unique values from a list
Python | os.path.join() method
Create a directory in Python
Python | Pandas dataframe.groupby()
Wipro interview questions for laterals | Set 1 - GeeksforGeeks

22 Aug, 2018
25 question1hr timeAll Are MCQ:1 mark each, no negative marksDomain: C language
1)
int main(){    int i;    i = 0;    if (x=0)    {        printf("x is zero");    }    else    {        printf("x is not zero");    }}
2)
int main(){    int i = -3;    printf("%d n", (++i + ++i));}
3)
int main(){    int x = 0xF01DEAD;    printf("%X n",(x>>1)<<1);}
4)
int main(){    char* s1 ;    char* s2 ;    s1 = "FIRST NAME";    s2 = "LAST NAME";    strcpy(s1,s2);    printf("%s %s n",s1,s2);}
5)
int main{    struct Student    {        int a;        char b;        char c;        float f;    }s1;    printf("%dn",sizeof(s1));}
6)
int main{    struct Student    {        short a[5];        union Student        {            long c;            float f;        }u1;    }s1;    printf("%dn",sizeof(s1));}
7)
int main(){    for (i=0; i<=2; i++)        for (j=0; j<=i; j++)            for(k=0; k<=j; k++)        printf(""hello world");}
8)
int main(){    for (count=5; sum+=--count; )        printf("%d n",sum);}
9)
int main(){    int i=0;    while (i<10);        print("hello world")'}
10)
int main(){      (x && (x&(x-1))) --- indicates what?}
some more on pointers, preprocessors and static
If you like GeeksQuiz and would like to contribute, you can also write an article and mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Wipro
Wipro-interview-experience
Interview Experiences
Wipro
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Amazon Interview Experience for SDE-1 (Off-Campus)
Amazon AWS Interview Experience for SDE-1
Amazon Interview Experience for SDE-1 (Off-Campus) 2022
Amazon Interview Experience
Amazon Interview Experience for SDE-1
Freshworks/Freshdesk Interview Experience for Software Developer (On-Campus)
Amazon Interview Experience (Off-Campus) 2022
Amazon Interview Experience for SDE-1 (On-Campus)
JPMorgan Chase & Co. Code for Good Internship Interview Experience 2021
EPAM Interview Experience (Off-Campus)
Python unittest - assertEqual() function - GeeksforGeeks

29 Aug, 2020
assertEqual() in Python is a unittest library function that is used in unit testing to check the equality of two values. This function will take three parameters as input and return a boolean value depending upon the assert condition. If both input values are equal assertEqual() will return true else return false.
Syntax: assertEqual(firstValue, secondValue, message)
Parameters: assertEqual() accept three parameter which are listed below with explanation:
firstValue  variable of any type which is used in the comparison by function
secondValue: variable of any type which is used in the comparison by function
message: a string sentence as a message which got displayed when the test case got failed.
Listed below are two different examples illustrating the positive and negative test case for given assert function:
Example 1: Negative Test case
Python3
# unit test caseimport unittest  class TestStringMethods(unittest.TestCase):    # test function to test equality of two value    def test_negative(self):        firstValue = "geeks"        secondValue = "gfg"        # error message in case if test case got failed        message = "First value and second value are not equal !"        # assertEqual() to check equality of first & second value        self.assertEqual(firstValue, secondValue, message)  if __name__ == '__main__':    unittest.main()
Output:
F
======================================================================
FAIL: test_negative (__main__.TestStringMethods)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "p1.py", line 12, in test_negative
    self.assertEqual(firstValue, secondValue, message)
AssertionError: 'geeks' != 'gfg'
- geeks
+ gfg
 : First value and second value are not equal!

----------------------------------------------------------------------
Ran 1 test in 0.000s

FAILED (failures=1)

Example 2: Positive Test case
Python3
# unit test caseimport unittest  class TestStringMethods(unittest.TestCase):    # test function to test equality of two value    def test_positive(self):        firstValue = "geeks"        secondValue = "geeks"        # error message in case if test case got failed        message = "First value and second value are not equal !"        # assertEqual() to check equality of first & second value        self.assertEqual(firstValue, secondValue, message)  if __name__ == '__main__':    unittest.main()
Output:
.
----------------------------------------------------------------------
Ran 1 test in 0.000s

OK



Reference: https://docs.python.org/3/library/unittest.html
Python unittest-library
Python
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
Iterate over a list in Python
Python String | replace()
*args and **kwargs in Python
Reading and Writing to text files in Python
Create a Pandas DataFrame from Lists
Python | SymPy Permutation.index() method - GeeksforGeeks

27 Aug, 2019
Permutation.index() : index() is a sympy Python library function that returns the index value of the permutation in argument.
Index of a permutation = Sum of all subscripts j such that permutation[j] is greater than permutation[j+1].
Syntax :sympy.combinatorics.permutations.Permutation.index()
Return :index value of the permutation
Code #1 : index() Example
# Python code explaining# SymPy.Permutation.index()  # importing SymPy librariesfrom sympy.combinatorics.partitions import Partitionfrom sympy.combinatorics.permutations import Permutation  # Using from sympy.combinatorics.permutations.Permutation.index() method   # creating Permutationa = Permutation([[2, 0], [3, 1]])  b = Permutation([1, 3, 5, 4, 2, 0])    print ("Permutation a - index form : ", a.index())print ("Permutation b - index form : ", b.index())
Output :
Permutation a – index form : 1Permutation b – index form : 9
Code #2 : index() Example – 2D Permutation
# Python code explaining# SymPy.Permutation.index()  # importing SymPy librariesfrom sympy.combinatorics.partitions import Partitionfrom sympy.combinatorics.permutations import Permutation  # Using from sympy.combinatorics.permutations.Permutation.index() method   # creating Permutationa = Permutation([[2, 4, 0],                  [3, 1, 2],                 [1, 5, 6]])    print ("Permutation a - index form : ", a.index())
Output :
Permutation a – index form : 8
SymPy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python Classes and Objects
How to drop one or multiple columns in Pandas Dataframe
Python | Get unique values from a list
Defaultdict in Python
Python | os.path.join() method
Create a directory in Python
Python | Pandas dataframe.groupby()
Gaussian Filter Generation in C++ - GeeksforGeeks

28 Feb, 2022
Gaussian Filtering is widely used in the field of image processing. It is used to reduce the noise of an image. In this article we will generate a 2D Gaussian Kernel. The 2D Gaussian Kernel follows the below given Gaussian Distribution. Where, y is the distance along vertical axis from the origin, x is the distance along horizontal axis from the origin and σ is the standard deviation.
Implementation in C++ 
// C++ program to generate Gaussian filter#include <cmath>#include <iomanip>#include <iostream>using namespace std; // Function to create Gaussian filtervoid FilterCreation(double GKernel[][5]){    // initialising standard deviation to 1.0    double sigma = 1.0;    double r, s = 2.0 * sigma * sigma;     // sum is for normalization    double sum = 0.0;     // generating 5x5 kernel    for (int x = -2; x <= 2; x++) {        for (int y = -2; y <= 2; y++) {            r = sqrt(x * x + y * y);            GKernel[x + 2][y + 2] = (exp(-(r * r) / s)) / (M_PI * s);            sum += GKernel[x + 2][y + 2];        }    }     // normalising the Kernel    for (int i = 0; i < 5; ++i)        for (int j = 0; j < 5; ++j)            GKernel[i][j] /= sum;} // Driver program to test above functionint main(){    double GKernel[5][5];    FilterCreation(GKernel);     for (int i = 0; i < 5; ++i) {        for (int j = 0; j < 5; ++j)            cout << GKernel[i][j] << "\t";        cout << endl;    }}
Output: 
0.00296902    0.0133062    0.0219382    0.0133062    0.00296902    
0.0133062    0.0596343    0.0983203    0.0596343    0.0133062    
0.0219382    0.0983203    0.162103    0.0983203    0.0219382    
0.0133062    0.0596343    0.0983203    0.0596343    0.0133062    
0.00296902    0.0133062    0.0219382    0.0133062    0.00296902
References: https://en.wikipedia.org/wiki/Gaussian_filterThis article is contributed by Harsh Agarwal. If you like GeeksforGeeks and would like to contribute, you can also write an article using write.geeksforgeeks.org or mail your article to review-team@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above. 
jit_t
gabaa406
surinderdawra388
Image-Processing
Mathematical
Mathematical
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Merge two sorted arrays
Modulo Operator (%) in C/C++ with Examples
Prime Numbers
Program to find GCD or HCF of two numbers
Print all possible combinations of r elements in a given array of size n
Sieve of Eratosthenes
Operators in C / C++
Program for factorial of a number
Find minimum number of coins that make a given value
Program for Decimal to Binary Conversion
Java program to print Even length words in a String - GeeksforGeeks

28 Feb, 2020
Given a string str, write a Java program to print all words with even length in the given string.
Examples:
Input: s = "This is a java language"
Output: This
        is
        java
        language 

Input: s = "i am GFG"
Output: am

Approach:
Take the string
Break the string into words with the help of split() method in String class. It takes the string by which the sentence is to be broken. So here ” “(space) is passed as the parameter. As a result, the words of the string are split and returned as a string arrayString[] words = str.split(" ");

String[] words = str.split(" ");

Traverse each word in the string array returned with the help of Foreach loop in Java.for(String word : words)
{ }

for(String word : words)
{ }

Calculate the length of each word using String.length() function.int lengthOfWord = word.length();

int lengthOfWord = word.length();

If the length is even, then print the word.
Below is the implementation of the above approach:
// Java program to print// even length words in a string  class GfG {    public static void printWords(String s)    {          // Splits Str into all possible tokens        for (String word : s.split(" "))              // if length is even            if (word.length() % 2 == 0)                  // Print the word                System.out.println(word);    }      // Driver Code    public static void main(String[] args)    {          String s = "i am Geeks for Geeks and a Geek";        printWords(s);    }}
am
Geek

Java-String-Programs
Java
Java Programs
Strings
Strings
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Object Oriented Programming (OOPs) Concept in Java
HashMap in Java with Examples
Stream In Java
Interfaces in Java
How to iterate any Map in Java
Initializing a List in Java
Convert a String to Character Array in Java
Java Programming Examples
Convert Double to Integer in Java
Implementing a Linked List in Java using Class
Stack size() method in Java with Example - GeeksforGeeks

24 Dec, 2018
The Java.util.Stack.size() method in Java is used to get the size of the Stack or the number of elements present in the Stack.
Syntax:
Stack.size()
Parameters: The method does not take any parameter.
Return Value: The method returns the size or the number of elements present in the Stack.
Below programs illustrate the Java.util.Stack.size() method:
Program 1: Stack with string elements.
// Java code to illustrate size()import java.util.*;  public class StackDemo {    public static void main(String args[])    {        // Creating an empty Stack        Stack<String> stack = new Stack<String>();          // Use add() method to add elements into the Stack        stack.add("Welcome");        stack.add("To");        stack.add("Geeks");        stack.add("4");        stack.add("Geeks");          // Displaying the Stack        System.out.println("Stack: " + stack);          // Displaying the size of Stack        System.out.println("The size is: " + stack.size());    }}
Stack: [Welcome, To, Geeks, 4, Geeks]
The size is: 5

Program 2: Stack with integer elements.
// Java code to illustrate size()import java.util.*;  public class StackDemo {    public static void main(String args[])    {        // Creating an empty Stack        Stack<Integer> stack = new Stack<Integer>();          // Use add() method to add elements into the Stack        stack.add(10);        stack.add(15);        stack.add(30);        stack.add(20);        stack.add(5);          // Displaying the Stack        System.out.println("Stack: " + stack);          // Displaying the size of Stack        System.out.println("The size is: " + stack.size());    }}
Stack: [10, 15, 30, 20, 5]
The size is: 5

Java - util package
Java-Collections
Java-Functions
Java-Stack
Java
Java
Java-Collections
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Arrays in Java
Split() String method in Java with examples
For-each loop in Java
Object Oriented Programming (OOPs) Concept in Java
HashMap in Java with Examples
Reverse a string in Java
Arrays.sort() in Java with examples
Stream In Java
Interfaces in Java
How to iterate any Map in Java
C++ program to implement Half Adder - GeeksforGeeks

26 Aug, 2021
Prerequisite : Half Adder in Digital Logic
We are given with two inputs A and B. Our task is to implement Half Adder circuit and print the outputs sum and carry of two inputs.
Introduction :  
The Half adder is a combinational circuit which add two1-bit binary numbers which are augend and addend to give the output value along with the carry.  The half adder has two input states and two output states. The two outputs are Sum and Carry.
Here we have two inputs A, B and two outputs sum, carry. And the truth table for Half Adder is 
Logical Expression : 
Sum = A XOR B  
Carry = A AND B 
Examples :
       Input : A=0, B= 0
       Output: Sum=0, Carry=0
       Explanation:  Here from logical expression Sum = A XOR B i.e  0 XOR 0 = 0, and Carry=A AND B  i.e 0 AND 0 = 0.
       Input : A=1, B= 0
       Output: Sum=1, Carry=0
       Explanation:   Here from  logical expression Sum=A XOR B  i.e 1 XOR 0 =1 , Carry=A AND B  i.e 1 AND 0 =  0.
Approach :
Initialize the variables Sum and Carry for storing outputs.
First we will take two inputs A and B.
By applying  A XOR B we get the value of Sum.
By applying  A AND B we get the value of Carry.
C++
// C++ program for above approach#include <bits/stdc++.h>using namespace std;// Function to print Sum and Carryvoid Half_Adder(int A,int B){    //initialize the variables Sum and Carry    int Sum , Carry;        // Calculating value of sum by applying A XOR B    Sum = A ^ B;        // Calculating value of Carry by applying A AND B    Carry = A & B;        // printing the values    cout<<"Sum = "<< Sum << endl;    cout<<"Carry = "<<Carry<< endl;}//Driver codeint main() {    int A = 1;    int B = 0;    // calling the function    Half_Adder(A,B);    return 0;}
Sum = 1
Carry = 0
Digital Electronics & Logic Design
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Introduction to memory and memory units
Ring Counter in Digital Logic
n-bit Johnson Counter in Digital Logic
Transmission Impairment in Data Communication
Half Subtractor in Digital Logic
Analog to Digital Conversion
Differences between Synchronous and Asynchronous Counter
Ripple Counter in Digital Logic
Properties of Boolean Algebra
Floating Point Representation - Basics
Create PySpark dataframe from dictionary - GeeksforGeeks

30 May, 2021
In this article, we are going to discuss the creation of Pyspark dataframe from the dictionary. To do this spark.createDataFrame() method method is used. This method takes two argument data and columns. The data attribute will contain the dataframe and the columns attribute will contain the list of columns name.
Example 1: Python code to create the student address details and convert them to dataframe
Python3
# importing moduleimport pyspark  # importing sparksession from # pyspark.sql modulefrom pyspark.sql import SparkSession  # creating sparksession and giving # an app namespark = SparkSession.builder.appName('sparkdf').getOrCreate()  # list  of college data with  dictionarydata = [{'student_id': 12, 'name': 'sravan',         'address': 'kakumanu'}]  # creating a dataframedataframe = spark.createDataFrame(data)  # show data framedataframe.show()
Output:
Example2: Create three dictionaries and pass them to the data frame in pyspark
Python3
# importing moduleimport pyspark  # importing sparksession from # pyspark.sql modulefrom pyspark.sql import SparkSession  # creating sparksession and giving # an app namespark = SparkSession.builder.appName('sparkdf').getOrCreate()  # list  of college data with  dictionary # with three  dictionariesdata = [{'student_id': 12, 'name': 'sravan', 'address': 'kakumanu'},        {'student_id': 14, 'name': 'jyothika', 'address': 'tenali'},        {'student_id': 11, 'name': 'deepika', 'address': 'repalle'}]  # creating a dataframedataframe = spark.createDataFrame(data)  # show data framedataframe.show()
Output:
Picked
Python-Pyspark
Python
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
Python OOPs Concepts
Python | Get unique values from a list
Check if element exists in list in Python
Python Classes and Objects
Python | os.path.join() method
How To Convert Python Dictionary To JSON?
Python | Pandas dataframe.groupby()
Create a directory in Python
How to get smooth interpolation when using pcolormesh (Matplotlib)?

To get smooth interpolation when using pcolormesh, we can use shading="gouraud" class by name.
Set the figure size and adjust the padding between and around the subplots.
Set the figure size and adjust the padding between and around the subplots.
Create data, x and y using numpy meshgrid.
Create data, x and y using numpy meshgrid.
Create a pseudocolor plot with a non-regular rectangular grid using pcolormesh() method.
Create a pseudocolor plot with a non-regular rectangular grid using pcolormesh() method.
To display the figure, use show() method.
To display the figure, use show() method.
import matplotlib.pylab as plt
import numpy as np

plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True

data = np.random.random((3, 3))
x = np.arange(0, 3, 1)
y = np.arange(0, 3, 1)
x, y = np.meshgrid(x, y)

plt.pcolormesh(x, y, data, cmap='RdBu', shading='gouraud')

plt.show()
Set size() method in Java with Example - GeeksforGeeks

31 Dec, 2018
The java.util.Set.size() method is used to get the size of the Set or the number of elements present in the Set.
Syntax:
int size()

Parameters: This method does not takes any parameter.
Return Value: The method returns the size or the number of elements present in the Set.
Below program illustrate the java.util.Set.size() method:
// Java code to illustrate Set.size() method  import java.util.*;  public class SetDemo {    public static void main(String args[])    {        // Creating an empty Set        Set<String> set = new HashSet<String>();          // Use add() method to add elements into the Set        set.add("Welcome");        set.add("To");        set.add("Geeks");        set.add("4");        set.add("Geeks");          // Displaying the Set        System.out.println("Set: " + set);          // Displaying the size of the Set        System.out.println("The size of the set is: " + set.size());    }}
Set: [4, Geeks, Welcome, To]
The size of the set is: 4

Reference: https://docs.oracle.com/javase/7/docs/api/java/util/Set.html#size()
Java-Collections
Java-Functions
java-set
Java
Java
Java-Collections
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Object Oriented Programming (OOPs) Concept in Java
HashMap in Java with Examples
How to iterate any Map in Java
Interfaces in Java
ArrayList in Java
Stack Class in Java
Multidimensional Arrays in Java
Singleton Class in Java
LinkedList in Java
Collections in Java
Difference between DELETE and TRUNCATE - GeeksforGeeks

12 Jan, 2022
1. DELETE : DELETE is a DML(Data Manipulation Language) command and is used when we specify the row(tuple) that we want to remove or delete from the table or relation. The DELETE command can contain a WHERE clause. If the WHERE clause is used with the DELETE command then it removes or deletes only those rows(tuple) that satisfy the condition otherwise by default it removes all the tuples(rows) from the table.  Remember that DELETE logs the row deletions.
Syntax of DELETE command : 
DELETE FROM TableName 
WHERE condition; 
2. TRUNCATE : TRUNCATE is a DDL(Data Definition Language) command and is used to delete all the rows or tuples from a table. Unlike the DELETE command, the TRUNCATE command does not contain a WHERE clause. In the TRUNCATE command, the transaction log for each deleted data page is not recorded. Unlike the DELETE command, the TRUNCATE command is fast. We cannot roll back the data after using the TRUNCATE command. 
Syntax of TRUNCATE command:- 
TRUNCATE TABLE  TableName; 
Let’s see the difference between DELETE and TRUNCATE command:- 
MKS075
kumarsanu805128
gbothra38
azamh64
SQL-Clauses
DBMS
Difference Between
GATE CS
SQL
DBMS
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Introduction of B-Tree
Difference between Clustered and Non-clustered index
CTE in SQL
Introduction of ER Model
SQL | Views
Difference between BFS and DFS
Class method vs Static method in Python
Differences between TCP and UDP
Difference between var, let and const keywords in JavaScript
Difference between Process and Thread
How to find the number of links in a document in JavaScript?

Javascript DOM has provided many properties to get the details regarding a document. It has provided a method called document.links.length to get the number of links that a document contains. This method won't disturb the code's normal functionality.
In the following example, there are three links provided in the code. Using the DOM property document.links.length the number of links were displayed in the output as shown.
Live Demo
<html>
<body>
   <a href="https://www.tutorialspoint.com/javascript/index.htm">Javascript</a><br>
   <a href="https://www.tutorialspoint.com/php/index.htm">Php</a><br>
   <a href="https://www.tutorialspoint.com/java8/index.htm">Php</a><br>
<p id="links"></p>
<script>
   document.getElementById("links").innerHTML =
   "The number of links are: " + document.links.length;
</script>
</body>
</html>
Javascript
Php
Java
The number of links are: 3
In the following example, there are two links provided in the code. Using the DOM property document.links.length the number of links were displayed in the output as shown.
Live Demo
<html>
<body>
   <a href="https://www.tutorialspoint.com/javascript/index.htm">Javascript</a><br>
   <a href="https://www.tutorialspoint.com/bitcoin/index.htm">Bitcoin</a></br>
<script>
   document.write("The number of links are: " + document.links.length);
</script>
</body>
</html>
Javascript
Bitcoin
The number of links are: 2
How to traverse a C++ set in reverse direction

05 Dec, 2018
Given a Set, the task is to traverse this Set in reverse order.
Examples:
Input: set = [10 20 30 70 80 90 100 40 50 60]
Output: 100 90 80 70 60 50 40 30 20 10 

Input: set = [1 2 3 4 5]
Output: 5 4 3 2 1

Approach:To traverse a Set in reverse order, a reverse_iterator can be declared on it and it can be used to traverse the set from the last element to the first element with the help of rbegin() and rend() functions.
Get the set.Declare the reverse iterator on this set.Traverse the set from the last element to the first element with the help of rbegin() and rend() functions.
Get the set.
Declare the reverse iterator on this set.
Traverse the set from the last element to the first element with the help of rbegin() and rend() functions.
Below is the implementation of the above approach:
Program:
#include <bits/stdc++.h>using namespace std;  int main(){      // Get the set    int arr[] = { 14, 12, 15, 11, 10 };      // initializes the set from an array    set<int> s(arr, arr + sizeof(arr) / sizeof(arr[0]));      // declare iterator on set    set<int>::iterator it;      cout << "Elements of Set in normal order:\n";      // prints all elements in normal order    // using begin() and end() methods    for (it = s.begin(); it != s.end(); it++)        cout << *it << " ";      // declare reverse_iterator on set    set<int>::reverse_iterator rit;      cout << "\nElements of Set in reverse order:\n";      // prints all elements in reverse order    // using rbegin() and rend() methods    for (rit = s.rbegin(); rit != s.rend(); rit++)        cout << *rit << " ";      return 0;}
Elements of Set in normal order:
10 11 12 14 15 
Elements of Set in reverse order:
15 14 12 11 10

cpp-set
Picked
STL
C++
STL
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Sorting a vector in C++
Polymorphism in C++
Pair in C++ Standard Template Library (STL)
Friend class and function in C++
std::string class in C++
Queue in C++ Standard Template Library (STL)
std::find in C++
Unordered Sets in C++ Standard Template Library
List in C++ Standard Template Library (STL)
vector insert() function in C++ STL
How to Use axis=0 and axis=1 in Pandas?

19 Dec, 2021
In this article, we will discuss how to use axis=0 and axis=1 in pandas using Python.
Sometimes we need to do operations only on rows, and sometimes only on columns, in such situations, we specify the axis parameter. In this article, let’s see a few examples to know when and how to use the axis parameter. In pandas axis = 0 refers to horizontal axis or rows and axis = 1 refers to vertical axis or columns. 
When the axis is set to zero while performing a specific action, the action is performed on rows that satisfy the condition.
Dataset Used:
Example: Using axis=0
Python3
# importing packagesimport pandas as pd  # importing our datasetdf = pd.read_csv('hiring.csv')  # dropping the column named 'experience'df = df.drop([0, 3], axis=0)  # 'viewing the dataframedf.head()
Output:
Example: Using axis=0
Python3
# importing packagesimport pandas as pd  # creating a datasetdf = pd.DataFrame([[1, 2, 3], [4, 5, 6],                   [7, 8, 9], [10, 11, 12]],                  columns=['a', 'b', 'c'])  # viewing the dataFrameprint(df)  # finding mean by rowsdf.mean(axis='rows')
Output:
When the axis is set to one while performing a specific action, the action is performed on column(s) that satisfy the condition.
Example: Using axis=1
Python3
# importing packagesimport pandas as pd  # importing our datasetdf = pd.read_csv('hiring.csv')  # dropping the column named 'experience'df = df.drop(['experience'], axis=1)  # 'viewing the dataframedf.head()
Output:
Example: Using axis=1
Python3
# importing packagesimport pandas as pd  # creating a datasetdf = pd.DataFrame([[1, 2, 3], [4, 5, 6],                   [7, 8, 9], [10, 11, 12]],                   columns=['a', 'b', 'c'])  # viewing the dataFrameprint(df)  # finding mean by columnsdf.mean(axis='columns')
Output:
Picked
Python pandas-dataFrame
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
Python | os.path.join() method
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 | Get unique values from a list
Python | datetime.timedelta() function