code-rag-bench/online-tutorials huggingface dataset:
What is arrow operator in C++?

The dot and arrow operator are both used in C++ to access the members of a class. They are just used in different scenarios. In C++, types declared as a class, struct, or union are considered "of class type". So the following refers to both of them.
a.b is only used if b is a member of the object (or reference[1] to an object) a. So for a.b, a will always be an actual object (or a reference to an object) of a class.
a →b is essentially a shorthand notation for (*a).b, ie, if a is a pointer to an object, then a→b is accessing the property b of the object that points to.
Note that . is not overloadable. → is an overloadable operator, so we can define our own function(operator→()) that should be called when this operator is used. so if a is an object of a class that overloads operator→ (common such types are smart pointers and iterators), then the meaning is whatever the class designer implemented.
[1] References are, semantically, aliases to objects, so I should have added "or reference to a pointer" to the #3 as well. However, I thought this would be more confusing than helpful since references to pointers (T*&) are rarely ever used.
#include<iostream>
class A {
   public: int b;
   A() { b = 5; }
};
int main() {
   A a = A();
   A* x = &a;
   std::cout << "a.b = " << a.b << "\n";
   std::cout << "x->b = " << x->b << "\n";
   return 0;
}
This will give the output −
5
5
What is the difference between method overloading and method overriding in Java?

Following are the notable differences between overloading and overriding.
In method overloading a class have two or more methods in with the same name and different parameters.
In overloading return type could vary in both methods.
JVM calls the respective method based on the parameters passed to it, at the time of method call.
 Live Demo
public class OverloadingExample {
   public void display(){
      System.out.println("Display method");
   }
   public void display(int a){
      System.out.println("Display method "+a);
   }
   public static void main(String args[]){
      OverloadingExample obj = new OverloadingExample();
      obj.display();
      obj.display(20);
   }
}
Display method
Display method 20

In method overriding Super class and subclass have methods with same name including parameters.
In overriding return types should also be same.
JVM calls the respective method based on the object used to call the method.
 Live Demo
class SuperClass{
   public static void sample(){
      System.out.println("Method of the super class");
   }
}
public class RuntimePolymorphism extends SuperClass {
   public static void sample(){
      System.out.println("Method of the sub class");
   }
   public static void main(String args[]){
      SuperClass obj1 = new RuntimePolymorphism();
      RuntimePolymorphism obj2 = new RuntimePolymorphism();
      
      obj1.sample();
      obj2.sample();
   }
}
Method of the super class
Method of the sub class
Golang | Replacing all String which Matches with Regular Expression

05 Sep, 2019
A regular expression is a sequence of characters which define a search pattern. Go language support regular expressions. A regular expression is used for parsing, filtering, validating, and extracting meaningful information from large text, like logs, the output generated from other programs, etc.In Go regexp, you are allowed to replace original string with another string if the specified string matches with the specified regular expression with the help of ReplaceAllString() method. In this method, $ sign means interpreted as in Expand like $1 indicates the text of the first submatch. This method is defined under the regexp package, so for accessing this method you need to import the regexp package in your program.
Syntax:
func (re *Regexp) ReplaceAllString(str, r string) string
Example 1:
// Go program to illustrate how to// replace string with the specified regexppackage main  import (    "fmt"    "regexp")  // Main functionfunc main() {      // Replace string with the specified regexp    // Using ReplaceAllString() method    m1 := regexp.MustCompile(`x(p*)y`)      fmt.Println(m1.ReplaceAllString("xy--xpppyxxppxy-", "B"))    fmt.Println(m1.ReplaceAllString("xy--xpppyxxppxy--", "$1"))    fmt.Println(m1.ReplaceAllString("xy--xpppyxxppxy-", "$1P"))    fmt.Println(m1.ReplaceAllString("xy--xpppyxxppxy-", "${1}Q"))  }
Output:
B--BxxppB-
--pppxxpp--
--xxpp-
Q--pppQxxppQ-

Example 2:
// Go program to illustrate how to replace// string with the specified regexppackage main  import (    "fmt"    "regexp")  // Main functionfunc main() {      // Creating and initializing a string    // Using shorthand declaration    s := "Geeks-for-Geeks-for-Geeks-for-Geeks-gfg"      // Replacing all the strings    // Using ReplaceAllString() method    m := regexp.MustCompile("^(.*?)Geeks(.*)$")    Str := "${1}GEEKS$2"    res := m.ReplaceAllString(s, Str)    fmt.Println(res)  }
Output:
GEEKS-for-Geeks-for-Geeks-for-Geeks-gfg
Golang
Golang-String
Go Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Zoom into ggplot2 Plot without Removing Data in R

