code-rag-bench/online-tutorials huggingface dataset:
C# | Check if two Tuple Objects are equal - GeeksforGeeks

10 May, 2019
A tuple is a data structure which gives you the easiest way to represent a data set. You can also check if the given tuple object is equal to the specified object or not using the Equals Method. This method will return true if the given tuple object is equal to the specified object, otherwise, return false.
Syntax:
public override bool Equals (object obj);
Here, obj is the object to compare with this instance.
Return Type: The return type of this method is Boolean. Means it will return true if the tuple object is equal to the given object. Otherwise, return false.
Importatnt Points: This obj parameter is considered to be equal when it meets the following conditions:
If it it is a Tuple<> object. Here Tuple<> is may be of 1-tuple, or 2-tuple, or 3-tuple, or 4-tuple, or 5-tuple, or 6-tuple, or 7-tuple, or 8-tuple.
It must contain the same number of elements that are of the same types as the current instance.
Its elements (including its nested components) are equal to those of the current instance. The equality is determined by the default equality comparer for each element.
Below programs illustrate the use of the above-discussed method:
Example 1:
// C# program to illustrate the // Equals methodusing System;  class GFG {      // Main Method    static public void Main()    {          // Taking tuple variables        var t1 = Tuple.Create(12, 34, 56, 78);        var t2 = Tuple.Create(12, 34, 67, 89);        var t3 = Tuple.Create(12, 34, 56, 78);        var t4 = Tuple.Create(34, 56, 78);          // Check whether the given         // tuples are Equal or not        // Using Equals() method        Console.WriteLine(t1.Equals(t2));        Console.WriteLine(t1.Equals(t3));        Console.WriteLine(t1.Equals(t4));    }}
False
True
False

Example 2:
// C# program to illustrate Equals// method with nested tupleusing System;  class GFG {      // Main Method    static public void Main()    {          // Taking Tuples        var t1 = Tuple.Create(34, 56, 78, Tuple.Create(12, 34, 56, 78));        var t2 = Tuple.Create(12, 34, 67, 89);        var t3 = Tuple.Create(12, 34, 56, Tuple.Create(23, 56));        var t4 = Tuple.Create(34, 56, 78, Tuple.Create(12, 34, 56, 78));        var t5 = Tuple.Create(12, 34, 56, Tuple.Create(24, 56));          // Check whether the given         // tuples are Equal or not        // Using Equals() method        Console.WriteLine(t1.Equals(t2));        Console.WriteLine(t1.Equals(t3));        Console.WriteLine(t1.Equals(t4));        Console.WriteLine(t3.Equals(t5));        Console.WriteLine(t1.Equals(t5));    }}
False
False
True
False
False

Akanksha_Rai
CSharp-Tuple
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Destructors in C#
Extension Method in C#
HashSet in C# with Examples
Top 50 C# Interview Questions & Answers
C# | How to insert an element in an Array?
Partial Classes in C#
C# | Inheritance
C# | List Class
Difference between Hashtable and Dictionary in C#
Lambda Expressions in C#
How to throw a C++ exception?

Exception handling is used to handle the exceptions. We can use try catch block to protect the code. Exception can be thrown anywhere within the code block. The keyword “throw” is used to throw an exception.
Here is an example of throw in C++ language,
 Live Demo
#include <iostream>
using namespace std;

int display(int x, int y) {
   if( y == 0 ) {
      throw "Division by zero condition!";
   }
   return (x/y);
}

int main () {
   int a = 50;
   int b = 0;
   int c = 0;

   try {
      c = display(a, b);
      cout << c << endl;
   } catch (const char* msg) {
      cerr << msg << endl;
   }
   return 0;
}
Here is the output
Division by zero condition!
OpenCV | Motion Blur in Python

26 Aug, 2019
This article explains how to add blur to an image using OpenCV. Motion blur is a specific type of blur used to lend a directed blur effect to images.
The Motion Blur FilterApplying motion blur to an image boils down to convolving a filter across the image. Sample 5*5 filter filters are given below.
Vertical:
Horizontal:
The greater the size of the filter, the greater will be the motion blur effect. Further, the direction of 1’s across the filter grid is the direction of the desired motion. To customize a motion blur in a specific vector direction, e.g. diagonally, simply place the 1’s along the vector to create the filter.
CodeConsider the following image of a car.
Code: Python code for applying a motion blur effect on the image.
# loading libraryimport cv2import numpy as np  img = cv2.imread('car.jpg')  # Specify the kernel size.# The greater the size, the more the motion.kernel_size = 30  # Create the vertical kernel.kernel_v = np.zeros((kernel_size, kernel_size))  # Create a copy of the same for creating the horizontal kernel.kernel_h = np.copy(kernel_v)  # Fill the middle row with ones.kernel_v[:, int((kernel_size - 1)/2)] = np.ones(kernel_size)kernel_h[int((kernel_size - 1)/2), :] = np.ones(kernel_size)  # Normalize.kernel_v /= kernel_sizekernel_h /= kernel_size  # Apply the vertical kernel.vertical_mb = cv2.filter2D(img, -1, kernel_v)  # Apply the horizontal kernel.horizonal_mb = cv2.filter2D(img, -1, kernel_h)  # Save the outputs.cv2.imwrite('car_vertical.jpg', vertical_mb)cv2.imwrite('car_horizontal.jpg', horizonal_mb)
Output
Vertical Blur:
Horizontal Blur:
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
How to Install PIP on Windows ?
Python String | replace()
*args and **kwargs in Python
Python Classes and Objects
Python OOPs Concepts
Iterate over a list in Python
PyQt5 – How to delete all the items in ComboBox ?

