code-rag-bench/online-tutorials huggingface dataset:
JavaScript removeEventListener() method with examples

The JavaScript removeEventListener() method is used to remove an event listener from an element that has been previously attached with the addEventListener() method.
Following is the code for removeEventListener() method −
 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>
<style>
   body {
      font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
   }
   .sample{
      font-size: 18px;
      font-weight: 500;
      color:red;
   }
</style>
</head>
<body>
<h1>JavaScript removeEventListener() method</h1>
<div class="sample"></div>
<button class="Btn">CLICK HERE</button>
<h3>
Click on the above button to print a number
</h3>
<button class="Btn">Remove event Listener</button>
<h3>Click on the above button to remove the event listener of the first button</h3>
<script>
   let sampleEle = document.querySelector('.sample');
   let j=0;
   function printNum(){
      sampleEle.innerHTML += 'Number = ' + j++ + '<br>';
   }
   document.querySelector('.Btn').addEventListener('click',printNum);
   document.querySelectorAll('.Btn')[1].addEventListener('click',()=>{
      document.querySelector('.Btn').removeEventListener('click',printNum);
      sampleEle.innerHTML = 'Event listener has been removed';
   })
</script>
</body>
</html>
The above code will produce the following output -
On clicking ‘CLICK HERE’ three times −
On clicking the ‘Remove event Listener’ button and clicking on the ‘CLICK HERE’ button again −
Excel’s CHOOSE Function with Array - GeeksforGeeks

29 Oct, 2021
The Excel CHOOSE function returns a value/reference from an array using a given position.
Syntax:
=CHOOSE (index_num, value1, [value2], ...)
Arguments:  
index_num: The value to choose.
value1: The first value from which to choose.
value2 [optional]: The second value from which to choose.
index_num: It is the first argument for CHOOSE function and it refers to the position of an array.
Sample Data: In the Sales Table, we have given Products_Id.  We use Excel CHOOSE() to fill Actual Products Name in the next column (Column – D).
Sales Table
Example 1: Returning a value
Step 1: Type “Products” in cell D1
Step 2: Write a CHOOSE function in cell D2  
=CHOOSE(C2,"Fashion","Electronics","Daily Essentials")
Step 3: Select cell D2 and drag till cell D11
Example 2: Returning a cell reference
Step 1: Type “Products” in cell D1
Step 2: Create a Product table (unique list of Products) in “Column H”  
Step 3: Write a CHOOSE function in cell D2
=CHOOSE(C2, $H$2,$H$3,$H$4)
Step 4: Select cell D2 and drag till cell D11.
Excel-functions
Picked
Excel
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Use Solver in Excel?
How to Find the Last Used Row and Column in Excel VBA?
How to Show Percentages in Stacked Column Chart in Excel?
Macros in Excel
Introduction to Excel Spreadsheet
How to Get Length of Array in Excel VBA?
How to Sum Values Based on Criteria in Another Column in Excel?
Excel Dynamic Chart Linked with a Drop-down List
How to Read Data From Text File in Excel VBA?
Using CHOOSE Function along with VLOOKUP in Excel
jQuery - Element Class Selector

The element class selector selects all the elements which match with the given class of the elements.
Here is the simple syntax to use this selector −
$('.classid')

Here is the description of all the parameters used by this selector −
classid − This is class ID available in the document.
classid − This is class ID available in the document.
Like any other jQuery selector, this selector also returns an array filled with the found elements.
$('.big') − Selects all the elements with the given class ID big.
$('.big') − Selects all the elements with the given class ID big.
$('p.small') − Selects all the paragraphs with the given class ID small.
$('p.small') − Selects all the paragraphs with the given class ID small.
$('.big.small') − Selects all the elements with a class of big and small.
$('.big.small') − Selects all the elements with a class of big and small.
Following example would select all divisions with class .big and will apply yellow color to its background −
<html>
   <head>
      <title>The Selecter Example</title>
      <script type = "text/javascript" 
         src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js">
      </script>
   
      <script type = "text/javascript" language = "javascript">
         $(document).ready(function() {
            /* This would select second division only*/
            $(".big").css("background-color", "yellow");
         });
      </script>
   </head>
	
   <body>
      <div class = "big" id="div1">
         <p>This is first division of the DOM.</p>
      </div>

      <div class = "medium" id = "div2">
         <p>This is second division of the DOM.</p>
      </div>

      <div class = "small" id = "div3">
         <p>This is third division of the DOM</p>
      </div>
   </body>
</html>
This will produce following result −
This is first division of the DOM.
This is second division of the DOM.
This is third division of the DOM

    27 Lectures 
     1 hours 

 Mahesh Kumar

    27 Lectures 
     1.5 hours 

 Pratik Singh

    72 Lectures 
     4.5 hours 

 Frahaan Hussain

    60 Lectures 
     9 hours 

 Eduonix Learning Solutions

    17 Lectures 
     2 hours 

 Sandip Bhattacharya

    12 Lectures 
     53 mins

 Laurence Svekis
 Print
 Add Notes
 Bookmark this page
How to get local time and date in android using LocalDateTime API class?

This example demonstrate about How to get local time and date in android using LocalDateTime API class.
Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.
Step 2 − Add the following code to res/layout/activity_main.xml.
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
   xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:app="http://schemas.android.com/apk/res-auto"
   xmlns:tools="http://schemas.android.com/tools"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   tools:context=".MainActivity">
   <TextView
      android:id="@+id/date"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="Local Date"
      app:layout_constraintBottom_toBottomOf="parent"
      app:layout_constraintLeft_toLeftOf="parent"
      app:layout_constraintRight_toRightOf="parent"
      app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
