code-rag-bench/online-tutorials huggingface dataset:
Network Security - GeeksforGeeks

09 Oct, 2019
 
I.  M’= Me mod n
    M = (M’)d mod n 

II.  ed ≡ 1 mod n 

III. ed ≡ 1 mod f(n)

IV. M’= Me mod f(n)
    M = (M’)d mod f(n) 
Encrypted-Text = (Plain-Text)e mod n
Plain-Text = (Encrypted-Text)d mod n 
   d-1 = e mod φ(n)
OR ed = 1 mod φ(n) 
(P) RSA 
(Q) SHA-1 
(R) DES 
(S) MD5
RSA – It is an algorithm used to encrypt and decrypt messages.
SHA 1 – Secure Hash Algorithm 1, or SHA 1 is a cryptographic hash function. It produces a 160 bit (20 byte) hash value (message digest).
DES – Data Encryption Standard, or DES is a symmetric key algorithm for encryption of electronic data.
MD5 – Message Digest 5, or MD5 is a widely used cryptographic hash function that produces a 128 bit hash value (message digest).
Injective Function:
A function F(X) is said to be injective if it has one-to-one mapping.
Statement 1: Hash function is an injective function
Statement 2: DES Encryption technique performs a permutation on the elements of its input alphabet
1) Generally, a hash function H(X) is mapping from a larger set to a predefined output set
For example, let H(X) = (X)%5
The above function H(X) is not injective because
Let X1 = 10, X2 = 15
H(10) = H(15) = 0
As the output of H(X1) = H(X2) where X1!= X2 => H(X) is many-to-one function.
Statement 1 is false.
2) In DES encryption scheme, it performs P-Box permutation.
Statement 1 is false,
Statement 2 is true.
This solution is contributed by Anil Saikrishna Devarasetty.
Writing code in comment? Please use ide.geeksforgeeks.org, generate link and share the link here.
Must Do Coding Questions for Companies like Amazon, Microsoft, Adobe, ...
Learn C++ Programming Step by Step - A 20 Day Curriculum!
Must Do Coding Questions for Product Based Companies
CSS Interview Questions and Answers
50 Common Ports You Should Know
GeeksforGeeks Jobathon - Are You Ready For This Hiring Challenge?
How to Find Length of String in Bash Script?
Samsung R&D Internship Interview Experience (On-Campus)
Types of Distributed System
How to use Material-UI with Next.js ?
Add style to Python tkinter button

Tkinter has great support for creating the GUI programs based on python. It offers different ways of styling a button on the Tkinter canvas based on its font, size, colour etc. In this article we will see how to apply style to specific buttons or all buttons in general on the canvas.
Lets consider the case when we have two buttons in the canvas and we want to apply some styling only to the first button. We use the W.TButton as part of the configuration along with the font and the foreground colour.
from tkinter import *
from tkinter.ttk import *

# Set the canvas
canv = Tk()
canv.geometry('200x150')

#Create style object
sto = Style()

#configure style
sto.configure('W.TButton', font= ('Arial', 10, 'underline'),
foreground='Green')

#Button with style
btns = Button(canv, text='Welcome !',
      style='W.TButton',
      command=canv.destroy)
btns.grid(row=0, column=1, padx=50)

#Button without style
btnns = Button(canv, text='Click to Start !', command=None)
btnns.grid(row = 1, column = 1, pady = 10, padx = 50)

canv.mainloop()
Running the above code gives us the following result −
It is a similar configuration as above except that it has Tbutton as its style which automatically applies to all the buttons on the canvas.
from tkinter import *
from tkinter.ttk import *

canv = Tk()
canv.geometry('200x150')

#Create style object
sto = Style()

#configure style
sto.configure('TButton', font=
('calibri', 10, 'bold', 'underline'),
foreground='Green')
# button 1
btns = Button(canv, text='Welcome !',
      style='TButton',
      command=canv.destroy)

btns.grid(row=0, column=1, padx=50)

# button 2
btnns = Button(canv, text='Click to start !', command=None)
btnns.grid(row=1, column=1, pady=10, padx=50)

canv.mainloop()
Running the above code gives us the following result −
sympy.stats.Cauchy() in Python

08 Jun, 2020
With the help of sympy.stats.Cauchy() method, we can get the continuous random variable which represents the cauchy distribution.
Syntax : sympy.stats.Cauchy(name, x, gamma)Where, x and gamma is a real number and gamma is greater 0.Return : Return the continuous random variable.
Example #1 :In this example we can see that by using sympy.stats.Cauchy() method, we are able to get the continuous random variable representing the cauchy distribution by using this method.
# Import sympy and cauchyfrom sympy.stats import Cauchy, densityfrom sympy import Symbol  x0 = Symbol("x0")gamma = Symbol("gamma", positive = True)z = Symbol("z")  # Using sympy.stats.Cauchy() methodX = Cauchy("x", x0, gamma)gfg = density(X)(z)  print(gfg)
Output :
1/(pi*gamma*(1 + (-x0 + z)**2/gamma**2))
Example #2 :
# Import sympy and cauchyfrom sympy.stats import Cauchy, densityfrom sympy import Symbol  x0 = 2gamma = 3z = 0.5  # Using sympy.stats.Cauchy() methodX = Cauchy("x", x0, gamma)gfg = density(X)(z)  print(gfg)
Output :
0.266666666666667/pi
Python SymPy-Stats
SymPy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Python OOPs Concepts
Convert integer to string in Python
Introduction To PYTHON
How to drop one or multiple columns in Pandas Dataframe
Check if Elements of a Vector are non-empty Strings in R Programming - nzchar() Function - GeeksforGeeks

