code-rag-bench/online-tutorials huggingface dataset:
What is the difference between $(window).load() and $(document).ready() functions in jQuery?

Both the methods are used in jQuery. Let’s see what purpose they fulfill.
$(window).load()
The code which gets included inside $( window ).on( "load", function() { ... }) runs only once the entire page is ready (not only DOM).
Note: The load() method deprecated in jQuery version 1.8. It was completely removed in version 3.0. To see its working, add jQuery version for CDN before 3.0.
$(document).ready()
The ready() method is used to make a function available after the document is loaded. Whatever code you write inside the $( document ).ready() method will run once the page DOM is ready to execute JavaScript code.
You can try to run the following code to learn how to use to use $(document).ready() in jQuery:
Live Demo
<html>

   <head>
      <title>jQuery Function</title>
      <script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

      <script>
         $(document).ready(function() {
           $("div").click(function() {
              alert("Hi!");
           });
         });
      </script>
   </head>
   
   <body>
      <div id = "mydiv">
         Click on this to see a dialogue box.
      </div>
   </body>
</html>
You can try to run the following code to learn how to use $(window).load() in jQuery:
Live Demo
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("img").load(function(){
      alert("Image successfully loaded.");
    });
});
</script>
</head>
<body>

<img src="/videotutorials/images/tutor_connect_home.jpg" alt="Tutor Connect" width="310" height="220">

<p><strong>Note:</strong> The load() method deprecated in jQuery version 1.8. It was completely removed in version 3.0. To see its working, add jQuery version for CDN before 3.0.</p>

</body>
</html>
GATE | GATE-CS-2015 (Set 3) | Question 51 - GeeksforGeeks

28 Jun, 2021
Let R be a relation on the set of ordered pairs of positive integers such that ((p, q), (r, s)) ∈ R if and only if p–s = q–r. Which one of the following is true about R?(A) Both reflexive and symmetric(B) Reflexive but not symmetric(C) Not reflexive but symmetric(D) Neither reflexive nor symmetricAnswer: (C)Explanation:
((p, q), (r, s)) ∈ R if and only if p–s = q–r

(p, q) is not related to (p, q)

as p-q is not same as q-p.

The relation is symmetric because if p–s = q–r, then s-q = s-p. 
Quiz of this Question
GATE-CS-2015 (Set 3)
GATE-GATE-CS-2015 (Set 3)
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | Gate IT 2007 | Question 25
GATE | GATE-CS-2000 | Question 41
GATE | GATE-CS-2001 | Question 39
GATE | GATE-CS-2005 | Question 6
GATE | GATE MOCK 2017 | Question 21
GATE | GATE-CS-2006 | Question 47
GATE | GATE MOCK 2017 | Question 24
GATE | Gate IT 2008 | Question 43
GATE | GATE-CS-2009 | Question 38
GATE | GATE-CS-2003 | Question 90
C++ | Operator Overloading | Question 4 - GeeksforGeeks

28 Jun, 2021
Which of the following operators should be preferred to overload as a global function rather than a member method?(A) Postfix ++(B) Comparison Operator(C) Insertion Operator <<(D) Prefix++Answer: (C)Explanation: cout is an object of ostream class which is a compiler defined class.
When we do “cout << obj" where obj is an object of our class, the compiler first looks for an operator function in ostream, then it looks for a global function.One way to overload insertion operator is to modify ostream class which may not be a good idea. So we make a global method. Following is an example.
#include <iostream>
using namespace std;

class Complex
{
private:
    int real;
    int imag;
public:
    Complex(int r = 0, int i =0)
    {
        real = r;
        imag = i;
    }
    friend ostream & operator << (ostream &out, const Complex &c);
};

ostream & operator << (ostream &out, const Complex &c)
{
    out << c.real;
    out << "+i" << c.imag;
    return out;
}

int main()
{
    Complex c1(10, 15);
    cout << c1;
    return 0;
}

Quiz of this Question
C++-Operator Overloading
Operator Overloading
C Language
C++ Quiz
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Function Pointer in C
rand() and srand() in C/C++
Substring in C++
fork() in C
std::string class in C++
C++ | new and delete | Question 4
C++ | new and delete | Question 1
C++ | Inheritance | Question 3
C++ | References | Question 4
C++ | Inheritance | Question 7
Output of C++ Program | Set 3

24 Sep, 2021
Predict the output of below C++ programs.Question 1
C++
#include<iostream> using namespace std;class P {public:   void print()   { cout <<" Inside P::"; }}; class Q : public P {public:   void print()   { cout <<" Inside Q"; }}; class R: public Q {}; int main(void){  R r;   r.print();  return 0;}
Output: Inside Q
The print function is not defined in class R. So it is looked up in the inheritance hierarchy. print() is present in both classes P and Q, which of them should be called? The idea is, if there is multilevel inheritance, then function is linearly searched up in the inheritance hierarchy until a matching function is found.
Question 2 
C++
#include<iostream>#include<stdio.h> using namespace std; class Base{public:  Base()  {    fun(); //note: fun() is virtual  }  virtual void fun()  {    cout<<"\nBase Function";  }}; class Derived: public Base{public:  Derived(){}  virtual void fun()  {    cout<<"\nDerived Function";  }}; int main(){  Base* pBase = new Derived();  delete pBase;  return 0;}
Output: Base Function
See following excerpt from C++ standard for explanation.
When a virtual function is called directly or indirectly from a constructor (including from the mem-initializer for a data member) or from a destructor, and the object to which the call applies is the object under construction or destruction, the function called is the one defined in the constructor or destructor’s own class or in one of its bases, but not a function overriding it in a class derived from the constructor or destructor’s class, or overriding it in one of the other base classes of the most derived object.
Because of this difference in behavior, it is recommended that object’s virtual function is not invoked while it is being constructed or destroyed. See this for more details.Please write comments if you find any of the answers/explanations incorrect, or you want to share more information about the topics discussed above. 
sagartomar9927
CPP-Output
Program Output
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
ReactJS Pure Components