In the above code, we have taken textview to show time and date.
Step 3 − Add the following code to src/MainActivity.java
package com.example.myapplication;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class MainActivity extends AppCompatActivity {
   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      TextView textView = findViewById(R.id.date);
      if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
         LocalDateTime time = LocalDateTime.now();
         DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm:ss");
         dateTimeFormatter.format(time);
         textView.setText(String.valueOf("Date & Time " + time));
      }
   }
}
Let's try to run your application. I assume you have connected your actual Android Mobile device with your computer. To run the app from android studio, open one of your project's activity files and click Run  icon from the toolbar. Select your mobile device as an option and then check your mobile device which will display your default screen −
In the above result, it is showing current time and date.
Click here to download the project code
GATE | GATE-CS-2015 (Set 2) | Question 40

28 Jun, 2021
Consider six memory partitions of size 200 KB, 400 KB, 600 KB, 500 KB, 300 KB, and 250 KB, where KB refers to kilobyte. These partitions need to be allotted to four processes of sizes 357 KB, 210 KB, 468 KB and 491 KB in that order. If the best fit algorithm is used, which partitions are NOT allotted to any process?
(A) 200 KB and 300 KB(B) 200 KB and 250 KB(C) 250 KB and 300 KB(D) 300 KB and 400 KBAnswer: (A)Explanation: Best fit allocates the smallest block among those that are large enough for the new process. So the memory blocks are allocated in below order.
357 ---> 400
210 ---> 250
468 ---> 500
491 ---> 600
Sot the remaining blocks are of 200 KB and 300 KB
Refer http://courses.cs.vt.edu/~csonline/OS/Lessons/MemoryAllocation/index.html for details of all allocation strategies.Quiz of this Question
GATE-CS-2015 (Set 2)
GATE-GATE-CS-2015 (Set 2)
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | GATE-CS-2014-(Set-2) | Question 65
GATE | Sudo GATE 2020 Mock I (27 December 2019) | Question 33
GATE | GATE CS 2008 | Question 46
GATE | GATE-CS-2015 (Set 3) | Question 65
GATE | GATE-CS-2014-(Set-1) | Question 51
GATE | GATE-CS-2014-(Set-3) | Question 65
GATE | GATE CS 1996 | Question 63
GATE | GATE-CS-2015 (Set 2) | Question 55
GATE | GATE-CS-2004 | Question 31
GATE | GATE-CS-2001 | Question 50
Python | sympy.zeros() method

29 Jun, 2019
With the help of sympy.zeros() method, we can create a matrix having dimension nxm and filled with zeros by using sympy.zeros() method.
Syntax : sympy.zeros()Return : Return a zero matrix.
Example #1 :In this example, we can see that by using sympy.zero() method, we are able to create the zero matrix having dimension nxn all filled with zeros, where nxm will be pass as a parameter.
# import sympyfrom sympy import *  # Use sympy.zero() methodmat = zeros(3, 4)   print(mat)
Output :
Matrix([[0, 0, 0, 0],[0, 0, 0, 0],[0, 0, 0, 0]])
Example #2 :
# import sympyfrom sympy import *  # Use sympy.zero() methodmat = zeros(2, 4)   print(mat)
Output :
Matrix([[0, 0, 0, 0],[0, 0, 0, 0]])
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
Enumerate() in Python
Read a file line by line in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Iterate over a list in Python
Convert integer to string in Python
GATE CS 2011 - GeeksforGeeks

11 Oct, 2021
A layer-4 firewall (a device that can look at all protocol headers up to the transport layer) CANNOT 
block entire HTTP traffic during 9:00PM and 5 :0OAM 
block all ICMP traffic 
stop incoming traffic from a specific IP address but allow outgoing traffic to the same IP address 
block TCP traffic from a specific user on a multi-user system during 9:00PM and 5:00AM 
A.Can Block entire HTTP traffic by blocking TCP port 80 and it is possible because it is L4 firewall. D) As it is L4 firewall can not block packets based on user identity because it is the responsibility of Application layer 
m1: Send an email from a mail client to a mail server
m2: Download an email from mailbox server to a mail client
m3: Checking email in a web browser
Effort Applied (E) = ab(KLOC)bb [ person-months ]
                   = 2.8 x(40)1.20 
                   = 2.8 x 83.65 
                   = 234.25 
NDPDA can handle languages or grammars with ambiguity, but DPDA cannot handle languages with ambiguity and any context-free grammar.
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, ...
Must Do Coding Questions for Product Based Companies
SDE SHEET - A Complete Guide for SDE Preparation
DSA Sheet by Love Babbar
Java Threads
Top 20 Puzzles Commonly Asked During SDE Interviews
Software Testing Metrics, its Types and Example
Software Testing - Test Plan
Software Testing - Boundary Value Analysis
TCS NQT Coding Sheet
How to Count the Number of Repeated Characters in a Golang String?

