code-rag-bench/online-tutorials huggingface dataset:
Ext.js - Yes NO Cancel Box

This is like a confirm box which asks the user for some confirmation, such as whether the user wants to do the task or decline or cancel the task. Based on the user selection different methods get called.
Following is a simple syntax.
Ext.MessageBox.show ({
   title: 'Details',
   msg: 'Please enter your details:',
   width:300,
   buttons: Ext.MessageBox.YESNOCANCEL   
   // this button property for all three options YES, NO, Cancel.
});

Following is a simple example showing the usage.
<!DOCTYPE html>
<html>
   <head>
      <link href = "https://cdnjs.cloudflare.com/ajax/libs/extjs/6.0.0/classic/theme-classic/resources/theme-classic-all.css" 
         rel = "stylesheet" />
      <script type = "text/javascript" 
         src = "https://cdnjs.cloudflare.com/ajax/libs/extjs/6.0.0/ext-all.js"></script>
      
      <script type = "text/javascript">
         Ext.onReady(function() {
            Ext.create('Ext.Button', {
               renderTo: Ext.getElementById('msgBox'),
               text: 'Click Me',
               
               listeners: {
                  click: function() {
                     Ext.MessageBox.show ({
                        title: 'Details',
                        msg: 'Please enter your details:',
                        width:300,
                        buttons: Ext.MessageBox.YESNOCANCEL,
                        multiline: true,
                        fn: callbackFunction
                     });
                     function callbackFunction() {
                        Ext.Msg.alert('status', 'Details entered succesfully');
                     }
                  }
               }
            });
         });
      </script>
   </head>
   
   <body>
      <p> Click the button for alert box </p>
      <div id = "msgBox" ></div>
   </body>
</html>
The above program will produce the following result −
 Click the button for alert box 
 Print
 Add Notes
 Bookmark this page
How to show node name in Matplotlib graphs using networkx?

To show node name in graphs using networkx, we can take the following steps −
Set the figure size and adjust the padding between and around the subplots.
Initialize a graph with edges, name, or graph attributes.
Add multiple nodes using add_nodes_from() method.
Add all the edges using add_edge_from() method.
Draw the graph G with Matplotlib using draw() method. Set with_labels to True.
To display the graph, we can use show() method.
import matplotlib.pylab as plt
import networkx as nx

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

G = nx.DiGraph()
G.add_nodes_from([1, 2, 3, 4])
G.add_edges_from([(1, 2), (2, 1), (2, 3), (1,4), (3,4)])
nx.draw(G, with_labels=True)

plt.show()
How to create a transparent polygon using ggplot2 in R?

A transparent polygon just represents the border lines and a hollow area; thus, we can only understand the area covered but it becomes a little difficult to understand the scales. Hence, this visualisation technique is not as useful as others that fills the area with a different color. But it could be used if the range of the data is not large.
Consider the below data frame −
 Live Demo
set.seed(123)
x<-sample(1:5,10,replace=TRUE)
y<-sample(3:8,10,replace=TRUE)
df<-data.frame(x,y)
df
   x y
1  2 8
2  4 5
3  3 7
4  5 6
5  5 3
6  1 8
7  3 4
8  5 3
9  3 4
10 3 8
Loading ggplot2 package and creating a polygon using x and y −
library(ggplot2) ggplot(df,aes(x,y))+geom_polygon()
Creating a polygon using x and y with transparency −
ggplot(df,aes(x,y))+geom_polygon(fill=NA,color="red")
How to skip first 10 results in MySQL?

To skip first 10 results, use “limit offset”. The syntax is as follows −
select *from yourTableName limit 10 offset lastValue;
Let us create a table to understand the above syntax. The following is the query to create a table −
mysql> create table SkipFirstTenRecords
   −> (
      −> StudentId int,
      −> StudentName varchar(200)
   −> );
Query OK, 0 rows affected (0.53 sec)
Now you can insert some records in the table with the help of insert command. The query is as follows −
mysql> insert into SkipFirstTenRecords values(100,'John');
Query OK, 1 row affected (0.12 sec)

mysql> insert into SkipFirstTenRecords values(101,'Johnson');
Query OK, 1 row affected (0.14 sec)

mysql> insert into SkipFirstTenRecords values(102,'Carol');
Query OK, 1 row affected (0.10 sec)

mysql> insert into SkipFirstTenRecords values(103,'Smith');
Query OK, 1 row affected (0.32 sec)

mysql> insert into SkipFirstTenRecords values(104,'Bob');
Query OK, 1 row affected (0.14 sec)

mysql> insert into SkipFirstTenRecords values(105,'David');
Query OK, 1 row affected (0.18 sec)

mysql> insert into SkipFirstTenRecords values(106,'Sam');
Query OK, 1 row affected (0.14 sec)

mysql> insert into SkipFirstTenRecords values(107,'Taylor');
Query OK, 1 row affected (0.23 sec)

mysql> insert into SkipFirstTenRecords values(108,'Ramit');
Query OK, 1 row affected (0.16 sec)

mysql> insert into SkipFirstTenRecords values(109,'Belly');
Query OK, 1 row affected (0.18 sec)

mysql> insert into SkipFirstTenRecords values(110,'Aaron ');
Query OK, 1 row affected (0.16 sec)

mysql> insert into SkipFirstTenRecords values(111,'Peter');
Query OK, 1 row affected (0.10 sec)