24 Oct, 2021
In this article, we will discuss how to zoom into the ggplot2 plot without removing data using ggplot2 package in the R programming language. The approaches to the zoom into ggplot2 plot without removing data are as follows:
Zoom in to ggplot2 plot without Removing data using ylim()/xlim() function
Zoom in to ggplot2 plot without Removing data using coord_cartesian() function
ylim()/xlim() function: Convenience function to set the limits of the y axis/x-axis.
Syntax:
ylim(...)
xlim(...)
Parameters:
...: if numeric, will create a continuous scale, if factor or character, will create a discrete scale.
Example:
In this, example, we will be using xlim() function to get the zoom into view of the ggplot2 bar plot of the given data without removing any initial data in the R programming language. 
R
# load the packageslibrary("ggplot2")  # create the dataframe with letters and numbersgfg < -data.frame(    x=c('A', 'B', 'C', 'D', 'E', 'F'),    y=c(4, 6, 2, 9, 7, 3))  # plot the given data# with A,B and C as titles to the barsplot < -ggplot(gfg, aes(x, y, fill=x)) +geom_bar(stat="identity")plot+xlim('A', 'B', 'C')
Output:
The Cartesian coordinate system is the most familiar, and common, type of coordinate system. Setting limits on the coordinate system will zoom the plot (like you’re looking at it with a magnifying glass), and will not change the underlying data like setting limits on a scale will.
Syntax:
coord_cartesian( xlim = NULL, ylim = NULL,expand = TRUE, default = FALSE, clip = “on”)
Parameters:
xlim, ylim: Limits for the x and y axes.
expand: If TRUE, the default, adds a small expansion factor to the limits to ensure that data and axes don’t overlap.
default: Is this the default coordinate system
clip: Should drawing be clipped to the extent of the plot panel?
Example:
In this, example, we will be using the coord_cartesian() function with ylim() function to get the zoom into view of the ggplot2 bar plot of the given data without removing any initial data in the R programming language. 
R
# load the packagelibrary("ggplot2")  # create the dataframe with letters# and numbersgfg < -data.frame(    x=c('A', 'B', 'C', 'D', 'E', 'F'),    y=c(4, 6, 2, 9, 7, 3))  # plot the catrtesian barplot < -ggplot(gfg, aes(x, y, fill=x)) +geom_bar(stat="identity")plot+coord_cartesian(ylim=c(5, 7))
Output:
Picked
R-ggplot
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Design a close button using Pure CSS

19 Jan, 2022
The task is to make the close button using Pure CSS. There are two approaches that are discussed below. 
Approach 1: Create a <div> inside another <div> which has alphabet ‘X’ in it which helps in displaying the close button. When the “click” event occurs on ‘X’, then perform the operation. In this example the outer <div> has been hidden when the event occurs. 
Example: This example implements the above approach.
 
html
<!DOCTYPE HTML><html> <head>    <style>        .outer {            background: green;            height: 60px;            display: block;        }         .button {            margin-left: 93%;            color: white;            font-weight: bold;            cursor: pointer;        }    </style></head> <body style="text-align:center;">         <h1>GeeksForGeeks</h1>         <p>        Click on the cross to        hide the element.    </p>         <div class="outer">        <div class="button">X</div>    </div>    <br>         <p id="GFG"></p>     <script>        var down = document.getElementById("GFG");        var el = document.querySelector('.button');                 el.addEventListener('click', function () {            var el2 = document.querySelector('.outer');            el2.style.display = "none";        });    </script></body> </html>
Output:  
 
Approach 2: jQuery is used in this approach. Create a <div> inside another <div> that contains the alphabet ‘X’ to display the close button. When the “Click” event occurs on ‘X’ then perform the operation. In this example, the outer <div> has been hidden when the event occurs.
 
Example: This example implements the above approach.
 
html
<!DOCTYPE HTML><html> <head>    <style>        .outer {            background: green;            height: 60px;            display: block;        }         .button {            margin-left: 93%;            color: white;            font-weight: bold;            cursor: pointer;        }    </style>    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js">    </script></head> <body style="text-align:center;">    <h1>        GeeksForGeeks    </h1>    <p>        Click on the cross to        hide the element.    </p>    <div class="outer">        <div class="button">X</div>    </div>    <br>    <p id="GFG">    </p>     <script>        var down = document.getElementById("GFG");        $('.button').on('click', function () {            $('.outer').hide();        });    </script></body> </html>
Output:  
 
varshagumber28
CSS-Misc
jQuery-Misc
JavaScript
JQuery
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python sympy | Matrix.eigenvects() method

26 Aug, 2019
With the help of sympy.Matrix().eigenvects() method, we can find the Eigenvectors of a matrix. eigenvects() method returns a list of tuples of the form (eigenvalue:algebraic multiplicity, [eigenvectors]).
Syntax: Matrix().eigenvects()
Returns: Returns a list of tuples of the form (eigenvalue:algebraic multiplicity, [eigenvectors]).
Example #1:
# import sympy from sympy import * M = Matrix([[3, -2,  4, -2],                                 [5,  3, -3, -2],                                [5, -2,  2, -2],                                [5, -2, -3,  3]])  print("Matrix : {} ".format(M))   # Use sympy.eigenvects() method M_eigenvects = M.eigenvects()        print("Eigenvects of a matrix : {}".format(M_eigenvects))  
Output:
Matrix : Matrix([[3, -2, 4, -2], [5, 3, -3, -2], [5, -2, 2, -2], [5, -2, -3, 3]])Eigenvects of a matrix : [(-2, 1, [Matrix([[0],[1],[1],[1]])]), (3, 1, [Matrix([[1],[1],[1],[1]])]), (5, 2, [Matrix([[1],[1],[1],[0]]), Matrix([[ 0],[-1],[ 0],[ 1]])])]
Example #2:
# import sympy from sympy import * M = Matrix([[1, -3, 3], [3, -5, 3], [6, -6, 4]]) print("Matrix : {} ".format(M))   # Use sympy.eigenvects() method M_eigenvects = M.eigenvects()        print("Eigenvects of a matrix : {}".format(M_eigenvects))
Output:
Matrix : Matrix([[1, -3, 3], [3, -5, 3], [6, -6, 4]])Eigenvects of a matrix : [(-2, 2, [Matrix([[1],[1],[0]]), Matrix([[-1],[ 0],[ 1]])]), (4, 1, [Matrix([[1/2],[1/2],[ 1]])])]
SymPy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
MySQL query to decrease the value of a specific record to zero?