26 Aug, 2019
In Go language, strings are different from other languages like Java, C++, Python, etc. It is a sequence of variable-width characters where each and every character is represented by one or more bytes using UTF-8 Encoding.In Go string, you can count some specific Unicode code points or the number of non-overlapping instances of costr (Repeated Characters) in the string with the help of Count() function. This function returns a value which represents the total number of the given string or Unicode code points present in the string. It is defined under the strings package so, you have to import strings package in your program for accessing Count function.
Syntax:
func Count(str, costr string) int
Here, str is the original string and costr is a string which we want to count. If the value of costr is empty, then this function returns 1 + the number of Unicode code points in str.
Example:
// Go program to illustrate how to// count the elements of the stringpackage main  import (    "fmt"    "strings")  // Main functionfunc main() {      // Creating and initializing the strings    str1 := "Welcome to the online portal of GeeksforGeeks"    str2 := "My dog name is Dollar"    str3 := "I like to play Ludo"      // Displaying strings    fmt.Println("String 1: ", str1)    fmt.Println("String 2: ", str2)    fmt.Println("String 3: ", str3)      // Counting the elements of the strings    // Using Count() function    res1 := strings.Count(str1, "o")    res2 := strings.Count(str2, "do")      // Here, it also counts white spaces    res3 := strings.Count(str3, "")    res4 := strings.Count("GeeksforGeeks, geeks", "as")      // Displaying the result    fmt.Println("\nResult 1: ", res1)    fmt.Println("Result 2: ", res2)    fmt.Println("Result 3: ", res3)    fmt.Println("Result 4: ", res4)  }
Output:
String 1:  Welcome to the online portal of GeeksforGeeks
String 2:  My dog name is Dollar
String 3:  I like to play Ludo

Result 1:  6
Result 2:  1
Result 3:  20
Result 4:  0

Golang
Golang-String
Go Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Arrays in Go
Golang Maps
How to Split a String in Golang?
Interfaces in Golang
Slices in Golang
How to Parse JSON in Golang?
How to Trim a String in Golang?
Different Ways to Find the Type of Variable in Golang
How to convert a string in lower case in Golang?
How to compare times in Golang?
gcd() in Python

30 May, 2022
The Highest Common Factor (HCF), also called gcd, can be computed in python using a single function offered by math module and hence can make tasks easier in many situations.
Python3
# Python code to demonstrate naive# method to compute gcd ( recursion ) def hcfnaive(a, b):    if(b == 0):        return abs(a)    else:        return hcfnaive(b, a % b) a = 60b = 48 # prints 12print("The gcd of 60 and 48 is : ", end="")print(hcfnaive(60, 48))
The gcd of 60 and 48 is : 12

Python3
# Python code to demonstrate naive# method to compute gcd ( Loops ) def computeGCD(x, y):     if x > y:        small = y    else:        small = x    for i in range(1, small + 1):        if((x % i == 0) and (y % i == 0)):            gcd = i                 return gcd a = 60b = 48 # prints 12print ("The gcd of 60 and 48 is : ", end="")print (computeGCD(60,48))
The gcd of 60 and 48 is : 12

Python3
# Python code to demonstrate naive# method to compute gcd ( Euclidean algo )  def computeGCD(x, y):    while(y):       x, y = y, x % y    return abs(x) a = 60b = 48 # prints 12print ("The gcd of 60 and 48 is : ",end="")print (computeGCD(60, 48))
Output:
The gcd of 60 and 48 is : 12
Both numbers are 0, gcd is 0
If only either number is Not a number, Type Error is raised.
lwchkg
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Proving elements of a finite group is finite - GeeksforGeeks

17 Mar, 2021
To Prove : The order of every element of a finite group is finite and is less than or equal to the order of the group. 
Proof : Suppose G is a finite group, the composition being denoted multiplicatively. Suppose a ∈ G, consider all positive integral powers of a i.e.,  a, a2, a3, ...... All these are elements of G, by closure axiom. Since G has a finite number of elements, therefore all these integral powers of a cannot be distinct elements of G.
Suppose,
ar = as    where r > s
Now                       
ar = as 
=> ar . a-s = as . a-s      (multiplying both sides by a-s )
=> ar . a-s = a0            ( as-s = a0)
=> ar . a-s = e 
=> am = e,                 where m = r - s 
Since    
r > s
Therefore, ‘m’ is a positive integer. Hence, there exists a positive integer m such that am = e. 
Now we know that every set of positive integers has the least member. Therefore, the set of all those positive integers m such that am = e has the least members, say n. Thus, there exists the least positive integer n such that 
an = e. 
Therefore, the order of a, o(a) is finite. Now to prove that o(a) ≤ o(G). 
Suppose,
o(a) = n, where n > o(G). 
Since a ∈ G, therefore by closure property a, a2, .... an are elements of G. No two of these are equal. For if possible, let ar = as, 1 ≤ s < r ≤ n. Then,
ar-s = e
Since 
0 < r - s < n
Therefore, 
ar-s = e implies that the order of a is less than n. 
This is a contradiction. Hence, a, a2,... an are n distinct elements of G. Since n > o(G), therefore this is not possible. Hence, we must have o(a) ≤ o(G). 
Therefore, it is proved that The order of every element (a, o(a)) of a finite group (G) is finite and is less than or equal to the order of the group(i.e. o(a) ≤ o(g) ).
Engineering Mathematics
GATE CS
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Activation Functions
Difference between Propositional Logic and Predicate Logic
Logic Notations in LaTeX
Univariate, Bivariate and Multivariate data and its analysis
Z-test
Layers of OSI Model
ACID Properties in DBMS
TCP/IP Model
Types of Operating Systems
Normal Forms in DBMS
Data Structures | Heap | Question 9 - GeeksforGeeks