22 Apr, 2020
In this article we will see how we can clear all the items in the combo box. We know we can add items in the combo box with the help of addItem method to add single item and addItems method to add multiple items. In order to delete all the items in the combo box we will use clear method.
Syntax : combo_box.clear()
Argument : It takes no argument
Action performed : It will delete all the items of combo box
Steps for implementation:
1. Create a combo box2. Add items to combo box3. Create push button4. Add action to the push button5. Inside the action delete the items of combo box with the help of clear method
Below is the implementation –
# 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 combo box widget        self.combo_box = QComboBox(self)          # setting geometry of combo box        self.combo_box.setGeometry(200, 150, 120, 30)          # geek list        geek_list = ["Geek", "Geeky Geek", "Legend Geek", "Ultra Legend Geek"]          # adding list of items to combo box        self.combo_box.addItems(geek_list)          # creating push button to clear the list        button = QPushButton("Clear", self)          # adding action to button        button.pressed.connect(self.delete)      def delete(self):          # delete items of list        self.combo_box.clear()  # create pyqt5 appApp = QApplication(sys.argv)  # create the instance of our Windowwindow = Window()  # start the appsys.exit(App.exec())
Output :
Python PyQt5-ComboBox
Python-gui
Python-PyQt
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
What is autoFlush attribute in JSP?

The autoFlush attribute specifies whether the buffered output should be flushed automatically when the buffer is filled, or whether an exception should be raised to indicate the buffer overflow.
A value of true (default) indicates automatic buffer flushing and a value of false throws an exception.
The following directive causes the servlet to throw an exception when the servlet's output buffer is full −
<%@ page autoFlush = "false" %>
This directive causes the servlet to flush the output buffer when full −
<%@ page autoFlush = "true" %>
Usually, the buffer and the autoFlush attributes are coded on a single page directive as follows −
<%@ page buffer = "16kb" autoflush = "true" %>
0/1 Knapsack using Branch and Bound in C++

The idea is to implement the fact that the Greedy approach provides the best solution for Fractional Knapsack problem.
To check whether a particular node can give us a better solution or not, we calculate the optimal solution (through the node) implementing Greedy approach. If the solution calculated by Greedy approach itself is more than the best so far, then we can’t obtain a better solution through the node.
Complete Algorithm is given below −
Sort all items according to decreasing order of ratio of value per unit weight so that an upper bound can becalculated implementing Greedy Approach.
Sort all items according to decreasing order of ratio of value per unit weight so that an upper bound can becalculated implementing Greedy Approach.
Initialize maximum profit, such as maxProfit = 0
Initialize maximum profit, such as maxProfit = 0
An empty queue, Q, is created.
An empty queue, Q, is created.
A dummy node of decision tree is created and insert or enqueue it to Q. Profit and weight of dummy node be 0.
A dummy node of decision tree is created and insert or enqueue it to Q. Profit and weight of dummy node be 0.
Do following while Q is not vacant or empty.An item from Q is created. Let the extracted item be u.Calculate profit of next level node. If the profit is higher than maxProfit, then modify maxProfit.Calculate bound of next level node. If bound is higher than maxProfit, then add next level node to Q.Consider the case when next level node is not treated or considered as part of solution and add a node to queue with level as next, but weight and profit without treating or considering next level nodes.
Do following while Q is not vacant or empty.
An item from Q is created. Let the extracted item be u.
An item from Q is created. Let the extracted item be u.
Calculate profit of next level node. If the profit is higher than maxProfit, then modify maxProfit.
Calculate profit of next level node. If the profit is higher than maxProfit, then modify maxProfit.
Calculate bound of next level node. If bound is higher than maxProfit, then add next level node to Q.
Calculate bound of next level node. If bound is higher than maxProfit, then add next level node to Q.
Consider the case when next level node is not treated or considered as part of solution and add a node to queue with level as next, but weight and profit without treating or considering next level nodes.
Consider the case when next level node is not treated or considered as part of solution and add a node to queue with level as next, but weight and profit without treating or considering next level nodes.
Illustrationis given below −
// First thing in every pair is treated as weight of item
// and second thing is treated as value of item
Item arr1[] = {{2, 40}, {3.14, 50}, {1.98, 100},
{5, 95}, {3, 30}};
Knapsack Capacity W1 = 10

The maximum possible profit = 235
C Program for efficiently print all prime factors of a given number?

In this section, we will see how we can get all the prime factors of a number in an efficient way. There is a number say n = 1092, we have to get all prime factors of this. The prime factors of 1092 are 2, 2, 3, 7, 13. To solve this problem, we have to follow this rule −
When the number is divisible by 2, then print 2, and divide the number by 2 repeatedly.
When the number is divisible by 2, then print 2, and divide the number by 2 repeatedly.
Now the number must be odd. Now starting from 3 to square root of the number, if the number is divisible by current value, then print, and change the number by divide it with the current number then continue.
Now the number must be odd. Now starting from 3 to square root of the number, if the number is divisible by current value, then print, and change the number by divide it with the current number then continue.
Let us see the algorithm to get a better idea.
begin
   while n is divisible by 2, do
      print 2
      n := n / 2
   done
   for i := 3 to √n, increase i by 2, do
      while n is divisible by i, do
         print i
         n := n / i
      done
   done
   if n > 2, then
      print n
   end if