07 Aug, 2020
Generally, In ReactJS, we use shouldComponentUpdate() Lifecycle method to customize the default behavior and implement it when the React component should re-render or update itself.
Prerequisite: 
ReactJS Components
ReactJS Components – Set 2
Now, ReactJS has provided us a Pure Component. If we extend a class with Pure Component, there is no need for shouldComponentUpdate() Lifecycle Method. ReactJS Pure Component Class compares current state and props with new props and states to decide whether the React component should re-render itself or  Not.
In simple words, If the previous value of state or props and the new value of state or props is the same, the component will not re-render itself. Since Pure Components restricts the re-rendering when there is no use of re-rendering of the component. Pure Components are Class Components which extends React.PureComponent. 
Example:  Program to demonstrate the creation of Pure Components. 
javascript
import React from ‘react’;  export default class Test extends React.PureComponent{   render(){      return <h1>Welcome to GeeksforGeeks</h1>;   }}
Output :
Extending React Class Components with Pure Components ensures the higher performance of the Component and ultimately makes your application faster, While in the case of Regular Component, it will always re-render either value of State and Props changes or not.
While using Pure Components, Things to be noted are that, In these components, the Value of State and Props are Shallow Compared (Shallow Comparison) and It also takes care of “shouldComponentUpdate” Lifecycle method implicitly.So there is a possibility that if these State and Props Objects contain nested data structure then Pure Component’s implemented shouldComponentUpdate will return false and will not update the whole subtree of Children of this Class Component. So in Pure Component, the nested data structure doesn’t work properly.
In this case, State and Props Objects should be simple objects and Child Elements should also be Pure, means to return the same output for the same input values at any instance.
react-js
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | sympy.simplify() method

25 Jun, 2019
With the help of sympy.simplify() method, we can simplify any mathematical expression.
Syntax: simplify(expression)
Parameters:expression – It is the mathematical expression which needs to be simplified.
Returns: Returns a simplified mathematical expression corresponding to the input expression.
Example #1:In this example we can see that by using sympy.lambdify() method, we can simplify any mathematical expression.
# import sympyfrom sympy import *   x = symbols('x')expr = sin(x)**2 + cos(x)**2  print("Before Simplification : {}".format(expr))    # Use sympy.simplify() methodsmpl = simplify(expr)     print("After Simplification : {}".format(smpl)) 
Output:
Before Simplification : sin(x)**2 + cos(x)**2
After Simplification : 1

Example #2:
# import sympyfrom sympy import *   x = symbols('x')expr = (x**3 + x**2 - x - 1)/(x**2 + 2 * x + 1)  print("Before Simplification : {}".format(expr))    # Use sympy.simplify() methodsmpl = simplify(expr)     print("After Simplification : {}".format(smpl)) 
Output:
Before Simplification : (x**3 + x**2 - x - 1)/(x**2 + 2*x + 1)
After Simplification : After Simplification : x - 1

SymPy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
MongoDB query to return specific fields from an array?

To return specific fields, use aggregate $project. Let us first create a collection with documents −
> db.returnSpecificFieldDemo.insertOne(
   {
      "StudentId":1,
      "StudentDetails": [
         {
            "StudentName":"Larry",
            "StudentAge":21,
            "StudentCountryName":"US"
         },
         {
            "StudentName":"Chris",
            "StudentAge":23,
            "StudentCountryName":"AUS"
         }
      ]
   }
);
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5ce23d3236e8b255a5eee943")
}
Following is the query to display all documents from a collection with the help of find() method −
> db.returnSpecificFieldDemo.find().pretty();
This will produce the following output −
{
   "_id" : ObjectId("5ce23d3236e8b255a5eee943"),
   "StudentId" : 1,
   "StudentDetails" : [
      {
         "StudentName" : "Larry",
         "StudentAge" : 21,
         "StudentCountryName" : "US"
      },
      {
         "StudentName" : "Chris",
         "StudentAge" : 23,
         "StudentCountryName" : "AUS"
      }
   ]
}
Following is the query to return specific fields from an array −
> db.returnSpecificFieldDemo.aggregate([{$project:{_id:0, StudentId:'$StudentId', StudentCountryName:{ $arrayElemAt: ['$StudentDetails.StudentCountryName',1] }}}]);
This will produce the following output −
{ "StudentId" : 1, "StudentCountryName" : "AUS" }
Python Pandas - Check if the index has duplicate values

To check if the index has duplicate values, use the index.has_duplicates property in Pandas.
At first, import the required libraries −
import pandas as pd
Creating the index −
index = pd.Index(['Car','Bike','Truck','Car','Airplane'])

Display the index −
print("Pandas Index...\n",index)
Check if the index is having duplicate values −
print("\nIs the Pandas index having duplicate values?\n",index.has_duplicates)

Following is the code −
import pandas as pd

# Creating the index
index = pd.Index(['Car','Bike','Truck','Car','Airplane'])

# Display the index
print("Pandas Index...\n",index)

# Return an array representing the data in the Index
print("\nArray...\n",index.values)

# Check if the index is having duplicate values
print("\nIs the Pandas index having duplicate values?\n",index.has_duplicates)
This will produce the following code −
Pandas Index...
Index(['Car', 'Bike', 'Truck', 'Car', 'Airplane'], dtype='object')