28 Jun, 2021
In a binary max heap containing n numbers, the smallest element can be found in time (GATE CS 2006)(A) 0(n)(B) O(logn)(C) 0(loglogn)(D) 0(1)Answer: (A)Explanation: In a max heap, the smallest element is always present at a leaf node. So we need to check for all leaf nodes for the minimum value. Worst case complexity will be O(n)
         12
        /  \
      /      \
    8         7
   / \        / \
 /     \    /     \
2      3   4       5
Quiz of this Question
Data Structures
Data Structures-Heap
Heap Quizzes
Data Structures
Data Structures
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Data Structures | Linked List | Question 5
Data Structures | Tree Traversals | Question 4
Data Structures | Linked List | Question 6
Difference between Singly linked list and Doubly linked list
Advantages and Disadvantages of Linked List
Data Structures | Graph | Question 9
FIFO vs LIFO approach in Programming
C program to implement Adjacency Matrix of a given Graph
Data Structures | Stack | Question 1
Introduction to Data Structures
Higher-Order Function in Golang - GeeksforGeeks

16 Jun, 2021
In Go, language, a function is called a Higher-Order Function if it fulfills one of the following conditions:1. Passing Functions as an Argument to Another Function:If a function is passed as an argument to another function, then such types of functions are known as a Higher-Order function. This passing function as an argument is also known as a callback function or first-class function in the Go language. As shown in the below example, here Sphere() function takes a function as an argument and returns vol float64 as an argument. In the Main function, we create an anonymous function whose signature matches the parameter of Sphere function so, we simply call the Sphere() function and pass the result as an argument in it.Example: 
CSharp
// Golang program to illustrate how to pass// a function as an argument to another// functionpackage main import (    "fmt"    "math") // Volume function takes// a function as a argumentfunc Sphere(vol func(radius float64) float64) {     fmt.Println("Volume of Sphere is:", vol(3))} // Main Functionfunc main() {     volume_of_sphere := func(radius float64) float64 {        result := 4 / 3 * math.Pi * radius * radius * radius        return result    }     // Passing function as an    // argument in Volume function    Sphere(volume_of_sphere)}
Output: 
Volume of Sphere is: 84.82300164692441
2. Returning Functions From Another Functions:If a function returns another function, then such types of functions are known as a Higher-Order function. It is also known as the First-Class function. As shown in the below example, here Sphere() function returns an anonymous function that takes one float64 argument and returns a float64 argument. Now in the Main function, sVol stores the function return by Sphere() function, so we call sVol and pass one argument in it.Example: 
CSharp
// Golang program to illustrate how to pass// a function returns another functionpackage main import (    "fmt"    "math") // Here, Volume function returns// an anonymous functionfunc Sphere() func(radius float64) float64 {     result := func(radius float64) float64 {        volume := 4 / 3 * math.Pi * radius * radius * radius        return volume    }     return result } // Main Functionfunc main() {     sVol := Sphere()    fmt.Println("Volume of Sphere is:", sVol(5))}
Output:  
Volume of Sphere is: 392.69908169872417
 
sagar0719kumar
Go Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
6 Best Books to Learn Go Programming Language
Arrays in Go
strings.Replace() Function in Golang With Examples
How to Split a String in Golang?
Golang Maps
Slices in Golang
Inheritance in GoLang
Different Ways to Find the Type of Variable in Golang
Interfaces in Golang
How to Trim a String in Golang?
Perl | Modules - GeeksforGeeks

17 Feb, 2019
A module in Perl is a collection of related subroutines and variables that perform a set of programming tasks. Perl Modules are reusable. Various Perl modules are available on the Comprehensive Perl Archive Network (CPAN). These modules cover a wide range of categories such as network, CGI, XML processing, databases interfacing, etc.
A modules name must be same as to the name of the Package and should end with .pm extension.
Example : Calculator.pm
package Calculator;  # Defining sub-routine for Multiplicationsub multiplication{    # Initializing Variables a & b    $a = $_[0];    $b = $_[1];          # Performing the operation    $a = $a * $b;          # Function to print the Sum    print "\n***Multiplication is $a";}  # Defining sub-routine for Divisionsub division{    # Initializing Variables a & b    $a = $_[0];    $b = $_[1];          # Performing the operation    $a = $a / $b;          # Function to print the answer    print "\n***Division is $a";}1;
Here, the name of the file is “Calculator.pm” stored in the directory Calculator. Notice that 1; is written at the end of the code to return a true value to the interpreter. Perl accepts anything which is true instead of 1 
Examples: Test.pl
#!/usr/bin/perl  # Using the Package 'Calculator'use Calculator;  print "Enter two numbers to multiply";  # Defining values to the variables$a = 5;$b = 10;  # Subroutine callCalculator::multiplication($a, $b);  print "\nEnter two numbers to divide";  # Defining values to the variables$a = 45;$b = 5;  # Subroutine callCalculator::division($a, $b);
Output:
Variables from different packages can be used by declaring them before using. Following example demonstrates thisExamples: Message.pm
#!/usr/bin/perl  package Message;  # Variable Creation$username;  # Defining subroutinesub Hello{  print "Hello $username\n";}1;
Perl file to access the module is as belowExamples: variable.pl
#!/usr/bin/perl  # Using Message.pm packageuse Message;  # Defining value to variable$Message::username = "Geeks";  # Subroutine callMessage::Hello();
Output:
Example:
#!/usr/bin/perl  use strict;use warnings;  print" Hello This program uses Pre-defined Modules";
Output:
Hello This program uses Pre-defined Modules
perl-basics
Picked
Perl
Perl
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Perl | split() Function
Perl | push() Function
Perl | chomp() Function
Perl | grep() Function
Perl | substr() function
Perl | exists() Function
Perl Tutorial - Learn Perl With Examples
Perl | Removing leading and trailing white spaces (trim)
Use of print() and say() in Perl
Perl | length() Function
Dart - Comments - GeeksforGeeks

