code-rag-bench/online-tutorials huggingface dataset:
HTML | <frame> scrolling Attribute

28 Jun, 2021
The HTML <frame> scrolling attribute is used to specify that whether the scrollbar will be displayed or not in the <frame> element. Basically, the scrollbar is used when the content is larger than the Iframe Element.Syntax:  
<frame scrolling="auto|yes|no">
Attribute Values:  
auto: It has the default value. The scrollbar appears when needed.
yes: This value shows the scrollbar in the iframe element.
no: This value does not show the scrollbar in the iframe element.
Note: The <frame> tag is not supported by HTML 5.Example:  
html
<!DOCTYPE html><html> <head>    <title>        HTML frame scrolling Attribute    </title></head> <frameset cols="30%, 40%, 30%">         <frame name = "left" src ="https://media.geeksforgeeks.org/wp-content/uploads/20190328185307/gfg28.png"            scrolling="auto" />         <frame name="middle" src="https://media.geeksforgeeks.org/wp-content/uploads/20190328185307/gfg28.png"            scrolling="yes" />         <frame name="right" src="https://media.geeksforgeeks.org/wp-content/uploads/20190328185307/gfg28.png"        scrolling="no" /> </frameset> </html>  
Output:  
Supported Browsers: The browsers supported by HTML <frame> scrolling attribute are listed below: 
Internet Explorer (before IE 9)
Firefox
Opera (upto 12.0) 
ysachin2314
HTML-Attributes
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Working with Radio buttons and Check boxes in Selenium with Python

26 Oct, 2021
Prerequisite: Browser Automation Using Selenium
Requirement: You need to install chrome driver and set path. Click here to download. 
Selenium is an effective device for controlling an internet browser through the program. It is purposeful for all browsers, works on all fundamental OS and its scripts are written in numerous languages i.e Python, Java, C#, etc, we can be running with Python.
Approach:
Take any URL.
Select radio button.
Navigate radio button using xpath.
Select check boxes.
Navigate check box using xpath.
Use the copied xpaths in the below program.
Python3
# Import selenium modulefrom selenium import webdriverfrom selenium.webdriver.common.by import Byfrom selenium.webdriver.common.keys import Keysimport time  # Using chrome driverdriver = webdriver.Chrome()  # Web page urldriver.get("https://fs2.formsite.com/meherpavan/form2/index.html?1537702596407")  # Selecting raido button# Select maledriver.find_element_by_xpath(    '//*[@id="q26"]/table/tbody/tr[1]/td/label').click()  # Selecting check box# Select sundaydriver.find_element_by_xpath(    '//*[@id="q15"]/table/tbody/tr[1]/td/label').click()  # Select mondaydriver.find_element_by_xpath(    '//*[@id="q15"]/table/tbody/tr[2]/td/label').click()
Output:
simranarora5sos
Misc
Misc
Misc
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
PostgreSQL - DELETE Query

The PostgreSQL DELETE Query is used to delete the existing records from a table. You can use WHERE clause with DELETE query to delete the selected rows. Otherwise, all the records would be deleted.
The basic syntax of DELETE query with WHERE clause is as follows −
DELETE FROM table_name
WHERE [condition];

You can combine N number of conditions using AND or OR operators.
Consider the table COMPANY, having records as follows −
# select * from COMPANY;
 id | name  | age | address   | salary
----+-------+-----+-----------+--------
  1 | Paul  |  32 | California|  20000
  2 | Allen |  25 | Texas     |  15000
  3 | Teddy |  23 | Norway    |  20000
  4 | Mark  |  25 | Rich-Mond |  65000
  5 | David |  27 | Texas     |  85000
  6 | Kim   |  22 | South-Hall|  45000
  7 | James |  24 | Houston   |  10000
(7 rows)
The following is an example, which would DELETE a customer whose ID is 7 −
testdb=# DELETE FROM COMPANY WHERE ID = 2;
Now, COMPANY table will have the following records −
 id | name  | age | address     | salary
----+-------+-----+-------------+--------
  1 | Paul  |  32 | California  |  20000
  3 | Teddy |  23 | Norway      |  20000
  4 | Mark  |  25 | Rich-Mond   |  65000
  5 | David |  27 | Texas       |  85000
  6 | Kim   |  22 | South-Hall  |  45000
  7 | James |  24 | Houston     |  10000
(6 rows)
If you want to DELETE all the records from COMPANY table, you do not need to use WHERE clause with DELETE queries, which would be as follows −
testdb=# DELETE FROM COMPANY;
Now, COMPANY table does not have any record because all the records have been deleted by the DELETE statement.

    23 Lectures 
     1.5 hours 

 John Elder

    49 Lectures 
     3.5 hours 

 Niyazi Erdogan

    126 Lectures 
     10.5 hours 

 Abhishek And Pukhraj

    35 Lectures 
     5 hours 

 Karthikeya T

    5 Lectures 
     51 mins

 Vinay Kumar

    5 Lectures 
     52 mins

 Vinay Kumar
 Print
 Add Notes
 Bookmark this page
Algorithms Quiz | Bit Algorithms | Question 4 - GeeksforGeeks