Array...
['Car' 'Bike' 'Truck' 'Car' 'Airplane']

Is the Pandas index having duplicate values?
True
How to query MySQL on the current week?

To query MySQL on the current week, you can use YEARWEEK() function.
The syntax is as follows
SELECT *FROM yourTableName WHERE YEARWEEK(yourDateColumnName) = YEARWEEK(NOW());
To understand the above syntax, let us create a table. The query to create a table is as follows
mysql> create table currentWeekDemo
   -> (
   -> UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   -> UserName varchar(20),
   -> UserPostDate date
   -> );
Query OK, 0 rows affected (0.68 sec)
Insert some records in the table using insert command. The query is as follows −
mysql> insert into currentWeekDemo(UserName,UserPostDate) values('Carol','2010-01-06');
Query OK, 1 row affected (0.20 sec)
mysql> insert into currentWeekDemo(UserName,UserPostDate) values('Bob','2019-06-04');
Query OK, 1 row affected (0.17 sec)
mysql> insert into currentWeekDemo(UserName,UserPostDate) values('David','2019-03-06');
Query OK, 1 row affected (0.16 sec)
mysql> insert into currentWeekDemo(UserName,UserPostDate) values('Maxwell','2018-04-21');
Query OK, 1 row affected (0.15 sec)
Display all records from the table using select statement. The query is as follows −
mysql> select *from currentWeekDemo;
The following is the output
+--------+----------+--------------+
| UserId | UserName | UserPostDate |
+--------+----------+--------------+
|      1 | Carol    | 2010-01-06   |
|      2 | Bob      | 2019-06-04   |
|      3 | David    | 2019-03-06   |
|      4 | Maxwell  | 2018-04-21   |
+--------+----------+--------------+
4 rows in set (0.00 sec)
The following is how you can query MySQL on the current week
mysql> select *from currentWeekDemo WHERE YEARWEEK(UserPostDate) = YEARWEEK(NOW());
The following is the output
+--------+----------+--------------+
| UserId | UserName | UserPostDate |
+--------+----------+--------------+
|      3 | David    | 2019-03-06   |
+--------+----------+--------------+
1 row in set (0.05 sec)
\small - Tex Command

\small - Used to turn on small size.
{ \small ...}
\small command turn on small size.

\rm\tiny tiny \Tiny Tiny
\small small \normalsize normal
\large lg \Large Lg \LARGE LG
\huge hg \Huge Hg

tinyTinysmallnormallgLgLGhgHg


\def\myExp{\alpha\frac xy}
\tiny\myExp \Tiny\myExp
\small\myExp \normalsize\myExp
\large\myExp \Large\myExp \LARGE\myExp
\huge\myExp \Huge\myExp

αxyαxyαxyαxyαxyαxyαxyαxyαxy


ab{\small cd} cd

abcdcd


ab\small{cd} cd

abcdcd



\rm\tiny tiny \Tiny Tiny
\small small \normalsize normal
\large lg \Large Lg \LARGE LG
\huge hg \Huge Hg

tinyTinysmallnormallgLgLGhgHg


\rm\tiny tiny \Tiny Tiny
\small small \normalsize normal
\large lg \Large Lg \LARGE LG
\huge hg \Huge Hg
\def\myExp{\alpha\frac xy}
\tiny\myExp \Tiny\myExp
\small\myExp \normalsize\myExp
\large\myExp \Large\myExp \LARGE\myExp
\huge\myExp \Huge\myExp

αxyαxyαxyαxyαxyαxyαxyαxyαxy


\def\myExp{\alpha\frac xy}
\tiny\myExp \Tiny\myExp
\small\myExp \normalsize\myExp
\large\myExp \Large\myExp \LARGE\myExp
\huge\myExp \Huge\myExp
ab{\small cd} cd

abcdcd


ab{\small cd} cd
ab\small{cd} cd

abcdcd


ab\small{cd} cd

    14 Lectures 
     52 mins

 Ashraf Said

    11 Lectures 
     1 hours 

 Ashraf Said

    9 Lectures 
     1 hours 

 Emenwa Global, Ejike IfeanyiChukwu

    29 Lectures 
     2.5 hours 

 Mohammad Nauman

    14 Lectures 
     1 hours 

 Daniel Stern

    15 Lectures 
     47 mins

 Nishant Kumar
 Print
 Add Notes
 Bookmark this page
Ways to concatenate tuples in Python

When it is required to concatenate multiple tuples, the '+' operator can be used. A tuple is an immutable data type. It means, values once defined can't be changed by accessing their index elements. If we try to change the elements, it results in an error. They are important contains since they ensure read-only access.
The '+' operator can be used to add numeric values or concatenate strings.
Below is a demonstration of the same −
Live Demo
my_tuple_1 = (11, 14, 0, 78, 33, 11)
my_tuple_2 = (10, 78, 0, 56, 8, 34)

print("The first tuple is : ")
print(my_tuple_1)
print("The second tuple is : ")
print(my_tuple_2)

my_result = my_tuple_1 + my_tuple_2

print("The tuple after concatenation is : " )
print(my_result)
The first tuple is :
(11, 14, 0, 78, 33, 11)
The second tuple is :
(10, 78, 0, 56, 8, 34)
The tuple after concatenation is :
(11, 14, 0, 78, 33, 11, 10, 78, 0, 56, 8, 34)
Two tuples are defined and are displayed on the console.
They are concatenated using the '+' operator.
This is assigned to a value.
It is displayed on the console.
arg() function for Complex Number in C++ - GeeksforGeeks