12 Nov, 2021
In every programming language comments play an important role for a better understanding of the code in the future or by any other programmer. Comments are a set of statements that are not meant to be executed by the compiler. They provide proper documentation of the code. 
Types of Dart Comments: 
Dart Single line Comment.Dart Multiline Comment.Dart Documentation Comment.
Dart Single line Comment.
Dart Multiline Comment.
Dart Documentation Comment.
1. Dart Single line Comment: Dart single line comment is used to comment a line until line break occurs. It is done using a double forward-slash (//). 
// This is a single line comment. 
Example: 
Dart
int main(){  double area = 3.14 * 4 * 4;  // It prints the area  // of a circle of radius = 4  print(area); return 0;}
 
Output:
50.24
2. Dart Multi-Line Comment: Dart Multiline comment is used to comment out a whole section of code. It uses ‘/*’ and ‘*/’ to start and end a multi-line comment respectively. 
/* 

These are 

multiple line 

of comments 

*/ 
Example: 
Dart
int main(){  var lst = [1, 2, 3];     /*  It prints  the whole list  at once  */  print(lst);   return 0; }
 
Output: 
[1, 2, 3]
3. Dart Documentation Comment: Dart Documentation Comments are a special type of comment used to provide references to packages, software, or projects.Dart supports two types of documentation comments “///”(C# Style) and “/**.....*/”(JavaDoc Style). It is preferred to use “///” for doc comments as many times * is used to mark list items in a bulleted list which makes it difficult to read the comments. Doc comments are recommended for writing public APIs. 
/// This is 

/// a documentation 

/// comment 
Example: 
Dart
bool checkEven(n){  /// Returns true  /// if n is even  if(n%2==0)       return true;  /// Returns false if n is odd  else       return false; } int main(){  int n = 43;  print(checkEven(n));  return 0;}
 
Output: 
false
prachisoda1234
Dart-basics
Dart
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Flutter - Custom Bottom Navigation Bar
ListView Class in Flutter
Flutter - Flexible Widget
Flutter - Stack Widget
Flutter - Dialogs
Android Studio Setup for Flutter Development
Flutter - Positioned Widget
Format Dates in Flutter
Flutter - Managing the MediaQuery Object
What is widgets in Flutter?
Create a shortcut key to activate an element in HTML

To create a shortcut key, use the access attribute in HTML. Let us say you need to add a shortcut key to the following link
Hadoop Tutorial
To let shortcut keys work correctly on Firefox web browser (Windows), you need to add it like this −
[Alt] [Shift] + accesskey
You can try to run the following code to create a shortcut key to activate an element in HTML −
<!DOCTYPE html>
<html>
   <body>
      <a href="https://www.tutorialspoint.com/hadoop/index.htm" accesskey="h">Hadoop Tutorial</a>
      <p>We have set ALT+SHIFT+H to access the Hadoop Tutorial</p>
   </body>
</html>
Redis - Sorted Set Zinterstore Command

Redis ZINTERSTORE command computes the intersection of numkeys sorted sets given by the specified keys, and stores the result in the destination. It is mandatory to provide the number of input keys (numkeys) before passing the input keys and the other (optional) arguments.
Integer reply, the number of elements in the resulting sorted set at the destination.
Following is the basic syntax of Redis ZINTERSTORE command.
redis 127.0.0.1:6379> ZINTERSTORE KEY INCREMENT MEMBER

redis 127.0.0.1:6379> ZADD myset 1 "hello" 
(integer) 1 
redis 127.0.0.1:6379> ZADD myset 2 "world" 
(integer) 1 
redis 127.0.0.1:6379> ZADD myset2 1 "hello" 
(integer) 1 
redis 127.0.0.1:6379> ZADD myset2 2 "world" 
(integer) 1 
redis 127.0.0.1:6379> ZADD myset2 3 "foo" 
(integer) 1 
redis 127.0.0.1:6379> ZINTERSTORE out 2 myset1 myset2 WEIGHTS 2 3" 
(integer) 3 
redis 127.0.0.1:6379> ZRANGE out 0 -1 WITHSCORES 
1) "hello" 
2) "5" 
3) "world" 
4) "10" 


    22 Lectures 
     40 mins

 Skillbakerystudios
 Print
 Add Notes
 Bookmark this page
Semantic Analysis in Compiler Design

