code-rag-bench/online-tutorials huggingface dataset:
C# Program to check a string for whitespace characters or null

This method returns true if the entered string has only whitespace characters or is null.
Let’s say you are checking for whitespace character.
bool val1 = string.IsNullOrWhiteSpace(“ “);
The above returns True, since the string is a whitespace character. In the same way, check it for null using the IsNullOrWhiteSpace() method.
Here is the entire example that checks for null and whitespace −
using System;
using System.IO;
public class Demo {
   public static void Main() {
      bool val1 = string.IsNullOrWhiteSpace(“100”);
      bool val2 = string.IsNullOrWhiteSpace(" ");
      bool val3 = string.IsNullOrWhiteSpace(null);
      Console.WriteLine(val1);
      Console.WriteLine(val2);
      Console.WriteLine(val3);
   }
}
How to safely open/close files in Python?

open() opens a file. You can use it like:
f = open('my_file', 'r+')
my_file_data = f.read()
f.close()
The above code opens 'my_file' in read mode then stores the data it reads from my_file in my_file_data and closes the file. The first argument of open is the name of the file and second one is the open mode. It determines how the file gets opened.
– If you want to read the file, pass in r
– If you want to read and write the file, pass in r+
– If you want to overwrite the file, pass in w
– If you want to append to the file, pass in a
When you open a file, the operating system gives a file handle to read/write the file. You need to close it once you are done using the file. If your program encounters an error and doesn't call f.close(), you didn't release the file. To make sure it doesn't happen, you can use with open(...) as f syntax as it automatically closes files regardless of whether an error was encountered:
with open('my_file', 'r+') as f:
    my_file_data = f.read()
Algorithms | Analysis of Algorithms | Question 13 - GeeksforGeeks

28 Jun, 2021
Consider the following functions:
  f(n)   = 2^n
  g(n)   = n!
  h(n)   = n^logn 
Which of the following statements about the asymptotic behavior of f(n), g(n), and h(n) is true?(A) f(n) = O(g(n)); g(n) = O(h(n))(B) f(n) = (g(n)); g(n) = O(h(n))(C) g(n) = O(f(n)); h(n) = O(f(n))(D) h(n) = O(f(n)); g(n) = (f(n))(A) A(B) B(C) C(D) DAnswer: (D)Explanation: According to order of growth: h(n) < f(n) < g(n) (g(n) is asymptotically greater than f(n) and f(n) is asymptotically greater than h(n) )We can easily see above order by taking logs of the given 3 functions
   lognlogn < n < log(n!)  (logs of the given f(n), g(n) and h(n)).
Note that log(n!) = (nlogn)Quiz of this Question
Algorithms-Analysis of Algorithms
Analysis of Algorithms
Algorithms Quiz
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Algorithms | Dynamic Programming | Question 2
Algorithms | Dynamic Programming | Question 3
Algorithms | Recursion | Question 9
Algorithms | Sorting | Question 11
Algorithms | Sorting | Question 1
Algorithms | Greedy Algorithms | Question 1
Algorithms | Divide and Conquer | Question 6
Algorithms Quiz | Dynamic Programming | Question 8
Algorithms | Analysis of Algorithms | Question 8
Algorithms | Graph Traversals | Question 12
Select maximum of sum of two columns in MySQL

To select maximum of sum of two columns, use aggregate function MAX() along with subquery. Let us first create a table −
mysql> create table DemoTable1587
   -> (
   -> Value1 int,
   -> Value2 int
   -> );