11 Oct, 2018
The arg() function for complex number is defined in the complex header file. This function is used to return the argument of the complex number z.
Syntax:
template<class T> T arg (const complex<T>& z);

Parameter:
z: It represents the given complex number.
Return: It returns the argument of the complex number.
Below programs illustrate the above function:-
Example 1:
// C++ program to demonstrate// example of arg() function.  #include <bits/stdc++.h>using namespace std;  int main (){  // defines the complex number: (5.0 + 12.0i)  complex<double> complexnumber (5.0, 12.0);    // prints the argument of the complex number  cout << "The argument of " << complexnumber << " is: ";  cout << arg(complexnumber) << endl;    return 0;}
The argument of (5,12) is: 1.17601

Example 2:
// C++ program to demonstrate// example of arg() function  #include <bits/stdc++.h>using namespace std;  int main (){  // defines the complex number: (4.0+3.0i)  complex<double> complexnumber (4.0, 3.0);    // prints the argument of the complex number  cout << "The argument of " << complexnumber << " is: ";  cout << arg(complexnumber) << endl;    return 0;}
The argument of (4,3) is: 0.643501

CPP-complex
CPP-Functions
CPP-Library
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Operator Overloading in C++
Polymorphism in C++
Friend class and function in C++
Sorting a vector in C++
std::string class in C++
Pair in C++ Standard Template Library (STL)
Inline Functions in C++
Array of Strings in C++ (5 Different Ways to Create)
Convert string to char array in C++
Destructors in C++
Create DATETIME from DATE and TIME in MySQL?

You can create DATETIME from DATE and TIME with the help of ADDTIME() function in MySQL. The syntax is as follows −
SELECT ADDTIME(CONVERT(yourDateColumnName,datetime),yourTimeColumnName) as anyVariableName from yourTableName;
To understand the above concept, let us create a table. The query to create a table is as follows −
mysql> create table DateTime
   −> (
   −> DueDate date,
   −> DueTime time
   −> );
Query OK, 0 rows affected (1.19 sec)
Now you can insert date and time separately. The query to insert is as follows −
mysql> insert into DateTime values(curdate(),now());
Query OK, 1 row affected (0.08 sec)
Display all records from the table with the help of select statement −
mysql> select *from DateTime;
The following is the output −
+------------+----------+
| DueDate    | DueTime  |
+------------+----------+
| 2018-12-11 | 09:59:07 |
+------------+----------+
1 row in set (0.00 sec)
Now you can implement the syntax we discussed in the beginning to create a datetime from date and time. The query is as follows −
mysql> select addtime(convert(DueDate,datetime),DueTime) as DATETimeDemo from DateTime;
The following is the output displaying datetime created from date and time −
+---------------------+
| DATETimeDemo        |
+---------------------+
| 2018-12-11 09:59:07 |
+---------------------+
1 row in set (0.00 sec)
Removing stop words with NLTK in Python

When computers process natural language, some extremely common words which would appear to be of little value in helping select documents matching a user need are excluded from the vocabulary entirely. These words are called stop words.
For example, if you give the input sentence as −
John is a person who takes care of the people around him.
After stop word removal, you'll get the output −
['John', 'person', 'takes', 'care', 'people', 'around', '.']
NLTK has a collection of these stopwords which we can use to remove these from any given sentence. This is inside the NLTK.corpus module. We can use that to filter out stop words from out sentence. For example,
from nltk.corpus import stopwords
from nltk.tokenize import word_tokenize

my_sent = "John is a person who takes care of people around him."
tokens = word_tokenize(my_sent)

filtered_sentence = [w for w in tokens if not w in stopwords.words()]

print(filtered_sentence)
This will give the output −
['John', 'person', 'takes', 'care', 'people', 'around', '.']
C++ Program to compute division upto n decimal places

Given with the value of x and y as a positive integer with the value of n for number of decimal places and the task is to generate the division up to n decimal places.
Input-: x = 36, y = 7, n = 5
Output-: 5.14285
Input-: x = 22, y = 7, n = 10
Output-: 3.1428571428
Approach used in the below program is as follows −
Input the value of a, b and n
Check if b is 0 than division will go upto infinite and if a is 0 than result will be 0 as something divides to 0 is 0
If n is greater than 1 than store the value of remainder and subtract it from the dividend after that multiply the result by ten. Start the next iteration
Print the result
START
Step 1-> declare function to compute division upto n decimal places
   void compute_division(int a, int b, int n)
   check IF (b == 0)
      print Infinite
   End
   check IF(a == 0)
      print 0
   End
   check IF(n <= 0)
      print a/b
   End
   check IF(((a > 0) && (b < 0)) || ((a < 0) && (b > 0)))
      print “-”
      set a = a > 0 ? a : -a
      set b = b > 0 ? b : -b
   End
   Declare and set int dec = a / b
   Loop For int i = 0 and i <= n and i++
      print dec
      Set a = a - (b * dec)
      IF(a == 0)
         break
      End
      Set a = a * 10
      set dec = a / b
      IF (i == 0)
         print “.”
      End
   End
Step 2-> In main()
   Declare and set int a = 36, b = 7, n = 5
   Call compute_division(a, b, n)
STOP
#include <bits/stdc++.h>
using namespace std;
void compute_division(int a, int b, int n) {
    if (b == 0) {
        cout << "Infinite" << endl;
        return;
    }
    if (a == 0) {
        cout << 0 << endl;
        return;
    }
    if (n <= 0) {
        cout << a / b << endl;
        return;
    }
    if (((a > 0) && (b < 0)) || ((a < 0) && (b > 0))) {
        cout << "-";
        a = a > 0 ? a : -a;
        b = b > 0 ? b : -b;
    }
    int dec = a / b;
    for (int i = 0; i <= n; i++) {
        cout <<dec;
        a = a - (b * dec);
        if (a == 0)
            break;
        a = a * 10;
        dec = a / b;
        if (i == 0)
            cout << ".";
    }
}
int main() {
    int a = 36, b = 7, n = 5;
    compute_division(a, b, n);
    return 0;
}
5.14285
Functional Programming - Recursion