22 Apr, 2020
Semantic Analysis is the third phase of Compiler. Semantic Analysis makes sure that declarations and statements of program are semantically correct. It is a collection of procedures which is called by parser as and when required by grammar. Both syntax tree of previous phase and symbol table are used to check the consistency of the given code. Type checking is an important part of semantic analysis where compiler makes sure that each operator has matching operands.
Semantic Analyzer:It uses syntax tree and symbol table to check whether the given program is semantically consistent with language definition. It gathers type information and stores it in either syntax tree or symbol table. This type information is subsequently used by compiler during intermediate-code generation.
Semantic Errors:Errors recognized by semantic analyzer are as follows:
Type mismatch
Undeclared variables
Reserved identifier misuse
Functions of Semantic Analysis:
Type Checking –Ensures that data types are used in a way consistent with their definition.Label Checking –A program should contain labels references.Flow Control Check –Keeps a check that control structures are used in a proper manner.(example: no break statement outside a loop)
Type Checking –Ensures that data types are used in a way consistent with their definition.
Label Checking –A program should contain labels references.
Flow Control Check –Keeps a check that control structures are used in a proper manner.(example: no break statement outside a loop)
Example:
float x = 10.1;
float y = x*30; 
In the above example integer 30 will be typecasted to float 30.0 before multiplication, by semantic analyzer.
Static and Dynamic Semantics:
Static Semantics –It is named so because of the fact that these are checked at compile time. The static semantics and meaning of program during execution, are indirectly related.Dynamic Semantic Analysis –It defines the meaning of different units of program like expressions and statements. These are checked at runtime unlike static semantics.
Static Semantics –It is named so because of the fact that these are checked at compile time. The static semantics and meaning of program during execution, are indirectly related.
Dynamic Semantic Analysis –It defines the meaning of different units of program like expressions and statements. These are checked at runtime unlike static semantics.
sachiniyermalkapur
Compiler Design
GATE CS
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Directed Acyclic graph in Compiler Design (with examples)
Type Checking in Compiler Design
Data flow analysis in Compiler
S - attributed and L - attributed SDTs in Syntax directed translation
Runtime Environments in Compiler Design
Layers of OSI Model
ACID Properties in DBMS
TCP/IP Model
Types of Operating Systems
Normal Forms in DBMS
JavaScript | Let

06 Jun, 2022
let is a keyword used to declare variables in JavaScript that are block scoped. There are three ways you can declare variables in JavaScript let, const, var(old). Like other keywords, let keyword could be easily used inside or outside a function as per user requirement. ES6 or ES2015 defines new keywords to declare variables in JavaScript. Generally, it is suggested that we must use the let keyword while working on any major or large-scale project. Even in a small project also, it makes a habit of an individual if let keyword is implemented while variable declaration. 
Syntax:
Following syntax we may use to declare using let keyword:
let variable_name = value;
 
Block Scope:
A variable can be either of global or local scope. A global variable is a variable declared in the main body of the source code, outside all functions, while a local variable is one declared within the body of a function or a block.  
Global Scope:
 
javascript
let num=10;console.log(num);function fun(){    console.log(num);}fun(); // calling the function
Output:  
 
Function Scope:
 
javascript
function fun(){    let num=10;    console.log(num);}fun(); //  calling the functionconsole.log(num);
Output:  
 
Block Scope:
 
javascript
{    let x=23;    console.log(x);}console.log(x);
Output:  
 
Redeclaring Variables in different blocks:
 
javascript
let x=77;{    let x=23;    console.log(x);}console.log(x);
Output:  
 
Redeclaring Variables in same blocks:
 