Use SET to decrease the value and WHERE to set the condition for a specific record to be 0. Let us first create a table −
mysql> create table DemoTable
   (
   Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Number int
   );
Query OK, 0 rows affected (0.54 sec)
Insert some records in the table using insert command &minus
mysql> insert into DemoTable(Number) values(10);
Query OK, 1 row affected (0.20 sec)

mysql> insert into DemoTable(Number) values(20);
Query OK, 1 row affected (0.14 sec)

mysql> insert into DemoTable(Number) values(1);
Query OK, 1 row affected (0.10 sec)

mysql> insert into DemoTable(Number) values(0);
Query OK, 1 row affected (0.12 sec)

mysql> insert into DemoTable(Number) values(-1);
Query OK, 1 row affected (0.39 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+----+--------+
| Id | Number |
+----+--------+
|  1 |     10 |
|  2 |     20 |
|  3 |      1 |
|  4 |      0 |
|  5 |     -1 |
+----+--------+
5 rows in set (0.00 sec)
Following is the query to decrease the value to 0 −
mysql> update DemoTable
   set Number = Number-1
   where Id = 3 AND Number > 0;
Query OK, 1 row affected (0.20 sec)
Rows matched: 1 Changed: 1 Warnings: 0
Let us display table records once again −
mysql> select *from DemoTable;
This will produce the following output. Now, record with Id 3 is 0 since we decremented it by 1 −
+----+--------+
| Id | Number |
+----+--------+
|  1 |     10 |
|  2 |     20 |
|  3 |      0 |
|  4 |      0 |
|  5 |     -1 |
+----+--------+
5 rows in set (0.00 sec)
How do I plot a step function with Matplotlib in Python?

To plot a step function with matplotlib in Python, we can take the following steps −
Create data points for x and y.
Create data points for x and y.
Make a step plot using step() method.
Make a step plot using step() method.
To display the figure, use show() method.
To display the figure, use show() method.
import matplotlib.pyplot as plt
import numpy as np
plt.rcParams["figure.figsize"] = [7.00, 3.50]
plt.rcParams["figure.autolayout"] = True
x = np.array([1, 3, 4, 5, 7])
y = np.array([1, 9, 16, 25, 49])
plt.step(x, y, 'r*')
plt.show()
Python | Pandas Series.repeat() - GeeksforGeeks

10 Feb, 2019
Pandas series is a One-dimensional ndarray with axis labels. The labels need not be unique but must be a hashable type. The object supports both integer- and label-based indexing and provides a host of methods for performing operations involving the index.
Pandas Series.repeat() function repeat elements of a Series. It returns a new Series where each element of the current Series is repeated consecutively a given number of times.
Syntax: Series.repeat(repeats, axis=None)
Parameter :repeats : The number of repetitions for each element.axis : None
Returns : repeated_series
Example #1: Use Series.repeat() function to repeat each value in the given Series object 2 times.
# importing pandas as pdimport pandas as pd  # Creating the Seriessr = pd.Series([10, 25, 3, 11, 24, 6])  # Create the Indexindex_ = ['Coca Cola', 'Sprite', 'Coke', 'Fanta', 'Dew', 'ThumbsUp']  # set the indexsr.index = index_  # Print the seriesprint(sr)
Output :
Now we will use Series.repeat() function to repeat each value of the given series object 2 times.
# repeat twiceresult = sr.repeat(repeats = 2)  # Print the resultprint(result)
Output :
As we can see in the output, the Series.repeat() function has returned a new series object where each values are repeated the specified number of times. Example #2 : Use Series.repeat() function to repeat each value in the given Series object 3 times.
# importing pandas as pdimport pandas as pd  # Creating the Seriessr = pd.Series(['New York', 'Chicago', 'Toronto', 'Lisbon', 'Rio'])  # Create the Indexindex_ = ['City 1', 'City 2', 'City 3', 'City 4', 'City 5']   # set the indexsr.index = index_  # Print the seriesprint(sr)
Output :
Now we will use Series.repeat() function to repeat each value of the given series object 3 times.
# repeat twiceresult = sr.repeat(repeats = 3)  # Print the resultprint(result)
Output :As we can see in the output, the Series.repeat() function has returned a new series object where each values are repeated the specified number of times.
Python pandas-series
Python pandas-series-methods
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Python Dictionary
Read a file line by line in Python
Enumerate() in Python
How to Install PIP on Windows ?
Different ways to create Pandas Dataframe
Python String | replace()
Reading and Writing to text files in Python
sum() function in Python
Create a Pandas DataFrame from Lists
How to drop one or multiple columns in Pandas Dataframe
RequireJS - Loading jQuery from CDN

jQuery uses CDN (Content Delivery Network) to define the dependencies for jQuery plugins by calling the define() function.
define(["jquery", "jquery.load_js1", "jquery.load_js2"], function($) {
   $(function() {
      //code here
   });
});
The following example uses CDN to define the dependencies for jQuery plugins. Create a html file with the name index.html and place the following code in it −
<!DOCTYPE html>
<html>
   <head>
      <title>Load jQuery from a CDN</title>
      <script data-main = "app" src = "lib/require.js"></script>
   </head>
   
   <body>
      <h2>Load jQuery from a CDN</h2>
      <p>Welcome to Tutorialspoint!!!</p>
   </body>
</html>
Create a js file with the name app.js and add the following code in it −
// you can configure loading modules from the lib directory
requirejs.config ({
   "baseUrl": "lib",
   
   "paths": {
      "app": "../app",
	  
      //loading jquery from CDN
      "jquery": "//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min"
   }
});

//to start the application, load the main module from app folder
requirejs(["app/main"]);
Create a folder called app and load the main.js module from this folder −
define(["jquery", "jquery.load_js1", "jquery.load_js2"], function($) {
   
   //loading the jquery.load_js1.js and jquery.load_js2.js plugins 
   $(function() {
      $('body').load_js1().load_js2();
   });
});
Create one more folder called lib to store the require.js file and other js files as shown below −
define(["jquery"], function($) {
   
   $.fn.load_js1 = function() {
      return this.append('<p>Loading from first js file!</p>');
   };
});
define(["jquery"], function($) {
   
   $.fn.load_js2 = function() {
      return this.append('<p>Loading from second js file!</p>');
   };
});
Open the HTML file in a browser; you will receive the following output −
 Print
 Add Notes
 Bookmark this page
Python | Pandas Series.str.decode()

27 Mar, 2019
Series.str can be used to access the values of the series as strings and apply several methods to it. Pandas Series.str.decode() function is used to decode character string in the Series/Index using indicated encoding. This function is equivalent to str.decode() in python2 and bytes.decode() in python3.
Syntax: Series.str.decode(encoding, errors=’strict’)
Parameter :encoding : strerrors : str, optional
Returns : decoded Series/Index of objects
Example #1: Use Series.str.decode() function to decode the character strings in the underlying data of the given series object. Use ‘UTF-8’ encoding method.
# importing pandas as pdimport pandas as pd  # Creating the Seriessr = pd.Series([b"b'New_York'", b"b'Lisbon'", b"b'Tokyo'", b"b'Paris'", b"b'Munich'"])  # Creating the indexidx = ['City 1', 'City 2', 'City 3', 'City 4', 'City 5']  # set the indexsr.index = idx  # Print the seriesprint(sr)
Output :
Now we will use Series.str.decode() function to decode the character strings in the underlying data of the given series object.
# use 'UTF-8' encodingresult = sr.str.decode(encoding = 'UTF-8')  # print the resultprint(result)
Output :
As we can see in the output, the Series.str.decode() function has successfully decodes the strings in the underlying data of the given series object.
Example #2 : Use Series.str.decode() function to decode the character strings in the underlying data of the given series object. Use ‘ASCII’ encoding method.
# importing pandas as pdimport pandas as pd  # Creating the Seriessr = pd.Series([b'Mike-', b'Alessa-', b'Nick-', b'Kim-', b'Britney-'])  # Creating the indexidx = ['Name 1', 'Name 2', 'Name 3', 'Name 4', 'Name 5']  # set the indexsr.index = idx  # Print the seriesprint(sr)
Output :
Now we will use Series.str.decode() function to decode the character strings in the underlying data of the given series object.
# use 'ASCII' encodingresult = sr.str.decode(encoding = 'ASCII')  # print the resultprint(result)
Output :
As we can see in the output, the Series.str.decode() function has successfully decodes the strings in the underlying data of the given series object.
Python-pandas
Python-pandas-series-str
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Different ways to create Pandas Dataframe
Enumerate() in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Python OOPs Concepts
Iterate over a list in Python
Introduction To PYTHON
Convert integer to string in Python
WSDL - <binding> Element

The <binding> element provides specific details on how a portType operation will actually be transmitted over the wire.
The bindings can be made available via multiple transports including HTTP GET, HTTP POST, or SOAP.
The bindings can be made available via multiple transports including HTTP GET, HTTP POST, or SOAP.
The bindings provide concrete information on what protocol is being used to transfer portType operations.
The bindings provide concrete information on what protocol is being used to transfer portType operations.
The bindings provide information where the service is located.
The bindings provide information where the service is located.
For SOAP protocol, the binding is <soap:binding>, and the transport is SOAP messages on top of HTTP protocol.
For SOAP protocol, the binding is <soap:binding>, and the transport is SOAP messages on top of HTTP protocol.
You can specify multiple bindings for a single portType.
You can specify multiple bindings for a single portType.
The binding element has two attributes : name and type attribute.
<binding name = "Hello_Binding" type = "tns:Hello_PortType">

The name attribute defines the name of the binding, and the type attribute points to the port for the binding, in this case the "tns:Hello_PortType" port.
WSDL 1.1 includes built-in extensions for SOAP 1.1. It allows you to specify SOAP specific details including SOAP headers, SOAP encoding styles, and the SOAPAction HTTP header. The SOAP extension elements include the following −
soap:binding
soap:operation
soap:body
This element indicates that the binding will be made available via SOAP. The style attribute indicates the overall style of the SOAP message format. A style value of rpc specifies an RPC format.
The transport attribute indicates the transport of the SOAP messages. The value http://schemas.xmlsoap.org/soap/http indicates the SOAP HTTP transport, whereas http://schemas.xmlsoap.org/soap/smtp indicates the SOAP SMTP transport.
This element indicates the binding of a specific operation to a specific SOAP implementation. The soapAction attribute specifies that the SOAPAction HTTP header be used for identifying the service.
This element enables you to specify the details of the input and output messages. In the case of HelloWorld, the body element specifies the SOAP encoding style and the namespace URN associated with the specified service.
Here is the piece of code from the Example chapter −
<binding name = "Hello_Binding" type = "tns:Hello_PortType">
   <soap:binding style = "rpc" transport = "http://schemas.xmlsoap.org/soap/http"/>
   <operation name = "sayHello">
      <soap:operation soapAction = "sayHello"/>
			
      <input>
         <soap:body
            encodingStyle = "http://schemas.xmlsoap.org/soap/encoding/"
            namespace = "urn:examples:helloservice" use = "encoded"/>
      </input>
			
      <output>
         <soap:body
            encodingStyle = "http://schemas.xmlsoap.org/soap/encoding/"
            namespace = "urn:examples:helloservice" use = "encoded"/>
How to round elements of the NumPy array to the nearest integer?

08 Jun, 2022
Prerequisites: Python NumPy
In this article, let’s discuss how to round elements of the NumPy array to the nearest integer. numpy.rint() function of Python that can convert the elements of an array to the nearest integer.
Syntax: numpy.rint(x, /, out=None, *, where=True, casting=’same_kind’, order=’K’, dtype=None, subok=True[, signature, extobj]) = <ufunc ‘rint’>
Example 1:
Python3
import numpy as n # create arrayy = n.array([0.2, 0.3, 0.4, 0.5, 0.6, 0.7])print("Original array:", end=" ")print(y) # round to nearest integery = n.rint(y)print("After rounding off:", end=" ")print(y)
Output:
Example 2:
Python3
import numpy as n # create arrayy = n.array([-0.2, 0.7, -1.4, -4.5, -7.6, -19.7])print("Original array:", end=" ")print(y) # round to nearest integery = n.rint(y)print("After rounding off:", end=" ")print(y)
Output:
simmytarika5
Python numpy-Mathematical Function
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 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
GATE | GATE-CS-2015 (Set 1) | Question 19

28 Jun, 2021
The following two functions P1 and P2 that share a variable B with an initial value of 2 execute concurrently.
P1() 
{ 
   C = B – 1; 
   B = 2*C;  
}

P2()
{
   D = 2 * B;
   B = D - 1; 
}
The number of distinct values that B can possibly take after the execution is(A) 3(B) 2(C) 5(D) 4Answer: (A)Explanation: There are following ways that concurrent processes can follow.
 C = B – 1;   // C = 1
 B = 2*C;    // B = 2
 D = 2 * B;   // D  = 4
 B = D - 1;   // B  = 3


 C = B – 1;   // C = 1
 D = 2 * B;   // D = 4
 B = D - 1;   // B = 3
 B = 2*C;    // B = 2

 C = B – 1;  // C = 1
 D = 2 * B; // D =  4
 B = 2*C;  // B = 2
 B = D - 1;  // B = 3

 D = 2 * B; // D =  4
 C = B – 1;  // C = 1
 B = 2*C;  // B = 2
 B = D - 1;  // B = 3

 D = 2 * B; // D =  4
 B = D - 1;  // B = 3
 C = B – 1;  // C = 2
 B = 2*C;  // B = 4 
There are 3 different possible values of B: 2, 3 and 4.Quiz of this Question
GATE-CS-2015 (Set 1)
GATE-GATE-CS-2015 (Set 1)
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | GATE-CS-2015 (Set 2) | Question 65

28 Jun, 2021
A Computer system implements 8 kilobyte pages and a 32-bit physical address space. Each page table entry contains a valid bit, a dirty bit three permission bits, and the translation. If the maximum size of the page table of a process is 24 megabytes, the length of the virtual address supported by the system is _______________ bits(A) 36(B) 32(C) 28(D) 40Answer: (A)Explanation:
Max size of virtual address can be calculated by 
calculating maximum number of page table entries.

Maximum Number of page table entries can be calculated 
using given maximum page table size and size of a page 
table entry.

Given maximum page table size = 24 MB

Let us calculate size of a page table entry.

A page table entry has following number of bits.
1 (valid bit) + 
1 (dirty bit) + 
3 (permission bits) + 
x bits to store physical address space of a page.

Value of x = (Total bits in physical address) - 
             (Total bits for addressing within a page)
Since size of a page is 8 kilobytes, total bits needed within
a page is 13.
So value of x = 32 - 13 = 19

Putting value of x, we get size of a page table entry =
                                   1 + 1 + 3  + 19 = 24bits.

Number of page table entries 
           = (Page Table Size) / (An entry size)
           =  (24 megabytes / 24 bits)                             
           =  223

Vrtual address Size 
             = (Number of page table entries) * (Page Size)
             =  223 * 8 kilobits
             = 236  
Therefore, length of virtual address space = 36
Quiz of this Question
GATE-CS-2015 (Set 2)
GATE-GATE-CS-2015 (Set 2)
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
VB.Net - Continue Statement

The Continue statement causes the loop to skip the remainder of its body and immediately retest its condition prior to reiterating. It works somewhat like the Exit statement. Instead of forcing termination, it forces the next iteration of the loop to take place, skipping any code in between.
For the For...Next loop, Continue statement causes the conditional test and increment portions of the loop to execute. For the While and Do...While loops, continue statement causes the program control to pass to the conditional tests.
The syntax for a Continue statement is as follows −
Continue { Do | For | While }

Module loops
   Sub Main()
      ' local variable definition 
      Dim a As Integer = 10
      Do
         If (a = 15) Then
            ' skip the iteration '
            a = a + 1
            Continue Do
         End If
         Console.WriteLine("value of a: {0}", a)
         a = a + 1
      Loop While (a < 20)
      Console.ReadLine()
   End Sub
End Module
When the above code is compiled and executed, it produces the following result −
value of a: 10
value of a: 11
value of a: 12
value of a: 13
value of a: 14
value of a: 16
value of a: 17
value of a: 18
value of a: 19
R - Histograms

A histogram represents the frequencies of values of a variable bucketed into ranges. Histogram is similar to bar chat but the difference is it groups the values into continuous ranges. Each bar in histogram represents the height of the number of values present in that range.
R creates histogram using hist() function. This function takes a vector as an input and uses some more parameters to plot histograms.
The basic syntax for creating a histogram using R is −
hist(v,main,xlab,xlim,ylim,breaks,col,border)

Following is the description of the parameters used −
v is a vector containing numeric values used in histogram.
v is a vector containing numeric values used in histogram.
main indicates title of the chart.
main indicates title of the chart.
col is used to set color of the bars.
col is used to set color of the bars.
border is used to set border color of each bar.
border is used to set border color of each bar.
xlab is used to give description of x-axis.
xlab is used to give description of x-axis.
xlim is used to specify the range of values on the x-axis.
xlim is used to specify the range of values on the x-axis.
ylim is used to specify the range of values on the y-axis.
ylim is used to specify the range of values on the y-axis.
breaks is used to mention the width of each bar.
breaks is used to mention the width of each bar.
A simple histogram is created using input vector, label, col and border parameters.
The script given below will create and save the histogram in the current R working directory.
# Create data for the graph.
v <-  c(9,13,21,8,36,22,12,41,31,33,19)

# Give the chart file a name.
png(file = "histogram.png")

# Create the histogram.
hist(v,xlab = "Weight",col = "yellow",border = "blue")

# Save the file.
dev.off()
When we execute the above code, it produces the following result −
To specify the range of values allowed in X axis and Y axis, we can use the xlim and ylim parameters.
The width of each of the bar can be decided by using breaks.
# Create data for the graph.
v <- c(9,13,21,8,36,22,12,41,31,33,19)

# Give the chart file a name.
png(file = "histogram_lim_breaks.png")

# Create the histogram.
hist(v,xlab = "Weight",col = "green",border = "red", xlim = c(0,40), ylim = c(0,5),
   breaks = 5)

# Save the file.
dev.off()
When we execute the above code, it produces the following result −
Boolean equals() method in Java with examples

09 Oct, 2018
The equals() method of Boolean class is a built in method of Java which is used check equality of two Boolean object.
Syntax:
BooleanObject.equals(Object ob)
Parameter: It take a parameter ob of type Object as input which is the instance to be compared.
Return Type: The return type is boolean. It returns true if the specified Object ‘ob’ has same value as the ‘BooleanObject’, else it returns false.
Below are programs to illustrate the equals() method of Boolean class:
Program 1:
// Java code to implement// equals() method of Boolean class  class GeeksforGeeks {      // Driver method    public static void main(String[] args)    {          // Boolean object        Boolean a = new Boolean(true);          // Boolean object        Boolean b = new Boolean(true);          // compare method        System.out.println(a + " comparing with " + b                           + " = " + a.equals(b));    }}
true comparing with true = true

Program 2:
// Java code to implement// equals() method of Java class  class GeeksforGeeks {      // Driver method    public static void main(String[] args)    {          // Boolean object        Boolean a = new Boolean(true);          // Boolean object        Boolean b = new Boolean(false);          // compare method        System.out.println(a + " comparing with " + b                           + " = " + a.equals(b));    }}
true comparing with false = false

Program 3:
// Java code to implement// equals() method of Java class  class GeeksforGeeks {      // Driver method    public static void main(String[] args)    {          // Boolean object        Boolean a = new Boolean(false);          // Boolean object        Boolean b = new Boolean(true);          // compare method        System.out.println(a + " comparing with " + b                           + " = " + a.equals(b));    }}
false comparing with true = false

Java - util package
Java-Boolean
Java-Functions
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Horn Clauses in Deductive Databases

01 Jul, 2020
Horn clause is clause (a disjunction of literals) with at most one positive, i.e. unnegated, literal. A clause with at most one positive (unnegated) literal is called a Horn Clause.
Deductive Database:A type of database which can make conclusions based on sets of well-defined rules, stored in database. RDBMS and logic programming are combined using this. Deductive database designing is done with help of pure declarative programming language known as Datalog.
Types of Horn Clauses :
Definite clause / Strict Horn clause –It has exactly one positive literal.
Unit clause –Definite clause with no negative literals.
Goal clause –Horn clause without a positive literal.
In Datalog, rules are expressed as a restricted form of clauses called Horn clauses, in which a clause can contain at most one positive literal.
A formula can have following quantifiers:
Universal quantifier –It can be understood as – “For all x, P(x) holds”, meaning P(x) is true for every object x in universe. For example, all trucks has wheels.
Existential quantifier –It can be understood as – “There exists an x such that P(x)”, meaning P(x) is true for at least one object x of universe. For example, someone cares for you.
Forms of a Horn Clause :
NOT(P1) OR NOT(P2) OR ... OR NOT(Pn) OR QNOT(P1) OR NOT(P2) OR ... OR NOT (Pn)
NOT(P1) OR NOT(P2) OR ... OR NOT(Pn) OR Q
NOT(P1) OR NOT(P2) OR ... OR NOT(Pn) OR Q
NOT(P1) OR NOT(P2) OR ... OR NOT (Pn)
NOT(P1) OR NOT(P2) OR ... OR NOT (Pn)
Transformation of Horn Clause :The Horn clause in (1) can be transformed into clause –
P1 AND P2 AND ... AND Pn → Q 
which is written in Datalog as following rules
Q :- P1, P2, ..., Pn 
The above Datalog Rule, is hence a Horn clause.
If predicates P1 AND P2 AND ... AND Pn, are all true for a particular binding to their variable arguments, then Q is also true and can hence be inferred.
The Horn clause in (2) can be transformed into –
P1 AND P2 AND ... AND Pn → 
which is written in Datalog as follows:
P1, P2, ..., Pn 
The above Datalog expression can be considered as an integrity constraint, where all predicates must be true to satisfy query.
A query in Datalog consists of two components:
A Datalog program, which is a finite set of rules.
A literal P(X1, X2, X3, ... Xn), where each X is a variable or a constant.
DBMS
DBMS
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | Pandas Series.plot() method

17 Sep, 2019
With the help of Series.plot() method, we can get the plot of pandas series by using Series.plot() method.
Syntax : Series.plot()Return : Return the plot of series.
# import Series and matplotlibimport pandas as pdimport matplotlib.pyplot as plt  # using Series.plot() methodgfg = pd.Series([0.1, 0.4, 0.16, 0.3, 0.9, 0.81])  gfg.plot()plt.show()
Output :
Example #2 :
# import Series and matplotlibimport pandas as pdimport matplotlib.pyplot as plt  # using Series.plot() methodgfg = pd.Series([10, 9.9, 9.8, 7.8, 6.7, 19, 5.5])  gfg.plot()plt.show()
Output :
Python pandas-series
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
How to drop one or multiple columns in Pandas Dataframe
Python | os.path.join() method
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python | Get unique values from a list
Python | datetime.timedelta() function
Check if the String ends with specified suffix in Golang

26 Aug, 2019
In Go language, strings are different from other languages like Java, C++, Python, etc. It is a sequence of variable-width characters where each and every character is represented by one or more bytes using UTF-8 Encoding.In Go strings, you can check whether the string ends with the specified suffix or not with the help of HasSuffix() function. This function returns true if the given string ends with the specified suffix and return false if the given string does not end with the specified suffix. It is defined under the strings package so, you have to import strings package in your program for accessing HasSuffix function.
Syntax:
func HasSuffix(str, suf string) bool
Here, str is the original string and suf is a string which represents the suffix. The return type of this function is of the bool type.
Example:
// Go program to illustrate how to check the// given string start with the specified prefixpackage main  import (    "fmt"    "strings")  // Main functionfunc main() {      // Creating and initializing strings    // Using shorthand declaration    s1 := "I am working as a Technical content writer in GeeksforGeeks!"    s2 := "I am currently writing articles on Go language!"      // Checking the given strings     // starts with the specified prefix    // Using HasSuffix() function    res1 := strings.HasSuffix(s1, "GeeksforGeeks!")    res2 := strings.HasSuffix(s1, "!")    res3 := strings.HasSuffix(s1, "Apple")    res4 := strings.HasSuffix(s2, "language!")    res5 := strings.HasSuffix(s2, "dog")    res6 := strings.HasSuffix("GeeksforGeeks, Geeks", "Geeks")    res7 := strings.HasSuffix("Welcome to GeeksforGeeks", "Welcome")      // Displaying results    fmt.Println("Result 1: ", res1)    fmt.Println("Result 2: ", res2)    fmt.Println("Result 3: ", res3)    fmt.Println("Result 4: ", res4)    fmt.Println("Result 5: ", res5)    fmt.Println("Result 6: ", res6)    fmt.Println("Result 7: ", res7)}
Output:
Result 1:  true
Result 2:  true
Result 3:  false
Result 4:  true
Result 5:  false
Result 6:  true
Result 7:  false

Golang
Golang-String
Go Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Parse JSON in Golang?
Constants- Go Language
Structures in Golang
Loops in Go Language
Time Durations in Golang
How to iterate over an Array using for loop in Golang?
Strings in Golang
Go Variables
time.Parse() Function in Golang With Examples
Class and Object in Golang
Seaborn – Coloring Boxplots with Palettes

27 Sep, 2021
Adding the right set of color with your data visualization makes it more impressive and readable, seaborn color palettes make it easy to use colors with your visualization. In this article, we will see how to color boxplot with seaborn color palettes also learn the uses of seaborn color palettes and it can be applied to other plots as well. 
Step-by-step Approach:
Step 1: Load the python packages and libraries required to color a boxplot.
Python3
# import librariesimport seaborn as sns import matplotlib.pyplot as plt
Step 2: Load the dataset to generate a boxplot.
Python3
# loading datasetds = sns.load_dataset('iris')
Step 3: Generate a boxplot using the boxplot() method. 
Python3
# create boxplot objectax = sns.boxplot(data=tips, orient="h")
Step 4: Seaborn boxplot() function has palette argument, in this example we have set palette=”Set1′′, it uses a qualitative color paletter Set3 to color the boxes in boxpolot. So add palette parameter in boxplot method.
Python3
# use palette methodax = sns.boxplot(data=ds, orient="h", palette="Set1")
Below is the complete program based on the above approach:
Python3
# import librariesimport seaborn as snsimport matplotlib.pyplot as plt # load datasetds = sns.load_dataset("tips") plt.figure(figsize=(8, 6)) # use palette methodax = sns.boxplot(data=ds, orient="h", palette="Set1")
Coloring Boxplots with Seaborn Palettes
abhishek0719kadiyan
Python-Seaborn
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
Different ways to create Pandas Dataframe
Taking input in Python
Enumerate() in Python
Read a file line by line in Python
Python String | replace()
Exceptions – Selenium Python

30 Apr, 2020
Exceptions in Selenium Python are the errors that occur when one of method fails or an unexpected event occurs. All instances in Python must be instances of a class that derives from BaseException. Two exception classes that are not related via subclassing are never equivalent, even if they have the same name. The built-in exceptions can be generated by the interpreter or built-in functions. This article revolves around multiple exceptions that can occur during the run of a Selenium program.
Let’s demonstrate Exception by trying to find an element that doesn’t exist and click it at geeksforgeeks.org
# import webdriverfrom selenium import webdriver  # create webdriver objectdriver = webdriver.Firefox()  # get geeksforgeeks.orgdriver.get("https://www.geeksforgeeks.org/")  # get element element = driver.find_element_by_link_text("abrakadabra")  # click the itemprint(element.click())
Now, let’s run this program, it first open geeksforgeeks.org and then raise exception – selenium.common.exceptions.NoSuchElementException, which means that element doesn’t exists on the website.
Exceptions are of primary use when you are writing development ready code especially which is at a high risk of causing certain type of exception. So here is list of all exceptions in Selenium Python.
Python-selenium
selenium
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Iterate over a list in Python
Read JSON file using Python
Python map() function
How to iterate through Excel rows in Python?
Enumerate() in Python
Adding new column to existing DataFrame in Pandas
Python OOPs Concepts
Different ways to create Pandas Dataframe
How to get column names in Pandas dataframe
Stack in Python
How to test the shared location path from the remote computer in PowerShell?

Many times we need to test the NAS path or shared path location from the remote server. Meaning we need to check if the shared path is accessible from the remote location and we use the Test-Path that time but we get an error of PermissionDenied or UnauthorizedAccessExcept.
Our sample code is shown below and in this example, we are using the Invoke-Command to connect to another computer and from there we are checking if the shared path is accessible.
Invoke-Command -ComputerName LabMachine2k16 -ScriptBlock {
   Test-Path -Path "\\ad\Shared\Temp"
}
This script throws an exception.
Access is denied
    + CategoryInfo          : PermissionDenied: (\\ad\Shared\Temp:String) [Test-Path], UnauthorizedAccessException
    + FullyQualifiedErrorId : ItemExistsUnauthorizedAccessError,Microsoft.PowerShell.Commands.TestPathCommand
    + PSComputerName        : LabMachine2k16
False
This is not the permission issue but this is a PowerShell remoting issue. By default PowerShell remoting supports one layer of remoting, here we are connecting to a remote machine and again checking the shared path from it so it becomes the 2 stages of remoting and PowerShell doesn't support it.
To get this issue solved, we can use the Map drive to test if we can connect to it successfully or not. If yes then the remote server has connectivity to that path. For example,
Invoke-Command -ComputerName LabMachine2k16 -ScriptBlock{
   if(New-PSDrive -Name X -PSProvider FileSystem `
      -Root "\\Ad\Shared\Temp" -EA Ignore){
       Write-Output "Path is accessible"
   }
}
Path is accessible
How to find SubString in R programming? - GeeksforGeeks

21 Oct, 2021
In this article, we are going to see how to find substring in R programming language. 
R provides different ways to find substrings. These are:
Using substr() method
Using str_detect() method
Using grep() method
Find substring in R using substr() method in R Programming is used to find the sub-string from starting index to the ending index values in a string.
Syntax: substr(string_name, start, end)
Return: Returns the sub string from a given string using indexes. 
Example 1:
R
# Given Stringgfg < - "Geeks For Geeks"  # Using substr() methodanswer < - substr(gfg, 0, 5)  print(answer)
Output:
[1] "Geeks"
Example 2:
R
# Given Stringgfg < - "The quick brown fox jumps over the lazy dog"  # Using substr() methodanswer < - substr(gfg, 20, 30)  print(answer)
Output: 
[1] " jumps over"
str_detect() Function in R Language is used to check if the specified match of the substring exists in the original string. It will return TRUE for a match found otherwise FALSE against each of the elements of the Vector or matrix.
Syntax: str_detect(string, pattern)
Parameter:
string: specified string
pattern: Pattern to be matched
Example:
R
# R Program to illustrate# the use of str_detect function  # Loading librarylibrary(stringr)  # Creating vectorx <- c("Geeks", "Hello", "Welcome", "For")  # Pattern to be matchedpat <- "Geeks"  # Calling str_detect() functionstr_detect(x, pat)
Output:
[1]  TRUE FALSE FALSE FALSE
grep() function returns the index at which the pattern is found in the vector. If there are multiple occurrences of the pattern, it returns a list of indices of the occurrences. This is very useful as it not only tells us about the occurrence of the pattern but also of its location in the vector.
Syntax: grep(pattern, string, ignore.case=FALSE)
Parameters:
pattern: A regular expressions pattern.
string: The character vector to be searched.
ignore.case: Whether to ignore case in the search. Here ignore.case is an optional parameter as is set to FALSE by default.
Example:
R
str <- c("Hello", "hello", "hi", "hey")grep('he', str)
Output:
[1] 2 4
kumar_satyam
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Change Color of Bars in Barchart using ggplot2 in R
How to Change Axis Scales in R Plots?
Group by function in R using Dplyr
How to Split Column Into Multiple Columns in R DataFrame?
Data Visualization in R
Logistic Regression in R Programming
Replace Specific Characters in String in R
How to filter R dataframe by multiple conditions?
How to import an Excel File into R ?
How to filter R DataFrame by values in a column?