A function that calls itself is known as a recursive function and this technique is known as recursion. A recursion instruction continues until another instruction prevents it.
The following example shows how recursion works in C++, which is an object-oriented programming language −
#include <stdio.h> 
long int fact(int n);  

int main() { 
   int n; 
   printf("Enter a positive integer: "); 
   scanf("%d", &n); 
   printf("Factorial of %d = %ld", n, fact(n)); 
   return 0; 
} 
long int fact(int n) { 
   if (n >= 1) 
      return n*fact(n-1); 
   else 
      return 1; 
} 
It will produce the following output
Enter a positive integer: 5 
Factorial of 5 = 120 

The following example shows how recursion works in Python, which is a functional programming language −
def fact(n): 
   if n == 1: 
      return n 
   else: 
      return n* fact (n-1)  

# accepts input from user 
num = int(input("Enter a number: "))  
# check whether number is positive or not 

if num < 0: 
   print("Sorry, factorial does not exist for negative numbers") 
else: 
   print("The factorial of " + str(num) +  " is " + str(fact(num))) 
It will produce the following output −
Enter a number: 6
The factorial of 6 is 720   


    32 Lectures 
     3.5 hours 

 Pavan Lalwani

    11 Lectures 
     1 hours 

 Prof. Paul Cline, Ed.D

    72 Lectures 
     10.5 hours 

 Arun Ammasai

    51 Lectures 
     2 hours 

 Skillbakerystudios

    43 Lectures 
     4 hours 

 Mohammad Nauman

    8 Lectures 
     1 hours 

 Santharam Sivalenka
 Print
 Add Notes
 Bookmark this page
AWT Event Classes

The Event classes represent the event. Java provides us various Event classes but we will discuss those which are more frequently used.
It is the root class from which all event state objects shall be derived. All Events are constructed with a reference to the object, the source, that is logically deemed to be the object upon which the Event in question initially occurred upon.This class is defined in java.util package.
Following is the declaration for java.util.EventObject class:
public class EventObject
   extends Object
      implements Serializable
Following are the fields for java.util.EventObject class:
protected Object source -- The object on which the Event initially occurred. 	
protected Object source -- The object on which the Event initially occurred. 	
EventObject(Object source) 
Constructs a prototypical Event.
Object getSource()
The object on which the Event initially occurred.
String	toString()
Returns a String representation of this EventObject.
This class inherits methods from the following classes:
java.lang.Object
java.lang.Object
Following is the list of commonly used event classes.
AWTEvent
It is the root event class for all AWT events. This class and its subclasses supercede the original java.awt.Event class.
ActionEvent
The ActionEvent is generated when button is clicked or the item of a list is double clicked.
InputEvent
The InputEvent class is root event class for all component-level input events.
KeyEvent
On entering the character the Key event is generated.
MouseEvent
This event indicates a mouse action occurred in a component.
TextEvent
The object of this class represents the text events.
WindowEvent
The object of this class represents the change in state of a window.
AdjustmentEvent
The object of this class represents the adjustment event emitted by Adjustable objects.
ComponentEvent
The object of this class represents the change in state of a window.
ContainerEvent
The object of this class represents the change in state of a window.
MouseMotionEvent
The object of this class represents the change in state of a window.
PaintEvent
The object of this class represents the change in state of a window.

    13 Lectures 
     2 hours 

 EduOLC
 Print
 Add Notes
 Bookmark this page
XML - Databases

XML Database is used to store huge amount of information in the XML format. As the use of XML is increasing in every field, it is required to have a secured place to store the XML documents. The data stored in the database can be queried using XQuery, serialized, and exported into a desired format.
There are two major types of XML databases −
XML- enabled
Native XML (NXD)
XML enabled database is nothing but the extension provided for the conversion of XML document. This is a relational database, where data is stored in tables consisting of rows and columns. The tables contain set of records, which in turn consist of fields.
Native XML database is based on the container rather than table format. It can store large amount of XML document and data. Native XML database is queried by the XPath-expressions.
Native XML database has an advantage over the XML-enabled database. It is highly capable to store, query and maintain the XML document than XML-enabled database.
Following example demonstrates XML database −
<?xml version = "1.0"?>
<contact-info>
   <contact1>
      <name>Tanmay Patil</name>
      <company>TutorialsPoint</company>
      <phone>(011) 123-4567</phone>
   </contact1>
	
   <contact2>
      <name>Manisha Patil</name>
      <company>TutorialsPoint</company>
      <phone>(011) 789-4567</phone>
   </contact2>
</contact-info>
Here, a table of contacts is created that holds the records of contacts (contact1 and contact2), which in turn consists of three entities − name, company and phone.

    84 Lectures 
     6 hours 

 Frahaan Hussain

    29 Lectures 
     2 hours 

 YouAccel

    27 Lectures 
     1 hours 

 Jordan Stanchev

    16 Lectures 
     2 hours 

 Simon Sez IT
 Print
 Add Notes
 Bookmark this page
Batch Script - Files