javascript
let x=77;{    let x=23; // legal    console.log(x);}let x=67;// illegalconsole.log(x);
Output:  
 
 
Does not support Hoisting:
 
javascript
x=12;console.log(x);let x;
Output:  
 Supported Browser:
Chrome 49 and above
Edge 14 and above
Firefox 44 and above
Opera 17 and above
Internet Explorer 11 and above
Safari 10 and above
arorakashish0911
ysachin2314
amansingla
technophpfij
javascript-basics
Picked
JavaScript
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
Remove elements from a JavaScript Array
Hide or show elements in HTML using display property
How to append HTML code to a div using JavaScript ?
Difference Between PUT and PATCH Request
How to Open URL in New Tab using JavaScript ?
How to calculate the number of days between two dates in javascript?
File uploading in React.js
Roadmap to Learn JavaScript For Beginners
Difference Between Imperative and Declarative Programming

07 Jul, 2021
A programming paradigm is an approach to solve problems using some programming language or also we can say it is a method to solve a problem using tools and techniques that are available to us following some approach. There are lots of programming languages that are known but all of them need to follow some strategy when they are implemented and this methodology/strategy is paradigms. Apart from varieties of programming languages, there are lots of paradigms to fulfill each and every demand.
Programming Paradigms
Imperative Programming as the name suggests is a type of programming paradigm that describes how the program executes. Developers are more concerned with how to get an answer step by step. It comprises the sequence of command imperatives. In this, the order of execution is very important and uses both mutable and immutable data. Fortran, Java, C, C++ programming languages are examples of imperative programming. 
Declarative Programming as the name suggests is a type of programming paradigm that describes what programs to be executed. Developers are more concerned with the answer that is received. It declares what kind of results we want and leave programming language aside focusing on simply figuring out how to produce them. In simple words, it mainly focuses on end result. It expresses the logic of computation. Miranda, Erlang, Haskell, Prolog are a few popular examples of declarative programming.
After getting the basics of understanding of both the languages now let u do discuss the key differences between these two different types of programming
Imperative Programming
Declarative Programming  
jacob341
Functions
logical-thinking
Difference Between
Programming Language
logical-thinking
Functions
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
Difference Between Method Overloading and Method Overriding in Java
Difference between Process and Thread
Difference between Clustered and Non-clustered index
Differences between IPv4 and IPv6
Arrow operator -> in C/C++ with Examples
Modulo Operator (%) in C/C++ with Examples
Structures in C++
Decorators with parameters in Python
C# | Data Types
C | Advanced Pointer | Question 1 - GeeksforGeeks

28 Jun, 2021
void fun(int *p) {   int q = 10;   p = &q; }         int main() {   int r = 20;   int *p = &r;   fun(p);   printf("%d", *p);   return 0; }
(A) 10(B) 20(C) Compiler error(D) Runtime ErrorAnswer: (B)Explanation: Inside fun(), q is a copy of the pointer p. So if we change q to point something else then p remains uneffected. If we want to change a local pointer of one function inside another function, then we must pass pointer to the pointer. By passing the pointer to the pointer, we can change pointer to point to something else. See the following program as an example.
void fun(int **pptr)
{
  static int q = 10;
  *pptr = &q;
}

int main()
{
  int r = 20;
  int *p = &r;
  fun(&p);
  printf("%d", *p);
  return 0;
}


In the above example, the function fun() expects a double pointer (pointer to a pointer to an integer). Fun() modifies the value at address pptr.  The value at address pptr is pointer p as we pass adderess of p to fun().  In fun(), value at pptr is changed to address of q.  Therefore, pointer p of main() is changed to point to a new variable q.
Also, note that the program won’t cause any out of scope problem because q is a static variable. Static variables exist in memory even after functions return. For an auto variable, we might have seen some unexpected output because auto variable may not exist in memory after functions return.Quiz of this Question
Advanced Pointer
C-Advanced Pointer
C Language
C Quiz
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Multidimensional Arrays in C / C++
rand() and srand() in C/C++
Left Shift and Right Shift Operators in C/C++
fork() in C
Command line arguments in C/C++
Compiling a C program:- Behind the Scenes
Operator Precedence and Associativity in C
C | File Handling | Question 1
C | Misc | Question 7
Output of C programs | Set 64 (Pointers)
Calculate the curl of a vector field in Python and plot it with Matplotlib

To calculate the curl of a vector field in Python and plot in with Matplotlib, we can use quiver() method and calculate the corresponding data.
Set the figure size and adjust the padding between and around the subplots.
Create a new figure or activate an existing figure using figure() method.
Add a 3D axes to the figure as part of a subplot arrangement.
Create x, y and z data points using numpy meshgrid.
Create u, v and w data curl vector positions.
Use quiver() method to get vectors.
Turn off the axes.
To display the figure, use show() method.
import matplotlib.pyplot as plt
import numpy as np

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

fig = plt.figure()

ax = fig.add_subplot(projection='3d')

x, y, z = np.meshgrid(np.arange(-0.8, 1, 0.2),
                     np.arange(-0.8, 1, 0.2),
                     np.arange(-0.8, 1, 0.8))

u = 0
v = y**2
w = -2*y*z - y

ax.quiver(x, y, z, u, v, w, length=0.1)
ax.axis('off')

plt.show()
Tryit Editor v3.7

Tryit: HTML border collapse
Mapping the letter of a string to an object of arrays - JavaScript

Given a string, we are required to write a function that creates an object that stores the indexes of each letter in an array. The letters (elements) of the string must be the keys of object
The indexes should be stored in an array and those arrays are values.
For example −
If the input string is −
const str = 'cannot';
Then the output should be −
const output = {
   'c': [0],
   'a': [1],
   'n': [2, 3],
   'o': [4],
   't': [5]
};
Following is the code −
const str = 'cannot';
const mapString = str => {
   const map = {};
   for(let i = 0; i < str.length; i++){
      if(map.hasOwnProperty(str[i])){
         map[str[i]] = map[str[i]].concat(i);
      }else{
         map[str[i]] = [i];
      };
   };
   return map;
};
console.log(mapString(str));
Following is the output in the console −
{ c: [ 0 ], a: [ 1 ], n: [ 2, 3 ], o: [ 4 ], t: [ 5 ] }
One Hot Encoding using Tensorflow - GeeksforGeeks

02 Sep, 2020
In this post, we will be seeing how to initialize a vector in TensorFlow with all zeros or ones. The function you will be calling is tf.ones(). To initialize with zeros you could use tf.zeros() instead. These functions take in a shape and return an array full of zeros and ones accordingly.
Code:
import tensorflow as tf  ones_matrix = tf.ones([2, 3])sess = tf.Session()ones = sess.run(ones_matrix)sess.close()  print(ones)
Output:
[[1. 1. 1.]  [1. 1. 1.]]
Using One Hot Encoding:Many times in deep learning and general vector computations you will have a y vector with numbers ranging from 0 to C-1 and you want to do the following conversion. If C is for example 5, then you might have the following y vector which you will need to convert as follows:
One Hot Encoding Example
This can be done as follows:
Parameters passed to the function:
indices: A Tensor of indices.depth: A scalar defining the depth of the one hot dimension.on_value: A scalar defining the value to fill in output when indices[j] = i. (default : 1)off_value: A scalar defining the value to fill in output when indices[j] != i. (default : 0)axis: The axis to fill (default : -1, a new inner-most axis).dtype: The data type of the output tensor.name: A name for the operation (optional).
Code:
indices = [1, 4, 2, 0, 3]C = tf.constant(5, name = "C")      one_hot_matrix = tf.one_hot(    indices, C, on_value = 1.0, off_value = 0.0, axis =-1)  sess = tf.Session()  one_hot = sess.run(one_hot_matrix)  sess.close()  # output is of dimension 5 x 5print(one_hot)
Output:
[[0.0, 1.0, 0.0, 0.0, 0.0 ]

[0.0, 0.0, 0.0, 0.0, 1.0]

[0.0, 0.0, 1.0, 0.0, 0.0]

[1.0, 0.0, 0.0, 0.0, 0.0]

[0.0, 0.0, 0.0, 1.0, 0.0]]
Feel free to change values and see the result.
Code:
indices = [[0, 2], [1, -1]]C = tf.constant(5, name = "C")      one_hot_matrix = tf.one_hot(    indices, C, on_value = 1.0, off_value = 0.0, axis =-1)  sess = tf.Session()  one_hot = sess.run(one_hot_matrix)  sess.close()      # output is of dimension 2 x 2 x 3print(one_hot) 
Output :
[[[1.0, 0.0, 0.0],  

  [0.0, 0.0, 1.0]],  

 [[0.0, 1.0, 0.0],  

 [0.0, 0.0, 0.0]]] 
Machine Learning
Python
Machine Learning
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Reinforcement learning
Activation functions in Neural Networks
Introduction to Recurrent Neural Network
Decision Tree Introduction with example
Support Vector Machine Algorithm
Read JSON file using Python
Adding new column to existing DataFrame in Pandas
Python map() function
How to get column names in Pandas dataframe
Sets difference() function | Guava | Java - GeeksforGeeks

15 Nov, 2018
Guava’s Sets.difference() returns an unmodifiable view of the difference of two sets.
Syntax:
public static <E> 
  Sets.SetView<E> 
    difference(Set<E> set1,
               Set<?> set2)

Return Value: This method returns a set containing all elements that are contained by set1 and not contained by set2.
Note: Set2 may also contain elements not present in set1, these are simply ignored. The iteration order of the returned set matches that of set1.
Example 1:
// Java code to show implementation of// Guava's Sets.difference() method  import com.google.common.collect.Sets;import java.util.Set;  class GFG {    // Driver's code    public static void main(String[] args)    {        // Creating first set named set1        Set<Integer>            set1 = Sets.newHashSet(1, 2, 3, 4, 5, 6);          // Creating second set named set2        Set<Integer>            set2 = Sets.newHashSet(1, 3, 5, 7);          // Using Guava's Sets.difference() method        Set<Integer>            diff = Sets.difference(set1, set2);          // Displaying the unmodifiable view of        // the difference of two sets.        System.out.println("Set 1: "                           + set1);        System.out.println("Set 2: "                           + set2);        System.out.println("Difference between "                           + "Set 1 and Set 2: "                           + diff);    }}
Set 1: [1, 2, 3, 4, 5, 6]
Set 2: [1, 3, 5, 7]
Difference between Set 1 and Set 2: [2, 4, 6]

Example 2 :
// Java code to show implementation of// Guava's Sets.difference() method  import com.google.common.collect.Sets;import java.util.Set;  class GFG {      // Driver's code    public static void main(String[] args)    {          // Creating first set named set1        Set<String>            set1 = Sets                       .newHashSet("H", "E", "L", "L", "O", "G");          // Creating second set named set2        Set<String>            set2 = Sets                       .newHashSet("L", "I", "K", "E", "G");          // Using Guava's Sets.difference() method        Set<String>            diff = Sets.difference(set1, set2);          // Displaying the unmodifiable view of        // the difference of two sets.        System.out.println("Set 1: "                           + set1);        System.out.println("Set 2: "                           + set2);        System.out.println("Difference between "                           + "Set 1 and Set 2: "                           + diff);    }}
Set 1: [E, G, H, L, O]
Set 2: [I, K, L, E, G]
Difference between Set 1 and Set 2: [H, O]

java-guava
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Stream In Java
Constructors in Java
Exceptions in Java
Functional Interfaces in Java
Different ways of Reading a text file in Java
Generics in Java
Introduction to Java
Internal Working of HashMap in Java
Comparator Interface in Java with Examples
Strings in Java
Python - PyTorch clamp() method - GeeksforGeeks

26 May, 2020
PyTorch torch.clamp() method clamps all the input elements into the range [ min, max ] and return a resulting tensor.
Syntax: torch.clamp(inp, min, max, out=None)
Arguments
inp: This is input tensor.
min: This is a number and specifies the lower-bound of the range to which input to be clamped.
max: This is a number and specifies the upper-bound of the range to which input to be clamped.
out: The output tensor.
Return: It returns a Tensor.
# Importing the PyTorch library import torch     # A constant tensor of size na = torch.randn(6)print(a)  # Applying the clamp function and # storing the result in 'out'out = torch.clamp(a, min = 0.5, max = 0.9)print(out)
Output:
 -0.9214
-0.1268
 1.1570
-0.2753
-0.0746
 0.7957
[torch.FloatTensor of size 6]
 0.5000
 0.5000
 0.9000
 0.5000
 0.5000
 0.7957
[torch.FloatTensor of size 6]

Example 2:
# Importing the PyTorch library import torch     # A constant tensor of size na = torch.FloatTensor([1, 4, 6, 8, 10, 14])print(a)  # Applying the clamp function and # storing the result in 'out'out = torch.clamp(a, min = 5, max = 10)print(out) 
Output:
 1
  4
  6
  8
 10
 14
[torch.FloatTensor of size 6]
  5
  5
  6
  8
 10
 10
[torch.FloatTensor of size 6]?

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