01 Jun, 2020
nzchar() function in R Language is used to test whether elements of a character vector are non-empty strings.
Syntax: nzchar(x)
Parameters:x: character vector
Example 1:
# R program to illustrate# nzchar function  # Initializing a character vectorx <- c("GFG", "gfg")y <- c("a", "b", "c")  # Calling the nzchar() functionnzchar(x)nzchar(y)
Output :
[1] TRUE TRUE
[1] TRUE TRUE TRUE

Example 2:
# R program to illustrate# nzchar function  # Initializing a character vectorx <- c("")y <- c("", "")  # Calling the nzchar() functionnzchar(x)nzchar(y)
Output:
[1] FALSE
[1] FALSE FALSE

R String-Functions
R Vector-Function
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Loops in R (for, while, repeat)
How to Replace specific values in column in R DataFrame ?
Filter data by multiple conditions in R using Dplyr
How to change Row Names of DataFrame in R ?
Change Color of Bars in Barchart using ggplot2 in R
Printing Output of an R Program
Data Visualization in R
How to Change Axis Scales in R Plots?
Remove rows with NA in one column of R DataFrame
Group by function in R using Dplyr
Take in array of objects and convert the above JSON to a Tree-structure in JavaScript

Suppose, we have an array of objects like this −
const arr = [
   {
      "parentIndex": '0' ,
      "childIndex": '3' ,
      "parent": "ROOT",
      "child": "root3"
   },
   {
      "parentIndex": '3' ,
      "childIndex": '2' ,
      "parent": "root3" ,
      "child": "root2"
   },
   {
      "parentIndex": '3' ,
      "childIndex": '1' ,
      "parent": "root3" ,
      "child": "root1"
   }
];
We are required to write a JavaScript function that takes in one such array of objects. The function should then use recursion and convert the above JSON to a Tree−structure.
The Tree−structure would look like −
nodeStructure: {
   text: { name: "root3" },
   children: [
      {
         text: { name: "root2" }
      },
      {
         text: { name: "root1" }
      }
   ]
}
};
The code for this will be −
const arr = [
   {
      "parentIndex": '0' ,
      "childIndex": '3' ,
      "parent": "ROOT",
      "child": "root3"
   },
   {
      "parentIndex": '3' ,
      "childIndex": '2' ,
      "parent": "root3" ,
      "child": "root2"
   },
   {
      "parentIndex": '3' ,
      "childIndex": '1' ,
      "parent": "root3" ,
      "child": "root1"
   }
];
const partial = (arr = [], condition) => {
   const result = [];
   for (let i = 0; i < arr.length; i++) {
      if(condition(arr[i])){
         result.push(arr[i]);
      }
   }
   return result;
}
const findNodes = (parentKey,items) => {
   let subItems = partial(items, n => n.parent === parentKey);
   const result = [];
   for (let i = 0; i < subItems.length; i++) {
      let subItem = subItems[i];
      let resultItem = {
         text: {name:subItem.child}
      };
      let kids = findNodes(subItem.child , items);
      if(kids.length){
         resultItem.children = kids;
      }
      result.push(resultItem);
   }
   return result;
}
console.log(JSON.stringify(findNodes('ROOT', arr), undefined, 4));
And the output in the console will be −
[
   {
      "text": {
         "name": "root3"
      },
      "children": [
         {
            "text": {
               "name": "root2"
            }
         },
         {
            "text": {
               "name": "root1"
            }
         }
      ]
   }
]
How to update empty string to NULL in MySQL?