mysql> insert into SkipFirstTenRecords values(112,'Travis');
Query OK, 1 row affected (0.14 sec)

mysql> insert into SkipFirstTenRecords values(113,'Alex');
Query OK, 1 row affected (0.18 sec)

mysql> insert into SkipFirstTenRecords values(114,'Pat ');
Query OK, 1 row affected (0.11 sec)

Display all records which I have inserted in the table. The query is as follows:

mysql> select *from SkipFirstTenRecords;
The following is the output −
+-----------+-------------+
| StudentId | StudentName |
+-----------+-------------+
|       100 | John        |
|       101 | Johnson     |
|       102 | Carol       |
|       103 | Smith       |
|       104 | Bob         |
|       105 | David       |
|       106 | Sam         |
|       107 | Taylor      |
|       108 | Ramit       |
|       109 | Belly       |
|       110 | Aaron       |
|       111 | Peter       |
|       112 | Travis      |
|       113 | Alex        |
|       114 | Pat         |
+-----------+-------------+
15 rows in set (0.00 sec)
The query to skip first 10 records from the above table is all follows −
mysql> select *from SkipFirstTenRecords limit 10 offset 10;
The following is the output displays only the last 5 records since we skipped the first 10 records −
+-----------+-------------+
| StudentId | StudentName |
+-----------+-------------+
|        110 | Aaron      |
|        111 | Peter      |
|        112 | Travis     |
|        113 | Alex       |
|        114 | Pat        |
+-----------+-------------+
5 rows in set (0.00 sec)
Python - Unnest single Key Nested Dictionary List - GeeksforGeeks

14 May, 2020
Sometimes, while working with Python data, we can have a problem in which we need to perform unnesting of all the dictionaries which have single nesting of keys, i.e a single key and value and can easily be pointed to outer key directly. This kind of problem is common in domains requiring data optimization. Let’s discuss certain ways in which this task can be performed.
Input : test_list = [{‘gfg’ : {‘data’ : 1}}, {‘is’ : {‘data’ : 5, ‘geeks’ : 7}}]Output : {‘is’: 5, ‘gfg’: 1}
Input : test_list = [{‘gfg’ : {‘data’ : ‘best’}}]Output : {‘gfg’: ‘best’}
Method #1 : Using loop + items()The combination of above methods can be used to solve this problem. In this, we iterate for the values in list, using loop and extract all dictionary items using items() and perform new dictionary creation using brute force method.
# Python3 code to demonstrate working of # Unnest single Key Nested Dictionary List# Using loop + items()  # initializing listtest_list = [{'gfg' : {'data' : 1}}, {'is' : {'data' : 5}}, {'best' : {'data' : 4}}]  # printing original listprint("The original list is : " + str(test_list))  # initializing key data_key = 'data'  # Unnest single Key Nested Dictionary List# Using loop + items()res = dict()for sub in test_list:    for key, val in sub.items():        res[key] = sub[key][data_key]  # printing result print("The constructed Dictionary list : " + str(res)) 
The original list is : [{‘gfg’: {‘data’: 1}}, {‘is’: {‘data’: 5}}, {‘best’: {‘data’: 4}}]The constructed Dictionary list : {‘gfg’: 1, ‘best’: 4, ‘is’: 5}
 
Method #2 : Using list comprehensionThis is yet another way in which this task can be performed. In this, we perform solution in similar approach but in shorthand way using list comprehension.
# Python3 code to demonstrate working of # Unnest single Key Nested Dictionary List# Using list comprehension  # initializing listtest_list = [{'gfg' : {'data' : 1}}, {'is' : {'data' : 5}}, {'best' : {'data' : 4}}]  # printing original listprint("The original list is : " + str(test_list))  # initializing key data_key = 'data'  # Unnest single Key Nested Dictionary List# Using list comprehensionres = {x : y[data_key] for idx in test_list for x, y in idx.items()}  # printing result print("The constructed Dictionary list : " + str(res)) 
The original list is : [{‘gfg’: {‘data’: 1}}, {‘is’: {‘data’: 5}}, {‘best’: {‘data’: 4}}]The constructed Dictionary list : {‘gfg’: 1, ‘best’: 4, ‘is’: 5}
Python dictionary-programs
Python-nested-dictionary
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Read a file line by line in Python
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Python program to convert a list to string
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Split string into list of characters
Python | Convert a list to dictionary
CSS | Number Data Type - GeeksforGeeks

