code-rag-bench/online-tutorials huggingface dataset:
MariaDB - Delete Query

The DELETE command deletes table rows from the specified table, and returns the quantity deleted. Access the quantity deleted with the ROW_COUNT() function. A WHERE clause specifies rows, and in its absence, all rows are deleted. A LIMIT clause controls the number of rows deleted.
In a DELETE statement for multiple rows, it deletes only those rows satisfying a condition; and LIMIT and WHERE clauses are not permitted. DELETE statements allow deleting rows from tables in different databases, but do not allow deleting from a table and then selecting from the same table within a subquery.
Review the following DELETE syntax −
DELETE FROM table_name [WHERE ...]

Execute a DELETE command from either the command prompt or using a PHP script.
At the command prompt, simply use a standard command −
root@host# mysql –u root –p password;
Enter password:*******
mysql> use PRODUCTS;
Database changed
mysql> DELETE FROM products_tbl WHERE product_id=133;
mysql> SELECT * from products_tbl WHERE ID_number='133';
ERROR 1032 (HY000): Can't find record in 'products_tbl'

Use the mysql_query() function in DELETE command statements −
<?php
   $dbhost = 'localhost:3036';
   $dbuser = 'root';
   $dbpass = 'rootpassword';
   $conn = mysql_connect($dbhost, $dbuser, $dbpass);
   
   if(! $conn ) {
      die('Could not connect: ' . mysql_error());
   }

   $sql = 'DELETE FROM products_tbl WHERE product_id = 261';
   mysql_select_db('PRODUCTS');
   $retval = mysql_query( $sql, $conn );

   if(! $retval ) {
      die('Could not delete data: ' . mysql_error());
   }

   echo "Deleted data successfully\n";
   mysql_close($conn);
?>
On successful data deletion, you will see the following output −
mysql> Deleted data successfully
mysql> SELECT * from products_tbl WHERE ID_number='261';
ERROR 1032 (HY000): Can't find record in 'products_tbl'

 Print
 Add Notes
 Bookmark this page
C Program to Minimum and Maximum prime numbers in an array

Given an array of n positive integers. We have to find the prime
number with minimum and maximum value.
If the given array is −
arr [] = {10, 4, 1, 12, 13, 7, 6, 2, 27, 33}
then minimum prime number is 2 and maximum prime number is 13
1. Find maximum number from given number. Let us call it maxNumber
2. Generate prime numbers from 1 to maxNumber and store them in a dynamic array
3. Iterate input array and use dynamic array to find prime number with minimum and maximum value
#include <iostream>
#include <vector>
#include <climit>
#define SIZE(arr) (sizeof(arr) / sizeof(arr[0]))
using namespace std;
void printMinAndMaxPrimes(int *arr, int n){
   int maxNumber = *max_element(arr, arr + n);
   vector<bool> primes(maxNumber + 1, true);
   primes[0] = primes[1] = false;
   for (int p = 2; p * p <= maxNumber; ++i) {
      if (primes[p]) {
         for (int i = p * 2; i <= maxNumber; i += p) {
            primes[p] = false;
         }
      }
   }
   int minPrime = INT_MAX;
   int maxPrime = INT_MIN;
   for (int i = 0; i < n; ++i) {
      if (primes[arr[i]]) {
         minPrime = min(minPrime, arr[i]);
         maxPrime = max(maxPrime, arr[i]);
      }
   }
   cout << "Prime number of min value = " << minPrime << "\n";
   cout << "Prime number of max value = " << maxPrime << "\n";
}
int main(){
   int arr [] = {10, 4, 1, 12, 13, 7, 6, 2, 27, 33};
   printMinAndMaxPrimes(arr, SIZE(arr));
   return 0;
}
When you compile and execute the above program. It generates the following output −
Prime number of min value = 2
Prime number of max value = 13
Output of C Programs | Set 1

26 Nov, 2021
Predict the output of below programs. 
Question 1 
c
#include<stdio.h>int main(){   int n;   for(n = 7; n!=0; n--)     printf("n = %d", n--);   getchar();   return 0;}
Output:Above program goes in infinite loop because n is never zero when loop condition (n != 0) is checked.Question 2 
c
#include<stdio.h>int main(){   printf("%x", -1<<1);   getchar();   return 0;}
Output is dependent on the compiler. For 32 bit compiler it would be fffffffe and for 16 bit it would be fffe.Question 3 
c
# include <stdio.h># define scanf  "%s Geeks For Geeks "main(){   printf(scanf, scanf);   getchar();   return 0;}
Output: %s Geeks For Geeks Geeks For Geeks Explanation: After pre-processing phase of compilation, printf statement will become.  
   printf("%s Geeks For Geeks ",  "%s Geeks For Geeks ");
Now you can easily guess why output is %s Geeks For Geeks Geeks For Geeks.Question 4 
c
#include <stdlib.h>#include <stdio.h>enum {false, true};int main(){   int i = 1;   do   {      printf("%d\n", i);      i++;      if (i < 15)        continue;   } while (false);    getchar();   return 0;}
Output: 1 Explanation: The do while loop checks condition after each iteration. So after continue statement, control transfers to the statement while(false). Since the condition is false ‘i’ is printed only once.Now try below program. 
c
#include <stdlib.h>#include <stdio.h>enum {false, true};int main(){   int i = 1;   do   {     printf("%d\n", i);     i++;     if (i < 15)       break;     } while (true);      getchar();     return 0;}
Question 5 
c
char *getString(){   char *str = "Nice test for strings";   return str;} int main(){   printf("%s", getString());   getchar();   return 0;}
Output: “Nice test for strings” The above program works because string constants are stored in Data Section (not in Stack Section). So, when getString returns *str is not lost. 
surindertarika1234
Output of C Programs
Program Output
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Runtime Errors
Different ways to copy a string in C/C++
Output of C++ Program | Set 1
Output of Java Program | Set 2
Output of Java Program | Set 3
Output of C++ programs | Set 47 (Pointers)
Output of Java Programs | Set 12
Output of Java Program | Set 7
Output of C programs | Set 59 (Loops and Control Statements)
unsigned specifier (%u) in C with Examples
Super Constructor in Dart