end
#include<stdio.h>
#include<math.h>
void primeFactors(int n) {
   int i;
   while(n % 2 == 0) {
      printf("%d, ", 2);
      n = n/2; //reduce n by dividing this by 2
   }
   for(i = 3; i <= sqrt(n); i=i+2){ //i will increase by 2, to get only odd numbers
      while(n % i == 0) {
         printf("%d, ", i);
         n = n/i;
      }
   }
   if(n > 2) {
      printf("%d, ", n);
   }
}
main() {
   int n;
   printf("Enter a number: ");
   scanf("%d", &n);
   primeFactors(n);
}
Enter a number: 24024
2, 2, 2, 3, 7, 11, 13,
Relative Positioning in CSS

With relative positioning, the element is positioned relative to its normal position. For this, use position: relative
Let us now see an example −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<style>
div.demo {
   position: relative;
   color: white;
   background-color: orange;
   border: 2px dashed blue;
   left: 50px;
}
</style>
</head>
<body>
<h2>Demo Heading</h2>
<p>This is demo text.</p>
<p>This is demo text.</p>
<div class="demo">
position: relative;
</div>
<p>This is another demo text.</p>
</body>
</html>
\hdashline - Tex Command

\hdashline - Used to draw horizontal dash line.
{ \hdashline }
\hdashline command draws horizontal dash line.

\begin{matrix}
x_{11} & x_{12} \\
x_{21} & x_{22} \strut \\
\hdashline
x_{31} & x_{32} \strut
\end{matrix}

x11x12x21x22x31x32



\begin{matrix}
x_{11} & x_{12} \\
x_{21} & x_{22} \strut \\
\hdashline
x_{31} & x_{32} \strut
\end{matrix}

x11x12x21x22x31x32


\begin{matrix}
x_{11} & x_{12} \\
x_{21} & x_{22} \strut \\
\hdashline
x_{31} & x_{32} \strut
\end{matrix}

    14 Lectures 
     52 mins

 Ashraf Said

    11 Lectures 
     1 hours 

 Ashraf Said

    9 Lectures 
     1 hours 

 Emenwa Global, Ejike IfeanyiChukwu

    29 Lectures 
     2.5 hours 

 Mohammad Nauman

    14 Lectures 
     1 hours 

 Daniel Stern

    15 Lectures 
     47 mins

 Nishant Kumar
 Print
 Add Notes
 Bookmark this page
Use error bars in a Matplotlib scatter plot

17 Dec, 2020
Prerequisites: Matplotlib
In this article, we will create a scatter plot with error bars using Matplotlib. Error bar charts are a great way to represent the variability in your data. It can be applied to graphs to provide an additional layer of detailed information on the presented data. 
Import required python library.
Create data.
Pass required values to errorbar() function
Plot graph.
Syntax: matplotlib.pyplot.errorbar(x, y, yerr=None, xerr=None, fmt=”, ecolor=None, elinewidth=None, capsize=None, barsabove=False, lolims=False, uplims=False, xlolims=False, xuplims=False, errorevery=1, capthick=None, \*, data=None, \*\*kwargs)
Parameters: This method accept the following parameters that are described below:
x, y: These parameters are the horizontal and vertical coordinates of the data points.
fmt: This parameter is an optional parameter and it contains the string value.
capsize: This parameter is also an optional parameter. And it is the length of the error bar caps in points with default value NONE.
Implementation of the concept discussed above is given below:
Example 1: Adding Some error in a ‘y’ value.
Python3
import matplotlib.pyplot as plt  a = [1, 3, 5, 7]b = [11, -2, 4, 19]plt.scatter(a, b)  c = [1, 3, 2, 1]  plt.errorbar(a, b, yerr=c, fmt="o")plt.show()
Output:
Example 2: Adding Some errors in the ‘x’ value.
Python3
import matplotlib.pyplot as plt  a = [1, 3, 5, 7]b = [11, -2, 4, 19]plt.scatter(a, b)  c = [1, 3, 2, 1]  plt.errorbar(a, b, xerr=c, fmt="o")plt.show()
Output:
Example 3: Adding error in x & y
Python3
import matplotlib.pyplot as plt  a = [1, 3, 5, 7]b = [11, -2, 4, 19]plt.scatter(a, b)    c = [1, 3, 2, 1]d = [1, 3, 2, 1]  # you can use color ="r" for red or skip to default as blueplt.errorbar(a, b, xerr=c, yerr=d, fmt="o", color="r")  plt.show()
Output:
Example 4: Adding variable error in x and y.
Python3
# importing matplotlibimport matplotlib.pyplot as plt    # making a simple plotx = [1, 2, 3, 4, 5]y = [1, 2, 1, 2, 1]  # creating errory_errormin = [0.1, 0.5, 0.9,              0.1, 0.9]y_errormax = [0.2, 0.4, 0.6,              0.4, 0.2]  x_error = 0.5y_error = [y_errormin, y_errormax]  # ploting graph# plt.plot(x, y)plt.errorbar(x, y,             yerr=y_error,             xerr=x_error,             fmt='o')  plt.show()
Output:
Picked
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 ?
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
Create a directory in Python
Getting the minimum value from a list in Julia – min() Method