11 Jun, 2020
CSS Value is represented by <number> which takes an integer as a parameter or a number with a fractional component. They can be used by the symbol (+) or (-). The number can be positive or negative. All the digits of the number are 0 to 9 and all are of numeric types.
Syntax:
<number>
Note: No unit associated with numbers.
Examples for valid numbers
23, +90, -76, 0.56, 34.67, 10e4, -4.6e-2
Examples for invalid numbers
23., -+45, 45.7.6
Example 1: The following example demonstrates applying opacity to any element.
<!DOCTYPE html><html>  <head>    <style>        img {            opacity: 0.5;        }    </style></head>  <body>    <h1>GeeksforGeeks Logo</h1>      <p>        The opacity property specifies         the transparency of an element.        It takes a number as parameter.        The lower the value, the image         is more transparent     </p>          <img src="https://media.geeksforgeeks.org/wp-content/cdn-uploads/20190710102234/download3.png"        alt="GFG" width="170" height="100"></body>  </html>
Output:
Example 2: The following example shows the opacity property with some changed value.
<!DOCTYPE html><html>  <head>    <style>        img {            opacity: .11;        }    </style></head>  <body>      <h1>GeeksforGeeks Logo</h1>]      <p>        The opacity property specifies         the transparency of an element.        It takes a number as parameter.        The lower the value, the image         is more transparent:    </p>          <img src="https://media.geeksforgeeks.org/wp-content/cdn-uploads/20190710102234/download3.png"        alt="GFG" width="170" height="100"></body>  </html>
Output:
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
CSS-Misc
HTML-Misc
Picked
CSS
HTML
Web Technologies
Web technologies Questions
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Design a web page using HTML and CSS
How to set space between the flexbox ?
Form validation using jQuery
Search Bar using HTML, CSS and JavaScript
How to style a checkbox using CSS?
How to set the default value for an HTML <select> element ?
Hide or show elements in HTML using display property
How to set input type date in dd-mm-yyyy format using HTML ?
REST API (Introduction)
How to Insert Form Data into Database using PHP ?
What is the Call Stack in JavaScript ? - GeeksforGeeks

05 Jan, 2021
The call stack is used by JavaScript to keep track of multiple function calls. It is like a real stack in data structures where data can be pushed and popped and follows the Last In First Out (LIFO) principle. We use call stack for memorizing which function is running right now. The below example demonstrates the call stack.
Example:
Javascript
function f1() {  console.log('Hi by f1!');}  function f2() {  f1();  console.log('Hi by f2!');}  f2();
Output:
"Hi by f1!"
"Hi by f2!"
Explanation:
The steps and illustrations below explain the call stack of the above function.
Step 1: When the code loads in memory, the global execution context gets pushed in the stack.
Step 2: The f2() function gets called, and the execution context of f2() gets pushed into the stack.
Step 3: The execution of f2() starts and during its execution, the f1() function gets called inside the f2() function. This causes the execution context of f1() to get pushed in the call stack.
Step 4: Now the f1() function starts executing. A new stack frame of the console.log() method will be pushed to the stack.
Step 5: When the console.log() method runs, it will print “Hi by f1” and then it will be popped from the stack. The execution context go will back to the function and now there not any line of code that remains in the f1() function, as a result, it will also be popped from the call stack.
Step 6: This will similarly happen with the console.log() method that prints the line “Hi by f2” and then finally the function f2() would finish and would be pushed off the stack.
JavaScript-Misc
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Remove elements from a JavaScript Array
Difference between var, let and const keywords in JavaScript
Difference Between PUT and PATCH Request
JavaScript | Promises
How to get character array from string in JavaScript?
Remove elements from a JavaScript Array
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
Difference between var, let and const keywords in JavaScript
Python | sympy.crt() method - GeeksforGeeks

17 Sep, 2019
With the help of sympy.crt() method, we can implement the Chinese Remainder Theorem in SymPy.
Syntax: crt(m, v)
Parameter:m – It denotes a list of integers.v – It denotes a list of integers.
Returns: Returns a tuple of integers where the first element is the required result.
Example #1:
# import crt() method from sympyfrom sympy.ntheory.modular import crt  m = [5, 7]v = [1, 3]  # Use crt() method crt_m_v = crt(m, v)       print("Result of the Chinese Remainder Theorem = {} ".format(crt_m_v[0]))
Output:
Result of the Chinese Remainder Theorem = 31 

Example #2:
# import crt() method from sympyfrom sympy.ntheory.modular import crt  m = [99, 97, 95]v = [49, 76, 65]  # Use crt() method crt_m_v = crt(m, v)       print("Result of the Chinese Remainder Theorem = {} ".format(crt_m_v[0]))
Output:
Result of the Chinese Remainder Theorem = 639985 

SymPy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Read a file line by line in Python
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Iterate over a list in Python
Python String | replace()
*args and **kwargs in Python
Reading and Writing to text files in Python
Create a Pandas DataFrame from Lists
__getitem__() in Python - GeeksforGeeks

26 Mar, 2020
In Python, everything is an object. There are a lot of ‘ordinary’ system call methods on these objects behind the scene which is not visible to the programmer. Here come what are called as magic methods. Magic methods in python are special methods that are invoked when we run any ordinary python code. To differentiate them with normal functions, they have surrounding double underscores.
If we want to add a and b, we write the following syntax:
c = a + b

Internally it is called as:
c = a.__add__(b)

__getitem__() is a magic method in Python, which when used in a class, allows its instances to use the [] (indexer) operators. Say x is an instance of this class, then x[i] is roughly equivalent to type(x).__getitem__(x, i).
The method __getitem__(self, key) defines behavior for when an item is accessed, using the notation self[key]. This is also part of both the mutable and immutable container protocols.
Example:
# Code to demonstrate use# of __getitem__() in python    class Test(object):          # This function prints the type    # of the object passed as well     # as the object item    def __getitem__(self, items):        print (type(items), items)  # Driver codetest = Test()test[5]test[5:65:5]test['GeeksforGeeks']test[1, 'x', 10.0]test['a':'z':2]test[object()]
Output:
<class 'int'> 5
<class 'slice'> slice(5, 65, 5)
<class 'str'> GeeksforGeeks
<class 'tuple'> (1, 'x', 10.0)
<class 'slice'> slice('a', 'z', 2)
<class 'object'> <object object at 0x7f75bcd6d0a0>