Query OK, 0 rows affected (0.59 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1587 values(30,50);
Query OK, 1 row affected (0.13 sec)
mysql> insert into DemoTable1587 values(80,90);
Query OK, 1 row affected (0.17 sec)
mysql> insert into DemoTable1587 values(40,67);
Query OK, 1 row affected (0.13 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1587;
This will produce the following output −
+--------+--------+
| Value1 | Value2 |
+--------+--------+
|     30 |     50 |
|     80 |     90 |
|     40 |     67 |
+--------+--------+
3 rows in set (0.00 sec)
Here is the query to select maximum of sum of two columns −
mysql> select * from DemoTable1587
  -> where Value1+Value2=( select max(Value1+Value2) from DemoTable1587);
This will produce the following output −
+--------+--------+
| Value1 | Value2 |
+--------+--------+
|     80 |     90 |
+--------+--------+
1 row in set (0.03 sec)
How to check existence of NaN keyword in an array JavaScript

We have an array of elements that contains both truth and false values. Our job is to write a
function that returns an array with indices of those elements which are NaN in the original array.
The datatype of NaN is actually number. Although NaN is a falsy value, it has a peculiar
property that no other datatype or variable has. It’s that the expression NaN === NaN yields
false. And it’s only in the case of NaN that its false.
So, we can use this behavior to our good and pick out NaN value index. The code for this will
be −
const arr = [7, 1, "123abc", undefined, NaN, 78, NaN, null, "aes", NaN,
'', null, NaN];
const pickNaN = (arr) => {
   return arr.reduce((acc, val, ind) => {
      if(val !== val){
         acc.push(ind);
      };
      return acc;
   }, []);
};
console.log(pickNaN(arr));
The isNaN() function returns true or false based on the fact whether or not the value provided is
a NaN or can be coerced to a NaN. Whereas the Number.isNaN() function only returns true if
the value provided is actually NaN.
So, the Number.isNaN() is a reliable way of checking for NaN over isNaN(). The difference in
the code outputs is illustrated below.
const arr = [7, 1, "abc", undefined, NaN, 78, NaN, null, "aes", NaN, '',
null, NaN];
const pickNaN = (arr) => {
   return arr.reduce((acc, val, ind) => {
      if(Number.isNaN(val)){
         acc.reliableWay.push(ind);
      };
      if(isNaN(val)){
         acc.unreliableWay.push(ind);
      }
      return acc;
   }, {
      reliableWay: [],
      unreliableWay: []
   });
};
console.log(pickNaN(arr));
This code prepares two arrays, one using Number.isNaN() and one using isNaN().
The output will be −
{
   reliableWay: [ 4, 6, 9, 12 ],
   unreliableWay: [ 2, 3, 4, 6, 8, 9, 12]
}
We can clearly see how isNaN() computed many non-NaN values as NaN. That’s why
Number.isNaN() is a more reliable way.
bz2.decompress(s) in Python - GeeksforGeeks

26 Mar, 2020
With the help of bz2.decompress(s) method, we can decompress the compressed bytes of string into original string by using bz2.decompress(s) method.
Syntax : bz2.decompress(string)Return : Return decompressed string.
Example #1 :In this example we can see that by using bz2.decompress(s) method, we are able to decompress the compressed string in the byte format of string by using this method.
# import bz2 and decompressimport bz2  s = b'This is GFG author, and final year student.'s = bz2.compress(s)  # using bz2.decompress(s) methodt = bz2.decompress(s)print(t)
Output :
b’This is GFG author, and final year student.’
Example #2 :
# import bz2 and compressimport bz2  s = b'GeeksForGeeks@12345678's = bz2.compress(s)  # using bz2.decompress(s) methodt = bz2.decompress(s)print(t)
Output :
b’GeeksForGeeks@12345678′
Python-bz2
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Check if element exists in list in Python
Selecting rows in pandas DataFrame based on conditions
Python | os.path.join() method
Defaultdict in Python
Python | Get unique values from a list
Create a directory in Python
Python | Pandas dataframe.groupby()
Python Operators Precedence Example

The following table lists all operators from highest precedence to lowest.
Operator precedence affects how an expression is evaluated.
For example, x = 7 + 3 * 2; here, x is assigned 13, not 20 because operator * has higher precedence than +, so it first multiplies 3*2 and then adds into 7.
Here, operators with the highest precedence appear at the top of the table, those with the lowest appear at the bottom.
#!/usr/bin/python

a = 20
b = 10
c = 15
d = 5
e = 0

e = (a + b) * c / d       #( 30 * 15 ) / 5
print "Value of (a + b) * c / d is ",  e

e = ((a + b) * c) / d     # (30 * 15 ) / 5
print "Value of ((a + b) * c) / d is ",  e

e = (a + b) * (c / d);    # (30) * (15/5)
print "Value of (a + b) * (c / d) is ",  e

e = a + (b * c) / d;      #  20 + (150/5)
print "Value of a + (b * c) / d is ",  e
When you execute the above program, it produces the following result −
Value of (a + b) * c / d is 90
Value of ((a + b) * c) / d is 90
Value of (a + b) * (c / d) is 90
Value of a + (b * c) / d is 50

    187 Lectures 
     17.5 hours 

 Malhar Lathkar

    55 Lectures 
     8 hours 

 Arnab Chakraborty

    136 Lectures 
     11 hours 

 In28Minutes Official

    75 Lectures 
     13 hours 

 Eduonix Learning Solutions

    70 Lectures 
     8.5 hours 

 Lets Kode It

    63 Lectures 
     6 hours 

 Abhilash Nelson
 Print
 Add Notes
 Bookmark this page
DATEPART() Function in SQL Server - GeeksforGeeks

18 Jan, 2021
DATEPART() function :This function in SQL Server is used to find a given part of the specified date. Moreover, it returns the output value as an integer.
Features :
This function is used to find a given part of the specified date.
This function comes under Date Functions.
This function accepts two parameters namely interval and date.
This function can also include time in the date section.
This function returns the output in integer form.
Syntax :
DATEPART(interval, date)
Parameter :This method accepts two parameters as given below as follows.
interval – It is the specified part which is to be returned. Moreover, the values of the interval can be as given below.
year, yyyy, yy      = Year, which is the specified year.
quarter, qq, q      = Quarter, which is the specified quarter.
month, mm, m        = month, which is the specified month.
dayofyear, dy, y    = Day of the year, which is the specified day of the year.
day, dd, d          = Day, which is the specified day.
week, ww, wk        = Week, which is the specified week.
weekday, dw, w      = Weekday, which is the specified week day.
hour, hh            = hour, which is the specified hour.
minute, mi, n       = Minute, which is the specified minute.
second, ss, s       = Second, which is the specified second.
millisecond, ms     = Millisecond, which is the specified millisecond.
date – It is the specified date which is to be used.
Returns :It returns a given part of the specified date.
Example-1 :
Using DATEPART() function and getting the year part of the specified date.
SELECT DATEPART(year, '2017/08/25');
Output :
2017
Example-2 :Using DATEPART() function and getting the month part of the specified date.
SELECT DATEPART(month, '2017/08/25');
Output :
8
Example-3 :Using DATEPART() function and getting the day part of the specified date.
SELECT DATEPART(day, '2017/08/25');
Output :
25
Example-4 :Using DATEPART() function and getting the hour part of the specified date which includes time as well.
SELECT DATEPART(hour, '2021/01/06 05:30');
Output :
5
Example-5 :Using DATEPART() function and getting the second part of the specified date which includes time as well using a variable.
DECLARE @date VARCHAR(50);
SET @date = '2019/06/05 07:37:54';
SELECT DATEPART(second, @date);
Output :
54
Application :This function is used to find the given part of the specified date. 
DBMS-SQL
SQL-Server
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Update Multiple Columns in Single Update Statement in SQL?
What is Temporary Table in SQL?
SQL Query to Find the Name of a Person Whose Name Starts with Specific Letter
SQL using Python
SQL | Subquery
How to Select Data Between Two Dates and Times in SQL Server?
How to Write a SQL Query For a Specific Date Range and Date Time?
SQL Query to Convert VARCHAR to INT
SQL - SELECT from Multiple Tables with MS SQL Server
SQL | Date functions
DDL Commands & Syntax - GeeksforGeeks

31 May, 2021
In this article, we will discuss the overview of DDL commands and will understand DDL commands like create, alter, truncate, drop. We will cover each command syntax with the help of an example for better understanding. Let’s discuss it one by one.
Overview :Data Definition Language(DDL) is a subset of SQL and a part of DBMS(Database Management System). DDL consist of Commands to commands like CREATE, ALTER, TRUNCATE and DROP. These commands are used to create or modify the tables in SQL.
DDL Commands :In this section, We will cover the following DDL commands as follows.
CreateAlter truncatedrop
Create
Alter 
truncate
drop
Let’s discuss it one by one.
Command-1 :CREATE :This command is used to create a new table in SQL. The user has to give information like table name, column names, and their datatypes.
Syntax –
CREATE TABLE table_name
(
column_1 datatype,
column_2 datatype,
column_3 datatype,
....
);
Example –We need to create a table for storing Student information of a particular College. Create syntax would be as below.
CREATE TABLE Student_info
(
College_Id number(2),
College_name varchar(30),
Branch varchar(10)
);
Command-2 :ALTER :This command is used to add, delete or change columns in the existing table. The user needs to know the existing table name and can do add, delete or modify tasks easily.
Syntax –Syntax to add a column to an existing table.
ALTER TABLE table_name
ADD column_name datatype;
Example –In our Student_info table, we want to add a new column for CGPA. The syntax would be as below as follows.
ALTER TABLE Student_info
ADD CGPA number;
Command-3 :TRUNCATE :This command is used to remove all rows from the table, but the structure of the table still exists.
Syntax –Syntax to remove an existing table.
TRUNCATE TABLE table_name;
Example –The College Authority wants to remove the details of all students for new batches but wants to keep the table structure. The command they can use is as follows.
TRUNCATE TABLE Student_info;
Command-4 :DROP :This command is used to remove an existing table along with its structure from the Database.
Syntax –Syntax to drop an existing table.
DROP TABLE table_name;
Example –If the College Authority wants to change their Database by deleting the Student_info Table. 
DROP TABLE Student_info;
DBMS-SQL
DBMS
SQL
DBMS
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Types of Functional dependencies in DBMS
Introduction of Relational Algebra in DBMS
What is Temporary Table in SQL?
Two Phase Locking Protocol
KDD Process in Data Mining
SQL | DDL, DQL, DML, DCL and TCL Commands
How to find Nth highest salary from a table
SQL | ALTER (RENAME)
How to Update Multiple Columns in Single Update Statement in SQL?
MySQL | Group_CONCAT() Function
C++ Program for Heap Sort - GeeksforGeeks

27 Mar, 2019
Heap sort is a comparison based sorting technique based on Binary Heap data structure. It is similar to selection sort where we first find the maximum element and place the maximum element at the end. We repeat the same process for remaining element.
// C++ program for implementation of Heap Sort#include <iostream>using namespace std;  // To heapify a subtree rooted with node i which is// an index in arr[]. n is size of heapvoid heapify(int arr[], int n, int i){    int largest = i; // Initialize largest as root    int l = 2 * i + 1; // left = 2*i + 1    int r = 2 * i + 2; // right = 2*i + 2      // If left child is larger than root    if (l < n && arr[l] > arr[largest])        largest = l;      // If right child is larger than largest so far    if (r < n && arr[r] > arr[largest])        largest = r;      // If largest is not root    if (largest != i) {        swap(arr[i], arr[largest]);          // Recursively heapify the affected sub-tree        heapify(arr, n, largest);    }}  // main function to do heap sortvoid heapSort(int arr[], int n){    // Build heap (rearrange array)    for (int i = n / 2 - 1; i >= 0; i--)        heapify(arr, n, i);      // One by one extract an element from heap    for (int i = n - 1; i >= 0; i--) {        // Move current root to end        swap(arr[0], arr[i]);          // call max heapify on the reduced heap        heapify(arr, i, 0);    }}  /* A utility function to print array of size n */void printArray(int arr[], int n){    for (int i = 0; i < n; ++i)        cout << arr[i] << " ";    cout << "\n";}  // Driver programint main(){    int arr[] = { 12, 11, 13, 5, 6, 7 };    int n = sizeof(arr) / sizeof(arr[0]);      heapSort(arr, n);      cout << "Sorted array is \n";    printArray(arr, n);}
Sorted array is 
5 6 7 11 12 13

Please refer complete article on Heap Sort for more details!
Heap Sort
C++ Programs
Heap
Sorting
Sorting
Heap
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Passing a function as a parameter in C++
Program to implement Singly Linked List in C++ using class
Const keyword in C++
cout in C++
Dynamic _Cast in C++
HeapSort
Binary Heap
Huffman Coding | Greedy Algo-3
K'th Smallest/Largest Element in Unsorted Array | Set 1
k largest(or smallest) elements in an array
FormatCurrency() and FormatDateTime() Function in MS Access - GeeksforGeeks

17 Jan, 2022
1. FormatCurrency() Function : FormatCurrency() Function in MS Access is used to Returns an expression formatted as a currency value using the currency symbol defined in the system control panel. 
Syntax :  
FormatCurrency 
( 
Expression [, NumDigitsAfterDecimal ] 
           [, IncludeLeadingDigit ] 
           [, UseParensForNegativeNumbers ] 
           [, GroupDigits ] // It represent group digit.
)
Parameter : FormatCurrency() accept five parameters as mentioned above and described below.  
Expression – It identifies Expression to be formatted.  
NumDigitsAfterDecimal – In this parameter NumDigitsAfterDecimal identifies Numeric value indicating how many places to the right of the decimal are displayed. -1 is the Default value, which indicates that the computer’s regional settings are used.It is optional.  
IncludeLeadingDigit – In this parameter LeadingDigit indicates whether or not a leading zero is displayed for fractional values. It is optional.  
UseParensForNegativeNumbers – It indicates whether or not to place negative values within parentheses . It is optional.  
GroupDigits – It indicates whether or not numbers are grouped using the group delimiter specified in the computer’s regional settings.It is also optional
Note : The IncludeLeadingDigit, UseParensForNegativeNumbers, and GroupDigits arguments have the following value.-1 for True, 0 for False, and -2 for Default value. 
Returns : It returns the formatted currency value. 
Example-1 : Converting for Positive currency value.  
Select FormatCurrency(1200.2) as New_Currency;
Output : 
Example-2 : Converting for negative currency value.  
Select Formatcurrency(-1000, 2, -1, -1, -1) 
AS New_Currency;
Output : 
2. FormatDateTime() Function : FormatDateTime() Function in MS Access is used to Returns an expression formatted as a date or time. 
Syntax :  
FormatDateTime( Date [, NamedFormat ] )
Parameter : FormatDateTime() accept two parameters as mentioned above and described below.  
Date – It identifies expression to be formatted.  
NamedFormat – It is numeric value that indicates the date/time format used. If omitted, GeneralDate is used. 0 Is used for General Date, 1 is used for Long Date, 2 for short Date, 3 for short Time, 4 for Long Time.
Returns : It returns a formatted Datetime expression. 
Example-1 : Formatting to long Date.  
SELECT FormatDateTime(#17/04/2004#, 1) 
as New_DFormat
Output : 
Example-2 : Formatting to long Time.  
SELECT FormatDateTime(#12:30#, 4) 
as Long_Format;
Output : 
adnanirshad158
DBMS-SQL
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
SQL | DROP, TRUNCATE
How to Select Data Between Two Dates and Times in SQL Server?
SQL vs NoSQL: Which one is better to use?
Advanced SQL Interview Questions
SQL | OFFSET-FETCH Clause
Insert multiple values into multiple tables using a single statement in SQL Server
How to Update Multiple Columns in Single Update Statement in SQL?
SQL | Comments
SQL | CREATE
Adding multiple constraints in a single table
Maximum and Minimum K elements in Tuple using Python

When it is required to find the maximum and minimum K elements in a tuple, the ‘sorted’ method is used to sort the elements, and enumerate over them, and get the first and last elements.
Below is the demonstration of the same −
 Live Demo
my_tuple = (7, 25, 36, 9, 6, 8)

print("The tuple is : ")
print(my_tuple)

K = 2
print("The value of K has been initialized to ")
print(K)
my_result = []
my_tuple = list(my_tuple)
temp = sorted(my_tuple)

for idx, val in enumerate(temp):
   if idx < K or idx >= len(temp) - K:
      my_result.append(val)
my_result = tuple(my_result)

print("The result is : " )
print(my_result)
The tuple is :
(7, 25, 36, 9, 6, 8)
The value of K has been initialized to
2
The result is :
(6, 7, 25, 36)
A tuple is defined, and is displayed on the console.
A tuple is defined, and is displayed on the console.
The value of K is defined.
The value of K is defined.
An empty list is defined.
An empty list is defined.
The tuple is converted to a list.
The tuple is converted to a list.
It is sorted and stored in a variable.
It is sorted and stored in a variable.
This is iterated over, and if it is less than K or greater than difference between length of list and K, it is appended to the empty list.
This is iterated over, and if it is less than K or greater than difference between length of list and K, it is appended to the empty list.
This is the output that is displayed on the console.
This is the output that is displayed on the console.
How to find the frequency of NA values per row in an R data frame?

Since column represent variables, we often find missing values in the columns of a data frame but we may want to find missing values(NA) for cases as well so that we can replace them based on case characteristic instead of the distribution of the variable. In R, we can use rowSums with apply function.
Consider the below data frame −
 Live Demo
set.seed(8)
x1<-sample(c(NA,1,2),20,replace=TRUE)
x2<-sample(c(NA,5,10),20,replace=TRUE)
df1<-data.frame(x1,x2)
df1
  x1 x2
1  2 10
2  1 10
3  2 5
4  2 10
5  1 5
6  2 NA
7  1 5
8 NA 10
9 NA 10
10 1 5
11 2 NA
12 2 5
13 1 NA
14 1 5
15 2 5
16 1 NA
17 NA 5
18 NA 10
19 1 5
20 2 5
Finding the frequency of NA values in rows of the data frame df1 −
df1$NA_frequency<-rowSums(apply(is.na(df1),2,as.numeric))
df1
  x1 x2 NA_frequency
1  2 10    0
2  1 10    0
3  2 5     0
4  2 10    0
5  1 5     0
6  2 NA    1
7  1 5     0
8 NA 10    1
9 NA 10    1
10 1 5     0
11 2 NA    1
12 2 5     0
13 1 NA    1
14 1 5     0
15 2 5     0
16 1 NA    1
17 NA 5    1
18 NA 10   1
19 1 5     0
20 2 5     0
Let’s have a look at another example −
 Live Demo
y1<-sample(c(NA,1),20,replace=TRUE)
y2<-sample(c(NA,400),20,replace=TRUE)
y3<-sample(c(NA,35),20,replace=TRUE)
y4<-sample(c(NA,127),20,replace=TRUE)
df2<-data.frame(y1,y2,y3,y4)
df2
  y1  y2 y3 y4
1  NA NA 35 127
2  1  NA NA NA
3  1 400 35 127
4  1 NA 35 127
5  1 NA 35 127
6 NA 400 NA NA
7  1 400 NA NA
8  1 NA 35 127
9  1 400 NA 127
10 NA 400 35 127
11 NA NA 35 NA
12 NA NA NA NA
13 NA NA 35 NA
14 1 400 35 NA
15 1 NA 35 NA
16 NA 400 35 NA
17 1 NA 35 NA
18 NA 400 35 127
19 NA 400 NA NA
20 1 NA NA 127
Finding the frequency of NA values in rows of the data frame df2 −
df2$NA_frequency<-rowSums(apply(is.na(df2),2,as.numeric))
df2
  y1 y2 y3 y4 NA_frequency
1 NA NA 35 127    2
2  1 NA NA NA     3
3  1 400 35 127   0
4  1 NA 35 127    1
5  1 NA 35 127    1
6 NA 400 NA NA    3
7  1 400 NA NA    2
8  1 NA 35 127    1
9  1 400 NA 127   1
10 NA 400 35 127  1
11 NA NA 35 NA    3
12 NA NA NA NA    4
13 NA NA 35 NA    3
14 1 400 35 NA    1
15 1 NA 35 NA     2
16 NA 400 35 NA   2
17 1  NA 35 NA    2
18 NA 400 35 127  1
19 NA 400 NA NA   3
20 1 NA NA 127    2
p5.js | createAudio() Function - GeeksforGeeks

21 Mar, 2020
The createAudio() function is used to create an audio element in the DOM. The audio is created as a p5.MediaElement, which has methods for controlling the media and its playback.
Syntax:
createAudio(src, callback)
Parameters: This function accept two parameters as mentioned above and described below:
src: It is a string or an array of strings that specified path of the audio file. The array of strings can be used to specify multiple paths for the support of various browsers.
callback: It is a callback function that would be fired when the ‘canplaythrough’ event fires. This event is fired when the audio has completed loading and does not require any additional buffering. It is an optional parameter.
Return Value: It returns a pointer to the p5.MediaElement with the audio.
Below examples illustrate the createAudio() function in p5.js:
Example 1:
function setup() {  createCanvas(300, 300);  text("Click on the buttons below to"+        "play/pause the audio", 20, 20);     audioElement = createAudio("sample_audio.wav");  audioElement.position(20, 50);  audioElement.size(300);     // Show the audio controls  audioElement.showControls();}
Output:
Example 2:
function setup() {  createCanvas(300, 300);  text("Loading the audio...", 20, 20);    audioElement = createAudio("sample_audio.mp3", afterLoad);  audioElement.position(20, 20);  audioElement.size(300);    playBtn = createButton("Play Audio");  playBtn.position(30, 80);  playBtn.mouseClicked(playAudio);    pauseBtn = createButton("Pause Audio");  pauseBtn.position(150, 80);  pauseBtn.mouseClicked(pauseAudio);}  function afterLoad() {  text("The audio has finished loading and"+              " can now be played!", 20, 40);}  function playAudio() {  audioElement.play();}  function pauseAudio() {  audioElement.pause();}
Output:
Online editor: https://editor.p5js.org/
Environment Setup: https://www.geeksforgeeks.org/p5-js-soundfile-object-installation-and-methods/
Reference: https://p5js.org/reference/#/p5/createAudio
JavaScript-p5.js
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Convert a string to an integer in JavaScript
Differences between Functional Components and Class Components in React
How to Open URL in New Tab using JavaScript ?
Form validation using HTML and JavaScript
Difference between var, let and const keywords in JavaScript
Express.js express.Router() Function
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to set the default value for an HTML <select> element ?
Top 10 Angular Libraries For Web Developers
How do we do a file upload using Python CGI Programming?

To upload a file, the HTML form must have the enctype attribute set to multipart/form-data. The input tag with the file type creates a "Browse" button.
<html>
<body>
   <form enctype = "multipart/form-data"
                     action = "save_file.py" method = "post">
   <p>File: <input type = "file" name = "filename" /></p>
   <p><input type = "submit" value = "Upload" /></p>
   </form>
</body>
</html>
The result of this code is the following form −
File: Choose file
Upload
Here is the script save_file.py to handle file upload −
#!/usr/bin/python
import cgi, os
import cgitb; cgitb.enable()
form = cgi.FieldStorage()
# Get filename here.
fileitem = form['filename']
# Test if the file was uploaded
if fileitem.filename:
   # strip leading path from file name to avoid
   # directory traversal attacks
   fn = os.path.basename(fileitem.filename)
   open('/tmp/' + fn, 'wb').write(fileitem.file.read())
   message = 'The file "' + fn + '" was uploaded successfully'
 
else:
   message = 'No file was uploaded'
 
print """\
Content-Type: text/html\n
<html>
<body>
   <p>%s</p>
</body>
</html>
""" % (message,)
If you run the above script on Unix/Linux, then you need to take care of replacing file separator as follows, otherwise on your windows machine above open() statement should work fine.
fn = os.path.basename(fileitem.filename.replace("\\", "/" ))
Write a program in Python to print the ‘A’ grade students’ names from a DataFrame

Input −
Assume, you have DataFrame,
 Id  Name Grade
0 1 stud1   A
1 2 stud2   B
2 3 stud3   C
3 4 stud4   A
4 5 stud5   A
Output −
And the result for ‘A’ grade students name,
0    stud1
3    stud4
4    stud5
To solve this, we will follow the below approaches.
Define a DataFrame
Define a DataFrame
Compare the value to the DataFrame
Compare the value to the DataFrame
df[df['Grade']=='A']
Store the result in another DataFrame and fetch Name.
Store the result in another DataFrame and fetch Name.
Let us see the following implementation to get a better understanding.
import pandas as pd
data =
[[1,'stud1','A'],[2,'stud2','B'],[3,'stud3','C'],[4,'stud4','A'],[5,'stud5','A']]
df = pd.DataFrame(data,columns=('Id','Name','Grade'))
print("DataFrame is\n",df)
print("find the A grade students name\n")
result = df[df['Grade']=='A']
print(result['Name'])
DataFrame is
 Id Name Grade
0 1 stud1  A
1 2 stud2  B
2 3 stud3  C
3 4 stud4  A
4 5 stud5  A
find the A grade students name
0    stud1
3    stud4
4    stud5
Name: Name, dtype: object
AWT AdjustmentListener Interface

The interfaceAdjustmentListener is used  for receiving adjustment events. The class that process adjustment  events needs to implements this interface.
Following is the declaration for java.awt.event.AdjustmentListener interface:
public interface AdjustmentListener
extends EventListener
void adjustmentValueChanged(AdjustmentEvent e) 
Invoked when the value of the adjustable has changed.
This class inherits methods from the following interfaces:
java.awt.event.EventListener
java.awt.event.EventListener
Create the following java program using any editor of your choice in say D:/ > AWT > com > tutorialspoint > gui >
package com.tutorialspoint.gui;

import java.awt.*;
import java.awt.event.*;

public class AwtListenerDemo {
   private Frame mainFrame;
   private Label headerLabel;
   private Label statusLabel;
   private Panel controlPanel;

   public AwtListenerDemo(){
      prepareGUI();
   }

   public static void main(String[] args){
      AwtListenerDemo  awtListenerDemo = new AwtListenerDemo();  
      awtListenerDemo.showAdjustmentListenerDemo();
   }

   private void prepareGUI(){
      mainFrame = new Frame("Java AWT Examples");
      mainFrame.setSize(400,400);
      mainFrame.setLayout(new GridLayout(3, 1));
      mainFrame.addWindowListener(new WindowAdapter() {
         public void windowClosing(WindowEvent windowEvent){
            System.exit(0);
         }        
      });    
   
      headerLabel = new Label();
      headerLabel.setAlignment(Label.CENTER);
      statusLabel = new Label();        
      statusLabel.setAlignment(Label.CENTER);
      statusLabel.setSize(350,100);

      controlPanel = new Panel();
      controlPanel.setLayout(new FlowLayout());

      mainFrame.add(headerLabel);
      mainFrame.add(controlPanel);
      mainFrame.add(statusLabel);
      mainFrame.setVisible(true);  
   }

   private void showAdjustmentListenerDemo(){
      headerLabel.setText("Listener in action: AdjustmentListener");      

      ScrollPane panel = new ScrollPane();      
      panel.setBackground(Color.magenta);
      panel.getHAdjustable().addAdjustmentListener(new CustomAdjustmentListener());

      Label msglabel = new Label();
      msglabel.setAlignment(Label.CENTER);   
      msglabel.setText("Welcome to TutorialsPoint AWT Tutorial.");
      panel.add(msglabel);
      
      controlPanel.add(panel);
      mainFrame.setVisible(true);  
   }

   class CustomAdjustmentListener implements AdjustmentListener {
      public void adjustmentValueChanged(AdjustmentEvent e) {
         statusLabel.setText("Adjustment value: "+Integer.toString(e.getValue()));
      }
   }
}
Compile the program using command prompt. Go to D:/ > AWT  and type the following command.
D:\AWT>javac com\tutorialspoint\gui\AwtListenerDemo.java
If no error comes that means compilation is successful. Run the program using following command.
D:\AWT>java com.tutorialspoint.gui.AwtListenerDemo
Verify the following output

    13 Lectures 
     2 hours 

 EduOLC
 Print
 Add Notes
 Bookmark this page
Ionic - Tabs

Ionic tabs are most of the time used for mobile navigation. Styling is optimized for different platforms. This means that on android devices, tabs will be placed at the top of the screen, while on IOS it will be at the bottom. There are different ways of creating tabs. We will understand in detail, how to create tabs in this chapter.
Simple Tabs menu can be created with a tabs class. For the inside element that is using this class, we need to add tab-item elements. Since tabs are usually used for navigation, we will use <a> tags for tab items. The following example is showing a menu with four tabs.
<div class = "tabs">
   <a class = "tab-item">
      Tab 1
   </a>
	
   <a class = "tab-item">
      Tab 2
   </a>

   <a class = "tab-item">
      Tab 3
   </a>
</div>
The above code will produce the following screen −
Ionic provides classes for adding icons to tabs. If you want your tabs to have icons without any text, a tabs-icon-only class should be added after the tabs class. Of course, you need to add icons you want to display.
<div class = "tabs tabs-icon-only">
   <a class = "tab-item">
      <i class = "icon ion-home"></i>
   </a>
	
   <a class = "tab-item">
      <i class = "icon ion-star"></i>
   </a>
	
   <a class = "tab-item">
      <i class = "icon ion-planet"></i>
   </a>
</div>
The above code will produce the following screen −
You can also add icons and text together. The tabs-icon-top and tabs-icon-left are classes that will place the icon above or on the left side respectively. Implementation is the same as the example given above, we will just add a new class and text that we want to use. The following example shows icons placed above the text.
<div class = "tabs tabs-icon-top">
   <a class = "tab-item">
      <i class = "icon ion-home"></i>
      Tab 1
   </a>
	
   <a class = "tab-item">
      <i class = "icon ion-star"></i>
      Tab 2
   </a>
	
   <a class = "tab-item">
      <i class = "icon ion-planet"></i>
      Tab 3
   </a>
</div>
The above code will produce the following screen −
Striped Tabs can be created by adding a container around our tabs with the tabs-striped class. This class allows the usage of the tabs-background and the tabs-color prefixes for adding some of the Ionic colors to the tabs menu.
In the following example, we will use the tabs-background-positive (blue) class to style the background of our menu, and the tabs-color-light (white) class to style the tab icons. Notice the difference between the second tab that is active and the other two that are not.
<div class = "tabs-striped tabs-background-positive tabs-color-light">
   <div class = "tabs">
      <a class = "tab-item">
         <i class = "icon ion-home"></i>
      </a>
		
      <a class = "tab-item active">
         <i class = "icon ion-star"></i>
      </a>
		
      <a class = "tab-item">
         <i class = "icon ion-planet"></i>
      </a>
   </div>
</div>
The above code will produce the following screen −

    16 Lectures 
     2.5 hours 

 Frahaan Hussain

    185 Lectures 
     46.5 hours 

 Nikhil Agarwal
 Print
 Add Notes
 Bookmark this page
SAS - Bar Charts

A bar chart represents data in rectangular bars with length of the bar proportional to the value of the variable. SAS uses the procedure PROC SGPLOT to create bar charts. We can draw both simple and stacked bars in the bar chart. In bar chart each of the bars can be given different colors.
The basic syntax to create a bar-chart in SAS is −
PROC SGPLOT DATA = DATASET;
VBAR variables;
RUN;

DATASET − is the name of the dataset used.
DATASET − is the name of the dataset used.
variables − are the values used to plot the histogram.
variables − are the values used to plot the histogram.
A simple bar chart is a bar chart in which a variable from the dataset is represented as bars.
The below script will create a bar-chart representing the length of cars as bars.
PROC SQL;
create table CARS1 as
SELECT make, model, type, invoice, horsepower, length, weight
   FROM 
   SASHELP.CARS
   WHERE make in ('Audi','BMW')
;
RUN;

proc SGPLOT data = work.cars1;
vbar length ;
title 'Lengths of cars';
run;
quit;

When we execute the above code, we get the following output −
A stacked bar chart is a bar chart in which a variable from the dataset is calculated with respect to another variable.
The below script will create a stacked bar-chart where the length of the cars are calculated for each car type. We use the group option to specify the second variable.
proc SGPLOT data = work.cars1;
vbar length /group = type ;
title 'Lengths of Cars by Types';
run;
quit;

When we execute the above code, we get the following output −
The clustered bar chart is created to show how the values of a variable are spread across a culture.
The below script will create a clustered bar-chart where the length of the cars is clustered around the car type.So we see two adjacent bars at length 191, one for the car type 'Sedan' and another for the car type 'Wagon'.
proc SGPLOT data = work.cars1;
vbar length /group = type GROUPDISPLAY = CLUSTER;
title 'Cluster of Cars by Types';
run;
quit;

When we execute the above code, we get the following output −

    50 Lectures 
     5.5 hours 

 Code And Create

    124 Lectures 
     30 hours 

 Juan Galvan

    162 Lectures 
     31.5 hours 

 Yossef Ayman Zedan

    35 Lectures 
     2.5 hours 

 Ermin Dedic

    167 Lectures 
     45.5 hours 

 Muslim Helalee
 Print
 Add Notes
 Bookmark this page
How to create boxplot for matrix columns in R?

To create a boxplot for data frame columns we can simply use boxplot function but it cannot be done directly for matrix columns. If we want to create boxplot for matrix columns then we need to convert the matrix into data frame and then use the boxplot function. For example, if we have a matrix called M then the boxplot for columns in M can be created by using boxplot(as.data.frame(M)).
Live Demo
> M<-matrix(rnorm(150,2,0.35),ncol=5)
> M
[,1] [,2] [,3] [,4] [,5]
[1,] 1.688556 1.697216 1.9469573 1.873956 2.010246
[2,] 1.655357 1.927145 2.0937415 2.273638 1.966972
[3,] 1.886917 1.182852 2.0291452 2.507944 2.338664
[4,] 2.013053 1.995526 1.8122830 2.531708 2.483359
[5,] 1.812015 1.950053 1.8902859 2.453222 2.123253
[6,] 1.781764 1.786285 2.3384120 2.275382 2.509708
[7,] 1.836378 1.192781 1.5382031 2.012324 2.290340
[8,] 2.061482 1.705481 2.5542404 1.958202 1.991252
[9,] 2.162214 1.958862 1.8096081 1.810033 1.856942
[10,] 1.897020 1.614834 2.3407207 2.199068 1.807968
[11,] 2.491147 2.317192 2.4486029 2.131722 1.947841
[12,] 1.860307 1.932982 2.2034280 1.982581 2.720482
[13,] 1.814205 2.214286 1.6917036 1.854341 2.150684
[14,] 1.224437 1.800944 1.7600398 1.503382 2.775012
[15,] 2.309462 2.534766 1.5111472 2.058761 1.823550
[16,] 2.190564 1.588298 1.8854163 1.694651 1.939035
[17,] 2.521611 2.339012 2.2959581 2.501148 1.951673
[18,] 1.808799 2.314207 1.8704730 1.937851 1.877917
[19,] 2.476626 1.806194 2.7111663 2.156506 1.521197
[20,] 1.819725 1.633549 1.9438948 2.213533 2.247944
[21,] 2.412117 1.797531 2.5320892 1.889267 2.586912
[22,] 1.679395 2.276218 1.6120445 1.648766 1.889033
[23,] 2.286285 2.221312 0.9408758 1.896072 1.996449
[24,] 2.274975 2.398884 2.0146319 1.814092 2.350100
[25,] 2.106620 1.640401 1.6416454 2.452356 1.638885
[26,] 1.556329 1.706762 1.8324196 2.348518 1.593293
[27,] 2.171867 1.707615 1.9667116 2.191344 1.595531
[28,] 1.796751 2.753674 2.1741976 1.623239 2.399018
[29,] 2.635992 2.180735 2.2114669 2.258419 2.277367
[30,] 1.874671 2.113165 2.3653358 2.231705 1.919449
> boxplot(as.data.frame(M))
How can we alter a MySQL stored procedure?

If we have ALTER ROUTINE privileges for the procedure then with the help of ALTER PROCEDURE statement we can alter a MySQL stored procedure. To demonstrate it we are taking an example of a stored procedure named ‘delete_studentinfo’ which have the following create a statement −
mysql> SHOW CREATE PROCEDURE Delete_studentinfo\G
*************************** 1. row ***************************
           Procedure: Delete_studentinfo
            sql_mode: ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_
ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
    Create Procedure: CREATE DEFINER=`root`@`localhost` PROCEDURE `Delete_studentinfo`( IN p_id INT)
BEGIN
DELETE FROM student_info
WHERE ID=p_id;
END
character_set_client: cp850
collation_connection: cp850_general_ci
  Database Collation: latin1_swedish_ci
1 row in set (0.01 sec)
In the above result set, it is clear that there is no comment in the stored procedure ‘delete_studentinfo’. Now, with the help of ALTER PROCEDURE statement, we can add a comment as follows −
mysql> ALTER PROCEDURE Delete_studentinfo
   -> COMMENT 'deleting the record'//
Query OK, 0 rows affected (0.03 sec)
Now, it can be confirmed, that comments have been added in the stored procedure, with the help of result set of the following query −
mysql> SHOW CREATE PROCEDURE Delete_studentinfo\G
*************************** 1. row ***************************
           Procedure: Delete_studentinfo
            sql_mode: ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_
ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
    Create Procedure: CREATE DEFINER=`root`@`localhost` PROCEDURE `Delete_studen
tinfo`( IN p_id INT)
   COMMENT 'deleting the record'
BEGIN
DELETE FROM student_info
WHERE ID=p_id;
END
character_set_client: cp850
collation_connection: cp850_general_ci
  Database Collation: latin1_swedish_ci
1 row in set (0.00 sec)
How to Get Windows features using PowerShell?

To get the windows features and roles available or installed using PowerShell, you need to use the Get-WIndowsFeature cmdlet. That is obvious that Windows features and roles are available only on the server operating systems not on the client operating system.
When you run the Get-WindowsFeature on the server operating system from Windows server 2008 onwards using PowerShell, you will get the output as below.
The crossed symbol in the square box indicates that the feature is installed. You can also check the same using ‘Install State’. To get only Installed features on the server, you need to filter out the Install state feature.
Get-WindowsFeature | where{$_.InstallState -eq "Installed"}
To get the windows features/roles which are not installed, you need to filter out the Install State with property value “Available” or using the NOT operator by the INSTALLED value.
Get-WindowsFeature | where{!($_.InstallState -eq "Installed")}
If you need to find a specific feature/role, you just need to type the Name or Display Name. If you don’t know the full name of the feature/role, the wildcard character is allowed to complete the search operation. For example,
Get-WindowsFeature *Remote*
To check the installed features on the remote servers, you need to run the above command with -ComputerName parameter. For example, we need to retrieve two features RemoteAccess and ADRMS then we can use the below command.
Get-WindowsFeature -ComputerName Test1-Win2k16 -Name ADRMS,Remoteaccess

If you need to retrieve windows feature information from multiple remote servers then you can use Invoke-Command because Get-WindowsFeature command with -ComputerName parameter doesn’t support the array and with Invoke-Command, you can also get the computer name on which particular features are installed. For example,
Invoke-Command -ComputerName Test1-Win2k16,Test1-Win2k12 -ScriptBlock{Get- WindowsFeature ADRMS,RemoteAccess}
You can also search the windows feature using Wildcard character (*). For example,
Invoke-Command -ComputerName Test1-win2k16 -ScriptBlock{Get-WindowsFeature *Backup*}
JavaScript Array constructor Property - GeeksforGeeks

01 Oct, 2021
Below is the example of the Array constructor property.  
Example:  
html
<!DOCTYPE html><html>    <head>        <title>            JavaScript Array constructor Property        </title>    </head>     <body style="text-align: center;">        <h1 style="color: green;">            GeeksforGeeks        </h1>         <b>JavaScript | Array constructor Property</b>        <br>        <button onclick="myGeeks()">            Submit        </button>         <p id="sudo"></p>           <!-- Script for array constructor -->        <script>            function myGeeks() {                var name = ["sahil", "Manas",                            "Sagar", "Harshit"];                document.getElementById("sudo").innerHTML =                  name.constructor;            }        </script>    </body></html>   
Output:
The JavaScript Array constructor property is used to return the constructor function for an array object. It only returns the reference of the function and not returns the name of the function. So, In JavaScript arrays, it returns the function Array() { [native code] }.Syntax:  
array.constructor
Return value: It returns the function reference i.e. function Array() { [native code] }.More example codes for the above property are as follows: Program 1:  
html
<script type = "text/javascript">        var arr = new Array( "Geeks", "for", "Geeks");        document.write("arr.constructor:" + arr.constructor);</script>   
Output:  
arr.constructor:function Array() { [native code] }
Program 2:  
html
<script type = "text/javascript">        var arr = new Array( 5, 10, 15);        document.write("arr.constructor:" + arr.constructor);</script>   
Output:  
arr.constructor:function Array() { [native code] }
Supported Browsers: The browsers supported by JavaScript Array constructor Property are listed below:  
Google Chrome 1 and above
Edge 12 and above
Firefox 1 and above
Internet Explorer 4 and above
Opera 4 and above
Safari 1 and above
 
arorakashish0911
ysachin2314
javascript-array
JavaScript-Properties
Picked
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Remove elements from a JavaScript Array
Convert a string to an integer in JavaScript
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
How to append HTML code to a div using JavaScript ?
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to convert DateTime to String using PHP ? - GeeksforGeeks

14 Jun, 2021
The task is to convert DateTime to String using PHP. There are two ways to convert it.  
In the Format method, we can convert the DateTime object to a string.
The DateTime to string program is programmed below:
Example:
PHP
<?php  // Store datetime in variable today$today = date("d/m/Y H:i:s");      if ($today) {     echo $today;   // If unknown time } else {      echo "can't display time"; }?>
Output:
07/05/2021 17:57:38

2. By using list() method:
The list() method is used to convert the DateTime object to string.
The shorter way of list method is programmed below:
PHP
<?PHP  // Using list method to display the datetimelist($day, $month, $year, $hour, $min, $sec)         = explode("/", date('d/m/Y/h/i/s'));   // Display the datetimeecho $month . '/' . $day . '/' . $year . ' '    . $hour . ':' . $min . ':' . $sec;  ?>
Output:
05/07/2021 05:58:48
PHP-date-time
PHP-function
PHP-Questions
PHP-string
Picked
PHP
Web Technologies
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to execute PHP code using command line ?
How to Insert Form Data into Database using PHP ?
How to convert array to string in PHP ?
PHP in_array() Function
How to pop an alert message box using PHP ?
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?