In this chapter, we will learn how to create, save, execute, and modify batch files.
Batch files are normally created in notepad. Hence the simplest way is to open notepad and enter the commands required for the script. For this exercise, open notepad and enter the following statements.
:: Deletes All files in the Current Directory With Prompts and Warnings 
::(Hidden, System, and Read-Only Files are Not Affected) 
:: 
@ECHO OFF 
DEL . 
DR
After your batch file is created, the next step is to save your batch file. Batch files have the extension of either .bat or .cmd. Some general rules to keep in mind when naming batch files −
Try to avoid spaces when naming batch files, it sometime creates issues when they are called from other scripts.
Try to avoid spaces when naming batch files, it sometime creates issues when they are called from other scripts.
Don’t name them after common batch files which are available in the system such as ping.cmd.
Don’t name them after common batch files which are available in the system such as ping.cmd.
The above screenshot shows how to save the batch file. When saving your batch file a few points to keep in mind.
Remember to put the .bat or .cmd at the end of the file name.
Choose the “Save as type” option as “All Files”.
Put the entire file name in quotes “”.
Following are the steps to execute a batch file −
Step 1 − Open the command prompt (cmd.exe).
Step 1 − Open the command prompt (cmd.exe).
Step 2 − Go to the location where the .bat or .cmd file is stored.
Step 2 − Go to the location where the .bat or .cmd file is stored.
Step 3 − Write the name of the file as shown in the following image and press the Enter button to execute the batch file.
Step 3 − Write the name of the file as shown in the following image and press the Enter button to execute the batch file.
Following are the steps for modifying an existing batch file.
Step 1 − Open windows explorer.
Step 1 − Open windows explorer.
Step 2 − Go to the location where the .bat or .cmd file is stored.
Step 2 − Go to the location where the .bat or .cmd file is stored.
Step 3 − Right-click the file and choose the “Edit” option from the context menu. The file will open in Notepad for further editing.
Step 3 − Right-click the file and choose the “Edit” option from the context menu. The file will open in Notepad for further editing.
 Print
 Add Notes
 Bookmark this page
C++ Break and Continue

You have already seen the break statement used in an earlier chapter of this tutorial. It was used to "jump out" of a switch statement.
The break statement can also be used to jump out of a 
loop.
This example jumps out of the loop when i is equal to 4:
The continue statement breaks one iteration (in the loop), if a specified condition occurs, and continues with the next iteration in the loop.
This example skips the value of 4:
You can also use break and continue in while loops:
Stop the loop if i is 5:
for (int i = 0; i < 10; i++) {
  if (i == 5) {   
    ;
  }
  cout << i << "\n";
}

Start the Exercise
We just launchedW3Schools videos
Get certifiedby completinga course today!
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com
Your message has been sent to W3Schools.
Longest Mountain in Array in C++

Consider any (contiguous) subarray B (of A) a called mountain if the following properties hold −
size of B >= 3
There exists some 0 < i < B.length - 1 such that B[0] < B[1] < ... B[i-1] < B[i] > B[i+1] > ... > B[B.length - 1]
Suppose we have an array A of integers; we have to find the length of the longest mountain. We have to return 0 if there is no mountain. So if the input is like [2,1,4,7,3,2,5], then the result will be 5. So the largest mountain will be [1,4,7,3,2], whose length is 5.
To solve this, we will follow these steps −
ret := 0, n := size of array a
i := 0 to n – 1, increase i by j + 1j := idown := false, up := falsewhile j + 1 < n and a[j + 1] > a[j]up := true and increase j by 1while up is true and j + 1 < n and a[j + 1] > a[j]down := true and increase j by 1if up and down both are true, set ret := max of j – i + 1 and ret, decrease j by 1
j := i
down := false, up := false
while j + 1 < n and a[j + 1] > a[j]up := true and increase j by 1
up := true and increase j by 1
while up is true and j + 1 < n and a[j + 1] > a[j]down := true and increase j by 1
down := true and increase j by 1
if up and down both are true, set ret := max of j – i + 1 and ret, decrease j by 1
return ret.
Let us see the following implementation to get better understanding −
 Live Demo
#include <bits/stdc++.h>
using namespace std;
class Solution {
public:
   int longestMountain(vector<int>& a) {
      int ret = 0;
      int n = a.size();
      int j;
      for(int i = 0; i < n; i = j + 1){
         j = i;
         bool down = false;
         bool up = false;
         while(j + 1 < n && a[j + 1] > a[j]) {
            up = true;
            j++;
         }
         while(up && j + 1 < n && a[j + 1] < a[j]){
            down = true;
            j++;
         }
         if(up && down){
            ret = max(j - i + 1, ret);
            j--;
         }
      }
      return ret;
   }
};
main(){
   vector<int> v = {2,1,4,7,3,2,5};
   Solution ob;
   cout << (ob.longestMountain(v));
}
[2,1,4,7,3,2,5]
5
How to delete a column from Pandas DataFrame

To delete a column from a DataFrame, use del(). You can also use pop() method to delete. Just drop it using square brackets. Mention the column to be deleted in the brackets and that’s it, for example −
del dataFrame[‘ColumnName’]
Import the required library with an alias −
import pandas as pd
Create a Pandas DataFrame −
dataFrame = pd.DataFrame(
   {
      "Car": ['BMW', 'Lexus', 'Audi', 'Mustang', 'Bentley', 'Jaguar'],
      "Units": [100, 150, 110, 80, 110, 90]
   }
)


Now, delete a column “Car” from a DataFrame −
del dataFrame['Car']
Following is the code −
import pandas as pd

# Create DataFrame
dataFrame = pd.DataFrame(
   {
      "Car": ['BMW', 'Lexus', 'Audi', 'Mustang', 'Bentley', 'Jaguar'],
      "Units": [100, 150, 110, 80, 110, 90]
   }
)

print"DataFrame ...\n",dataFrame