Unlike some other languages, Python basically lets you pass any object into the indexer. You may be surprised that the test[1, 'x', 10.0] actually parses. To the Python interpreter, that expression is equivalent to this: test.__getitem__((1, 'x', 10.0)). As you can see, the 1, ‘x’, 10.0 part is implicitly parsed as a tuple. The test[5:65:5] expression makes use of Python’s slice syntax. It is equivalent to this expression: test[slice(5, 65, 5)].
The __getitem__ magic method is usually used for list indexing, dictionary lookup, or accessing ranges of values. Considering how versatile it is, it’s probably one of Python’s most underutilized magic methods.
python-oop-concepts
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 | os.path.join() method
Python | Get unique values from a list
Create a directory in Python
Defaultdict in Python
Python | Pandas dataframe.groupby()
Java Collections emptySet() Method with Examples - GeeksforGeeks

28 Dec, 2021
The emptySet() method is used to get the set that has no elements. This method is used in set collection. A set is a data structure that can store unique elements.
Syntax:
public static final <T> Set<T> emptySet()   
Parameters: This method will take no parameters.
Return Type: It will return an empty set that is immutable.
Example 1:
Java program to create an empty set
Java
import java.util.*;  public class GFG {    // main method    public static void main(String[] args)    {        // create an empty set        Set<String> data = Collections.<String>emptySet();                // display        System.out.println(data);    }}
[]

Example 2:
In this program, we are going to create an empty set and add elements to the set. This method will return an error.
Java
import java.util.*;  public class GFG {    // main method    public static void main(String[] args)    {        // create an empty set        Set<String> data = Collections.<String>emptySet();                // add 3 elements        data.add("ojaswi");        data.add("ramya");        data.add("deepu");          // display        System.out.println(data);    }}
Output:
Exception in thread "main" java.lang.UnsupportedOperationException
    at java.util.AbstractCollection.add(AbstractCollection.java:262)
    at GFG.main(GFG.java:8)
Java-Collections-Class
Java-Functions
Picked
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Stream In Java
Constructors in Java
Exceptions in Java
Functional Interfaces in Java
Different ways of Reading a text file in Java
Generics in Java
Introduction to Java
Internal Working of HashMap in Java
Comparator Interface in Java with Examples
Strings in Java
MySQL | IF( ) Function - GeeksforGeeks

21 Nov, 2019
The MySQL IF() function is used for validating a condition. The IF() function returns a value if the condition is TRUE and another value if the condition is FALSE. The MySQL IF() function can return values that can be either numeric or strings depending upon the context in which the function is used.The IF() function accepts one parameter which is the condition to be evaluated.
Syntax:
IF(condition, true_value, false_value)
Parameters Used:
condition – It is used to specify the condition to be evaluated.
true_value – It is an optional parameter which is used to specify the value to be returned if the condition evaluates to be true.
false_value – It is an optional parameter which is used to specify the value to be returned if the condition evaluates to be false.
Return Value:The MySQL IF() function returns a value if the condition is TRUE or a different value if the condition is FALSE.
Supported Versions of MySQL:
MySQL 5.7
MySQL 5.6
MySQL 5.5
MySQL 5.1
MySQL 5.0
MySQL 4.1
MySQL 4.0
MySQL 3.23
Example-1: Implementing IF() function on a numeric condition and returning a string value.
SELECT IF(5<12, 'TRUE', 'FALSE'); 
Output:
TRUE 
Example-2: Implementing IF() function to compare two strings.
SELECT IF(STRCMP('geeksforgeeks', 'gfg')=0, 'TRUE', 'FALSE'); 
Output:
FALSE 
Example-3: Implementing IF() function on a numeric condition and returning a numeric value.
SELECT IF(5<12, '1', '0'); 
Output:
1 
mysql
SQLmysql
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
SQL Interview Questions
CTE in SQL
How to Update Multiple Columns in Single Update Statement in SQL?
Difference between SQL and NoSQL
Difference between DDL and DML in DBMS
Difference between DELETE, DROP and TRUNCATE
MySQL | Group_CONCAT() Function
Difference between DELETE and TRUNCATE
SQL - ORDER BY
How to Create a Table With Multiple Foreign Keys in SQL?
Effect of Bias in Neural Network - GeeksforGeeks

25 Sep, 2018
Neural Network is conceptually based on actual neuron of brain. Neurons are the basic units of a large neural network. A single neuron passes single forward based on input provided.
In Neural network, some inputs are provided to an artificial neuron, and with each input a weight is associated. Weight increases the steepness of activation function. This means weight decide how fast the activation function will trigger whereas bias is used to delay the triggering of the activation function.
For a typical neuron, if the inputs are x1, x2, and x3, then the synaptic weights to be applied to them are denoted as w1, w2, and w3.
Output is
y  =  f(x)  =  Σxiwi
where i is 1 to the number of inputs.
The weight shows the effectiveness of a particular input. More the weight of input, more it will have impact on network.
On the other hand Bias is like the intercept added in a linear equation. It is an additional parameter in the Neural Network which is used to adjust the output along with the weighted sum of the inputs to the neuron. Therefore Bias is a constant which helps the model in a way that it can fit best for the given data.
The processing done by a neuron is thus denoted as :
output  =  sum (weights * inputs) + bias
In above figure
y = mx+c
where
m  =  weight
and
c  =  bias
Now, Suppose if c was absent, then the graph will be formed like this:
Due to absence of bias, model will train over point passing through origin only, which is not in accordance with real-world scenario. Also with the introduction of bias, the model will become more flexible.
For Example:Suppose an activation function act() which get triggered on some input greater than 0.Now,
input1 = 1
weight1 = 2
input2 = 2
weight2 = 2
so
output  =  input1*weight1 + input2*weight2
output  =  6
let
suppose act(output)  =  1
Now a bias is introduced in output as
bias  =  -6
the output become 0.
act(0)  =  0
so activation function will not trigger.
Here in graph, as it can be seen that when:
weight WI changed from  1.0 to 4.0 
 changed from  1.0 to 4.0 
weight W2 changed from  -0.5 to 1.5 
 changed from  -0.5 to 1.5 
On increasing the weight the steepness is increasing.
Therefore it can be inferred that
More the weight earlier activation function will trigger.
Here in graph below, when
Bias changed from  -1.0 to -5.0
The change in bias is increasing the value of triggering activation function.
Therefore it can be inferred that from above graph that,
bias helps in controlling the value at which activation function will trigger.
Misc
Misc
Misc
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Activation Functions
Characteristics of Internet of Things
Advantages and Disadvantages of OOP
Sensors in Internet of Things(IoT)
Challenges in Internet of things (IoT)
Election algorithm and distributed processing
Introduction to Internet of Things (IoT) | Set 1
Introduction to Electronic Mail
Communication Models in IoT (Internet of Things )
Introduction to Parallel Computing
numpy.ptp() in Python - GeeksforGeeks

23 Nov, 2021
numpy.ptp()function plays an important role in statistics by finding out Range of given numbers. Range = max value – min value.  
Syntax : ndarray.ptp(arr, axis=None, out=None) Parameters : arr :input array. axis :axis along which we want the range value. Otherwise, it will consider arr to be flattened(works on all the axis). axis = 0 means along the column and axis = 1 means working along the row. out : [ndarray, optional]Different array in which we want to place the result. The array must have same dimensions as expected output. Return : Range of the array (a scalar value if axis is none) or array with range of values along specified axis.  
Code #1: Working 
Python
# Python Program illustrating# numpy.ptp() method   import numpy as np   # 1D arrayarr = [1, 2, 7, 20, np.nan]print("arr : ", arr)print("Range of arr : ", np.ptp(arr)) # 1D arrayarr = [1, 2, 7, 10, 16]print("arr : ", arr)print("Range of arr : ", np.ptp(arr))
Output : 
arr :  [1, 2, 7, 20, nan]
Range of arr :  nan
arr :  [1, 2, 7, 10, 16]
Range of arr :  15
 Code #2 : 
Python
# Python Program illustrating# numpy.ptp() method import numpy as np # 3D arrayarr = [[14, 17, 12, 33, 44],        [15, 6, 27, 8, 19],       [23, 2, 54, 1, 4,]]print("\narr : \n", arr)    # Range of the flattened arrayprint("\nRange of arr, axis = None : ", np.ptp(arr))    # Range along the first axis# axis 0 means verticalprint("Range of arr, axis = 0 : ", np.ptp(arr, axis = 0))    # Range along the second axis# axis 1 means horizontalprint("Min of arr, axis = 1 : ", np.ptp(arr, axis = 1)) 
Output : 
arr : 
 [[14, 17, 12, 33, 44], [15, 6, 27, 8, 19], [23, 2, 54, 1, 4]]

Range of arr, axis = None :  53
Range of arr, axis = 0 :  [ 9 15 42 32 40]
Min of arr, axis = 1 :  [32 21 53]
 Code #3 : 
Python
# Python Program illustrating# numpy.ptp() method import numpy as np arr1 = np.arange(5)print("\nInitial arr1 : ", arr1)  # using out parameternp.ptp(arr, axis = 0, out = arr1)  print("Changed arr1(having results) : ", arr1)
Output :  
Initial arr1 :  [0 1 2 3 4]
Changed arr1(having results) :  [ 9 15 42 32 40]
cedricaganzebahirwe
Python numpy-Statistics Functions
Python-numpy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Iterate over a list in Python
*args and **kwargs in Python
Reading and Writing to text files in Python
Create a Pandas DataFrame from Lists
Convert integer to string in Python
Check if element exists in list in Python
Add space between histogram bars in Matplotlib - GeeksforGeeks

24 Jan, 2021
Matplotlib is a plotting library in Python programming language and it’s by default numerical mathematics extension of NumPy library in python language. While programming in python language we use the matplotlib library package for graph and histogram visualizations. But while plotting histogram using matplotlib in python, it lacks division or space between adjacent bars. This makes histograms very tedious to work with and it becomes very difficult to interpret. In this article, we will study how to add space between histogram bars in matplotlib. Let’s understand with this example:
Example 1: Creating a simple plot.
Python3
import matplotlib.pyplot as plt  values = [1, 2, 3, 3, 4, 5, 6, 6, 7, 8]  # Adjust the bar widths hereplt.hist(values)  plt.ylabel("Quantity")plt.xlabel("Value")plt.show()
Output:
Now we will add space between the histogram bars:
The space between bars can be added by using rwidth parameter inside the “plt.hist()” function. This value specifies the width of the bar with respect to its default width and the value of rwidth cannot be greater than 1.
Python3
import matplotlib.pyplot as plt  values = [1, 2, 3, 3, 4, 5, 6, 6, 7, 8]  # Adjust the bar widths hereplt.hist(values, rwidth=0.7)  plt.ylabel("Quantity")plt.xlabel("Value")plt.show()
Output:
Example 2: Creating a simple plot.
Python3
# Implementation of matplotlib function import matplotlib import numpy as np import matplotlib.pyplot as plt       np.random.seed(10**7) n_bins = 20x = np.random.randn(10000, 3)       colors = ['green', 'blue', 'lime']     plt.hist(x, n_bins, density = True,           histtype ='bar',          color = colors,          label = colors)     plt.legend(prop ={'size': 10})   plt.show()
Output:
With adding space:
Python3
# Implementation of matplotlib function import matplotlib import numpy as np import matplotlib.pyplot as plt       np.random.seed(10**7) n_bins = 20x = np.random.randn(10000, 3)       colors = ['green', 'blue', 'lime']     plt.hist(x, n_bins, density = True,           histtype ='bar',          color = colors,          label = colors,         rwidth = 0.5)     plt.legend(prop ={'size': 10})     plt.title('matplotlib.pyplot.hist() function Example\n\n',           fontweight ="bold")     plt.show()
Output:
Picked
Python-matplotlib
Technical Scripter 2020
Python
Technical Scripter
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
Defaultdict in Python
Create a directory in Python
Python | Pandas dataframe.groupby()
Scala Int toChar() method with example - GeeksforGeeks

04 Feb, 2020
The toChar() method is utilized to convert the specified int number into char type value.
Method Definition: (Number).toChar
Return Type: It returns the converted char datatype value.
Example #1:
// Scala program of Int toChar()// method  // Creating objectobject GfG{       // Main method    def main(args:Array[String])    {              // Applying toChar method        val result = (64).toChar                  // Displays output        println(result)    }} 
@

Example #2:
// Scala program of Int toChar()// method  // Creating objectobject GfG{       // Main method    def main(args:Array[String])    {              // Applying toChar method        val result = (68).toChar                  // Displays output        println(result)    }} 
D

Scala
Scala-Method
Scala
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Inheritance in Scala
Scala | Traits
Scala ListBuffer
Scala | Case Class and Case Object
Hello World in Scala
Scala | Functions - Basics
Scala | Try-Catch Exceptions
Scala | Decision Making (if, if-else, Nested if-else, if-else if)
Comments In Scala
Scala List map() method with example
HTML | DOM Table rows Collection - GeeksforGeeks

19 Feb, 2019
The Table rows collection is used for returning the collection of all the <tr> elements in a table. The sequence of the <tr> elements are sorted in the same way as their position in the source code.
Syntax
tableObject.rows
Properties
length : It is used to return the number of <tr> elements in the collection.
Methods
[index] : It is used for returning the <tr> element from the collection with a specified index.
item(index) : It is also used for returning the <tr> element from the collection with a specified index.
namedItem(id) : It is also used for returning the <tr> element from the collection with a specified id.
Below program illustrates the Table rows collection :Example: Finding out the number of rows in a table.
<!DOCTYPE html><html>  <head>    <title>Table rows Collection in HTML  </title>    <style>        table,        td {            border: 1px solid green;        }                  h1 {            color: green;        }                  h2 {            font-family: Impact;        }                  body {            text-align: center;        }    </style></head>  <body>      <h1>GeeksforGeeks</h1>    <h2>Table rows Collection</h2>      <p>To return the number of rows in the table,      double-click the "Return Count" button.</p>      <table id="Courses" align="center">        <caption>Courses by Geeksforgeeks</caption>        <tr>            <td>Java</td>            <td>Fork Java</td>        </tr>        <tr>            <td>Python</td>            <td>Fork Python</td>        </tr>        <tr>            <td>Placements</td>            <td>Sudo Placement</td>        </tr>    </table>    <br>      <button ondblclick="tr()">Return Count</button>      <p id="test"></p>      <script>        function tr() {                        // number of rows.            var c = document.getElementById(              "Courses").rows.length;            document.getElementById("test").innerHTML =               c + " Rows are present in the table.";        }    </script>  </body>  </html>
Output:
Before clicking the button:
After clicking the button:
Supported Browsers:
Apple Safari
Internet Explorer
Firefox
Google Chrome
Opera
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
HTML-DOM
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
REST API (Introduction)
HTML Cheat Sheet - A Basic Guide to HTML
Design a web page using HTML and CSS
Form validation using jQuery
Angular File Upload
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
Difference between var, let and const keywords in JavaScript
preventDefault() Event Method - GeeksforGeeks

18 Jan, 2019
The preventDefault() method is used to prevent the browser from executing the default action of the selected element. It can prevent the user from processing the request by clicking the link.Syntax:
event.preventDefault()
Parameters: It does not accept any parameter.The event is used to denote the event or action by the user in the response of which the method works.
<html>      <head>            <title>GEEKSFORGEEKS ARTICLE<title/>                <!-- INCLUDE THE JQUERY CDN -->                <script src="https://ajax.googleapis.com/ajax/                libs/jquery/3.3.1/jquery.min.js"></script>            <script type="text/javascript">               $(document).ready(function()                {                  $("a").click(function(event)               {                            event.preventDefault();                alert("prevented");               });                });             </script>    </head>    <body>        <p>Click the link:</p>           <a href="https://www.google.com">GOOGLE</a>    </body></html>
Output:It shows the output like given below-Code #2:This code will prevent the browser from redirecting the page to another PHP file.
<html>         <head>             <title>GEEKSFORGEEKS ARTICLE<title/>        <script src="https://ajax.googleapis.com/ajax/             libs/jquery/3.3.1/jquery.min.js"></script>           <script type="text/javascript">              $(document).ready(function()               {                  $("#submit").click(function(event)               {                            event.preventDefault();                alert("ACTION IS PREVENTED");                });                });            </script>    </head>    <body>       <form action="submit.php">            <input type="text" placeholder="enter username">            <input id="submit" type="submit" name="submit">       </form>    </body></html>
Output:It shows the output like given below-
JavaScript
JQuery
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Remove elements from a JavaScript Array
Convert a string to an integer in JavaScript
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
How to append HTML code to a div using JavaScript ?
JQuery | Set the value of an input text field
Form validation using jQuery
How to change the background color after clicking the button in JavaScript ?
How to fetch data from JSON file and display in HTML table using jQuery ?
How to Dynamically Add/Remove Table Rows using jQuery ?
Java program to find the 3rd largest number in an array

To find the third largest number of the given array, first of all, sort the array.
Compare the first two elements of the array
If the first element is greater than the second swap them.
Then, compare 2nd and 3rd elements if the second element is greater than the 3rd swap them.
Repeat this till the end of the array.
After sorting an array print the third element from the end of the array.
Live Demo
public class ThirdLargestNumberInAnArray {
   public static void main(String args[]){
   int temp, size;
   int array[] = {10, 20, 25, 63, 96, 57};
   size = array.length;
   
   for(int i = 0; i<size; i++ ){
      for(int j = i+1; j<size; j++){
         if(array[i]>array[j]){
            temp = array[i];
            array[i] = array[j];
            array[j] = temp;
         }
      }
   }
   System.out.println("Third largest number is:: "+array[size-3]);
   }
}
Third largest number is:: 57
You can also sort the elements of the given array using the sort method of the java.util.Arrays class then, print the third element from the end of the array.
Live Demo
import java.util.Arrays;
public class LargestNumberSample {
   public static void main(String args[]){
      int array[] = {10, 20, 25, 63, 96, 57};
      int size = array.length;
      Arrays.sort(array);
      System.out.println("sorted Array ::"+Arrays.toString(array));
      int max = array[size-3];
      System.out.println("3rd largest element is :"+max);
   }
}
sorted Array ::[10, 20, 25, 57, 63, 96]
3rd largest element is :57
Why do we need to change the delimiter for creating a trigger?

As we know that in MySQL we use the delimiter semicolon (;) to end each statement. The semicolon is the by default delimiter in MySQL. We need to change the delimiter, while creating a trigger, to tell MySQL that this is not the end of our trigger statement because we can use multiple statements in the trigger. We can change the delimiter temporarily by DELIMITER // statement to change the delimiter from Semicolon (;) to two back-slash (//). After this MySQL would know that the triggering statement only ends when it encounters a two back-slash (//). Following is an example of changing the delimiter −
mysql> DELIMITER //
Now to end the MySQL statements, the delimiter would be a two back-slash (//). And to change it again to a semicolon(;), we can use the following statement −
mysql> DELIMITER ;
Remember that there must be a space between the keyword DELIMITER and the symbol which we want to use as a delimiter.
Python - Chart Styling

The charts created in python can have further styling by using some appropriate methods from the libraries used for charting. In this lesson we will see
the implementation of Annotation, legends and chart background. We will continue to use the code from the last chapter and modify it to add these styles to the chart.
Many times, we need to annotate the chart by highlighting the specific locations of the chart. In the below example we indicate the sharp change in values in the chart by adding annotations at those points.
import numpy as np 
from matplotlib import pyplot as plt 

x = np.arange(0,10) 
y = x ^ 2 
z = x ^ 3
t = x ^ 4 
# Labeling the Axes and Title
plt.title("Graph Drawing") 
plt.xlabel("Time") 
plt.ylabel("Distance") 
plt.plot(x,y)

#Annotate
plt.annotate(xy=[2,1], s='Second Entry') 
plt.annotate(xy=[4,6], s='Third Entry') 
Its output is as follows −
We sometimes need a chart with multiple lines being plotted. Use of legend represents the meaning associated with each line. In the below chart we have 3 lines with appropriate legends.
import numpy as np 
from matplotlib import pyplot as plt 

x = np.arange(0,10) 
y = x ^ 2 
z = x ^ 3
t = x ^ 4 
# Labeling the Axes and Title
plt.title("Graph Drawing") 
plt.xlabel("Time") 
plt.ylabel("Distance") 
plt.plot(x,y)

#Annotate
plt.annotate(xy=[2,1], s='Second Entry') 
plt.annotate(xy=[4,6], s='Third Entry') 
# Adding Legends
plt.plot(x,z)
plt.plot(x,t)
plt.legend(['Race1', 'Race2','Race3'], loc=4) 
Its output is as follows −
We can modify the presentation style of the chart by using different methods from the style package.
import numpy as np 
from matplotlib import pyplot as plt 

x = np.arange(0,10) 
y = x ^ 2 
z = x ^ 3
t = x ^ 4 
# Labeling the Axes and Title
plt.title("Graph Drawing") 
plt.xlabel("Time") 
plt.ylabel("Distance") 
plt.plot(x,y)

#Annotate
plt.annotate(xy=[2,1], s='Second Entry') 
plt.annotate(xy=[4,6], s='Third Entry') 
# Adding Legends
plt.plot(x,z)
plt.plot(x,t)
plt.legend(['Race1', 'Race2','Race3'], loc=4) 

#Style the background
plt.style.use('fast')
plt.plot(x,z)
Its output is as follows −

    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
How to Find Sum of Natural Numbers Using Recursion in Python?

If a function calls itself, it is called a recursive function. In order to prevent it from falling in infinite loop, recursive call is place in a conditional statement.
Following program accepts a number as input from user and sends it as argument to rsum() function. It recursively calls itself by decrementing the argument each time till it reaches 1.
def rsum(n):
    if n <= 1:
        return n
    else:
        return n + rsum(n-1)

num = int(input("Enter a number: "))
ttl=rsum(num)
print("The sum is",ttl)
Sample run of above program prints sum o natural numbers upto input number
Enter a number: 10
The sum is 55
Constructors in Java


Constructors are similar to methods and are different in the following sense.
They do not have any return type.
They do not have any return type.
The name of the constructor is the same as the name of the class.
The name of the constructor is the same as the name of the class.
Every class has a constructor. If we do not explicitly write a constructor for a class, the Java compiler builds a default constructor for that class.
Every class has a constructor. If we do not explicitly write a constructor for a class, the Java compiler builds a default constructor for that class.
Each time a new object is created, at least one constructor will be invoked.
Each time a new object is created, at least one constructor will be invoked.
A class can have more than one constructor.
A class can have more than one constructor.
class A {
   public int a;
   //default constructor
   public A() {
      this(-1);
   }

   //parameterized constructor
   public A(int a) {
      this.a = a;
   }
}

public class Tester {
   public static void main(String[] args) {
      //new object created using default constructor
      A a1 = new A();        
      System.out.println(a1.a);

      //new object created using parameterized constructor
      A a2 = new A(1);        
      System.out.println(a2.a);
   }
}
-1
1
C library Macro - EDOM

As mentioned above, the C library macro EDOM represents a domain error, which occurs if an input argument is outside the domain, over which the mathematical function is defined and errno is set to EDOM.
Following is the declaration for EDOM Macro.
#define EDOM some_value
NA
NA
NA
NA
The following example shows the usage of EDOM Macro.
#include <stdio.h>
#include <errno.h>
#include <math.h>

int main () {
   double val;

   errno = 0;
   val = sqrt(-10);
   
   if(errno == EDOM) {
      printf("Invalid value \n");
   } else {
      printf("Valid value\n");
   }
   
   errno = 0;
   val = sqrt(10);
   
   if(errno == EDOM) {
      printf("Invalid value\n");
   } else {
      printf("Valid value\n");
   }
   
   return(0);
}
Let us compile and run the above program that will produce the following result −
Trape – Free GUI Based Phishing or Tracking Tool

18 Jul, 2021
Trape is a tool written in Python which can be used to lure the victim in phishing or redirecting him to another website etc. So when a victim gets lure into the phishing attack, the tool captures the victim’s IP address, location, and sessions, etc. The captured results can be seen in the dashboard in a web browser. It can also be said that it is an OSINT research tool, which allows people to track and execute social engineering attacks in real-time.
Easy to use.
Traces the path between you and the target.
Easy to install.
It can manage social engineering attacks in the target’s browser.
First clone the tool from the Github repo using the following commands.
git clone https://github.com/boxug/trape.git
Change directory by,
cd trape
Now we need to install some requirements before running trape.
pip install -r requirements.txt
Fig 1: Cloning Trape from GitHub Repository.
Run the tool by entering python trape.py -h to check the options it provides.
Fig 2: Trape tool.
Enter the URL on which you want the victim to be redirected when he clicks on it say, we want the victim to be redirected to google.com. So the command will be:
python trape.py -u https://google.com -p 8080.
Fig 3: Waiting for victim to click on the url.
In the meantime, open the control panel by copying the control panel link in your web browser and sign in with the access key you have been provided.
Fig 4: Control Panel.
Now in the dashboard, we can see, that the victim has clicked on the URL and we can see his public IP, what browser he is using. Click on details on the bottom right to know other things about the victim like his location etc.
FIg 5: Victim’s Report.
Here we can see both the public IP and the local IP of the victim, his operating system, browser, which country and city he resides in.
FIg 6: Victim’s detailed information.
We can also perform social engineering attacks using trape tools like we can generate an alert.
Fig 7: Alert generated.
We can send a file.
Fig 8: Sending file to victim.
We can also redirect him to a phishing page.
Fig 9: Victim redirected to phishing page.
Linux-Tools
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Docker - COPY Instruction
scp command in Linux with Examples
chown command in Linux with Examples
Introduction to Linux Operating System
SED command in Linux | Set 2
Array Basics in Shell Scripting | Set 1
nohup Command in Linux with Examples
chmod command in Linux with examples
mv command in Linux with examples
Basic Operators in Shell Scripting