20 Jul, 2020
In dart, the subclass can inherit all the variables and methods of the parent class, with the use of extends keyword but it can’t inherit constructor of the parent class. To do so we make use of super constructor in the dart. There are two ways to call super constructor: 
ImplicitlyExplicitly
Implicitly
Explicitly
When calling explicitly we make use of super constructor as:  
Child_class_constructor() :super() {
...
}

Implicit super: In this case, the parent class is called implicitly, when there is object creation of child class. Here we don’t make use of the super constructor but when the child class constructor is invoked then it calls default parent class constructor. 
Example: Calling parent constructor taking no parameter(s).  
Dart
// Dart program for calling parent// constructor taking no parameterclass SuperGeek {      // Creating parent constructor  SuperGeek(){    print("You are inside Parent constructor!!");  }}   class SubGeek extends SuperGeek {      // Creating child constructor  SubGeek(){    print("You are inside Child constructor!!");  }}   void main() {  SubGeek geek = new SubGeek();}
 
Output:  
You are inside Parent constructor!!
You are inside Child constructor!!

Explicit super: If the parent constructor is default then we call it as followed in implicit super, but if it takes parameters then the superclass is invoked as shown in the syntax mentioned above. 
Example: Calling parent constructor taking parameter(s). 
Dart
class SuperGeek {      // Creating parent constructor  SuperGeek(String geek_name){    print("You are inside Parent constructor!!");    print("Welcome to $geek_name");  }}   class SubGeek extends SuperGeek {      // Creating child constructor  // and calling parent class constructor  SubGeek() : super("Geeks for Geeks"){    print("You are inside Child constructor!!");  }}   void main() {  SubGeek geek = new SubGeek();}
 
Output: 
You are inside Parent constructor!!
Welcome to Geeks for Geeks
You are inside Child constructor!!

Dart-OOPs
Dart
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
reflect.Type() Function in Golang with Examples

05 May, 2020
Go language provides inbuilt support implementation of run-time reflection and allowing a program to manipulate objects with arbitrary types with the help of reflect package. The reflect.Type() Function in Golang is used to get v’s type. To access this function, one needs to imports the reflect package in the program.
Syntax:
func (v Value) Type() Type

Parameters: This function does not accept any parameter.
Return Value: This function returns the v’s type.
Below examples illustrate the use of above method in Golang:
Example 1:
// Golang program to illustrate// reflect.Type() Function   package main   import (    "fmt"    "reflect")   // Main functionfunc main() {       var val chan int       // use of Type() method    value := reflect.MakeChan(reflect.Indirect(reflect.ValueOf(&val)).Type(), 0)       fmt.Println("Value :", value)}
Output:
Value : 0xc00010c000

Example 2:
// Golang program to illustrate// reflect.Type() Function   package main   import (    "fmt"    "reflect")   // Main functionfunc main() {       var str map[int]string            var strValue reflect.Value = reflect.ValueOf(&str)       indirectStr := reflect.Indirect(strValue)           //Use of Type() method       valueMap := reflect.MakeMap(indirectStr.Type())           fmt.Printf("ValueMap is [%v] .", valueMap)   }
Output:
ValueMap is [map[]] .

Golang-reflect
Go Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | Pandas dataframe.isna()

19 Nov, 2018
Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier.
Pandas dataframe.isna() function is used to detect missing values. It return a boolean same-sized object indicating if the values are NA. NA values, such as None or numpy.NaN, gets mapped to True values. Everything else gets mapped to False values. Characters such as empty strings ” or numpy.inf are not considered NA values (unless you set pandas.options.mode.use_inf_as_na = True).
Syntax: DataFrame.isna()
Returns : Mask of bool values for each element in DataFrame that indicates whether an element is not an NA value.
For link to the CSV file used in the example, click here
Example #1: Use isna() function to detect the missing values in a dataframe.
# importing pandas as pdimport pandas as pd  # Creating the dataframe df = pd.read_csv("nba.csv")  # Print the dataframedf
Lets use the isna() function to detect the missing values.
# detect the missing valuesdf.isna()
Output :In the output, cells corresponding to the missing values contains true value else false. Example #2: Use isna() function to detect missing values in a pandas series object
# importing pandas as pdimport pandas as pd  # Creating the series sr = pd.Series([12, 5, None, 5, None, 11])  # Print the seriessr
Let’s detect all the missing values in the series.
# to detect the missing valuessr.isna()
Output :
Python pandas-dataFrame
Python pandas-dataFrame-methods
Python-pandas
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
Python OOPs Concepts
Introduction To PYTHON
Implement DELETE query in MySQL stored procedure

You can use stored procedure and can pass the value via parameter. Let us first create a table −
mysql> create table DemoTable1464
   -> (
   -> Id int,
   -> FirstName varchar(20)
   -> );
Query OK, 0 rows affected (0.51 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1464 values(101,'Chris Brown');
Query OK, 1 row affected (0.11 sec)
mysql> insert into DemoTable1464 values(102,'John Doe');
Query OK, 1 row affected (0.09 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1464;
This will produce the following output −
+------+-------------+
| Id   | FirstName   |
+------+-------------+
|  101 | Chris Brown |
|  102 | John Doe    |
+------+-------------+
2 rows in set (0.00 sec)
Here is the query to implement delete query in stored procedure −
mysql> DELIMITER //
mysql> CREATE PROCEDURE delete_demo(IN local_Id int, IN local_Name varchar(20))
   -> BEGIN
   ->    delete from DemoTable1464
   ->    where Id=local_Id and
   ->      FirstName=local_Name;
   -> END //
Query OK, 0 rows affected (0.24 sec)
mysql> DELIMITER ;
Now you can call the stored procedure using CALL command −
mysql> call delete_demo(102,'John Doe');
Query OK, 1 row affected, 1 warning (0.11 sec)
Let us check the table records once again −
mysql> select * from DemoTable1464;
This will produce the following output −
+------+-------------+
| Id   | FirstName   |
+------+-------------+
|  101 | Chris Brown |
+------+-------------+
1 row in set (0.00 sec)
VB.Net - MenuStrip Control

The MenuStrip control represents the container for the menu structure.
The MenuStrip control works as the top-level container for the menu structure. The ToolStripMenuItem class and the ToolStripDropDownMenu class provide the functionalities to create menu items, sub menus and drop-down menus.
The following diagram shows adding a MenuStrip control on the form −
The following are some of the commonly used properties of the MenuStrip control −
CanOverflow
Gets or sets a value indicating whether the MenuStrip supports overflow functionality.
GripStyle
Gets or sets the visibility of the grip used to reposition the control.
MdiWindowListItem
Gets or sets the ToolStripMenuItem that is used to display a list of Multiple-document interface (MDI) child forms.
ShowItemToolTips
Gets or sets a value indicating whether ToolTips are shown for the MenuStrip.
Stretch
Gets or sets a value indicating whether the MenuStrip stretches from end to end in its container.
The following are some of the commonly used events of the MenuStrip control −
MenuActivate
Occurs when the user accesses the menu with the keyboard or mouse.
MenuDeactivate
Occurs when the MenuStrip is deactivated.
In this example, let us add menu and sub-menu items.
Take the following steps −
Drag and drop or double click on a MenuStrip control, to add it to the form.
Drag and drop or double click on a MenuStrip control, to add it to the form.
Click the Type Here text to open a text box and enter the names of the menu items or sub-menu items you want. When you add a sub-menu, another text box with 'Type Here' text opens below it.
Click the Type Here text to open a text box and enter the names of the menu items or sub-menu items you want. When you add a sub-menu, another text box with 'Type Here' text opens below it.
Complete the menu structure shown in the diagram above.
Complete the menu structure shown in the diagram above.
Add a sub menu Exit under the File menu.
Add a sub menu Exit under the File menu.

Double-Click the Exit menu created and add the following code to the Click event of ExitToolStripMenuItem −
Double-Click the Exit menu created and add the following code to the Click event of ExitToolStripMenuItem −
Private Sub ExitToolStripMenuItem_Click(sender As Object, e As EventArgs) _
   Handles ExitToolStripMenuItem.Click
   End
End Sub
When the above code is executed and run using Start button available at the Microsoft Visual Studio tool bar, it will show the following window:
Click on the File -> Exit to exit from the application −

    63 Lectures 
     4 hours 

 Frahaan Hussain

    103 Lectures 
     12 hours 

 Arnold Higuit

    60 Lectures 
     9.5 hours 

 Arnold Higuit

    97 Lectures 
     9 hours 

 Arnold Higuit
 Print
 Add Notes
 Bookmark this page
C# BitConverter.ToSingle() Method

The BitConverter.ToSingle() method in C# is used to return a single-precision floating point number converted from four bytes at a specified position in a byte array.
The syntax is as follows −
public static float ToSingle (byte[] value, int begnIndex);
Above, val is the byte array, whereas begnIndex is the beginning position within val.
Let us now see an example −
 Live Demo
using System;
public class Demo {
   public static void Main() {
      byte[] arr = {0, 1, 2, 3, 5, 7, 10};
      Console.WriteLine("Byte Array = {0} ",
      BitConverter.ToString(arr));
      for (int i = 0; i < arr.Length - 4; i = i + 4) {
         float res = BitConverter.ToSingle(arr, i);
         Console.WriteLine("\nValue = "+arr[i]);
         Console.WriteLine("Result = "+res);
      }
   }
}
This will produce the following output −
Byte Array = 00-01-02-03-05-07-0A
Value = 0
Result = 3.820471E-37
Let us now see another example −
 Live Demo
using System;
public class Demo {
   public static void Main() {
      byte[] arr = {0, 10, 2, 5, 32, 45, 0, 0, 9, 20, 30, 50, 76, 88};
      Console.WriteLine("Byte Array = {0} ", BitConverter.ToString(arr));
      for (int i = 0; i < arr.Length - 4; i = i + 4) {
         float res = BitConverter.ToSingle(arr, i);
         Console.WriteLine("\nValue = "+arr[i]);
         Console.WriteLine("Result = "+res);
      }
   }
}
This will produce the following output −
Byte Array = 00-0A-02-05-20-2D-00-00-09-14-1E-32-4C-58
Value = 0
Result = 6.114407E-36
Value = 32
Result = 1.61878E-41
Value = 9
Result = 9.201366E-09
How to compute the histogram of a tensor in PyTorch?

The histogram of a tensor is computed using torch.histc(). It returns a histogram represented as a tensor. It takes four parameters: input, bins, min and max. It sorts the elements into equal width bins between min and max. It ignores the elements smaller than the min and greater than the max.
Import the required library. In all the following Python examples, the required Python libraries are torch and Matplotlib. Make sure you have already installed them.
Import the required library. In all the following Python examples, the required Python libraries are torch and Matplotlib. Make sure you have already installed them.
Create a tensor and print it.
Create a tensor and print it.
Compute torch.histc(input, bins=100, min=0, max=100). It
returns a tensor of histogram values. Set bins, min, and max to
appropriate values according to your need.
Compute torch.histc(input, bins=100, min=0, max=100). It
returns a tensor of histogram values. Set bins, min, and max to
appropriate values according to your need.
Print the above calculated histogram.
Print the above calculated histogram.
Visualize the histogram as a bar diagram.
Visualize the histogram as a bar diagram.
# Python program to calculate histogram of a tensor
# import necessary libraries
import torch
import matplotlib.pyplot as plt

# Create a tensor
T = torch.Tensor([2,3,1,2,3,4,3,2,3,4,3,4])
print("Original Tensor T:\n",T)

# Calculate the histogram of the above created tensor
hist = torch.histc(T, bins = 5, min = 0, max = 4)
print("Histogram of T:\n", hist)
Original Tensor T:
   tensor([2., 3., 1., 2., 3., 4., 3., 2., 3., 4., 3., 4.])
Histogram of T:
   tensor([0., 1., 3., 5., 3.])
# Python program to calculate histogram of a tensor
# import necessary libraries
import torch
import matplotlib.pyplot as plt

# Create a tensor
T = torch.Tensor([2,3,1,2,3,4,3,2,3,4,3,4])
print("Original Tensor T:\n",T)

# Calculate the histogram of the above created tensor
hist = torch.histc(T, bins = 5, min = 0, max = 4)

# Visualize above calculated histogram as bar diagram
bins = 5
x = range(bins)
plt.bar(x, hist, align='center')
plt.xlabel('Bins')
plt.ylabel('Frequency')
plt.show()
Original Tensor T:
   tensor([2., 3., 1., 2., 3., 4., 3., 2., 3., 4., 3., 4.])
PostgreSQL - ALIAS Syntax

You can rename a table or a column temporarily by giving another name, which is known as ALIAS. The use of table aliases means to rename a table in a particular PostgreSQL statement. Renaming is a temporary change and the actual table name does not change in the database.
The column aliases are used to rename a table's columns for the purpose of a particular PostgreSQL query.
The basic syntax of table alias is as follows −
SELECT column1, column2....
FROM table_name AS alias_name
WHERE [condition];

The basic syntax of column alias is as follows −
SELECT column_name AS alias_name
FROM table_name
WHERE [condition];

Consider the following two tables, (a) COMPANY table is as follows −
testdb=# select * from COMPANY;
 id | name  | age | address   | salary
----+-------+-----+-----------+--------
  1 | Paul  |  32 | California|  20000
  2 | Allen |  25 | Texas     |  15000
  3 | Teddy |  23 | Norway    |  20000
  4 | Mark  |  25 | Rich-Mond |  65000
  5 | David |  27 | Texas     |  85000
  6 | Kim   |  22 | South-Hall|  45000
  7 | James |  24 | Houston   |  10000
(7 rows)
(b) Another table is DEPARTMENT as follows −
 id | dept         | emp_id
----+--------------+--------
  1 | IT Billing   |      1
  2 | Engineering  |      2
  3 | Finance      |      7
  4 | Engineering  |      3
  5 | Finance      |      4
  6 | Engineering  |      5
  7 | Finance      |      6
(7 rows)
Now, following is the usage of TABLE ALIAS where we use C and D as aliases for COMPANY and DEPARTMENT tables, respectively −
testdb=# SELECT C.ID, C.NAME, C.AGE, D.DEPT
   FROM COMPANY AS C, DEPARTMENT AS D
   WHERE  C.ID = D.EMP_ID;
The above given PostgreSQL statement will produce the following result −
 id | name  | age |  dept
----+-------+-----+------------
  1 | Paul  |  32 | IT Billing
  2 | Allen |  25 | Engineering
  7 | James |  24 | Finance
  3 | Teddy |  23 | Engineering
  4 | Mark  |  25 | Finance
  5 | David |  27 | Engineering
  6 | Kim   |  22 | Finance
(7 rows)

Let us see an example for the usage of COLUMN ALIAS where COMPANY_ID is an alias of ID column and COMPANY_NAME is an alias of name column −
testdb=# SELECT C.ID AS COMPANY_ID, C.NAME AS COMPANY_NAME, C.AGE, D.DEPT
   FROM COMPANY AS C, DEPARTMENT AS D
   WHERE  C.ID = D.EMP_ID;
The above given PostgreSQL statement will produce the following result −
 company_id | company_name | age | dept
------------+--------------+-----+------------
      1     | Paul         |  32 | IT Billing
      2     | Allen        |  25 | Engineering
      7     | James        |  24 | Finance
      3     | Teddy        |  23 | Engineering
      4     | Mark         |  25 | Finance
      5     | David        |  27 | Engineering
      6     | Kim          |  22 | Finance
(7 rows)


    23 Lectures 
     1.5 hours 

 John Elder

    49 Lectures 
     3.5 hours 

 Niyazi Erdogan

    126 Lectures 
     10.5 hours 

 Abhishek And Pukhraj

    35 Lectures 
     5 hours 

 Karthikeya T

    5 Lectures 
     51 mins

 Vinay Kumar

    5 Lectures 
     52 mins

 Vinay Kumar
 Print
 Add Notes
 Bookmark this page
Cordova - Media

Cordova media plugin is used for recording and playing audio sounds in Cordova apps.
Media plugin can be installed by running the following code in command prompt window.
C:\Users\username\Desktop\CordovaProject>cordova plugin add cordova-plugin-media

In this tutorial, we will create simple audio player. Let's create buttons that we need in index.html.
<button id = "playAudio">PLAY</button>
<button id = "pauseAudio">PAUSE</button>
<button id = "stopAudio">STOP</button>
<button id = "volumeUp">VOLUME UP</button>
<button id = "volumeDown">VOLUME DOWN</button>
Now we need to add event listeners for our buttons inside onDeviceReady function inside index.js.
document.getElementById("playAudio").addEventListener("click", playAudio);
document.getElementById("pauseAudio").addEventListener("click", pauseAudio);
document.getElementById("stopAudio").addEventListener("click", stopAudio);
document.getElementById("volumeUp").addEventListener("click", volumeUp);
document.getElementById("volumeDown").addEventListener("click", volumeDown);
The first function that we are going to add is playAudio. We are defining myMedia outside of the function because we want to use it in functions that are going to be added later (pause, stop, volumeUp and volumeDown). This code is placed in index.js file.
var myMedia = null;
function playAudio() {
   var src = "/android_asset/www/audio/piano.mp3";

   if(myMedia === null) {
      myMedia = new Media(src, onSuccess, onError);

      function onSuccess() {
         console.log("playAudio Success");
      }

      function onError(error) {
         console.log("playAudio Error: " + error.code);
      }
   }
   myMedia.play();
}
We can click PLAY button to start the piano music from the src path.
The next functions that we need is pauseAudio and stopAudio.
function pauseAudio() {
   if(myMedia) {
      myMedia.pause();
   }
}

function stopAudio() {
   if(myMedia) {
      myMedia.stop(); 
   }
   myMedia = null;
}
Now we can pause or stop the piano sound by clicking PAUSE or STOP buttons.
To set the volume, we can use setVolume method. This method takes parameter with values from 0 to 1. We will set starting value to 0.5.
var volumeValue = 0.5;
function volumeUp() {
   if(myMedia && volumeValue < 1) {
      myMedia.setVolume(volumeValue += 0.1);
   }
}

function volumeDown() {
   if(myMedia && volumeValue > 0) {
      myMedia.setVolume(volumeValue -= 0.1);
   }
}
Once we press VOLUME UP or VOLUME DOWN we can change the volume value by 0.1.
The following table shows other methods that this plugin provides.
getCurrentPosition
Returns current position of an audio.
getDuration
Returns duration of an audio.
play
Used for starting or resuming audio.
pause
Used for pausing audio.
release
Releases the underlying operating system's audio resources.
seekTo
Used for changing position of an audio.
setVolume
Used for setting volume for audio.
startRecord
Start recording an audio file.
stopRecord
Stop recording an audio file.
stop
Stop playing an audio file.

    45 Lectures 
     2 hours 

 Skillbakerystudios

    16 Lectures 
     1 hours 

 Nilay Mehta
 Print
 Add Notes
 Bookmark this page
C++ Regex Library - regex_match

It returns whether the target sequence matches the regular expression rgx. The target sequence is either s or the character sequence between first and last, depending on the version used.
Following is the declaration for std::regex_match.
template <class charT, class traits>
   bool regex_match (const charT* s, const basic_regex<charT,traits>& rgx,
   regex_constants::match_flag_type flags = regex_constants::match_default);
template <class charT, class traits>
   bool regex_match (const charT* s, const basic_regex<charT,traits>& rgx,
   regex_constants::match_flag_type flags = regex_constants::match_default);
template <class charT, class traits>
   bool regex_match (const charT* s, const basic_regex<charT,traits>& rgx,
   regex_constants::match_flag_type flags = regex_constants::match_default);
s − It is a string with the target sequence.
s − It is a string with the target sequence.
rgx − It is a basic_regex object to match.
rgx − It is a basic_regex object to match.
flags − It is used to control how rgx is matched.
flags − It is used to control how rgx is matched.
m − It is an object of a match_results type.
m − It is an object of a match_results type.
It returns true if rgx is matched against the target sequence. false otherwise.
No-noexcept − this member function never throws exceptions.
In below example for std::regex_match.
#include <iostream>
#include <string>
#include <regex>

int main () {

   if (std::regex_match ("subject", std::regex("(sub)(.*)") ))
      std::cout << "string literal matched\n";

   const char cstr[] = "subject";
   std::string s ("subject");
   std::regex e ("(sub)(.*)");

   if (std::regex_match (s,e))
      std::cout << "string object matched\n";

   if ( std::regex_match ( s.begin(), s.end(), e ) )
      std::cout << "range matched\n";

   std::cmatch cm;
   std::regex_match (cstr,cm,e);
   std::cout << "string literal with " << cm.size() << " matches\n";

   std::smatch sm;
   std::regex_match (s,sm,e);
   std::cout << "string object with " << sm.size() << " matches\n";

   std::regex_match ( s.cbegin(), s.cend(), sm, e);
   std::cout << "range with " << sm.size() << " matches\n";

  
   std::regex_match ( cstr, cm, e, std::regex_constants::match_default );

   std::cout << "the matches were: ";
   for (unsigned i=0; i<sm.size(); ++i) {
      std::cout << "[" << sm[i] << "] ";
   }

   std::cout << std::endl;

   return 0;
}
The output should be like this −
string literal matched
string object matched
range matched
string literal with 3 matches
string object with 3 matches
range with 3 matches
the matches were: [subject] [sub] [ject] 

 Print
 Add Notes
 Bookmark this page
Initialize HashMap in Java

The HashMap class uses a hashtable to implement the Map interface. This allows the execution time of basic operations, such as get( ) and put( ), to remain constant even for large sets.
Following is the list of constructors supported by the HashMap class.
Following is an example displaying how to initialize and work with HashMap in Java −
 Live Demo
import java.util.*;
public class Demo {
   public static void main(String args[]) {
      HashMap<Integer, String> hashMap = new HashMap<Integer, String>(7);
      hashMap.put(1, "Laptop");
      hashMap.put(2, "LCD");
      hashMap.put(3, "LED");
      hashMap.put(4, "Desktop");
      hashMap.put(5, "Laptop");
      hashMap.put(6, "Notebook");
      hashMap.put(7, "Mobile");
      System.out.println("HashMap = " + hashMap);
   }
}
HashMap = {1=Laptop, 2=LCD, 3=LED, 4=Desktop, 5=Laptop, 6=Notebook, 7=Mobile}
Let us see another example −
 Live Demo
import java.util.*;
public class Main {
   public static void main(String args[]) {
      HashMap hashMap = new HashMap();
      hashMap.put("John", new Integer(10000));
      hashMap.put("Tim", new Integer(25000));
      hashMap.put("Adam", new Integer(15000));
      hashMap.put("Katie", new Integer(30000));
      hashMap.put("Jacob", new Integer(45000));
      hashMap.put("Steve", new Integer(23000));
      hashMap.put("Nathan", new Integer(25000));
      hashMap.put("Amy", new Integer(27000));
      Set set = hashMap.entrySet();
      Iterator iterator = set.iterator();
      while(iterator.hasNext()) {
         Map.Entry map = (Map.Entry)iterator.next();
         System.out.print(map.getKey() + ": ");
         System.out.println(map.getValue());
      }
      System.out.println();
      System.out.println("Size of IdentintyHashMap: "+hashMap.size());
      int bonus = ((Integer)hashMap.get("Amy")).intValue();
      hashMap.put("Amy", new Integer(bonus + 5000));
      System.out.println("Amy's salary after bonus = " + hashMap.get("Amy"));
      int deductions = ((Integer)hashMap.get("Steve")).intValue();
      hashMap.put("Steve", new Integer(deductions - 3000));
      System.out.println("Steve's salary after deductions = " + hashMap.get("Steve"));
   }
}
Adam: 15000
Nathan: 25000
Katie: 30000
Steve: 23000
John: 10000
Tim: 25000
Amy: 27000
Jacob: 45000
Size of IdentintyHashMap: 8
Amy's salary after bonus = 32000
Steve's salary after deductions = 20000
Unix / Linux Shell - The if...elif...fi statement

The if...elif...fi statement is the one level advance form of control statement that allows Shell to make correct decision out of several conditions.
if [ expression 1 ]
then
   Statement(s) to be executed if expression 1 is true
elif [ expression 2 ]
then
   Statement(s) to be executed if expression 2 is true
elif [ expression 3 ]
then
   Statement(s) to be executed if expression 3 is true
else
   Statement(s) to be executed if no expression is true
fi

This code is just a series of if statements, where each if is part of the else clause of the previous statement. Here statement(s) are executed based on the true condition, if none of the condition is true then else block is executed.
#!/bin/sh

a=10
b=20

if [ $a == $b ]
then
   echo "a is equal to b"
elif [ $a -gt $b ]
then
   echo "a is greater than b"
elif [ $a -lt $b ]
then
   echo "a is less than b"
else
   echo "None of the condition met"
fi
Upon execution, you will receive the following result −
a is less than b


    129 Lectures 
     23 hours 

 Eduonix Learning Solutions

    5 Lectures 
     4.5 hours 

 Frahaan Hussain

    35 Lectures 
     2 hours 

 Pradeep D

    41 Lectures 
     2.5 hours 

 Musab Zayadneh

    46 Lectures 
     4 hours 

 GUHARAJANM

    6 Lectures 
     4 hours 

 Uplatz
 Print
 Add Notes
 Bookmark this page
JavaScript - Array length Property

JavaScript array length property returns an unsigned, 32-bit integer that specifies the number of elements in an array.
Its syntax is as follows −
array.length

Returns the length of the array.
Try the following example.
<html>
   <head>
      <title>JavaScript Array length Property</title>
   </head>
   
   <body>   
      <script type = "text/javascript">
         var arr = new Array( 10, 20, 30 );
         document.write("arr.length is : " + arr.length); 
      </script>      
   </body>
</html>
arr.length is : 3 


    25 Lectures 
     2.5 hours 

 Anadi Sharma

    74 Lectures 
     10 hours 

 Lets Kode It

    72 Lectures 
     4.5 hours 

 Frahaan Hussain

    70 Lectures 
     4.5 hours 

 Frahaan Hussain

    46 Lectures 
     6 hours 

 Eduonix Learning Solutions

    88 Lectures 
     14 hours 

 Eduonix Learning Solutions
 Print
 Add Notes
 Bookmark this page
Create a pandas column using for loop - GeeksforGeeks

14 Jan, 2019
Let’s see how to create a column in pandas dataframe using for loop. Such operation is needed sometimes when we need to process the data of dataframe created earlier for that purpose, we need this type of computation so we can process the existing data and make a separate column to store the data.
It can be easily done by for-loop. The data of column can be taken from the existing Dataframe or any of the array.
# importing librariesimport pandas as pdimport numpy as np  raw_Data = {'Voter_name': ['Geek1', 'Geek2', 'Geek3', 'Geek4',                            'Geek5', 'Geek6', 'Geek7', 'Geek8'],             'Voter_age': [15, 23, 25, 9, 67, 54, 42, np.NaN]}  df = pd.DataFrame(raw_Data, columns = ['Voter_name', 'Voter_age'])#       //DataFrame will look like## Voter_name          Voter_age# Geek1                15# Geek2                23# Geek3                25# Geek4                09# Geek5                67# Geek6                54# Geek7                42# Geek8           not a number  eligible = []  # For each row in the columnfor age in df['Voter_age']:           if age >= 18:                   # if Voter eligible        eligible.append('Yes')    elif age < 18:                  # if voter is not eligible        eligible.append("No")    else:        eligible.append("Not Sure")  # Create a column from the listdf['Voter'] = eligible              print(df)
    Voter_name  Voter_age     Voter
0      Geek1         15        No
1      Geek2         23       Yes
2      Geek3         25       Yes
3      Geek4          9        No
4      Geek5         67       Yes
5      Geek6         54       Yes
6      Geek7         42       Yes
7      Geek8        NaN  Not Sure

pandas-dataframe-program
Picked
Python pandas-dataFrame
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Install PIP on Windows ?
How to drop one or multiple columns in Pandas Dataframe
Selecting rows in pandas DataFrame based on conditions
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | os.path.join() method
Python | Get unique values from a list
Create a directory in Python
Defaultdict in Python
Python | Pandas dataframe.groupby()
Is it possible to have an HTML canvas element in the background of my page?

Yes, try to set the CSS style with position: fixed (or absolute):
canvas{
   position:absolute;
   left:0;
   top:0;
   z-index:-1;
}
You can also set it to the following:
<style>
   #canvasSection{
      position:fixed;
   }
</style>
JavaScript - While Loops

While writing a program, you may encounter a situation where you need to perform an action over and over again. In such situations, you would need to write loop statements to reduce the number of lines.
JavaScript supports all the necessary loops to ease down the pressure of programming.
The most basic loop in JavaScript is the while loop which would be discussed in this chapter. The purpose of a while loop is to execute a statement or code block repeatedly as long as an expression is true. Once the expression becomes false, the loop terminates.
The flow chart of while loop looks as follows −
The syntax of while loop in JavaScript is as follows −
while (expression) {
   Statement(s) to be executed if expression is true
}

Try the following example to implement while loop.
<html>
   <body>
      
      <script type = "text/javascript">
         <!--
            var count = 0;
            document.write("Starting Loop ");
         
            while (count < 10) {
               document.write("Current Count : " + count + "<br />");
               count++;
            }
         
            document.write("Loop stopped!");
         //-->
      </script>
      
      <p>Set the variable to different value and then try...</p>
   </body>
</html>
Starting Loop
Current Count : 0
Current Count : 1
Current Count : 2
Current Count : 3
Current Count : 4
Current Count : 5
Current Count : 6
Current Count : 7
Current Count : 8
Current Count : 9
Loop stopped!
Set the variable to different value and then try... 

The do...while loop is similar to the while loop except that the condition check happens at the end of the loop. This means that the loop will always be executed at least once, even if the condition is false.
The flow chart of a do-while loop would be as follows −
The syntax for do-while loop in JavaScript is as follows −
do {
   Statement(s) to be executed;
} while (expression);

Note − Don’t miss the semicolon used at the end of the do...while loop.
Try the following example to learn how to implement a do-while loop in JavaScript.
<html>
   <body>   
      <script type = "text/javascript">
         <!--
            var count = 0;
            
            document.write("Starting Loop" + "<br />");
            do {
               document.write("Current Count : " + count + "<br />");
               count++;
            }
            
            while (count < 5);
            document.write ("Loop stopped!");
         //-->
      </script>      
      <p>Set the variable to different value and then try...</p>
   </body>
</html>
Starting Loop
Current Count : 0 
Current Count : 1 
Current Count : 2 
Current Count : 3 
Current Count : 4
Loop Stopped!
Set the variable to different value and then try...


    25 Lectures 
     2.5 hours 

 Anadi Sharma

    74 Lectures 
     10 hours 

 Lets Kode It

    72 Lectures 
     4.5 hours 

 Frahaan Hussain

    70 Lectures 
     4.5 hours 

 Frahaan Hussain

    46 Lectures 
     6 hours 

 Eduonix Learning Solutions

    88 Lectures 
     14 hours 

 Eduonix Learning Solutions
 Print
 Add Notes
 Bookmark this page
\enspace - Tex Command

\enspace - Used to add 0.5 em space.
{ \enspace }
\enspace command adds 0.5 em space.

|\enspace|\enspace|

|||



|\enspace|\enspace|

|||


|\enspace|\enspace|

    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
Sum of list with stream filter in Java

15 May, 2021
We generally iterate through the list when adding integers in a range, but java.util.stream.Stream has a sum() method that when used with filter() gives the required result easily.
Java
// Simple method (without filter) to find sum of a listimport java.util.*; class Addition {    public static void main(String[] args)    {        // create a list of integers        List<Integer> list = new ArrayList<Integer>();         // add elements to the list        list.add(1);        list.add(5);        list.add(6);        list.add(7);        list.add(8);        list.add(9);        list.add(10);         System.out.println(sum(list));    }     public static int sum(List<Integer> list)    {        // iterator for accessing the elements        Iterator<Integer> it = list.iterator();         int res = 0;        while (it.hasNext()) {            int num = it.next();             // adding the elements greater than 5            if (num > 5) {                res += num;            }        }         return res;    }}
40
 
The above task can be easily performed using sum() method with filter() method  
Java
// Using stream filter to find sum of a listimport java.util.*; class Addition {    public static void main(String[] args)    {        // create a list of integers        List<Integer> list = new ArrayList<Integer>();         // add elements to the list        list.add(1);        list.add(5);        list.add(6);        list.add(7);        list.add(8);        list.add(9);        list.add(10);         System.out.println(sum(list));    }     public static int sum(List<Integer> list)    {        // create a stream of integers        // filter the stream        // add the integers        return list.stream()            .filter(i -> i > 5)            .mapToInt(i -> i)            .sum();    }}
40
 
Stefan Vlahov
Java-ArrayList
java-list
Java-List-Programs
java-stream
Java-Stream-programs
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Convert a UTF8 value to Integer in R Programming - utf8ToInt() Function - GeeksforGeeks

16 Jun, 2020
utf8ToInt() function in R Language is used to convert a UTF8 value to an integer value.
Syntax: utf8ToInt(x, multiple)
Parameters:x: Integer or integer vectormultiple: Boolean value to convert into single or multiple strings
Example 1:
# R program to convert a UTF8 to Integer  # Calling the utf8ToInt() functionutf8ToInt("[")utf8ToInt("+")utf8ToInt(":")
Output:
[1] 91
[1] 43
[1] 58

Example 2:
# R program to convert a UTF8 to Integer  # Creating a vectorx1 <- c("&@\n")x2 <- c("[+:")x3 <- c("1d<U>")  # Calling the utf8ToInt() functionutf8ToInt(x1)utf8ToInt(x2)utf8ToInt(x3)
Output:
[1] 38 64 10
[1] 91 43 58
[1]  49 100  60  85  62

R Math-Function
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Change Color of Bars in Barchart using ggplot2 in R
Group by function in R using Dplyr
How to Change Axis Scales in R Plots?
How to Split Column Into Multiple Columns in R DataFrame?
Replace Specific Characters in String in R
How to filter R DataFrame by values in a column?
R - if statement
How to filter R dataframe by multiple conditions?
Plot mean and standard deviation using ggplot2 in R
How to import an Excel File into R ?
How to set “checked” for a checkbox with jQuery?

Use the checked attribute to set the checkbox with jQuery. Also, the prop() method is used to get the property value.
You can try to run the following code to learn how to set checked for a checkbox:
Live Demo
<!DOCTYPE html>
<html>
<head>
  <title>jQuery Example</title>
  <style>
  b {
     color: green;
  }
  </style>
  <script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
 
<input id="checkbox1" type="checkbox" checked="checked">
<label for="checkbox1">Check/ Uncheck this checkbox</label>
<p></p>
 
<script>
$( "input" ).change(function() {
  var $input = $( this );
  $( "p" ).html(
    ".attr( \"checked\" ): <b>" + $input.attr( "checked" ) + "</b><br>" +
    ".prop( \"checked\" ): <b>" + $input.prop( "checked" ) + "</b><br>" +
    ".is( \":checked\" ): <b>" + $input.is( ":checked" ) + "</b>" );
}).change();
</script>
 
</body>
</html>
Adding a line to a scatter plot using Python's Matplotlib

To add a line to a scatter plot using Python's Matplotlib, we can take the following steps −
Set the figure size and adjust the padding between and around the subplots.
Initialize a variable, n, for number of data points.
Plot x and y data points using scatter() method.
Plot a line using plot() method.
Limt the X-axis using xlim() method.
To display the figure, use show() method.
import numpy as np
from matplotlib import pyplot as plt

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

n = 100
x = np.random.rand(n)
y = np.random.rand(n)

plt.scatter(x, y, c=x)
plt.plot([0.1, 0.4, 0.3, 0.2])
plt.xlim(0, 1)

plt.show()
Duration ofMinutes(long) method in Java with Examples - GeeksforGeeks

26 Nov, 2018
The ofMinutes(long) method of Duration Class in java.time package is used to get a duration in a 1 minute format. In this method, the seconds are calculated as total seconds in 1 minute format, i.e. 60 seconds per minute.
Syntax:
public static Duration ofMinutes(long minutes)

Parameters: This method accepts a parameter minutes which is the number of minutes. It can be positive or negative.
Return Value: This method returns a Duration representing the time in 1 minute format.
Exception: This method throws ArithmeticException if the input minutes exceeds the capacity of Duration.
Below examples illustrate the Duration.ofMinutes() method:
Example 1:
// Java code to illustrate ofMinutes() method  import java.time.Duration;  public class GFG {    public static void main(String[] args)    {          // input number of Minutes        long noOfMinutes = 5;          // Duration using ofMinutes() method        Duration duration            = Duration.ofMinutes(noOfMinutes);          System.out.println(duration.getSeconds());    }}
300

Example 2:
// Java code to illustrate ofMinutes() method  import java.time.Duration;  public class GFG {    public static void main(String[] args)    {          // input number of Minutes        long noOfMinutes = -214545;          // Duration using ofMinutes() method        Duration duration            = Duration.ofMinutes(noOfMinutes);          System.out.println(duration.getSeconds());    }}
-12872700

Reference: https://docs.oracle.com/javase/9/docs/api/java/time/Duration.html#ofMinutes-long-
Java-Duration
Java-Functions
Java-time package
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Object Oriented Programming (OOPs) Concept in Java
Stream In Java
HashMap in Java with Examples
Interfaces in Java
How to iterate any Map in Java
ArrayList in Java
Initialize an ArrayList in Java
Stack Class in Java
Singleton Class in Java
Multithreading in Java
How to get the title and URL of the page in Selenium with python?

We can get the title and URL of the page in Selenium.
For getting the title of the browser, the title method is to be used.
For getting the URL of the page, the current_url method is to be used.
Both these methods can be used for testing if we are navigated to the correct page and page title.
Code Implementation
from selenium import webdriver
#browser exposes an executable file
#Through Selenium test we will invoke the executable file which will then #invoke actual browser
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 print the page title in console
print(driver.title)
# to print the current URL in console
print(driver.current_url)
#to refresh the browser
driver.refresh()
#to close the browser
driver.close()
Tryit Editor v3.7

Tryit: HSL Saturation
Generate 10 random four-digit numbers in Java

To generated random integer, use the Random class with nextInt. At first, create a Random object −
Random rand = new Random();
The Random above is a random number generator. Now, pick the random numbers one by one. We want 10 random four-digit numbers, therefore loop it until i = 1 to 10 −
for (int i = 1; i<= 10; i++) {
   intresRandom = rand.nextInt((9999 - 100) + 1) + 10;
   System.out.println(resRandom);
}
The following is an example to generate 10 random four-digit numbers −
 Live Demo
import java.util.Random;
public class Demo {
   public static void main(String[] args) {
      Random rand = new Random();
      System.out.println("Random numbers...");
      for (int i = 1; i<= 10; i++) {
         int resRandom = rand.nextInt((9999 - 100) + 1) + 10;
         System.out.println(resRandom);
      }
   }
}
Random numbers...
6075
4943
2141
5701
4181
9534
3539
6793
3058
4766