21 Apr, 2020
The min() is an inbuilt function in julia which is used to return the minimum value of the parameters.
Syntax: min(x, y, ...)
Parameters:
x: Specified 1st value.
y: Specified 2nd value and so on.
Returns: It returns the minimum value of the parameters.
Example 1:
# Julia program to illustrate # the use of min() method  # Getting the minimum value of the parameters.println(min(1, 2, 3, 4))println(min(1, 3, 5))println(min(2, 4, 6))
Output:
1
1
2

Example 2:
# Julia program to illustrate # the use of min() method  # Getting the minimum value of the parameters.println(min(0.6, 0.7, 0.2))println(min(2.5, 3.5, 0.3, 1.7))
Output:
0.2
0.3

Julia
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Vectors in Julia
Getting rounded value of a number in Julia - round() Method
Manipulating matrices in Julia
Reshaping array dimensions in Julia | Array reshape() Method
Exception handling in Julia
Formatting of Strings in Julia
Get number of elements of array in Julia - length() Method
Storing Output on a File in Julia
Get array dimensions and size of a dimension in Julia - size() Method
Tuples in Julia
Python sympy | Matrix.nullspace() method

13 Aug, 2019
With the help of sympy.Matrix().nullspace() method, we can find the Nullspace of a Matrix. Matrix().nullspace() returns a list of column vectors that span the nullspace of the matrix.
Syntax: Matrix().nullspace()
Returns: Returns a list of column vectors that span the nullspace of the matrix.
Example #1:
# import sympy from sympy import *   M = Matrix([[1, 0, 1, 3], [2, 3, 4, 7], [-1, -3, -3, -4]])print("Matrix : {} ".format(M))   # Use sympy.nullspace() method M_nullspace = M.nullspace()        print("Nullspace of a matrix : {}".format(M_nullspace))  
Output:
Matrix : Matrix([[1, 0, 1, 3], [2, 3, 4, 7], [-1, -3, -3, -4]]) 
Nullspace of a matrix : [Matrix([
[  -1],
[-2/3],
[   1],
[   0]]), Matrix([
[  -3],
[-1/3],
[   0],
[   1]])]

Example #2:
# import sympy from sympy import *   M = Matrix([[14, 0, 11, 3], [22, 23, 4, 7], [-12, -34, -3, -4]])print("Matrix : {} ".format(M))   # Use sympy.nullspace() method M_nullspace = M.nullspace()        print("Nullspace of a matrix : {}".format(M_nullspace)) 
Output:
Matrix : Matrix([[14, 0, 11, 3], [22, 23, 4, 7], [-12, -34, -3, -4]]) 
Nullspace of a matrix : [Matrix([
[-1405/4254],
[   -10/709],
[  314/2127],
[         1]])]

SymPy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Iterate over a list in Python
Python OOPs Concepts
CSS clamp() Method