# deleting a column
del dataFrame['Car']

print"\nDataFrame after deleting a column = \n",dataFrame
This will produce the following output −
DataFrame ...
       Car   Units
0      BMW    100
1    Lexus    150
2     Audi    110
3  Mustang     80
4  Bentley    110
5   Jaguar     90

DataFrame after deleting a column =
   Units
0   100
1   150
2   110
3    80
4   110
5    90
Python - Recursion

Recursion allows a function to call itself. Fixed steps of code get executed again and again for new values. We also have to set criteria for deciding when the recursive call ends. In the below example we see a recursive approach to the binary search. We take a sorted list and give its index range as input to the recursive function.
We implement the algorithm of binary search using python as shown below. We use an ordered list of items and design a recursive function to take in the list along with starting and ending index as input. Then, the binary search function calls itself till find the searched item or concludes about its absence in the list.
def bsearch(list, idx0, idxn, val):
   if (idxn < idx0):
      return None
   else:
      midval = idx0 + ((idxn - idx0) // 2)
# Compare the search item with middle most value
   if list[midval] > val:
      return bsearch(list, idx0, midval-1,val)
   else if list[midval] < val:
      return bsearch(list, midval+1, idxn, val)
   else:
      return midval
list = [8,11,24,56,88,131]
print(bsearch(list, 0, 5, 24))
print(bsearch(list, 0, 5, 51))
When the above code is executed, it produces the following result −
2
None


    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 bitwise XOR of hex numbers in Python?

You can get the XOR of any type of numbers using the ^ operator. Specifically for hex numbers, you can use:
a = 0x12ef
b = 0xabcd
print(hex(a ^ b))
This will give the output:
0xb922
The 0x at the beginning of the numbers implies that the number is in hex representation. You can use the ^ operator for other integer representations as well.
JavaScript Events

HTML events are "things" that happen to HTML elements.
When JavaScript is used in HTML pages, JavaScript can 
"react" on 
these events.
An HTML event can be something the browser does, or something a user does.
Here are some examples of HTML events:
An HTML web page has finished loading
An HTML input field was changed
An HTML button was clicked
Often, when events happen, you may want to do something.
JavaScript lets you execute code when events are detected.
HTML allows event handler attributes, with JavaScript code, to be added to HTML elements.
With single quotes:
With double quotes:
In the following example, an onclick attribute (with code), is added to a 
<button> element:
In the example above, the JavaScript code changes the content of 
the element with id="demo".
In the next example, the code changes the content of 
its own element (using this.innerHTML): 
JavaScript code is often several lines long. It is more common to see event attributes calling functions:
Here is a list of some common HTML events:
The list is much longer: W3Schools JavaScript Reference HTML DOM Events.
Event handlers can be used to handle and verify user input, user actions, 
and browser actions:
Things that should be done every time a page loads
Things that should be done when the page is closed
Action that should be performed when a user clicks a button
Content that should be verified when a user inputs data
And more ...
Many different methods can be used to let JavaScript work with events:
HTML event attributes can execute JavaScript code directly
HTML event attributes can call JavaScript functions
You can assign your own event handler functions to HTML elements
You can prevent events from being sent or being handled
And more ...
You will learn a lot more about events and event handlers in the HTML DOM chapters.
The <button> element should do something when someone clicks on it. Try to fix it!
<button ="alert('Hello')">Click me.</button>

Start the Exercise
We just launchedW3Schools videos
Get certifiedby completinga course today!
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com
Your message has been sent to W3Schools.
CSS3 - Rounded Corners

CSS3 Rounded corners are used to add special colored corner to body or text by using the border-radius property.A simple syntax of rounded corners is as follows −
#rcorners7 {
   border-radius: 60px/15px;
   background: #FF0000;
   padding: 20px; 
   width: 200px;
   height: 150px; 
}
The following table shows the possible values for  Rounded corners as follows −
border-radius
Use this element for setting four boarder radius property
border-top-left-radius
Use this element for setting the boarder of top left corner
border-top-right-radius
Use this element for setting the boarder of top right corner
border-bottom-right-radius
Use this element for setting the boarder of bottom right corner
border-bottom-left-radius
Use this element for setting the boarder of bottom left corner
This property can have three values. The following example uses both the values −
<html>
   <head>
      <style>
         #rcorners1 {
            border-radius: 25px;
            background: #8AC007;
            padding: 20px;
            width: 200px;
            height: 150px;
         }
         #rcorners2 {
            border-radius: 25px;
            border: 2px solid #8AC007;
            padding: 20px; 
            width: 200px;
            height: 150px;
         }
         #rcorners3 {
            border-radius: 25px;
            background: url(/css/images/logo.png);
            background-position: left top;
            background-repeat: repeat;
            padding: 20px; 
            width: 200px;
            height: 150px;
         }
      </style>
   </head>

   <body>
      <p id = "rcorners1">Rounded corners!</p>
      <p id = "rcorners2">Rounded corners!</p>
      <p id = "rcorners3">Rounded corners!</p>
   </body>
</html>
It will produce the following result −
Rounded corners!
Rounded corners!
Rounded corners!
We can specify the each corner property as shown below example −
<html>
   <head>
      <style>
         #rcorners1 {
            border-radius: 15px 50px 30px 5px;
            background: #a44170;
            padding: 20px; 
            width: 100px;
            height: 100px; 
         }
         #rcorners2 {
            border-radius: 15px 50px 30px;
            background: #a44170;
            padding: 20px;
            width: 100px;
            height: 100px; 
         }
         #rcorners3 {
            border-radius: 15px 50px;
            background: #a44170;
            padding: 20px; 
            width: 100px;
            height: 100px; 
         }
      </style>
   </head>

   <body>
      <p id = "rcorners1"></p>
      <p id = "rcorners2"></p>
      <p id = "rcorners3"></p>
   </body>