28 Sep, 2018
Consider the following code snippet for checking whether a number is power of 2 or not.
/* Incorrect function to check if x is power of 2*/bool isPowerOfTwo (unsigned int x) {   return (!(x&(x-1))); }
What is wrong with above function?(A) It does reverse of what is required(B) It works perfectly fine for all values of x.(C) It does not work for x = 0(D) It does not work for x = 1Answer: (C)Explanation: Please see https://www.geeksforgeeks.org/program-to-find-whether-a-no-is-power-of-two/Quiz of this Question
Algorithms Quiz
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Algorithms | Dynamic Programming | Question 2
Algorithms | Dynamic Programming | Question 3
Algorithms | Analysis of Algorithms | Question 17
Algorithms | Sorting | Question 11
Algorithms | Sorting | Question 1
Algorithms | Greedy Algorithms | Question 1
Algorithms Quiz | Dynamic Programming | Question 8
Algorithms | Analysis of Algorithms | Question 8
Algorithms | Divide and Conquer | Question 6
Algorithms | Graph Traversals | Question 12
YAML - Block Sequences

The block sequences of YAML represent a series of nodes. Each item is denoted by a leading “-“ indicator.  Note that the “-“ indicator in YAML should be separated from the node with a white space.
The basic representation of block sequence is given below −
block sequence:
··- one↓
  - two : three↓

Observe the following examples for a better understanding of block sequences.
port: &ports
  adapter:  postgres
  host:     localhost

development:
  database: myapp_development
  <<: *ports
The output of block sequences in JSON format is given below −
{
   "port": {
      "adapter": "postgres",
      "host": "localhost"
   },
   "development": {
      "database": "myapp_development",
      "adapter": "postgres",
      "host": "localhost"
   }
}


    33 Lectures 
     44 mins

 Tarun Telang
 Print
 Add Notes
 Bookmark this page
Bootstrap show.bs.modal Event

The show.bs.modal event in Bootstrap fires when the modal is about to be displayed.
Here the alert is set using the same event and when the model is ready to be displayed, the event fires. This results in dispaying the alert to the visitor.
With that, I have also set a button that clicks the modal to open as shown in the below code snippet −
$(document).ready(function(){
  $("#button1").click(function(){
    $("#newModal").modal("show");
  });
  $("#newModal").on('show.bs.modal', function () {
    alert('The modal will be displayed now!');
  });
});
The following is an example to implement the show.bs.modal event in Bootstrap −
Live Demo
<!DOCTYPE html>
<html>
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>

<div class="container">
  <h2>Entrance Exams</h2>
  <p>The following is the result of the entrance exam:</p>
  <button type="button" class="btn btn-default btn-lg" id="button1">Result</button>

  <div class="modal fade" id="newModal" role="dialog">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal">×</button>
          <h4 class="modal-title">Selected Students</h4>
        </div>
        <div class="modal-body">
          <p>Harry and Chris cleared the entrance exam.</p>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
        </div>
      </div>
    </div>
  </div>
</div>

<script>
$(document).ready(function(){
  $("#button1").click(function(){
    $("#newModal").modal("show");
  });
  $("#newModal").on('show.bs.modal', function () {
    alert('The modal will be displayed now!');
  });
});
</script>

</body>
</html>
Python program to find the highest 3 values in a dictionary

In this article, we will learn about the solution and approach to solve the given problem statement.
Given a dictionary, we need to find the three highest valued values and display them.
 Live Demo
from collections import Counter
# Initial Dictionary
my_dict = {'t': 3, 'u': 4, 't': 6, 'o': 5, 'r': 21}
k = Counter(my_dict)
# Finding 3 highest values
high = k.most_common(3)
print("Dictionary with 3 highest values:")
print("Keys: Values")
for i in high:
   print(i[0]," :",i[1]," ")
Dictionary with 3 highest values:
Keys: Values
r : 21
t : 6
o : 5
 Live Demo
from collections import Counter
# Initial Dictionary
my_dict = {'t': 3, 'u': 4, 't': 6, 'o': 5, 'r': 21}
k = Counter(my_dict)
# Finding 3 highest values
high = k.most_common(3)
print("Dictionary with 3 highest values:")
print("Keys: Values")
for i in high:
   print(i[0]," :",i[1]," ")
Dictionary with 3 highest values:
Keys: Values
r : 21
t : 6
o : 5
In this article, we learned about the approach to convert a decimal number to a binary number.
How to update array of subdocuments in MongoDB?

To update, use update() along with $set. Let us create a collection with documents −
>db.demo134.insertOne({"EmployeeId":101,"EmployeeDetails":[{"EmployeeName":"Chris","EmployeeAge":27},{"EmployeeName":"Bob","EmployeeAge":28}]});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e319b2f68e7f832db1a7f7c")
}
>db.demo134.insertOne({"EmployeeId":102,"EmployeeDetails":[{"EmployeeName":"David","EmployeeAge":24},{"EmployeeName":"Carol","EmployeeAge":29}]});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e319b4468e7f832db1a7f7d")
}
Display all documents from a collection with the help of find() method −
> db.demo134.find().pretty();
This will produce the following output −
{
   "_id" : ObjectId("5e319b2f68e7f832db1a7f7c"),
   "EmployeeId" : 101,
   "EmployeeDetails" : [
      {
         "EmployeeName" : "Chris",
         "EmployeeAge" : 27
      },
      {
         "EmployeeName" : "Bob",
         "EmployeeAge" : 28
      }
   ]
}
{
   "_id" : ObjectId("5e319b4468e7f832db1a7f7d"),
   "EmployeeId" : 102,
   "EmployeeDetails" : [
      {
         "EmployeeName" : "David",
         "EmployeeAge" : 24
      },
      {
         "EmployeeName" : "Carol",
         "EmployeeAge" : 29
      }
   ]
}
Following is the query to update array of subdocuments in MongoDB −
> db.demo134.update(
...    {
...       "EmployeeId":101,
...       "EmployeeDetails.EmployeeName":"Chris"
...    },
...    {
...       $set: {
...          "EmployeeDetails.$.EmployeeName" : "Robert"
...       }
...    }
... );
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
Display all documents from a collection with the help of find() method −
> db.demo134.find().pretty();
This will produce the following output −
{
   "_id" : ObjectId("5e319b2f68e7f832db1a7f7c"),
   "EmployeeId" : 101,
   "EmployeeDetails" : [
      {
         "EmployeeName" : "Robert",
         "EmployeeAge" : 27
      },
      {
         "EmployeeName" : "Bob",
         "EmployeeAge" : 28
      }
   ]
}
{
   "_id" : ObjectId("5e319b4468e7f832db1a7f7d"),
   "EmployeeId" : 102,
   "EmployeeDetails" : [
      {
         "EmployeeName" : "David",
         "EmployeeAge" : 24
      },
      {
         "EmployeeName" : "Carol",
         "EmployeeAge" : 29
      }
   ]
}
MongoDB query to get specific month|year (not date)?