15 Oct, 2020
The clamp() method is used to clamp the value between an upper and lower bound. It takes three parameters which are listed below:
Minimum value
Preferred value
Maximum value
The minimum value comes in handy when the preferred value is smaller than the minimum value similarly maximum value comes in handy when the preferred value is more than the maximum value. The preferred value becomes useful when it is between the minimum and maximum value.
The clamp() function can be used with the various elements such as font-size, width etc. Lets built a simple layout to get a clear understanding of the clamp() function
Syntax : 
clamp(value1, value2, value3)
Parameters:
Here value1 represents the minimum value, value2 represents the preferred value and value3 represents the maximum value.
Example:
<!DOCTYPE html><html>  <head>    <style>          /* Setting clamp property of heading */        h1 {            font-size: clamp(2rem, 4vw, 4rem);            color: #eb4034;        }          /* Setting clamp property of box */        .box {            width: clamp(150px, 50%, 400px);            height: 8rem;            background: #5f76e8;        }    </style></head>  <body>    <div class="container">        <h1>Welcome To GFG</h1>        <div class="box"></div>    </div></body>  </html>
Output:
In the above-shown example, we see how easily the width and font-size are adjusted according to viewport with the help of the clamp function. The clamp() function is very useful for typography and for creating fluid layout.
Supported Browsers:
Chrome
Opera
Safari
Firefox
Edge
CSS-Properties
CSS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to set space between the flexbox ?
Design a Tribute Page using HTML & CSS
Form validation using jQuery
How to Change the Position of Scrollbar using CSS ?
What is the difference between SCSS and SASS ?
Installation of Node.js on Linux
How to set the default value for an HTML <select> element ?
How do you run JavaScript script through the Terminal?
Node.js fs.readFileSync() Method
How to set space between the flexbox ?
p5.js | html() Function

20 Aug, 2019
The html() function is used to set the inner HTML of the element by replacing any existing html. If the value of the second parameter is true then html is appended instead of replacing the existing html element. If this function does not contain any parameters then it returns the inner HTML of the element.
Note: This function requires the p5.dom library. So add the following line in the head section of the index.html file.
<script language="javascript"     type="text/javascript" src="path/to/p5.dom.js"></script>
Syntax:
html()
or
html( html, append )
Parameters:
html: This parameter holds the HTML element in string format which needs to be placed inside the element.
append: This parameter holds the Boolean value to append existing HTML element.
Return Value: This function returns a string which contains the inner HTML of the element.
Below examples illustrate the html() function in p5.js:
Example 1:
function setup() {          // Create a canvas of given size    createCanvas(400, 200);          // Set background color    background('green');          var div = createDiv('');          // Use html() function    div.html('Welcome to GeeksforGeeks');           // Set the position of div element    div.position(60, 80);         // Set font-size of text    div.style('font-size', '24px');        // Set font-color of text    div.style('color', 'white');  } 
Output:
Example 2:
function setup() {          // Create canvas of given size    createCanvas(400, 200);          // Set background color    background('green');          var div = createDiv('').size(200, 70);      // Use html() function        div.html('Welcome to GeeksforGeeks', true);           // Set the position of div element    div.position(100, 60);         // Set font-size of text    div.style('font-size', '24px');        // Set font-color of text    div.style('color', 'white');        div.style('border', '1px solid white');        div.style('text-align', 'center');  } 
Output:
JavaScript-p5.js
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
Difference Between PUT and PATCH Request
How to append HTML code to a div using JavaScript ?
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
numpy.rollaxis() function | Python

22 Apr, 2020
numpy.rollaxis() function roll the specified axis backwards, until it lies in a given position.
Syntax : numpy.rollaxis(arr, axis, start=0)Parameters :arr : [ndarray] Input array.axis : [int] The axis to roll backwards. The positions of the other axes do not change relative to one another.start : [int, optional] The axis is rolled until it lies before this position. The default, 0, results in a “complete” roll.Return : [ndarray] In earlier NumPy versions, arr is returned only if the order of the axes is changed, otherwise the input array is returned. For NumPy >= 1.10.0, a view of arr is always returned.
Code #1 :
# Python program explaining# numpy.rollaxis() function  # importing numpy as geek import numpy as geek  arr = geek.ones((1, 2, 3, 4))  gfg = geek.rollaxis(arr, 3, 1).shape  print (gfg)
Output :
(1, 4, 2, 3)

 Code #2 :
# Python program explaining# numpy.rollaxis() function  # importing numpy as geek import numpy as geek  arr = geek.ones((1, 2, 3, 4))  gfg = geek.rollaxis(arr, 2).shape  print (gfg)
Output :
(3, 1, 2, 4)

Python numpy-arrayManipulation
Python-numpy
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 | os.path.join() method
Introduction To PYTHON
Python OOPs Concepts
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
Create a directory in Python
How to toggle a div visibility using jQuery?

To toggle a div visibility in jQuery, use the toggle() method. It checks the div element for visibility i.e. the show() method if div is hidden. And hide() id the div element is visible. This eventually creates a toggle effect.
The toggle( speed, [callback]) method toggles displaying each of the set of matched elements using a graceful animation and firing an optional callback after completion.
Here is the description of all the parameters used by this method −
speed − A string representing one of the three predefined speeds ("slow", "normal", or "fast") or the number of milliseconds to run the animation (e.g. 1000).
callback − This is optional parameter representing a function to call once the animation is complete.
You can try to run the following code to toggle div visibility using jQuery −
Live Demo
<html>

   <head>
      <title>jQuery toggle() method</title>
      <script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
       
      <script>
   
         $(document).ready(function() {

            $("#toggle").click(function(){
               $(".target").toggle( 'slow', function(){
                  $(".log").text('Toggle Transition Complete');
               });
            });
         });
           
      </script>
       
      <style>
         p {
             background-color:#bca;
             width:200px;
             border:1px solid green;
         }
      </style>
   </head>
   
   <body>

      <p>Click on the following button:</p>
      <button id = "toggle"> Toggle </button>

      <div class = "target">
         <img src = "../images/jquery.jpg" alt = "jQuery" />
      </div>
       
      <div class = "log"></div>
 
   </body>
</html>
Simple Arithmetic Operators Example Program In C++

C++ has 5 basic arithmetic operators. They are −
Addition(+)
Subtraction(-)
Division(/)
Multiplication(*)
Modulo(%)
These operators can operate on any arithmetic operations in C++. Let's have a look at an example −
#include <iostream>
using namespace std;
main() {
   int a = 21;
   int b = 10;
   int c ;
   c = a + b;
   cout << "Line 1 - Value of c is :" << c << endl ;
   
   c = a - b;
   cout << "Line 2 - Value of c is  :" << c << endl ;
   
   c = a * b;
   cout << "Line 3 - Value of c is :" << c << endl ;
   
   c = a / b;
   cout << "Line 4 - Value of c is  :" << c << endl ;
   
   c = a % b;
   cout << "Line 5 - Value of c is  :" << c << endl ;
   return 0;
}
This will give the output −
Line 1 - Value of c is :31
Line 2 - Value of c is  :11
Line 3 - Value of c is :210
Line 4 - Value of c is  :2
Line 5 - Value of c is  :1
Menu Driven C++ Program for a Simple Calculator - GeeksforGeeks

16 Jul, 2019
Problem Statement:Write a menu-driven program using the Switch case to calculate the following:
Addition of two numbersDifference between two numbersProduct of two numbersDivision of two numbersHCF of two numbersLCM of two numbers
Addition of two numbers
Difference between two numbers
Product of two numbers
Division of two numbers
HCF of two numbers
LCM of two numbers
Examples:
Input: num1 = 5, num2 = 7, choice = 1
Output: Sum is 12

Input: num1 = 5, num2 = 7, choice = 5
Output: GCD is 1

Implementation:
// C++ program to illustrate// Menu-Driven program using Switch-case  #include <bits/stdc++.h>using namespace std;  // Function to display the menuvoid menu(){    cout << "Press 1 to calculate Sum of Numbers\n";    cout << "Press 2 to calculate Difference of Numbers\n";    cout << "Press 3 to calculate Product of numbers\n";    cout << "Press 4 to calculate Division of numbers\n";    cout << "Press 5 to calculate HCF of numbers\n";    cout << "Press 6 to calculate LCM of numbers\n";    cout << "Press 7 to exit\n";}  // Function to calculate and display the resultvoid result(int choice, int a, int b){      // Display the result    switch (choice) {    case 1: {        cout << "Sum is " << (a + b) << "\n";        break;    }    case 2: {        cout << "Difference is " << (a - b) << "\n";        break;    }    case 3: {        cout << "Product is " << (a * b) << "\n";        break;    }    case 4: {        cout << "Division is " << (a / b) << "\n";        break;    }    case 5: {        cout << "GCD is " << __gcd(a, b) << "\n";        break;    }    case 6: {        cout << "LCM is "             << ((a * b) / __gcd(a, b))             << "\n";        break;    }    case 7: {        cout << "Thank you\n";        break;    }    default:        printf("Wrong Input\n");    }}  int main(){      // Get the two numbers    int a = 5, b = 7;      int choice, res;      // Display the menu    menu();      // Enter the choice    cout << "Enter your choice:\n";    choice = 1;    cout << "Choice is " << choice << endl;      // Display the result    // according to the choice    result(choice, a, b);      return 0;}
Press 1 to calculate Sum of Numbers
Press 2 to calculate Difference of Numbers
Press 3 to calculate Product of numbers
Press 4 to calculate Division of numbers
Press 5 to calculate HCF of numbers
Press 6 to calculate LCM of numbers
Press 7 to exit
Enter your choice:
Choice is 1
Sum is 12

Time Complexity: O(n).
Menu driven programs
C++ Programs
Mathematical
School Programming
Mathematical
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
CSV file management using C++
C++ Program for QuickSort
cin in C++
Generics in C++
delete keyword in C++
Program for Fibonacci numbers
Write a program to print all permutations of a given string
C++ Data Types
Set in C++ Standard Template Library (STL)
Coin Change | DP-7
Python 3 - dictionary keys() Method

The method keys() returns a list of all the available keys in the dictionary.
Following is the syntax for keys() method −
dict.keys()

NA
This method returns a list of all the available keys in the dictionary.
The following example shows the usage of keys() method.
#!/usr/bin/python3

dict = {'Name': 'Zara', 'Age': 7}
print ("Value : %s" %  dict.keys())
When we run above program, it produces the following result −
Value : dict_keys(['Age', 'Name'])


    187 Lectures 
     17.5 hours 

 Malhar Lathkar

    55 Lectures 
     8 hours 

 Arnab Chakraborty

    136 Lectures 
     11 hours 

 In28Minutes Official

    75 Lectures 
     13 hours 

 Eduonix Learning Solutions

    70 Lectures 
     8.5 hours 

 Lets Kode It

    63 Lectures 
     6 hours 

 Abhilash Nelson
 Print
 Add Notes
 Bookmark this page
C# program to find the maximum of three numbers

Firstly, let’s set the three numbers −
int num1, num2, num3;
// set the value of the three numbers
num1 = 10;
num2 = 20;
num3 = 50;
Now check the first number with the second number. If num1 > num2, then check num1 with num3. If num1 is greater than num3, that would mean the largest number is num1.
You can try to run the following code to find the maximum of three numbers.
Live Demo
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Demo {
   class MyApplication {
      static void Main(string[] args) {
         int num1, num2, num3;
         // set the value of the three numbers
         num1 = 10;
         num2 = 20;
         num3 = 50;
         if (num1 > num2) {
            if (num1 > num3) {
               Console.Write("Number one is the largest!\n");
            } else {
               Console.Write("Number three is the largest!\n");
         }
      }
      else if (num2 > num3)
         Console.Write("Number two is the largest!\n");
      else
         Console.Write("Number three is the largest!\n");
      }
   }
}
Number three is the largest!
Java Examples - Read-only Collection

How to make a collection read-only ?
Following example shows how to make a collection read-only by using Collections.unmodifiableList() method of Collection class.
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class Main {
   public static void main(String[] argv) throws Exception {
      List stuff = Arrays.asList(new String[] { "a", "b" });
      List list = new ArrayList(stuff);
      list = Collections.unmodifiableList(list);
      try {
         list.set(0, "new value");
      } catch (UnsupportedOperationException e) {
      }
      Set set = new HashSet(stuff);
      set = Collections.unmodifiableSet(set);
      Map map = new HashMap();
      map = Collections.unmodifiableMap(map);
      System.out.println("Collection is read-only now.");
   }
}
The above code sample will produce the following result.
Collection is read-only now.

 Print
 Add Notes
 Bookmark this page
How to log in to the Azure account using Az CLI command in PowerShell?

To login to the Azure account using Azure CLI, we need to use the az login command. Once you type the az login command, it will prompt for the Azure portal login console.
If you need to log in with the device authentication code in the browser, you need to use the parameter –use-device-code.
PS C:\> az login --use-device-code
To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code ‘DeviceCode’ to authenticate.
You need to open a website https://microsoft.com/devicelogin/ and have to enter a code. If you are not already connected with the Microsoft Azure portal, you need to log in first.
You can also provide the username and password in the command line as shown below.
PS C:\> az login --username azureusername --password azurepassword
If the password is not provided, it will prompt for the secret password.
PS C:\> az login --username azureuseraccount
Password:
Truncate with condition in MySQL?

In MySQL, there is no way to truncate with condition. You cannot use truncate statement with where clause.
If you want the condition, use delete command −
DELETE FROM yourTableName WHERE youCondition;
The above syntax is fine but if you want a faster solution, then DELETE is not good in comparison to Truncate. The advantage with truncate is that it does not write to the logs.
Let us create a table. The query to create a table is as follows −
mysql> create table DeleteDemo
   -> (
   -> Id int,
   -> Name varchar(100)
   -> );
Query OK, 0 rows affected (1.22 sec)
Insert some records in the table using insert command. The query is as follows −
mysql> insert into DeleteDemo values(101,'Carol');
Query OK, 1 row affected (0.15 sec)

mysql> insert into DeleteDemo values(102,'Sam');
Query OK, 1 row affected (0.15 sec)

mysql> insert into DeleteDemo values(103,'Bob');
Query OK, 1 row affected (0.16 sec)

mysql> insert into DeleteDemo values(104,'Mike');
Query OK, 1 row affected (0.17 sec)

mysql> insert into DeleteDemo values(105,'John');
Query OK, 1 row affected (0.09 sec)

mysql> insert into DeleteDemo values(106,'Maria');
Query OK, 1 row affected (0.20 sec)

mysql> insert into DeleteDemo values(107,'Johnson');
Query OK, 1 row affected (0.17 sec)
Let us now display all records from the table using select command. The query is as follows −
mysql> select *from DeleteDemo;
+------+---------+
| Id   | Name    |
+------+---------+
|  101 | Carol   |
|  102 | Sam     |
|  103 | Bob     |
|  104 | Mike    |
|  105 | John    |
|  106 | Maria   |
|  107 | Johnson |
+------+---------+
7 rows in set (0.00 sec)
Now you can use delete command but that won’t truncate with where clause. The query to delete records from the table using where clause is as follows −
mysql> delete from DeleteDemo where Id>104;
Query OK, 3 rows affected (0.13 sec)
Let us check the table data once again using select command. The query is as follows −
mysql> select *from DeleteDemo;
+------+-------+
| Id   | Name  |
+------+-------+
|  101 | Carol |
|  102 | Sam   |
|  103 | Bob   |
|  104 | Mike  |
+------+-------+
4 rows in set (0.00 sec)
Look at the above sample output, all records greater than 104 is deleted from the table.
In MySQL how to select the top 2 rows for each group?

To select the top 2 rows from each group, use the where condition with subquery. Let us create a table. The query to create a table is as follows:
mysql> create table selectTop2FromEachGroup
   -> (
   -> Name varchar(20),
   -> TotalScores int
   -> );
Query OK, 0 rows affected (0.80 sec)
Now insert some records in the table using insert command. The query is as follows:
mysql> insert into selectTop2FromEachGroup values('John',32);
Query OK, 1 row affected (0.38 sec)
mysql> insert into selectTop2FromEachGroup values('John',33);
Query OK, 1 row affected (0.21 sec)
mysql> insert into selectTop2FromEachGroup values('John',34);
Query OK, 1 row affected (0.17 sec)
mysql> insert into selectTop2FromEachGroup values('Carol',35);
Query OK, 1 row affected (0.17 sec)
mysql> insert into selectTop2FromEachGroup values('Carol',36);
Query OK, 1 row affected (0.14 sec)
mysql> insert into selectTop2FromEachGroup values('Carol',37);
Query OK, 1 row affected (0.15 sec)
Display all records from the table using select statement. The query is as follows:
mysql> select *from selectTop2FromEachGroup;
The following is the output:
+-------+-------------+
| Name  | TotalScores |
+-------+-------------+
| John  |          32 |
| John  |          33 |
| John  |          34 |
| Carol |          35 |
| Carol |          36 |
| Carol |          37 |
+-------+-------------+
6 rows in set (0.00 sec)
Here is the query to select top 2 rows from each group using where condition and subquery:
mysql> select *from selectTop2FromEachGroup tbl
   -> where
   -> (
   ->    SELECT COUNT(*)
   ->    FROM selectTop2FromEachGroup tbl1
   ->    WHERE tbl1.Name = tbl.Name AND
   ->    tbl1.TotalScores >= tbl.TotalScores
   -> ) <= 2 ;
The following is the output:
+-------+-------------+
| Name  | TotalScores |
+-------+-------------+
| John  |          33 |
| John  |          34 |
| Carol |          36 |
| Carol |          37 |
+-------+-------------+
4 rows in set (0.06 sec)
How to merge two object arrays of different size by key in JavaScript

Suppose, we have an object like this −
const obj = {
   "part1": [{"id": 1, "a": 50},{"id": 2, "a": 55},{"id": 4, "a": 100}],
   "part2":[{"id": 1, "b": 40}, {"id": 3, "b": 45}, {"id": 4, "b": 110}]
};
We are required to write a JavaScript function that takes in one such object. The function should merge part1 and part2 of the object to form an array of objects like this −
const output = [
   {"id": 1, "a": 50, "b": 40},
   {"id": 2, "a": 55},
   {"id": 3, "b": 45},
   {"id": 4, "a": 100, "b": 110}
];
The code for this will be −
const obj = {
   "part1": [{"id": 1, "a": 50},{"id": 2, "a": 55},{"id": 4, "a": 100}],
   "part2":[{"id": 1, "b": 40}, {"id": 3, "b": 45}, {"id": 4, "b": 110}]
};
const mergeObject = (obj = {}) => {
   let result = [];
   result = Object.keys(obj).reduce(function (hash) {
      return function (r, k) {
         obj[k].forEach(function (o) {
            if (!hash[o.id]) {
               hash[o.id] = {};
               r.push(hash[o.id]);
            }
            Object.keys(o).forEach(function (l) {
               hash[o.id][l] = o[l];
            });
         });
         return r;
      };
   }(Object.create(null)), []).sort((a, b) => {
      return a['id'] − b['id'];
   });
   return result;
};
console.log(mergeObject(obj));
And the output in the console will be −
[
   { id: 1, a: 50, b: 40 },
   { id: 2, a: 55 },
   { id: 3, b: 45 },
   { id: 4, a: 100, b: 110 }
]
Tryit Editor v3.7

Tryit: Using align-self: center
PrimePy module in Python - GeeksforGeeks

05 Aug, 2021
A prime number is a natural number greater than 1 whose only factors are 1 and the number itself. 2 is the only even Prime number. We can represent any prime number with ‘6n+1’ or ‘6n-1’ (except 2 and 3) where n is a natural number.
primePy is that library of Python which is used to compute operations related to prime numbers. It will perform all the functions in less time with the help of the functions of this primePy module. 
This module does not come built-in with Python. You need to install it externally. To install this module type the below command in the terminal. 
 pip install primePy  
1. primes.check(n): It will return True if ‘n’ is a prime number otherwise it will return False.
Example:
Python3
# Importing primes function# From primePy Libraryfrom primePy import primes  print(primes.check(105))print(primes.check(71))
Output: 
False
True
2. primes.factor(n): It will return the lowest prime factor of ‘n’.
Example: 
Python3
# Importing primes function# From primePy Libraryfrom primePy import primes  a = primes.factor(15)print(a) a = primes.factor(75689456252)print(a)
Output: 
3
2
3. primes.factors(n): It will return all the prime factors of ‘n’ with repetition of factors if exist.
Example: 
Python3
# Importing primes function# From primePy Libraryfrom primePy import primes  a = primes.factors(774177)print(a) a = primes.factors(15)print(a)
Output: 
[3, 151, 1709]
[3, 5]
4. primes.first(n) : It will return first ‘n’ prime numbers.
Example: 
Python3
# Importing primes function# From primePy Libraryfrom primePy import primes  a = primes.first(5)print(a) a = primes.first(10)print(a)
Output: 
[2, 3, 5, 7, 11]
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29]
5. primes.upto(n): It will return all the prime numbers less than or equal to ‘n’.
Example: 
Python3
# Importing primes function# From primePy Libraryfrom primePy import primes  a = primes.upto(17)print(a) a = primes.upto(100)print(a)
Output:
[2, 3, 5, 7, 11, 13, 17] [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]  
6. primes.between(m, n): It will return all the prime numbers between m and n.
Example: 
Python3
# Importing primes function# From primePy Libraryfrom primePy import primes  a = primes.between(4, 15)print(a) a = primes.between(25, 75)print(a)
Output: 
[5, 7, 11, 13]
[29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73]
7. primes.phi(n): It will return the number of integers less than ‘n’ which have no common factor with n.
Example: 
Python3
# Importing primes function# From primePy Libraryfrom primePy import primes  a = primes.phi(5)print(a) a = primes.phi(10)print(a)
Output: 
4
4
 
simmytarika5
python-modules
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Python | Get unique values from a list
Python | os.path.join() method
Create a directory in Python
Defaultdict in Python
Python | Pandas dataframe.groupby()
Scroll Web Page Base On Pixel Method Using Selenium in Python - GeeksforGeeks

28 Apr, 2022
Selenium is a powerful tool for controlling web browsers through programs and performing browser automation. It is functional for all browsers, works on all major OS and its scripts are written in various languages i.e Python, Java, C#, etc, we will be working with Python.
A Scrollbar is helped you to circulate round display in vertical route if the modern-day web page scroll does now no longer the seen place of the display. It is used to transport the window up and down. Selenium Webdriver does now no longer requires scroll to carry out moves because it manipulates DOM. But in positive internet pages, factors best emerge as seen as soon as the person has scrolled to them. In such instances, scrolling can be necessary.
Requirements:
selenium
You need to install chromedriver and set the path. Click here to download. 
Step-by-step Approach:
Step 1: Import required modules
Python3
from selenium import webdriverimport timefrom webdriver_manager.chrome import ChromeDriverManager # create instance of Chrome webdriverdriver=webdriver.Chrome(ChromeDriverManager().install())
Step 2: Taking any URL.
Python3
from selenium import webdriverimport timefrom webdriver_manager.chrome import ChromeDriverManager # create instance of Chrome webdriverdriver=webdriver.Chrome(ChromeDriverManager().install()) #urldriver.get("https://www.countries-ofthe-world.com/flags-of-the-world.html")
Step 3: Maximize the window.
Python3
driver.maximize_window()
Step 4: Scrolling base on the pixel.
Python3
driver.execute_script("window.scrollBy(0,2000)","")
Below is the full Implementation:
Python3
from selenium import webdriverimport timefrom webdriver_manager.chrome import ChromeDriverManager # create instance of Chrome webdriverdriver=webdriver.Chrome(ChromeDriverManager().install()) #urldriver.get("https://www.countries-ofthe-world.com/flags-of-the-world.html") #maximize windowdriver.maximize_window() #scroll by pixeldriver.execute_script("window.scrollBy(0,2000)","")time.sleep(4)
Output:
rkbhola5
Python Selenium-Exercises
Python-selenium
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()