<body>
It will produce the following result −

    33 Lectures 
     2.5 hours 

 Anadi Sharma

    26 Lectures 
     2.5 hours 

 Frahaan Hussain

    44 Lectures 
     4.5 hours 

 DigiFisk (Programming Is Fun)

    21 Lectures 
     2.5 hours 

 DigiFisk (Programming Is Fun)

    51 Lectures 
     7.5 hours 

 DigiFisk (Programming Is Fun)

    52 Lectures 
     4 hours 

 DigiFisk (Programming Is Fun)
 Print
 Add Notes
 Bookmark this page
Fortran - Logical Operators

The following table shows all the logical operators supported by Fortran. Assume variable A holds .true. and variable B holds .false. , then −
Try the following example to understand all the logical operators available in Fortran −
program logicalOp
! this program checks logical operators
implicit none

   ! variable declaration
   logical :: a, b
   
   ! assigning values
   a = .true.
   b = .false.
   
   if (a .and. b) then
      print *, "Line 1 - Condition is true"
   else
      print *, "Line 1 - Condition is false"
   end if
   
   if (a .or. b) then
      print *, "Line 2 - Condition is true"
   else
      print *, "Line 2 - Condition is false"
   end if
   
   ! changing values
   a = .false.
   b = .true.
   
   if (.not.(a .and. b)) then
      print *, "Line 3 - Condition is true"
   else
      print *, "Line 3 - Condition is false"
   end if
   
   if (b .neqv. a) then
      print *, "Line 4 - Condition is true"
   else
      print *, "Line 4 - Condition is false"
   end if
   
   if (b .eqv. a) then
      print *, "Line 5 - Condition is true"
   else
      print *, "Line 5 - Condition is false"
   end if
   
end program logicalOp
When you compile and execute the above program it produces the following result −
Line 1 - Condition is false
Line 2 - Condition is true
Line 3 - Condition is true
Line 4 - Condition is true
Line 5 - Condition is false

 Print
 Add Notes
 Bookmark this page
Swift - Literals

A literal is the source code representation of a value of an integer, floating-point number, or string type. The following are examples of literals −
42                // Integer literal
3.14159           // Floating-point literal
"Hello, world!"   // String literal

An integer literal can be a decimal, binary, octal, or hexadecimal constant. Binary literals begin with 0b, octal literals begin with 0o, and hexadecimal literals begin with 0x and nothing for decimal.
Here are some examples of integer literals −
let decimalInteger = 17         // 17 in decimal notation
let binaryInteger = 0b10001     // 17 in binary notation
let octalInteger = 0o21         // 17 in octal notation
let hexadecimalInteger = 0x11   // 17 in hexadecimal notation

A floating-point literal has an integer part, a decimal point, a fractional part, and an exponent part. You can represent floating point literals either in decimal form or hexadecimal form.
Decimal floating-point literals consist of a sequence of decimal digits followed by either a decimal fraction, a decimal exponent, or both.
Hexadecimal floating-point literals consist of a 0x prefix, followed by an optional hexadecimal fraction, followed by a hexadecimal exponent.
Here are some examples of floating-point literals −
let decimalDouble = 12.1875
let exponentDouble = 1.21875e1
let hexadecimalDouble = 0xC.3p0

A string literal is a sequence of characters surrounded by double quotes, with the following form −
"characters"

String literals cannot contain an unescaped double quote ("), an unescaped backslash (\), a carriage return, or a line feed. Special characters can be included in string literals using the following escape sequences −
The following example shows how to use a few string literals −
let stringL = "Hello\tWorld\n\nHello\'Swift 4\'"
print(stringL)
When we run the above program using playground, we get the following result −
Hello World

Hello'Swift 4'

There are three Boolean literals and they are part of standard Swift 4 keywords −
A value of true representing true.
A value of true representing true.
A value of false representing false.
A value of false representing false.
A value of nil representing no value.
A value of nil representing no value.

    38 Lectures 
     1 hours 

 Ashish Sharma

    13 Lectures 
     2 hours 

 Three Millennials

    7 Lectures 
     1 hours 

 Three Millennials

    22 Lectures 
     1 hours 

 Frahaan Hussain

    12 Lectures 
     39 mins

 Devasena Rajendran

    40 Lectures 
     2.5 hours 

 Grant Klimaytys
 Print
 Add Notes
 Bookmark this page
\pmb - Tex Command

\pmb - poor man's bold.
{ \pmb #1 }
\pmb command turns on poor man's bold. It works by duplicating its argument slightly offset, giving a bold effect (at least in the horizontal direction); doesn't work well for horizontal lines, like - or +.

a \pmb a \boldsymbol a

aaaa


\pmb{a+b-c}\ \ a+b-c

a+b−ca+b−c  a+b−c



a \pmb a \boldsymbol a

aaaa


a \pmb a \boldsymbol a
\pmb{a+b-c}\ \ a+b-c

a+b−ca+b−c  a+b−c


\pmb{a+b-c}\ \ a+b-c

    14 Lectures 
     52 mins

 Ashraf Said

    11 Lectures 
     1 hours 

 Ashraf Said

    9 Lectures 
     1 hours 

 Emenwa Global, Ejike IfeanyiChukwu

    29 Lectures 
     2.5 hours 

 Mohammad Nauman

    14 Lectures 
     1 hours 

 Daniel Stern

    15 Lectures 
     47 mins

 Nishant Kumar
 Print
 Add Notes
 Bookmark this page