For this, use LENGTH(), since if the length is 0 that would mean the string is empty. After finding, you can set it to NULL using the SET clause in the UPDATE command. Let us first create a table −
mysql> create table DemoTable
(
   Name varchar(50)
);
Query OK, 0 rows affected (0.68 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('Chris');
Query OK, 1 row affected (0.18 sec)
mysql> insert into DemoTable values('');
Query OK, 1 row affected (0.14 sec)
mysql> insert into DemoTable values('David');
Query OK, 1 row affected (0.12 sec)
mysql> insert into DemoTable values('');
Query OK, 1 row affected (0.15 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+-------+
| Name  |
+-------+
| Chris |
|       |
| David |
|       |
+-------+
4 rows in set (0.00 sec)
Following is the query to update empty string to NULL −
mysql> update DemoTable set Name=NULL where length(Name)=0;
Query OK, 2 rows affected (0.12 sec)
Rows matched: 2 Changed: 2 Warnings: 0
Let us check the table records once again −
mysql> select *from DemoTable;
This will produce the following output −
+-------+
| Name  |
+-------+
| Chris |
| NULL  |
| David |
| NULL  |
+-------+
4 rows in set (0.00 sec)
Count elements in a vector that match a target value or condition - GeeksforGeeks

11 Nov, 2018
To determine number of integers in a vector that matches a particular value.
We use count in C++ STL
// CPP program to count vector elements that// match given target value.#include <algorithm>#include <iostream>#include <vector>using namespace std;  int main(){    vector<int> v{ 10, 30, 30, 10, 30, 30 };    int target = 30;    int res = count(v.begin(), v.end(), target);    cout << "Target: " << target << " Count : " << res << endl;    return 0;}
Target: 30 Count : 4

How to count elements matching a condition?We can use lambda expressions in C++ to achieve this.
We use count_if in C++ STL
// lambda expression to count elements// divisible by 3.#include <algorithm>#include <iostream>#include <vector>using namespace std;int main(){    vector<int> v{ 10, 18, 30, 10, 12, 45 };    int res = count_if(v.begin(), v.end(),                       [](int i) { return i % 3 == 0; });    cout << "Numbers divisible by 3: " << res << '\n';    return 0;}
Numbers divisible by 3: 4

cpp-vector
STL
C++
STL
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Iterators in C++ STL
Operator Overloading in C++
Friend class and function in C++
Polymorphism in C++
Sorting a vector in C++
Convert string to char array in C++
Inline Functions in C++
List in C++ Standard Template Library (STL)
std::string class in C++
new and delete operators in C++ for dynamic memory
Count total bits in a number in C++

We are given an integer number let’s say, num and the task is to firstly calculate the binary digit of a number and calculate the total digits of a number.
Input − int number = 50
Output − Count of total bits in a number are − 6
Explanation − Binary representation of a number 50 is 110010 and if we calculate it in 8-digit number then two 0’s will be appended in the beginning. So, the total bits in a number are 6.
Input − int number = 10
Output − Count of total bits in a number are − 6
Explanation − Binary representation of a number 10 is 00001010 and if we calculate it in 8-digit number then four 0’s will be appended in the beginning. So, the total bits in a number are 4.
Input the number in a variable of integer type
Input the number in a variable of integer type
Declare a variable count to store the total count of bits of type unsigned int
Declare a variable count to store the total count of bits of type unsigned int
Start loop FOR from i to 1<<7 and i > 0 and i to i / 2
Start loop FOR from i to 1<<7 and i > 0 and i to i / 2
Inside the loop, check num & 1 == TRUE then print 1 else print 0
Inside the loop, check num & 1 == TRUE then print 1 else print 0
Start loop while to calculate the total count of bits till number isn’t 0
Start loop while to calculate the total count of bits till number isn’t 0
Inside the loop, increment the value of count by 1 and set number >>=1
Inside the loop, increment the value of count by 1 and set number >>=1
Print the count
Print the count
 Live Demo
#include
using namespace std;
//Count total bits in a number
unsigned int bits(unsigned int number){
   unsigned int count = 0;
   unsigned i;
   //display the total 8-bit number
   cout<<"8-bit digits of "<<number<<" is: ";
   for (i = 1 << 7; i > 0; i = i / 2){
      (number & i)? cout<<"1": cout<<"0";
   }
   //calculate the total bits in a number
   while (number){
      count++;
      number >>= 1;
   }
   cout<<"\nCount of total bits in a number are: "<<count;
}
int main(){
   int number = 50;
   bits(number);
   return 0;
}
If we run the above code it will generate the following output −
8-bit digits of 50 is: 00110010
Count of total bits in a number are: 6
Is final method inherited in Java?

No, we cannot override a final method in Java.
The final modifier for finalizing the implementations of classes, methods, and variables.
We can declare a method as final, once you declare a method final it cannot be overridden. So, you cannot modify a final method from a sub class.
The main intention of making a method final would be that the content of the method should not be changed by any outsider.
class Demo{
   public final void demoMethod(){
      System.out.println("Hello");
   }
}
public class Sample extends Demo{
   public final void demoMethod(){
      System.out.println("demo method");
   }
   public static void main(String args[]){
      Sample obj = new Sample();
      obj.demoMethod();
   }
}
C:\Sample>javac Sample.java
Sample.java:8: error: demoMethod() in Sample cannot override demoMethod() in Demo
public final void demoMethod(){
                  ^
overridden method is final
1 error
How to Create Embossed Text Effect using CSS ? - GeeksforGeeks

14 May, 2020
The embossed text effect can be easily generated using HTML and CSS. We will use the CSS text-shadow property to get the desired output.
HTML Code: In this section, we will create a basic structure of the body that holds text or heading.
<!DOCTYPE html><html lang="en" dir="ltr">  <head>    <meta charset="utf-8">    <title>Embossed Text Effect</title></head>  <body>    <div>        <h2>GeeksforGeeks</h2>    </div></body>  </html>
CSS Code: In this section we will style the text. We will use the CSS text-shadow property to add shadow to the text and create the embossed effect.
<style>    body {        margin: 0;        padding: 0;        font-family: serif;        justify-content: center;        align-items: center;        display: flex;        background-color: #65E73C;    }      div {        content: '';        font-size: 3em;        position: absolute;        top: 50%;        left: 50%;        transform: translate(-50%, -50%);    }      h2 {        color: #65E73C;        text-shadow: -2px 2px 4px             rgba(0, 0, 0, 0.5),             2px -2px 0             rgba(255, 255, 255, 0.9);    }</style>
Final Code: It is the combination of the above two code sections.
<!DOCTYPE html><html lang="en" dir="ltr">  <head>    <meta charset="utf-8">    <title>Embossed Text Effect</title>    <style>        body {            margin: 0;            padding: 0;            font-family: serif;            justify-content: center;            align-items: center;            display: flex;            background-color: #65E73C;        }          div {            content: '';            font-size: 3em;            position: absolute;            top: 50%;            left: 50%;            transform: translate(-50%, -50%);        }          h2 {            color: #65E73C;            text-shadow: -2px 2px 4px rgba(0, 0, 0, 0.5),                2px -2px 0 rgba(255, 255, 255, 0.9);        }    </style></head>  <body>    <div>        <h2>GeeksforGeeks</h2>    </div></body>  </html>
Output:
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
CSS-Misc
HTML-Misc
CSS
HTML
Web Technologies
Web technologies Questions
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to set space between the flexbox ?
Design a web page using HTML and CSS
Form validation using jQuery
How to style a checkbox using CSS?
Search Bar using HTML, CSS and JavaScript
How to set the default value for an HTML <select> element ?
Hide or show elements in HTML using display property
How to set input type date in dd-mm-yyyy format using HTML ?
REST API (Introduction)
HTML Cheat Sheet - A Basic Guide to HTML
Java - The SortedMap Interface

The SortedMap interface extends Map. It ensures that the entries are maintained in an ascending key order.
Several methods throw a NoSuchElementException when no items are in the invoking map. A ClassCastException is thrown when an object is incompatible with the elements in a map. A NullPointerException is thrown if an attempt is made to use a null object when null is not allowed in the map.
The methods declared by SortedMap are summarized in the following table −
Comparator comparator( )
Returns the invoking sorted map's comparator. If the natural ordering is used for the invoking map, null is returned.
Object firstKey( )
Returns the first key in the invoking map.
SortedMap headMap(Object end)
Returns a sorted map for those map entries with keys that are less than end.
Object lastKey( )
Returns the last key in the invoking map.
SortedMap subMap(Object start, Object end)
Returns a map containing those entries with keys that are greater than or equal to start and less than end.
SortedMap tailMap(Object start)
Returns a map containing those entries with keys that are greater than or equal to start.
SortedMap has its implementation in various classes like TreeMap. Following is the example to explain SortedMap functionlaity −
import java.util.*;
public class TreeMapDemo {

   public static void main(String args[]) {
      // Create a hash map
      TreeMap tm = new TreeMap();
      
      // Put elements to the map
      tm.put("Zara", new Double(3434.34));
      tm.put("Mahnaz", new Double(123.22));
      tm.put("Ayan", new Double(1378.00));
      tm.put("Daisy", new Double(99.22));
      tm.put("Qadir", new Double(-19.08));
      
      // Get a set of the entries
      Set set = tm.entrySet();
      
      // Get an iterator
      Iterator i = set.iterator();
      
      // Display elements
      while(i.hasNext()) {
         Map.Entry me = (Map.Entry)i.next();
         System.out.print(me.getKey() + ": ");
         System.out.println(me.getValue());
      }
      System.out.println();
      
      // Deposit 1000 into Zara's account
      double balance = ((Double)tm.get("Zara")).doubleValue();
      tm.put("Zara", new Double(balance + 1000));
      System.out.println("Zara's new balance: " + tm.get("Zara"));
   }
}
This will produce the following result −
Ayan: 1378.0
Daisy: 99.22
Mahnaz: 123.22
Qadir: -19.08
Zara: 3434.34

Zara's new balance: 4434.34


    16 Lectures 
     2 hours 

 Malhar Lathkar

    19 Lectures 
     5 hours 

 Malhar Lathkar

    25 Lectures 
     2.5 hours 

 Anadi Sharma

    126 Lectures 
     7 hours 

  Tushar Kale

    119 Lectures 
     17.5 hours 

 Monica Mittal

    76 Lectures 
     7 hours 

 Arnab Chakraborty
 Print
 Add Notes
 Bookmark this page
Python program to create 3D list.

3D list means 3D array. In this program we create 3D array with integer elements.
Input: 3× 3 × 2
[[1,1,1],[2,2,2],[3,3,3]],
[[4,4,4],[5,5,5],[6,6,6]]
Step 1: given the order of 3D list.
Step 2: using for loop we create list and print data.
# Python program to created 3D list
import pprint
def print3D(i, j, k):
   lst = [[ ['*' for cc1 in range(i)] for cc2 in range(j)] for r in range(k)]
   return lst
   # Driver Code
   c1 = 3
   c2 = 2
   r = 2
   # used the pretty printed function
pprint.pprint(print3D(c1, c2, r))
[[['*', '*', '*'], ['*', '*', '*']], [['*', '*', '*'], ['*', '*', '*']]]
What are multiple statement groups as suites in python?

A group of individual statements, which make a single code block are called suites in Python. Compound or complex statements, such as if, while, def, and class require a header line and a suite.
Header lines begin the statement (with the keyword) and terminate with a colon (: ) and are followed by one or more lines which make up the suite. 
if expr1==True:
  stmt1
  stmt2
elif expr2==True:
  stmt3
  stmt4
else:
  stmt5
  stmt6
while expr==True:
  stmt1
  stmt2
How can I use multiple submit buttons in an HTML form?

yes, multiple submit buttons can include in the html form. One simple example is given below.
Here I am using MVC VB.net.In view I am using three buttons with the same name but in different values. In the controller, I am using same name parameter(cmd) which is string type and compare with the value of button's value(Save, Update, Delete).
multisubmit.aspx
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>multiple submit button</title>
</head>
<body>
<div>
<% Using Html.BeginForm()%>
<%: Html.ValidationSummary(True) %>
<button type="submit" id="postback1" name="cmd" value="Save" >Save</button>
<button type="submit" id="postback2" name="cmd" value="Update">Update</button>
<button type="submit" id="postback3" name="cmd" value="Delete">Delete</button>
<%: Html.Encode(ViewData("msg"))%>
<% End Using%>
</div>
</body>
</html>
Test.controller
Function multisubmit() As ActionResult
Return View()
End Function

<HttpPost()> _
Function multisubmit(ByVal cmd As String) As ActionResult
If (cmd = "Save") Then
ViewData("msg") = " SAVE"
ElseIf (cmd = "Update") Then
ViewData("msg") = "UPDATE"
ElseIf (cmd = "Delete") Then
ViewData("msg") = "DELETE"
End If
Return View()
End Function
C# Enums

An enum is a special "class" that represents a group of 
constants (unchangeable/read-only variables).
To create an enum, use the enum keyword (instead of class or interface), and separate 
the enum items with a comma:
enum Level 
{
  Low,
  Medium,
  High
}

You can access enum items with the dot syntax:
Level myVar = Level.Medium;
Console.WriteLine(myVar);
Enum is short for "enumerations", which means "specifically listed".
You can also have an enum inside a class:
class Program
{
  enum Level
  {
    Low,
    Medium,
    High
  }
  static void Main(string[] args)
  {
    Level myVar = Level.Medium;
    Console.WriteLine(myVar);
  }
}
The output will be:
By default, the first item of an enum has the value 0. The second has the value 1, and so on.
To get the integer value from an item, you must explicitly convert the item to an 
int:
enum Months
{
  January,    // 0
  February,   // 1
  March,      // 2
  April,      // 3
  May,        // 4
  June,       // 5
  July        // 6
}

static void Main(string[] args)
{
  int myNum = (int) Months.April;
  Console.WriteLine(myNum);
}
The output will be:
You can also assign your own enum values, and the next items will update the number accordingly:
enum Months
{
  January,    // 0
  February,   // 1
  March=6,    // 6
  April,      // 7
  May,        // 8
  June,       // 9
  July        // 10
}

static void Main(string[] args)
{
  int myNum = (int) Months.April;
  Console.WriteLine(myNum);
}
The output will be:
Enums are often used in switch statements to check for corresponding values:
enum Level 
{
  Low,
  Medium,
  High
}

static void Main(string[] args) 
{
  Level myVar = Level.Medium;
  switch(myVar) 
  {
    case Level.Low:
      Console.WriteLine("Low level");
      break;
    case Level.Medium:
       Console.WriteLine("Medium level");
      break;
    case Level.High:
      Console.WriteLine("High level");
      break;
  }
}
The output will be:
Use enums when you have values that you know aren't going to change, like month days, days, colors, deck of cards, etc.
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.
How to count the total number of links in Selenium with python?

We can count the total number of links in a page in Selenium with the help of find_elements method. While working on links, we will always find the tagname in the html code and its value should be anchor (a).
This characteristic is only applicable to links on that particular page and to no other types of UI elements like edit box, radio buttons and so on.
To retrieve all the elements with the tagname as anchor we will use find_elements_by_tag_name() method. This method returns a list of web elements with the type of tagname specified in the method argument. In case there are no matching elements, an empty list will be returned.
After the list of links is fetched, in order to count its total numbers, we need to get the size of that list. The size of the list can be obtained from the len() method of the list data structure.
Finally this length is printed on the console.
driver.find_elements_by_tag_name("a")
Code Implementation to count links.
from selenium import webdriver
driver = webdriver.Chrome(executable_path="C:\\chromedriver.exe")
# to maximize the browser window
driver.maximize_window()
#get method to launch the URL
driver.get("https://www.tutorialspoint.com/index.htm")
#to refresh the browser
driver.refresh()
#to get the list of links present on the web page
l = driver.find_elements_by_tag_name('a')
#print the count with the len method on console
print(len(l))
#to close the browser
driver.quit()
HTML DOM Image Object

The HTML DOM image Object represents the <img> element of an HTML document.
Let us create an img object −
Following is the syntax −
document.createElement(“IMG”);
Following are the properties of image Object −
Let us see an example of HTML DOM image object −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<style>
   body{
      text-align:center;
   }
   .btn{
      background-color:lightblue;
      border:none;
      height:2rem;
      border-radius:50px;
      width:60%;
      margin:1rem auto;
      display:block;
   }
</style>
</head>
<body>
<h1>DOM Image Object Example</h1>
<button onclick="createIframe()" class="btn">Click me to create an image</button>
<script>
   function createIframe() {
      var x = document.createElement("IMG");
      x.setAttribute("src",https://www.tutorialspoint.com/servlets/images/servlets-mini-logo.jpg");
      x.setAttribute("alt", "Learn Servlets");
      document.body.appendChild(x);
   }
</script>
</body>
</html>
This will produce the following output −
Click on “Click me to create an image” button to create an image element −
GATE | GATE-CS-2016 (Set 2) | Question 21

12 Aug, 2021
Breadth First Search (BFS) is started on a binary tree beginning from the root vertex. There is a vertex t at a distance four from the root. If t is the n-th vertex in this BFS traversal, then the maximum possible value of n is ________
[This Question was originally a Fill-in-the-blanks Question]
(A) 15(B) 16(C) 31(D) 32Answer: (C)Explanation: It would be node number 31 for given distance 4.
For example if we consider at distance 2, below highlighted node G can be the farthest node at position 7.
            A
         /    \
        B       C
       / \     / \
      D   E   F   G

Alternative Solution :t is the n-th vertex in this BFS traversal at distance four from the root. So height of tree is 4.Max number of nodes = 2^{h+1} − 1 = 2^{5} − 1 = 31At distance four, last node is 31. option (C).
GATE PYQs 2016 with Shubham Agrawal | GeeksforGeeks GATE CSE - YouTubeGeeksforGeeks GATE Computer Science17.5K subscribersGATE PYQs 2016 with Shubham Agrawal | GeeksforGeeks GATE CSEWatch laterShareCopy linkInfoShoppingTap to unmuteIf playback doesn't begin shortly, try restarting your device.More videosMore videosYou're signed outVideos you watch may be added to the TV's watch history and influence TV recommendations. To avoid this, cancel and sign in to YouTube on your computer.CancelConfirmSwitch cameraShareInclude playlistAn error occurred while retrieving sharing information. Please try again later.Watch on0:000:0040:19 / 1:07:54•Live•<div class="player-unavailable"><h1 class="message">An error occurred.</h1><div class="submessage"><a href="https://www.youtube.com/watch?v=Key2RKhzRGY" target="_blank">Try watching this video on www.youtube.com</a>, or enable JavaScript if it is disabled in your browser.</div></div>Quiz of this Question
GATE-CS-2016 (Set 2)
GATE-GATE-CS-2016 (Set 2)
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Java IO FileReader Class

09 Feb, 2022
FileReader is a class in the java.io package which can be used to read a stream of characters from the files. This class uses either specified charset or the platform’s default charset for decoding from bytes to characters.
Charset: The Charset class is used to define methods for producing encoders and decoders and for recovering several names combined with the charset.
Default Charset: The default charset is defined during implicit computer start-up and it depends on the locale and charset of the underlying operating system.
The following image shows the Hierarchical Flow of FileReader class.
Hierarchical Flow of FileReader Class
The Constructors inside FileReader are shown in the table below.
Constructor
Description
The methods under FileReader are shown in the table below.
Example:
Java
// Java program to show the usage of// IO FileReader Class import java.io.*; class GFG {    public static void main(String[] args)    {        try {            FileReader fileReader                = new FileReader("gfg.txt");             System.out.println("Reading char by char : \n");            int i;            while ((i = fileReader.read()) != -1) {                System.out.print((char)i);            }             System.out.println("Reading using array : \n");            char[] charArray = new char[10];            fileReader.read(charArray);            System.out.print(charArray);             fileReader.close();            System.out.println("FileReader closed!");        }        catch (Exception e) {            System.out.println(e);        }    }}
 Output:
Reading char by char :
GeeksForGeeks
Reading using array : 
GeeksForGeeks
FileReader closed!
nishkarshgandhi
Java-Classes
Java-Files
Java-IO package
Picked
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Drop Shadow with HTML5 Canvas

HTML5 canvas provides capabilities to create nice shadows around the drawings. All drawing operations are affected by the four global shadow attributes.
You can try to run the following code to create shadows:
<!DOCTYPE HTML>
<html>
   <head>
      <style>
         #test {
            width: 100px;
            height:100px;
            margin: 0px auto;
         }
      </style>

      <script type>
         function drawShape(){
            // get the canvas element using the DOM
            var canvas = document.getElementById('mycanvas');
            // Make sure we don't execute when canvas isn't supported
                 
            if (canvas.getContext){
               // use getContext to use the canvas for drawing
               var ctx = canvas.getContext('2d');
               ctx.shadowOffsetX = 2;
               ctx.shadowOffsetY = 2;
               ctx.shadowBlur = 2;
               ctx.shadowColor = "rgba(0, 0, 0, 0.5)";
               ctx.font = "20px Times New Roman";
               ctx.fillStyle = "Black";
               ctx.fillText("This is shadow test", 5, 30);
            } else {
               alert('You need Safari or Firefox 1.5+ to see this demo.');
            }
         }
      </script>
   </head>

   <body id = "test" onload = "drawShape();">
      <canvas id = "mycanvas"></canvas>
   </body>
</html>
How to convert multiple numerical variables to factor variable in R?

Sometimes the data type for a variable is not correct and it is very common that a factor variable is read as a numeric variable, especially in cases where factor levels are represented by numbers. If we do not change the data type of a factor variable then the result of the analysis will be incorrect. Therefore, if a factor variable has a different data type than factor then it must be converted to factor data type. To convert multiple variables to factor type, we can create a vector that will have the name of all factor variables then using lapply to convert them to factor.
Consider the below data frame −
> set.seed(123)
> x1<-rep(c(1,2,3,4,5),times=4)
> x2<-rep(c(5,10,15,20),each=5)
> x3<-sample(1:10,20,replace=TRUE)
> x4<-sample(1:100,20)
> x5<-rep(c(LETTERS[1:5]),times=4)
> x6<-rnorm(20,1)
> x7<-runif(20,2,10)
> df<-data.frame(x1,x2,x3,x4,x5,x6,x7)
> df
x1 x2 x3 x4 x5 x6 x7
1 1 5 3 9 A 0.18148428 3.501529
2 2 5 3 83 B 1.68493608 8.258354
3 3 5 10 36 C 0.67994358 2.748760
4 4 5 2 78 D -0.31152241 5.734232
5 5 5 6 81 E 0.40039167 6.092044
6 1 10 5 43 A 0.87058931 6.799912
7 2 10 4 76 B 1.88673615 4.662588
8 3 10 6 15 C 0.84860404 5.908904
9 4 10 9 32 D 1.32979120 9.635791
10 5 10 10 7 E -2.22732283 5.863219
11 1 15 5 100 A 0.22820823 9.122802
12 2 15 3 41 B 1.28654857 9.315505
13 3 15 9 74 C -0.22051198 6.869880
14 4 15 9 23 D 1.43455038 5.285518
15 5 15 9 27 E 1.80017687 3.176758
16 1 20 3 60 A 0.83606903 9.482398
17 2 20 8 53 B 2.24291877 4.409831
18 3 20 10 91 C 0.06561494 2.485765
19 4 20 7 84 D 1.39370865 9.581816
20 5 20 10 86 E 1.40363146 7.764770
> str(df)
'data.frame': 20 obs. of 7 variables:
$ x1: num 1 2 3 4 5 1 2 3 4 5 ...
$ x2: num 5 5 5 5 5 10 10 10 10 10 ...
$ x3: int 3 3 10 2 6 5 4 6 9 10 ...
$ x4: int 9 83 36 78 81 43 76 15 32 7 ...
$ x5: Factor w/ 5 levels "A","B","C","D",..: 1 2 3 4 5 1 2 3 4 5 ...
$ x6: num 0.181 1.685 0.68 -0.312 0.4 ...
$ x7: num 3.5 8.26 2.75 5.73 6.09 ...
Here, we have one Factor variable. Now suppose that we want to convert x1, x2, and x3 to a factor variable then it can be done as follows −
> Factors<-c("x1","x2","x3")
> df[Factors]<-lapply(df[Factors],factor)
Checking whether x1, x2, and x3 are factor variables or not −
> str(df)
'data.frame': 20 obs. of 7 variables:
$ x1: Factor w/ 5 levels "1","2","3","4",..: 1 2 3 4 5 1 2 3 4 5 ...
$ x2: Factor w/ 4 levels "5","10","15",..: 1 1 1 1 1 2 2 2 2 2 ...
$ x3: Factor w/ 9 levels "2","3","4","5",..: 2 2 9 1 5 4 3 5 8 9 ...
$ x4: int 9 83 36 78 81 43 76 15 32 7 ...
$ x5: Factor w/ 5 levels "A","B","C","D",..: 1 2 3 4 5 1 2 3 4 5 ...
$ x6: num 0.181 1.685 0.68 -0.312 0.4 ...
$ x7: num 3.5 8.26 2.75 5.73 6.09 ...
HashMap getOrDefault(key, defaultValue) method in Java with Examples

15 Oct, 2019
The getOrDefault(Object key, V defaultValue) method of Map interface, implemented by HashMap class is used to get the value mapped with specified key. If no value is mapped with the provided key then the default value is returned.
Syntax:
default V getOrDefault(Object key, V defaultValue)
Parameters: This method accepts two parameters:
key: which is the key of the element whose value has to be obtained.
defaultValue: which is the default value that has to be returned, if no value is mapped with the specified key.
Return Value: This method returns value mapped with the specified key, otherwise default value is returned.
Program 1:
// Java program to demonstrate// getOrDefault(Object key, V defaultValue) method  import java.util.*;  public class GFG {      // Main method    public static void main(String[] args)    {          // Create a HashMap and add some values        HashMap<String, Integer> map            = new HashMap<>();        map.put("a", 100);        map.put("b", 200);        map.put("c", 300);        map.put("d", 400);          // print map details        System.out.println("HashMap: "                           + map.toString());          // provide key whose value has to be obtained        // and default value for the key. Store the        // return value in k        int k = map.getOrDefault("b", 500);          // print the value of k returned by        // getOrDefault(Object key, V defaultValue) method        System.out.println("Returned Value: " + k);    }}
HashMap: {a=100, b=200, c=300, d=400}
Returned Value: 200

Program 2:
// Java program to demonstrate// getOrDefault(Object key, V defaultValue) method  import java.util.*;  public class GFG {      // Main method    public static void main(String[] args)    {          // Create a HashMap and add some values        HashMap<String, Integer> map            = new HashMap<>();        map.put("a", 100);        map.put("b", 200);        map.put("c", 300);        map.put("d", 400);          // print map details        System.out.println("HashMap: "                           + map.toString());          // provide key whose value has to be obtained        // and default value for the key. Store the        // return value in k        int k = map.getOrDefault("y", 500);          // print the value of k returned by        // getOrDefault(Object key, V defaultValue) method        System.out.println("Returned Value: " + k);    }}
HashMap: {a=100, b=200, c=300, d=400}
Returned Value: 500

References: https://docs.oracle.com/javase/8/docs/api/java/util/HashMap.html#getOrDefault-java.lang.Object-V-
Java - util package
Java-Collections
Java-Functions
Java-HashMap
Picked
Java
Java
Java-Collections
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Interfaces in Java
Stream In Java
ArrayList in Java
Collections in Java
Singleton Class in Java
Multidimensional Arrays in Java
Stack Class in Java
Initialize an ArrayList in Java
Introduction to Java
Constructors in Java
How to use JavaScript variables in jQuery selectors ?

03 Aug, 2021
In this article, we will discuss how to use JavaScript variables in jQuery selectors. In the following examples, it can be seen that we have used the values stored in JavaScript Variables are used inside the jQuery Selectors.
Example 1: The concatenation technique can be applied in order to use the values stored in JavaScript variables. In the following example, whenever the button is clicked, the content present inside the <span> element is appended to the <p> element. Then we will use the ready() method that helps to load the whole page then execute the rest code.
<!DOCTYPE html>  <html>  <head>    <title>JavaScript variables in jQuery slectors</title>      <script src="https://code.jquery.com/jquery-3.4.1.js"            integrity="sha256-WpOohJOqMqqyKL9FccASB9O0KwACQJpFTUBLTYOVvVU="             crossorigin="anonymous">    </script></head>  <body>    <div>        <button id="button"                style="color: green;">            Click Me        </button>          <p id="firstpara">            <span id="span"                   style="color: green;">                A Computer Science Portal fo Geeks<br>             </span>        </p>    </div>    <script>        $(document).ready(function() {            $("#button").click(function() {                var paraId = "firstpara";                var spanId = "span";                $("#" + paraId).append($("#" + spanId).html());            });        })    </script></body>  </html>
Output:
Example 2: The following example changes the color of the text when the link is pressed. In this example, javascript:void(0); is used inside <a> element. Then we will use the ready() method helps to load the whole page then execute the rest code.
<!DOCTYPE html><html>  <head>    <title>JavaScript variables in jQuery slectors</title>      <script src="https://code.jquery.com/jquery-3.4.1.js"            integrity="sha256-WpOohJOqMqqyKL9FccASB9O0KwACQJpFTUBLTYOVvVU="             crossorigin="anonymous">    </script></head>  <body>    <form>        <p>           Text:          <input type="text">         </p>        <br>          <a href="javascript:void(0);">          Change the color of Text         </a>    </form>    <script>        $(document).ready(function() {              $("a").click(function() {                var type = $("input").attr("type");                var attribute = "color";                var color = "green";                  $("input[type=" + type + "]")                .css(attribute, color);            });        })    </script></body>  </html>
Output:
jQuery is an open source JavaScript library that simplifies the interactions between an HTML/CSS document, It is widely famous with it’s philosophy of “Write less, do more”.You can learn jQuery from the ground up by following this jQuery Tutorial and jQuery Examples.
JavaScript-Misc
jQuery-Misc
Picked
JavaScript
JQuery
Web Technologies
Web technologies Questions
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
jQuery | insertAfter() with Examples

03 Aug, 2021
The insertAfter() is an inbuilt method in jQuery which is used to insert some HTML content after a specified element. The HTML content will be inserted after each occurrence of the specified element.Syntax:
$(content).insertAfter(target)

Here the “content” is the HTML content which is to be inserted after the specified target.Parameters: It takes a parameter “target” which is target after which the content is to be inserted.Return Value: It doesn’t return any value.
<!DOCTYPE html><html>  <head>    <script     src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">    </script>    <script>        $(document).ready(function() {            $("div").click(function() {                // insertAfter                $("<p>You should follow GeeksForGeeks</p>").insertAfter("p");            });        });    </script></head>  <body>      <p>To learn jQuery : </p>      <div>Click here to complete</div>  </body>  </html>
Output:Before clicking the div content-
To learn jQuery :
Click here to complete

After clicking the div content-
To learn jQuery :
You should follow GeeksForGeeks
Click here to complete

Code #2:
<!DOCTYPE html><html>  <head>    <script     src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">    </script>    <script>        $(document).ready(function() {            $("div").click(function() {                // insertAfter                $("<p>You should follow GeeksForGeeks</p>").insertAfter("p");            });        });    </script></head>  <body>      <p>To learn jQuery : </p>      <p> To learn coding : </p>      <div>Click here to complete</div>  </body>  </html>
Output:Before clicking the div content-
To learn jQuery :
To learn coding :
Click here to complete

After clicking the div content-
To learn jQuery :
You should follow GeeksForGeeks
To learn coding :
You should follow GeeksForGeeks
Click here to complete

jQuery is an open source JavaScript library that simplifies the interactions between an HTML/CSS document, It is widely famous with it’s philosophy of “Write less, do more”.You can learn jQuery from the ground up by following this jQuery Tutorial and jQuery Examples.
jQuery-HTML/CSS
JavaScript
JQuery
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
Lodash _.groupBy() Method
JavaScript | Promises
Difference Between PUT and PATCH Request
Form validation using jQuery
JQuery | Set the value of an input text field
How to Dynamically Add/Remove Table Rows using jQuery ?
How to change selected value of a drop-down list using jQuery?
How to add options to a select element using jQuery?
PHP | gettype() Function

31 Jul, 2021
The gettype() function is an inbuilt function in PHP which is used to get the type of a variable. It is used to check the type of existing variable.
Syntax:
string gettype ( $var )

Parameter: This function accepts a single parameter $var. It is the name of variable which is needed to be checked for type of variable.
Return Value: This function returns a string type value. Possible values for the returned string are:
boolean
integer
double (for historical reasons “double” is returned in case of float)
string
array
object
resource
NULL
unknown type
Below programs illustrate the gettype() function in PHP:
Program 1:
<?php// PHP program to illustrate gettype() function  $var1 = true; // boolean value $var2 = 3; // integer value$var3 = 5.6; // double value$var4 = "Abc3462"; // string value$var5 = array(1, 2, 3); // array value$var6 = new stdClass; // object value$var7 = NULL; // null value$var8 = tmpfile(); // resource value  echo gettype($var1)."\n";echo gettype($var2)."\n";echo gettype($var3)."\n";echo gettype($var4)."\n";echo gettype($var5)."\n";echo gettype($var6)."\n";echo gettype($var7)."\n";echo gettype($var8)."\n";  ?>
boolean
integer
double
string
array
object
NULL
resource

Program 2:
<?php  // PHP program to illustrate gettype() function  $var1 = "GfG"; $var2 = 10 % 7;$var3 = pow(10, 2);$var4 = pow(10, 0.5);$var5 = sqrt(9);  echo gettype($var1)."\n";echo gettype($var2)."\n";echo gettype($var3)."\n";echo gettype($var4)."\n";echo gettype($var5);?>
string
integer
integer
double
double

Reference: http://php.net/manual/en/function.gettype.php
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.
PHP-function
PHP
Web Technologies
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
\Lambda - Tex Command

\Lambda - Used to draw uppercase Lambda symbol.
{ \Lambda }
\Lambda command is used to draw uppercase Lambda symbol.

\Lambda

Λ



\Lambda

Λ


\Lambda

    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