You can use aggregate framework along with $month projection operator. Let us first create a collection with documents −
> db.specificMonthDemo.insertOne({"StudentName":"Larry","StudentDateOfBirth":new ISODate('1995-01-12')});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5cb9a9ca8f1d1b97daf71819")
}
> db.specificMonthDemo.insertOne({"StudentName":"Chris","StudentDateOfBirth":new ISODate('1999-12-31')});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5cb9a9db8f1d1b97daf7181a")
}
> db.specificMonthDemo.insertOne({"StudentName":"David","StudentDateOfBirth":new ISODate('2000-06-01')});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5cb9a9ee8f1d1b97daf7181b")
}
Following is the query to display all documents from the collection with the help of find() method −
> db.specificMonthDemo.find().pretty();
This will produce the following output −
{
   "_id" : ObjectId("5cb9a9ca8f1d1b97daf71819"),
   "StudentName" : "Larry",
   "StudentDateOfBirth" : ISODate("1995-01-12T00:00:00Z")
}
{
   "_id" : ObjectId("5cb9a9db8f1d1b97daf7181a"),
   "StudentName" : "Chris",
   "StudentDateOfBirth" : ISODate("1999-12-31T00:00:00Z")
}
{
   "_id" : ObjectId("5cb9a9ee8f1d1b97daf7181b"),
   "StudentName" : "David",
   "StudentDateOfBirth" : ISODate("2000-06-01T00:00:00Z")
}
Following is the query to get specific month|year, not date −
> db.specificMonthDemo.aggregate([ {$project: {StudentName: 1, StudentDateOfBirth:
   {$month: '$StudentDateOfBirth'}}}, {$match: {StudentDateOfBirth: 01}} ]).pretty();
This will produce the following output −
{
   "_id" : ObjectId("5cb9a9ca8f1d1b97daf71819"),
   "StudentName" : "Larry",
   "StudentDateOfBirth" : 1
}
What is unmanaged code in C#?

The following states what is an unmanaged code −
Applications that are not under the control of the CLR are unmanaged
The unsafe code or the unmanaged code is a code block that uses a pointer variable.
The unsafe modifier allows pointer usage in unmanaged code.
Here is the module showing how to declare and use a pointer variable. We have used the unsafe modifier here.
Let us see the example −
static unsafe void Main(string[] args) {
   int var = 20;
   int* p = &var;

   Console.WriteLine("Data is: {0} ", var);
   Console.WriteLine("Address is: {0}", (int)p);
   Console.ReadKey();
}
C/C++ Program to check whether it is possible to make a divisible by 3 number using all digits in an array?

In this section we will see if one array is given with n numbers, we have to check if we make a number using all of the elements of these numbers, that number will be divisible by 3 or not. If the array elements are {15, 24, 23, 13}, then the we can make integer like 15242313. It will be
divisible by 3.
Begin
   rem := 0
   for each element e in arr, do
      rem := (rem + e) mod 3
   done
   if rem is 0, then
      return true
   end if
   return false
End
#include<iostream>
#define MAX 4
using namespace std;
bool checkDivThree(int arr[], int n){
   int rem = 0;
   for(int i = 0; i<n; i++){
      rem = (rem + arr[i]) % 3;
   }
   if(rem == 0){
      return true;
   }
   return false;
}
main() {
   int arr[] = {15, 24, 23, 13};
   int n = sizeof(arr)/sizeof(arr[0]);
   if(checkDivThree(arr, n)){
      cout << "Divisible";
   }else{
      cout << "Not Divisible";
   }
}
Divisible
JavaScript - Create an alert on clicking an HTML button

To fire an alert on click of a button, use addEventListener(). Let’s say the following is our button on an HTML web page −
<button type="button">Please Press Me</button>
Following is the code −
 Live Demo
<!DOCTYPE html>
<html lang="en">
<head>
   <meta charset="UTF-8">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <title>Document</title>
</head>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<body>
   <button type="button">Please Press Me</button>
</body>
<script>
   var pressedButton = document.getElementsByTagName("button")[0];
   pressedButton.addEventListener("click", function (event) {
      alert("You have pressed the button..........")
   })
</script>
</html>
To run the above program, save the file name anyName.html(index.html). Right click on the file and select the option “Open with live server” in VS Code editor −
The output is as follows −
Whenever you press the button, you will get an alert message.
The output is as follows −
Clojure - Atoms swap!

Atomically swaps the value of the atom with a new one based on a particular function.
Following is the syntax.
(swap! atom-name function)

Parameters − ‘atom-name’ is the name of the atom whose value needs to be reset. ‘function’ is the function which is used to generate the new value of the atom.
Return Value − The atom with the new value will be set based on the function provided.
An example on how this is used is shown in the following program.
(ns clojure.examples.example
   (:gen-class))
(defn example []
   (def myatom (atom 1))
   (println @myatom)
   
   (swap! myatom inc)
   (println @myatom))
(example)
The above program produces the following output.
1
2

From the above program you can see that the ‘inc’ (Increment function) is used to increment the value of the atom and with the help of the swap! function, the new value is automatically associated with the atom.
 Print
 Add Notes
 Bookmark this page
Java switch Keyword

❮ Java Keywords

Use the switch  statement to calculate the weekday name:
int day = 4;
switch (day) {
  case 1:
    System.out.println("Monday");
    break;
  case 2:
    System.out.println("Tuesday");
    break;
  case 3:
    System.out.println("Wednesday");
    break;
  case 4:
    System.out.println("Thursday");
    break;
  case 5:
    System.out.println("Friday");
    break;
  case 6:
    System.out.println("Saturday");
    break;
  case 7:
    System.out.println("Sunday");
    break;
}
// Outputs "Thursday" (day 4)


Try it Yourself »

The switch keyword selects one of many code blocks to be executed.
From the example above, it works like this:
The switch expression is evaluated once.
The value of the expression is compared with the values of each case.
If there is a match, the associated block of code is executed.
The break keyword is used to break out of the switch block when a match is found
Read more about the switch statement in our Java Switch Tutorial.

❮ Java Keywords

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.
Python | Numpy np.heaviside() method - GeeksforGeeks

02 Dec, 2019
With the help of np.heaviside() method, we can get the heaviside step function by using np.heaviside() method.
Syntax : np.heaviside(array1, array2 or value)Return : Return the heaviside series.
Example #1 :In this example we can see that by using np.heaviside() method, we are able to get the array of series of heaviside step function by using this method.
# import numpyimport numpy as np  x = np.array([-1.5, 0.5, 0, 0.5, 1.5])# using np.heaviside() methodgfg = np.heaviside(x, 0.5)  print(gfg)
Output :
[0. 1. 0.5 1. 1.]
Example #2 :
# import numpyimport numpy as np  x = np.zeros(5)y = np.array([-1.5, 0.5, 0, 0.5, -1.5])  # using np.heaviside() methodgfg = np.heaviside(x, y)  print(gfg)
Output :
[-1.5 0.5 0. 0.5 -1.5]
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
Python String | replace()
*args and **kwargs in Python
Create a Pandas DataFrame from Lists
Convert integer to string in Python
Check if element exists in list in Python
sum() function in Python
Count elements in a vector that match a target value or condition in C++

We are given a vector and the task is to calculate the count of those elements in a vector that matches a target value or condition.
Vectors are sequence containers that can change size. Container is an object that holds data of the same type. Sequence containers store elements strictly in linear sequence.
Vector stores elements in contiguous memory locations and enables direct access to any element using subscript operator []. Unlike arrays, vectors can shrink or expand as needed at run time. The storage of the vector is handled automatically.
To support shrink and expand functionality at runtime, vector containers may allocate some extra storage to accommodate for possible growth thus containers have actual capacity greater than the size. Therefore, compared to array, vector consumes more memory in exchange for the ability to manage storage and grow dynamically in an efficient way.
Input − vector vec = {1, 2, 3, 4, 4, 4, 4}
      Target = 4
Output − count is: 4
Explanation − in the given vector the target is occurring 4 times so the count is 4
Input − vector vec = {1, 2, 3}
      Target = 4
Output − count is: 0
Explanation − in the given vector the target is occurring 0 times so the count is 0
Input the vector and store it in a vector type variable let’s say vec
Input the vector and store it in a vector type variable let’s say vec
Set the target value as an integer value
Set the target value as an integer value
Take a temporary variable that will store the count
Take a temporary variable that will store the count
Call the inbuilt count function available in C++ STL and pass vec.begin(), vec.end(), target to the function call
Call the inbuilt count function available in C++ STL and pass vec.begin(), vec.end(), target to the function call
Print the result.
Print the result.
 Live Demo
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main(){
   vector<int> myvector{ 1, 2, 3, 4, 4, 4, 4, 4 };
   int target = 4;
   int res = count(myvector.begin(), myvector.end(), target);
   cout << "Target is: " << target << "\nCount is: " << res << endl;
   return 0;
}
If we run the above code we will get the following output −
Target is: 4
Count is: 5
Left-Child Right-Sibling Representation of Tree

Left-Child Right-Sibling Representation is a different representation of an n-ary tree where instead of maintaining a pointer to each and every child node, a node holds just two pointers, first a pointer to its first child, and the other pointer to its immediate next sibling. This new transformation not only eliminates the need of prior knowledge of the number of children a node has, but also restricts the number of pointers to a maximum of two, so making it so much simpler to code.
At each node, link or connect children of same parent from left to right.
Parent should be linked with only first child.
Left Child Right Sibling tree representation
10
|
2 -> 3 -> 4 -> 5
| |
6 7 -> 8 -> 9
This representation saves up memory by restricting the maximum number of pointers required per node to two.
It is simpler to code.
Basic operations like searching/insertion/deletion consume longer time because in order to select the exact position we would have to traverse through all the siblings of the node to be searched/inserted/deleted (according to the worst case).
How to check if a list element is greater than a certain value in R?

If we have a list that contains numeric elements and we want to check whether the elements are greater than a certain value then as.numeric function can be used. The output of the function will be in 0/1 format where 0 represents FALSE and 1 represents TRUE. For example, if we have a list called LIST then to check whether elements in LIST are greater than 2 can be done as as.numeric(LIST>2).
 Live Demo
List1<−list(1,2,2,2,4,1,2,5,5,2,3,5,2,2,2,2,5,5,8,9,6,5,5)
List1
[[1]]
[1] 1
[[2]]
[1] 2
[[3]]
[1] 2
[[4]]
[1] 2
[[5]]
[1] 4
[[6]]
[1] 1
[[7]]
[1] 2
[[8]]
[1] 5
[[9]]
[1] 5
[[10]]
[1] 2
[[11]]
[1] 3
[[12]]
[1] 5
[[13]]
[1] 2
[[14]]
[1] 2
[[15]]
[1] 2
[[16]]
[1] 2
[[17]]
[1] 5
[[18]]
[1] 5
[[19]]
[1] 8
[[20]]
[1] 9
[[21]]
[1] 6
[[22]]
[1] 5
[[23]]
[1] 5
Checking whether elements in List1 are greater than 5 or not −
as.numeric(List1>5)
[1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0
 Live Demo
List2<−list(4,7,5,4,1,2,5,2,3,6,5,7,7,1,1,2,5,5,9,2)
List2
[[1]]
[1] 4
[[2]]
[1] 7
[[3]]
[1] 5
[[4]]
[1] 4
[[5]]
[1] 1
[[6]]
[1] 2
[[7]]
[1] 5
[[8]]
[1] 2
[[9]]
[1] 3
[[10]]
[1] 6
[[11]]
[1] 5
[[12]]
[1] 7
[[13]]
[1] 7
[[14]]
[1] 1
[[15]]
[1] 1
[[16]]
[1] 2
[[17]]
[1] 5
[[18]]
[1] 5
[[19]]
[1] 9
[[20]]
[1] 2
Checking whether elements in List2 are greater than 2 or not −
as.numeric(List2>2)
[1] 1 1 1 1 0 0 1 0 1 1 1 1 1 0 0 0 1 1 1 0
How to use chrome webdriver in Selenium to download files in Python?

We can use chrome webdriver in Selenium to download files in Python. We shall use the ChromeOptions class for this purpose. First, we shall create an object of the ChromeOptions class.
Then apply the add_experimental_option method on the object created. We shall set the download.default_directory:<location of downloaded file> parameter. Finally, this information shall be passed to the driver object.
op = webdriver.ChromeOptions()
p = {'download.default_directory':'C:\\Users\\ghs6kor\\Downloads\\Test'}
op.add_experimental_option('prefs', p)
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
#object of Options class
op = webdriver.ChromeOptions()
#browser preferences
p = {'download.default_directory':'C:\\Users\\ghs6kor\\Downloads\\Test'}
#add options to browser
op.add_experimental_option('prefs', p)
#set chromedriver.exe path
driver = webdriver.Chrome(executable_path="C:\\chromedriver.exe",
options=op)
#maximize browser
driver.maximize_window()
#launch URL
driver.get("https://www.seleniumhq.org/download/");
#click download link
l = driver.find_element_by_link_text("32 bit Windows IE")
l.click()
Also, the file gets downloaded at the desired location.
How to preselect a value in a dropdown list of items in HTML forms?

With HTML, you can easily create a simple drop down list of items to get user input in HTML forms. A select box also called drop down box provides an option to list down various options in the form of drop down list.
You can also preselect a value in dropdown list of items in HTML forms. For that, add selected in the <option> tag for the value you want to preselect.
You can try to run the following code to learn how to preselect value in a dropdown list of items works in HTML form −
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <title>Select Box Control</title>
   </head>
   <body>
      <p> Select any one:</p>
      <form>
         <select name = "dropdown">
            <option value = "Java" selected>Java</option>
            <option value = "Discrete Mathematics">Discrete Mathematics</option>
         </select>
      </form>
   </body>
</html>
How to compress images using Python and PIL?

18 Aug, 2020
There are organizations who receive data form lakhs or more persons, which is mostly in form of text, with a few images. Most of you know that the text part is stored in databases in the form of tables, but what about the images? The images are small compared to the textual data but constitute a much higher space in terms of storage. Hence, to save on the part of space and keep running the processes smoothly, they ask the users to submit the compressed images. As most of the readers have a bit of CS background(either in school or college), they understand that using online free tools to compress images is not a good practice for them.
Till Windows 7, Microsoft used to give MS Office Picture Manager which could be used to compress images till an extent, but it also had some limitations.
Those who know a bit of python can install python and use pip install pillow in command prompt(terminal for Linux users) to install pillow fork.
You’ll get a screen like this 
Assemble all the files in a folder and keep the file Compress.py in the same folder.
Run the python file with python.
Below is the Source Code of the file:
Python3
# run this in any directory # add -v for verbose # get Pillow (fork of PIL) from# pip before running --># pip install Pillow  # import required librariesimport osimport sysfrom PIL import Image  # define a function for# compressing an imagedef compressMe(file, verbose = False):          # Get the path of the file    filepath = os.path.join(os.getcwd(),                             file)          # open the image    picture = Image.open(filepath)          # Save the picture with desired quality    # To change the quality of image,    # set the quality variable at    # your desired level, The more     # the value of quality variable     # and lesser the compression    picture.save("Compressed_"+file,                  "JPEG",                  optimize = True,                  quality = 10)    return  # Define a main functiondef main():        verbose = False          # checks for verbose flag    if (len(sys.argv)>1):                if (sys.argv[1].lower()=="-v"):            verbose = True                          # finds current working dir    cwd = os.getcwd()      formats = ('.jpg', '.jpeg')          # looping through all the files    # in a current directory    for file in os.listdir(cwd):                # If the file format is JPG or JPEG        if os.path.splitext(file)[1].lower() in formats:            print('compressing', file)            compressMe(file, verbose)      print("Done")  # Driver codeif __name__ == "__main__":    main()
Folder before running file
PS: Please run code after getting into the directory.
Command Line for executing Code
Folder after running code
You can clearly see the compressed file.
Image-Processing
Python-pil
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
CSS | element element Selector

31 Dec, 2018
The element element selector in CSS is used to select elements inside the elements i.e it combines two selectors such that elements matched by the second selector are selected if they have an ancestor element matching the first selector.
Syntax:
element element {
    // CSS Property
}

Example 1:
<!-- HTML code to illustrates space selector --><!DOCTYPE html><html>    <head>        <title>            element element Selector        </title>                  <style>            div p {                background-color: green;                color: white;            }        </style>    </head>          <body style="text-align: center;">                  <h1 style = "color: green;">            GeeksforGeeks        </h1>                  <div>            <h2>element element Selector</h2>                          <!-- CSS property is used here -->            <p>A computer science portal for geeks.</p>        </div>                  <p>This paragraph will not be selected.</p>    </body></html>                    
Output:
Example 2:
<!DOCTYPE html><html>    <head>        <title>            element element Selector        </title>                  <style>            li {                color: black;            }                     li li {                color: white;                background: green;            }        </style>    </head>          <body style="text-align: center;">                  <h1 style = "color: green;">            GeeksforGeeks        </h1>                  <h2>element element Selector</h2>        <ul>            <li>                <div>Searching Algo</div>                <ul>                    <li>Binary Search</li>                    <li>Linear Search</li>                </ul>            </li>            <li>                <div>Sorting Algo</div>                <ul>                    <li>Bubble Sort</li>                    <li>Merge Sort</li>                </ul>            </li>        </ul>    </body></html>                    
Output:
Supported Browsers: The browser supported by element element selector are listed below:
Apple Safari
Google Chrome
Firefox
Opera
Internet Explorer
CSS-Selectors
CSS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to update Node.js and NPM to next version ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
How to create footer to stay at the bottom of a Web page?
CSS to put icon inside an input element in a form
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
Python | Convert string List to Nested Character List

29 Nov, 2019
Sometimes, while working with Python, we can have a problem in which we need to perform interconversion of data. In this article we discuss converting String list to Nested Character list split by comma. Let’s discuss certain ways in which this task can be performed.
Method #1 : Using list comprehension + split()The combination of above functionalities can be used to perform this task. In this, we iterate through list using list comprehension and can perform split using split().
# Python3 code to demonstrate working of# Convert String List to Nested Character List# using split() + list comprehension  # initialize list test_list = ["a, b, c", "gfg, is, best", "1, 2, 3"]  # printing original list print("The original list : " + str(test_list))  # Convert String List to Nested Character List# using split() + list comprehensionres = [char.split(', ') for char in test_list]  # printing resultprint("List after performing conversion : " + str(res))
The original list : [‘a, b, c’, ‘gfg, is, best’, ‘1, 2, 3’]List after performing conversion : [[‘a’, ‘b’, ‘c’], [‘gfg’, ‘is’, ‘best’], [‘1’, ‘2’, ‘3’]]
 
Method #2 : Using map() + split() + lambdaThe combination of above functions can be used to perform this task. In this, we perform the task of iteration using map() and lambda function is used to apply the logic of split using split() to all the list elements.
# Python3 code to demonstrate working of# Convert String List to Nested Character List# using map() + split() + lambda  # initialize list test_list = ["a, b, c", "gfg, is, best", "1, 2, 3"]  # printing original list print("The original list : " + str(test_list))  # Convert String List to Nested Character List# using map() + split() + lambdares = list(map(lambda ele: ele.split(', '), test_list))  # printing resultprint("List after performing conversion : " + str(res))
The original list : [‘a, b, c’, ‘gfg, is, best’, ‘1, 2, 3’]List after performing conversion : [[‘a’, ‘b’, ‘c’], [‘gfg’, ‘is’, ‘best’], [‘1’, ‘2’, ‘3’]]
Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Str() and StrComp() Function in MS Access

31 Aug, 2020
1. Str() Function :In MS Access, the Str() function return a number in the string format. In this function, we can pass any number the function will return that in the string format.
Syntax :
 Str(number) 
Example –
SELECT Str(100) AS ConvertToString;
Output –
Example –
SELECT Str(421) AS ConvertToString;
Output –
2. StrComp() Function :In MS Access, The StrComp() function compare two strings . It will take two parameter string1, string2 as the parameter. If both strings will be same then it will return 0, and if the first string is greater than second then it will return 1 if string1<string2 then it returns -1 and if string1 or string2 is null then it will return null.
Syntax :
StrComp(string1, string2) 
Example –
SELECT StrComp("geeksforgeeks", "gfg") AS CompString;
Output –
Example –
SELECT StrComp("gfg", "geeksforgeeks") AS CompString;
Output :
DBMS-SQL
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to receive JSON POST with PHP ?

06 Dec, 2021
In this article, we will see how to retrieve the JSON POST with PHP, & will also see their implementation through the examples. First, we will look for the below 3 features:
php://input: This is a read-only stream that allows us to read raw data from the request body. It returns all the raw data after the HTTP headers of the request, regardless of the content type.
file_get_contents() function: This function in PHP is used to read a file into a string.
json_decode() function: This function takes a JSON string and converts it into a PHP variable that may be an array or an object.
It is known that all of the post data can be received in a PHP script using the $_POST[] global variable. But this fails in the case when we want to receive JSON string as post data. To receive JSON string we can use the “php://input” along with the function file_get_contents() which helps us receive JSON data as a file and read it into a string. Later, we can use the json_decode() function to decode the JSON string.
Handling JSON POST requests:
// Takes raw data from the request
$json = file_get_contents('php://input');

// Converts it into a PHP object
$data = json_decode($json);
Example 1: This example uses the json_decode() function that is used to decode a JSON string.
PHP
<?php  $json = '["geeks", "for", "geeks"]';  $data = json_decode($json);  echo $data[0];?>
geeks
 
Example 2: This example uses the json_decode() function that is used to decode a JSON string.
PHP
<?php  $json = '{      "title": "PHP",      "site": "GeeksforGeeks"  }';  $data = json_decode($json);  echo $data->title;  echo "\n";  echo $data->site;?>
PHP
GeeksforGeeks
 
PHP is a server-side scripting language designed specifically for web development. You can learn PHP from the ground up by following this PHP Tutorial and PHP Examples.
bhaskargeeksforgeeks
JSON
Picked
PHP
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
HTTP headers | Keep-Alive

27 Feb, 2020
The Keep-Alive header is a general-type header. This header is used to hint at how the connection may be used to set a timeout and a maximum amount of requests. It can also be used to allow a single TCP connection to remain open for multiple HTTP requests/responses (default HTTP connection closed after each request). It is also known as a persistent connection. Enabling keep-alive totally depends on what server you are using and what access you have.
Syntax:
Keep-Alive: parameters
Directives: This header accepts a single directive as mentioned above and described below:
Parameters: This directive holds two comma-separated parameters timeout and max. The timeout parameter holds the minimum amount of time which is the time(in seconds) of connection has to be kept open. The ax parameter holds an integer number define how the number of requests can be sent to this connection before closing the connection.
Example: In this example connection header has to set on Keep-Alive.
HTTP/1.1 200 OK
Connection: Keep-Alive
Content-Encoding: gzip
Content-Type: text/html; charset=utf-8
Date: Thu, 17 Feb 2020 18:23:13 GMT
Keep-Alive: timeout=5, max=1000
Last-Modified: Mon, 17 Feb 2020 04:32:39 GMT
Server: Apache
To check this Keep-Alive in action go to Inspect Element -> Network check the header for Keep-ALive like below.
Supported Browsers: The browsers compatible with HTTP header Keep-Alive are listed below:
Google Chrome
Internet Explorer
Firefox
Safari
Opera
HTTP-headers
Picked
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
How to fetch data from an API in ReactJS ?
Remove elements from a JavaScript Array
Differences between Functional Components and Class Components in React
Roadmap to Learn JavaScript For Beginners
REST API (Introduction)
How to float three div side by side using CSS?
Difference Between PUT and PATCH Request
ReactJS | Router
Axios in React: A Guide for Beginners
Intersection of two arrays JavaScript

We have two arrays of Numbers, and we are required to write a function, say intersection() that
computes their intersection and returns an array that contains the intersecting elements in any
order. Each element in the result should appear as many times as it shows in both arrays.
For example − If,
Input: arr1 = [1,2,3,1], arr2 = [1,3,1]
Output: [1,3,1]
Had the arrays been sorted, we could have used the two pointer approach with initially both
pointing to 0 the start of the respective array and we could have proceeded with increasing the
corresponding pointer and that would have been O(m+n) complex w.r.t. time where m and n are
the sizes of array.
But since we have unsorted arrays there is no logic in sorting the arrays and then using this
approach, we will check every value of first against the second and construct an intersection
array. This would cost us O(n^2) time.
And the code for doing this will be −
const arr1 = [1, 2, 43, 5, 3, 7, 7,8, 4, 2];
const arr2 = [1, 1, 6, 6, 2, 78, 7, 2, 3, 7, 23, 5, 3];
const intersection = (arr1, arr2) => {
   const res = [];
   const { length: len1 } = arr1;
   const { length: len2 } = arr2;
   const smaller = (len1 < len2 ? arr1 : arr2).slice();
   const bigger = (len1 >= len2 ? arr1 : arr2).slice();
   for(let i = 0; i < smaller.length; i++){
      if(bigger.indexOf(smaller[i]) !== -1){
         res.push(smaller[i]);
         bigger.splice(bigger.indexOf(smaller[i]), 1, undefined);
      }
   };
   return res;
};
console.log(intersection(arr1 ,arr2));
The output in the console will be −
[1, 2, 5, 3, 7, 7, 2]
How to write a C program to find the roots of a quadratic equation?

Applying the software development method to solve any problem in C Language
Find roots of a quadratic equation, ax2+bx+c.
There will be 2 roots for given quadratic equation.
Input − a,b,c values
Output − r1, r2 values
r1=−b+b2−4ac2a
r2=−b−b2−4ac2a
Start
Read a, b, c values
Compute d = b2 4ac
if d > 0 thenr1 = b+ sqrt (d)/(2*a)r2 = b sqrt(d)/(2*a)
r1 = b+ sqrt (d)/(2*a)
r2 = b sqrt(d)/(2*a)
Otherwise if d = 0 thencompute r1 = -b/2a, r2=-b/2aprint r1,r2 values
compute r1 = -b/2a, r2=-b/2a
print r1,r2 values
Otherwise if d < 0 then print roots are imaginary
Stop
# include<stdio.h>
# include<conio.h>
# include<math.h>
main (){
   float a,b,c,r1,r2,d;
   printf (“enter the values of a b c”);
   scanf (“ %f %f %f”, &a, &b, &c);
   d= b*b – 4*a*c;
   if (d>0){
      r1 = -b+sqrt (d) / (2*a);
      r2 = -b-sqrt (d) / (2*a);
      printf (“The real roots = %f %f”, r1, r2);
   }
   else if (d= =0){
      r1 = -b/(2*a);
      r2 = -b/(2*a);
      printf (“roots are equal =%f %f”, r1, r2);
   }
   else
      printf(“Roots are imaginary”);
   getch ();
}
Case 1: enter the values of a b c: 1 4 3
   r1 = -1
   r2 = -3
Case 2: enter the values of a b c: 1 2 1
   r1 = -1
   r2 = -1
Case 3: enter the values of a b c: 1 1 4
Roots are imaginary
How to set the environmental variable LD_LIBRARY_PATH in Linux?

There are plenty of ways in which we can set an environment variable in Linux and then make use of it later. Some ways provide us access to that variable in a particular window, in other cases, we can get access to those variables in every terminal window and in a permanent manner.
Let’s explore setting a new environment variable on an Ubuntu machine and then we can talk about setting the LD_LIBRARY_PATH.
In order to set a new environment variable, follow the commands shown below in sequence.
Open your bash-profile with the command shown below −
vi ~/.bashrc
Make use of the export linux utility command and insert the paste the command shown below in your bash-profile.
export GOPATH=/root/go_projects
Exit the bash-profile and then source the profile with the command shown below.
source ~/.bashrc
Open a new terminal to check that the environment variable you set is available to you.
echo $GOPATH
Output should look something like below −
/root/go_projects
If you don’t get any output, then make sure you followed the steps mentioned above correctly.
In case of LD_LIBRARY_PATH, we can follow the same steps as mentioned above, the command to change inside the bash-profile would look something like this −
export LD_LIBRARY_PATH = /path/to/your/library
And then you can source the file and make use of it.
Though it is recommended that you shouldn’t change the LD_LIBRARY_PATH as the other libraries and their dependencies might get broken, so it's better to append the path you want to the already existing LD_LIBRARY_PATH with the command shown below −
export LD_LIBRARY_PATH=$LD_LIBRARY_PAT:H/path/to/your/library
Now if you do echo $LD_LIBRARY_PATH
/usr/local/bin:/path/to/your/directory
C# difference in milliseconds between two DateTime

Let’s say the following are two DateTime objects for our dates.
DateTime date1 = new DateTime(2018, 8, 11, 08, 15, 20);
DateTime date2 = new DateTime(2018, 8, 11, 11, 14, 25);
Find the difference between both these dates using TimeSpan.
TimeSpan ts = date2 - date1;
Now to get the Milliseconds, use the following property −
ts.TotalMilliseconds
Let us see the complete code.
 Live Demo
using System;
using System.Linq;
public class Demo {
   public static void Main() {
      DateTime date1 = new DateTime(2018, 8, 11, 08, 15, 20);
      DateTime date2 = new DateTime(2018, 8, 11, 11, 14, 25);
      TimeSpan ts = date2 - date1;
      Console.WriteLine("No. of Seconds (Difference) = {0}", ts.TotalMilliseconds);
   }
}
No. of Seconds (Difference) = 10745000
How to count child element using jQuery ? - GeeksforGeeks

27 Apr, 2020
It is very simple to count the number of child elements in the HTML file using jQuery. For example: If you have a parent element consisting of many children elements then you can use .length or.children().length method as given below.
Syntax:
var len=$("#parentID").length;

or
var count = $("#parentId").children().length;
Example 1:
<!DOCTYPE html><html>  <head>    <meta charset="utf-8">    <meta http-equiv="X-UA-Compatible" content="IE=edge">    <title>Count child elements using Jquery</title>    <meta name="viewport"           content="width=device-width, initial-scale=1">    <link rel="stylesheet" href=""></head>  <body>    <div id="parentID">        <p>Red</p>        <p>White</p>        <p>Green</p>        <p>Black</p>        <p>Blue</p>        <p>Orange</p>    </div>          <script src="https://code.jquery.com/jquery-3.5.0.min.js"integrity="sha256-xNzN2a4ltkB44Mc/Jz3pT4iU1cmeR0FkXs4pru/JxaQ="         crossorigin="anonymous">    </script>      <script>                       // Here we count the child element in parentID        var count = $("#parentID p").length;        document.writeln(count);    </script></body>  </html>
Output:
Example 2:
<!DOCTYPE html><html>  <head>   <meta charset="utf-8">   <meta name="viewport" content="width=device-width">   <title>Count child elements using  jQuery.</title>   <script src=      "https://code.jquery.com/jquery-3.4.1.js">    </script></head>  <body>   <div id="parentId">   <ul>      <li>1 child</li>      <li>2 child</li>      <li>3 child</li>      <li>4 child</li>      <li>5 child</li>    </ul>    </div>    <script>         var count = $("#parentId ul").children().length;         document.writeln(count);    </script></body>  </html>
Output:
jQuery-Misc
Picked
JQuery
Web Technologies
Web technologies Questions
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Form validation using jQuery
How to Dynamically Add/Remove Table Rows using jQuery ?
Scroll to the top of the page using JavaScript/jQuery
How to get the ID of the clicked button using JavaScript / jQuery ?
jQuery | children() with Examples
Top 10 Front End Developer Skills That You Need in 2022
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
C# DateTime Max Value

To set the max value for a Date, use the DateTime property MaxValue.
DateTime max = DateTime.MaxValue;
Now, display the value of max to get the maximum value of a date as shown below.
 Live Demo
using System;
using System.Linq;
public class Demo {
   public static void Main() {
      DateTime max = DateTime.MaxValue;
      Console.WriteLine(max);
   }
}
12/31/9999 11:59:59 PM