code-rag-bench/online-tutorials huggingface dataset:
How to populate select list with jQuery?

To populate select list with jQuery, use for loop along with append() and append the options to the already created select.
Let’s say we have the following select with options −
<select id="customerNameList" name="customer">
<option value="John">John</option>
<option value="David">David</option>
</select>
Following is the code to append more number of options using append() −
 Live Demo
<!DOCTYPE html>
<html lang="en">
<head>
   <meta charset="UTF-8">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <title>Document</title>
</head>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<body>
   <select id="customerNameList" name="customer">
      <option value="John">John</option>
      <option value="David">David</option>
   </select>
</body>
<script>
$(document).ready(function () {
   var data = [
      { "name": "Bob", "customerName": "Bob" },
      { "name": "Mike", "customerName": "Mike" }
   ];
   for (var index = 0; index <= data.length; index++) {
      $('#customerNameList').append('<option value="' + data[index].name + '">' + data[index].customerName + '</option>');
   }
});
</script>
</html>
To run the above program, save the file name anyName.html (index.html). Right click on the file and select the option “Open with Live Server” in VS Code editor.
The output is as follows −
How to use variable-length arguments in a function in Python?

In Python, the single-asterisk form of *args can be used as a parameter to send a non-keyworded variable-length argument list to functions. It is seen that the asterisk (*) is important here, and along with the word args it means there is a variable length list of non-keyworded arguments.
def multiply(*args):
    y = 1  
    for num in args:
        y *= num
    print(y)
multiply(3, 7)
multiply(9, 8)
multiply(3, 4, 7)
multiply(5, 6, 10, 8)
21
72
84
2400
Explain the concept of grammar in TOC

Grammar in theory of computation is a finite set of formal rules that are generating syntactically correct sentences.
The formal definition of grammar is that it is defined as four tuples −
G=(V,T,P,S)
G is a grammar, which consists of a set of production rules. It is used to generate the strings of a language.
G is a grammar, which consists of a set of production rules. It is used to generate the strings of a language.
T is the final set of terminal symbols. It is denoted by lower case letters.
T is the final set of terminal symbols. It is denoted by lower case letters.
V is the final set of non-terminal symbols. It is denoted by capital letters.
V is the final set of non-terminal symbols. It is denoted by capital letters.
P is a set of production rules, which is used for replacing non-terminal symbols (on the left side of production) in a string with other terminals (on the right side of production).
P is a set of production rules, which is used for replacing non-terminal symbols (on the left side of production) in a string with other terminals (on the right side of production).
S is the start symbol used to derive the string.
S is the start symbol used to derive the string.
Grammar is composed of two basic elements
Terminal Symbols - Terminal symbols are the components of the sentences that are generated using grammar and are denoted using small case letters like a, b, c etc.
Non-Terminal Symbols - Non-Terminal Symbols take part in the generation of the sentence but are not the component of the sentence. These types of symbols are also called Auxiliary Symbols and Variables. They are represented using a capital letter like A, B, C, etc.
Consider a grammar
G = (V , T , P , S)
Where,
V = { S , A , B }    ⇒ Non-Terminal symbols
T = { a , b }        ⇒ Terminal symbols
Production rules    P = { S → ABa , A → BB , B → ab , AA → b }
S = { S }           ⇒ Start symbol
Consider a grammar
G=(V,T,P,S)
Where,
V= {S, A, B}    ⇒ non terminal symbols
T = { 0,1}      ⇒ terminal symbols
Production rules P = { S→A1B
                 A→0A| ε
                 B→0B| 1B| ε }
S= {S}          ⇒ start symbol.
The different types of grammar −
The diagram representing the types of grammar in the theory of computation (TOC) is as follows −
Java Iterator

An Iterator is an object that can be used to loop through collections, like ArrayList
and HashSet. It is called an "iterator" because "iterating" is the technical term for looping.
To use an Iterator, you must import it from the java.util package.
The iterator() method can be used to get an Iterator for any collection:
// Import the ArrayList class and the Iterator class
import java.util.ArrayList;
import java.util.Iterator;

public class Main {
  public static void main(String[] args) {

    // Make a collection
    ArrayList<String> cars = new ArrayList<String>();
    cars.add("Volvo");
    cars.add("BMW");
    cars.add("Ford");
    cars.add("Mazda");

    // Get the iterator
    Iterator<String> it = cars.iterator();

    // Print the first item
    System.out.println(it.next());
  }
}


Try it Yourself »

To loop through a collection, use the hasNext() and next() methods of the Iterator:
while(it.hasNext()) {
  System.out.println(it.next());
}

Try it Yourself »

Iterators are designed to easily change the collections that they loop through. The remove() method can remove items from a collection while looping.
Use an iterator to remove numbers less than 10 from a collection:
import java.util.ArrayList;
import java.util.Iterator;

public class Main {
  public static void main(String[] args) {
    ArrayList<Integer> numbers = new ArrayList<Integer>();
    numbers.add(12);
    numbers.add(8);
    numbers.add(2);
    numbers.add(23);
    Iterator<Integer> it = numbers.iterator();
    while(it.hasNext()) {
      Integer i = it.next();
      if(i < 10) {
        it.remove();
      }
    }
    System.out.println(numbers);
  }
}

Try it Yourself »

Note: Trying to remove items using a for loop or a 
for-each loop would not work correctly
because the collection is changing size at the same time that the code is trying to loop.
We just launchedW3Schools videos
Get certifiedby completinga course today!
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com
Your message has been sent to W3Schools.
Can We declare main() method as Non-Static in java?

The public static void main(String ar[]) method is the entry point of the execution in Java. When we run a .class file JVM searches for the main method and executes the contents of it line by line.
You can write the main method in your program without the static modifier, the program gets compiled without compilation errors. 
But, at the time of execution JVM does not consider this new method (without static) as the entry point of the program.  It searches for the main method which is public, static, with return type void, and a String array as an argument.
public static int main(String[] args){
}
If such a method is not found, a run time error is generated.
In the following Java program in the class Sample, we have a main method which is public, returns nothing (void), and accepts a String array as an argument. But, not static.
 Live Demo
import java.util.Scanner;
public class Sample{
   public void main(String[] args){
      System.out.println("This is a sample program");
   }
}
On executing, this program generates the following error −
Error: Main method is not static in class Sample, please define the main method as − public static void main(String[] args)
C/C++ Program to Find the Number Occurring Odd Number of Times?

In this program we will see how we can get a number that is occurring odd number of times in an array. There are many different approaches. One of the easiest approach is performing ZOR operation. If a number is XORed with itself, it will be 0. So if a number XORed even number of times, it will be 0, otherwise the number itself.
This solution has one problem, if more than one element has odd number of occurrences, it will return one of them.
begin
   res := 0
   for each element e from arr, do
      res := res XOR e
   done
   return res
end
 Live Demo
#include <iostream>
using namespace std;
int getNumOccurredOdd(int arr[], int n) {
   int res = 0;
   for (int i = 0; i < n; i++)
      res = res ^ arr[i];
   return res;
}
int main() {
   int arr[] = {3, 4, 6, 5, 6, 3, 5, 4, 6, 3, 5, 5, 3};
   int n = sizeof(arr)/sizeof(arr[0]);
   cout << getNumOccurredOdd(arr, n) << " is present odd number of times";
}
6 is present odd number of times
How do I run two or more functions when using 'onclick' JavaScript?

Let’s first set a button −
<button type="submit" onclick="callTwoOtherFunctions()"> Call </button>
Above, we have set a function under “onclick” to call two other functions −
function callTwoOtherFunctions(){
   fun1();
   fun2();
}
In this way, work around the fun1() and fun2() as in the complete code below −
 Live Demo
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initialscale=1.0">
<title>Document</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
</head>
<body>
<button type="submit" onclick="callTwoOtherFunctions()"> Call
</button>
<script>
   function callTwoOtherFunctions(){
      fun1();
      fun2();
   }
   function fun1(){
      console.log("Function1()")
   }
   function fun2(){
      console.log("Function2()")
   }
</script>
</body>
</html>
To run the above program, save the file name “anyName.html(index.html)” and right click on the
file. Select the option “Open with Live Server” in VS Code editor.
This will produce the following output −
When you click on the Call button, you will get the following output. The snapshot is as follows −
Python | Remove Reduntant Substrings from Strings List - GeeksforGeeks

13 Jul, 2021
Given list of Strings, task is to remove all the strings, which are substrings of other Strings.
Input : test_list = [“Gfg”, “Gfg is best”, “Geeks”, “for”, “Gfg is for Geeks”] Output : [‘Gfg is best’, ‘Gfg is for Geeks’] Explanation : “Gfg”, “for” and “Geeks” are present as substrings in other strings.Input : test_list = [“Gfg”, “Geeks”, “for”, “Gfg is for Geeks”] Output : [‘Gfg is for Geeks’] Explanation : “Gfg”, “for” and “Geeks” are present as substrings in other strings. 
Method #1 : Using enumerate() + join() + sort() 
The combination of above functions can be used to solve this problem. In this, first the sorting is performed on length parameter, and current word is checked with other words, if it occurs as substring, if yes, its excluded from filtered result.
Python3
# Python3 code to demonstrate working of# Remove Reduntant Substrings from Strings List# Using enumerate() + join() + sort() # initializing listtest_list = ["Gfg", "Gfg is best", "Geeks", "Gfg is for Geeks"] # printing original listprint("The original list : " + str(test_list)) # using loop to iterate for each stringtest_list.sort(key = len)res = []for idx, val in enumerate(test_list):         # concatenating all next values and checking for existence    if val not in ', '.join(test_list[idx + 1:]):        res.append(val) # printing resultprint("The filtered list : " + str(res))
The original list : ['Gfg', 'Gfg is best', 'Geeks', 'Gfg is for Geeks']
The filtered list : ['Gfg is best', 'Gfg is for Geeks']
Method #2 : Using list comprehension + join() + enumerate()
The combination of above functions can be used to solve this problem. In this, we perform task in similar way as above just the difference being in more compact way in list comprehension.
Python3
# Python3 code to demonstrate working of# Remove Reduntant Substrings from Strings List# Using list comprehension + join() + enumerate() # initializing listtest_list = ["Gfg", "Gfg is best", "Geeks", "Gfg is for Geeks"] # printing original listprint("The original list : " + str(test_list)) # using list comprehension to iterate for each string# and perform join in one linertest_list.sort(key = len)res = [val for idx, val in enumerate(test_list) if val not in ', '.join(test_list[idx + 1:])] # printing resultprint("The filtered list : " + str(res))
The original list : ['Gfg', 'Gfg is best', 'Geeks', 'Gfg is for Geeks']
The filtered list : ['Gfg is best', 'Gfg is for Geeks']
anikakapoor
Python list-programs
Python string-programs
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
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | Pandas dataframe.groupby()
Defaultdict in Python
Python | Get unique values from a list
Python Classes and Objects
Python | os.path.join() method
Create a directory in Python
ENDOFYEAR function

Returns the last date of the year in the current context for the specified column of dates.
ENDOFYEAR (<dates>, [<year_end_date>]) 

dates
A column that contains dates.
year_end_date
Optional.
A literal string with a date that defines the year-end date.
If omitted, the default is December 31.
A table containing a single column and a single row with a date value.
The dates parameter can be any of the following −
A reference to a date/time column.
A reference to a date/time column.
A table expression that returns a single column of date/time values.
A table expression that returns a single column of date/time values.
A Boolean expression that defines a single-column table of date/time values.
A Boolean expression that defines a single-column table of date/time values.
Constraints on Boolean expressions −
The expression cannot reference a calculated field.
The expression cannot reference a calculated field.
The expression cannot use CALCULATE function.
The expression cannot use CALCULATE function.
The expression cannot use any function that scans a table or returns a table, including aggregation functions.
The expression cannot use any function that scans a table or returns a table, including aggregation functions.
However, a Boolean expression can use any function that looks up a single value, or that calculates a scalar value.
However, a Boolean expression can use any function that looks up a single value, or that calculates a scalar value.
= ENDOFYEAR (Sales [Date]) 

    53 Lectures 
     5.5 hours 

 Abhay Gadiya

    24 Lectures 
     2 hours 

 Randy Minder

    26 Lectures 
     4.5 hours 

 Randy Minder
 Print
 Add Notes
 Bookmark this page
How to set preferred Size for BoxLayout Manager in Java?

Let’s say we have a Frame with layout set as BoxLayout −
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(new BoxLayout(frame.getContentPane(), BoxLayout.Y_AXIS));
Set the preferred size using setPreferredSize() and withing that specify the values for width and height −
JPanel panel = new JPanel();
panel.setPreferredSize(new Dimension(100, 500));
The following is an example to set preferred size for BoxLayout Manager in Java −
package my;
import java.awt.Component;
import java.awt.Dimension;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class SwingDemo {
   public static void main(String[] args) {
      JFrame frame = new JFrame();
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.getContentPane().setLayout(new BoxLayout(frame.getContentPane(), BoxLayout.Y_AXIS));
      JPanel panel = new JPanel();
      JButton btn1 = new JButton("One");
      JButton btn2 = new JButton("Two");
      JButton btn3 = new JButton("Three");
      JButton btn4 = new JButton("Four");
      JButton btn5 = new JButton("Five");
      panel.add(btn1);
      panel.add(btn2);
      panel.add(btn3);
      panel.add(btn4);
      panel.add(btn5);
      panel.setAlignmentX(Component.LEFT_ALIGNMENT);
      panel.setPreferredSize(new Dimension(100, 500));
      panel.setMaximumSize(new Dimension(100, 500));
      panel.setBorder(BorderFactory.createTitledBorder("demo"));
      frame.getContentPane().add(panel);
      frame.setSize(550, 300);
      frame.setVisible(true);
   }
}
Playit

background-image:url('w3css.gif');    background-repeat:no-repeat;    background-position:left top;}
MySQL Query a List of Values?

To query a list of values, you can use IN operator. The syntax is as follows −
SELECT * FROM yourTableName WHERE yourColumnName IN(Value1,Value2,...N) ORDER BY FIELD(yourColumnName,Value1,Value2,...N);
To understand the above syntax, let us create a table. The query to create a table is as follows −
mysql> create table ListOfValues
   -> (
   -> Id int NOT NULL AUTO_INCREMENT,
   -> Name varchar(30),
   -> Age int,
   -> PRIMARY KEY(Id)
   -> );
Query OK, 0 rows affected (0.72 sec)
Insert some records in the table using insert command. The query is as follows −
mysql> insert into ListOfValues(Name,Age) values('Carol',23);
Query OK, 1 row affected (0.14 sec)

mysql> insert into ListOfValues(Name,Age) values('Bob',25);
Query OK, 1 row affected (0.17 sec)

mysql> insert into ListOfValues(Name,Age) values('Sam',26);
Query OK, 1 row affected (0.16 sec)

mysql> insert into ListOfValues(Name,Age) values('John',20);
Query OK, 1 row affected (0.37 sec)

mysql> insert into ListOfValues(Name,Age) values('Mike',28);
Query OK, 1 row affected (0.13 sec)

mysql> insert into ListOfValues(Name,Age) values('David',27);
Query OK, 1 row affected (0.21 sec)

mysql> insert into ListOfValues(Name,Age) values('Larry',21);
Query OK, 1 row affected (0.20 sec)
Now you can display all records from the table using a select statement. The query is as follows −
mysql> select *from ListOfValues;
The following is the output −
+----+-------+------+
| Id | Name  | Age  |
+----+-------+------+
|  1 | Carol |   23 |
|  2 | Bob   |   25 |
|  3 | Sam   |   26 |
|  4 | John  |   20 |
|  5 | Mike  |   28 |
|  6 | David |   27 |
|  7 | Larry |   21 |
+----+-------+------+
7 rows in set (0.00 sec)
Here is the query to get the list of values on the basis of the Age column. The query is as follows −
mysql> select *from ListOfValues where Age IN(20,21,23,25,26,27,28)
-> order by field(Age,20,21,23,25,26,27,28);
The following is the output.
+----+-------+------+
| Id | Name  | Age  |
+----+-------+------+
|  4 | John  |   20 |
|  7 | Larry |   21 |
|  1 | Carol |   23 |
|  2 | Bob   |   25 |
|  3 | Sam   |   26 |
|  6 | David |   27 |
|  5 | Mike  |   28 |
+----+-------+------+
7 rows in set (0.06 sec)
How to get an attribute value of an element in Selenium Webdriver?

We can get an attribute value of an element in the Selenium Webdriver. This is achieved with the help of the getAttribute method. In an html document, each element is identified with its tagname along with the element attributes with their values. To get an attribute value, we have to pass the element attribute as an argument to the getAttribute method.
Let us see the html code of an element and obtain the value of its src attribute. The value of its src attribute shall be /about/images/logo.png.
Code Implementation.
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import java.util.concurrent.TimeUnit;
public class AttributeVal{
   public static void main(String[] args) {
      System.setProperty("webdriver.chrome.driver",
      "C:\\Users\\ghs6kor\\Desktop\\Java\\chromedriver.exe");
      WebDriver driver = new ChromeDriver();

      //implicit wait
      driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);

      //application launch
      driver.get("https://www.tutorialspoint.com/about/about_careers.htm");

      // identify element
      WebElement l=driver.findElement(By.className("tp-logo"));

      // getAttribute() to get src value
      String value = l.getAttribute("src");
      System.out.println("Src attribute is: "+ value);

      //browser close
      driver.close()
   }
}
How to declare a variable in C++?

In C++, declaration and definition are often confused. A declaration means (in C) that you are telling the compiler about type, size and in case of function declaration, type and size of its parameters of any variable, or user-defined type or function in your program. No space is reserved in memory for any variable in case of a declaration.
The Definition on the other hand means that in additions to all the things that declaration does, space is additionally reserved in memory. You can say "DEFINITION = DECLARATION + SPACE RESERVATION".
Following are examples of declarations −
extern int a;                          // Declaring a variable a without defining it
struct _tagExample { int a; int b; };  // Declaring a struct
int myFunc (int a, int b);             // Declaring a function
While following are examples of definition −
int a;
int b = 0;
int myFunc (int a, int b) { return a + b; }
struct _tagExample example;
How to use toLowerCase () in Android textview?

This example demonstrate about How to use toLowerCase () in Android textview.
Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.
Step 2 − Add the following code to res/layout/activity_main.xml.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:app="http://schemas.android.com/apk/res-auto"
   xmlns:tools="http://schemas.android.com/tools"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:orientation="vertical"
   android:gravity="center"
   tools:context=".MainActivity" />
   <EditText
      android:id="@+id/name"
      android:layout_width="match_parent"
      android:hint="Enter name"
      android:layout_height="wrap_content" />
   <Button
      android:id="@+id/click"
      android:text="Click"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content" />
   <TextView
      android:id="@+id/textview"
      android:layout_width="wrap_content"
      android:textSize="25sp"
      android:layout_height="wrap_content" />
</LinearLayout>
In the above code, we have taken name as Edit text, when user click on button it will take data and Convert into lower letters.
Step 3 − Add the following code to src/MainActivity.java
package com.example.myapplication;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
   EditText name;
   Button button;
   TextView text;
   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      name = findViewById(R.id.name);
      button = findViewById(R.id.click);
      text = findViewById(R.id.textview);
      button.setOnClickListener(new View.OnClickListener() {
         @Override
         public void onClick(View v) {
            if (!name.getText().toString().isEmpty()) {
               if (name.getText().toString().length() > 0) {
                  String tolowercase = name.getText().toString().toLowerCase();
                  text.setText(String.valueOf(tolowercase));
               }
            } else {
               name.setError("Plz enter name");
            }
         }
      });
   }
}
Let's try to run your application. I assume you have connected your actual Android Mobile device with your computer. To run the app from android studio, open one of your project's activity files and click Run  icon from the toolbar. Select your mobile device as an option and then check your mobile device which will display your default screen &−
In the above result, enter the string as “KRISHNA” (ALL CAPS) and it returned lower case letters as krishna.
Click here to download the project code
Difference between while and do-while loop in C, C++, Java - GeeksforGeeks

06 Jun, 2019
while loop:
A while loop is a control flow statement that allows code to be executed repeatedly based on a given Boolean condition. The while loop can be thought of as a repeating if statement.Syntax :
while (boolean condition)
{
   loop statements...
}

Flowchart:
Example:
C
C++
Java
#include <stdio.h>  int main(){      int i = 5;      while (i < 10) {        printf("GFG\n");        i++;    }      return 0;}
#include <iostream>using namespace std;  int main(){      int i = 5;      while (i < 10) {        i++;        cout << "GFG\n";    }      return 0;}
import java.io.*;  class GFG {    public static void main(String[] args)    {          int i = 5;          while (i < 10) {            i++;            System.out.println("GfG");        }    }}
Chapters
descriptions off, selected
captions settings, opens captions settings dialog
captions off, selected
English
This is a modal window.
Beginning of dialog window. Escape will cancel and close the window.
End of dialog window.
GFG
GFG
GFG
GFG
GFG

do-while loop:
do while loop is similar to while loop with the only difference that it checks for the condition after executing the statements, and therefore is an example of Exit Control Loop.
Syntax:
do
{
    statements..
}
while (condition);

Flowchart:
Example:
C
C++
Java
#include <stdio.h>  int main(){      int i = 5;      do {        printf("GFG\n");        i++;    } while (i < 10);      return 0;}
#include <iostream>using namespace std;  int main(){      int i = 5;      do {        i++;        cout << "GFG\n";    } while (i < 10);      return 0;}
import java.io.*;  class GFG {    public static void main(String[] args)    {          int i = 5;          do {            i++;            System.out.println("GfG");        } while (i < 10);    }}
GFG
GFG
GFG
GFG
GFG

Here is the difference table:
Loops & Control Structure
C Language
C++
Difference Between
Java
Programming Language
School Programming
Java
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Multidimensional Arrays in C / C++
Left Shift and Right Shift Operators in C/C++
Function Pointer in C
Substring in C++
Core Dump (Segmentation fault) in C/C++
Vector in C++ STL
Inheritance in C++
Initialize a vector in C++ (6 different ways)
Map in C++ Standard Template Library (STL)
C++ Classes and Objects
numpy string operations | join() function - GeeksforGeeks

05 Feb, 2019
numpy.core.defchararray.join(sep, arr) is another function for doing string operations in numpy. For each element in arr, it returns a copy of the string in which the string elements of array have been joined by separator.
Parameters:sep : It joins elements with the string between them.arr :Input array.
Returns : Output array of str or unicode with joined elements.
Code #1 :
# Python program explaining# numpy.core.defchararray.join() method   # importing numpy import numpy as geek  # input array in_arr = geek.array(['Python', 'Numpy', 'Pandas'])print ("Input original array : ", in_arr)   # creating the separatorsep = geek.array(['-', '+', '*'])    out_arr = geek.core.defchararray.join(sep, in_arr)print ("Output joined array: ", out_arr) 
Input original array :  ['Python' 'Numpy' 'Pandas']
Output joined array:  ['P-y-t-h-o-n' 'N+u+m+p+y' 'P*a*n*d*a*s']


Python numpy-String Operation
Python-numpy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Python String | replace()
*args and **kwargs in Python
Reading and Writing to text files in Python
Create a Pandas DataFrame from Lists
Convert integer to string in Python
Check if element exists in list in Python
Difference between inv() and pinv() functions in MATLAB - GeeksforGeeks

21 Aug, 2021
While Handling data, used for Machine Learning, it’s become easy to do operations on data if stored in form of a Matrix. Where inverse is one of the important operations which is used in many places while handling data. Here are below two methods to find the inverse of a matrix used in different situations.
It is used to handle Singular as well as Non-Singular Matrices, it refers to the pseudo-inverse of a matrix.
The pinv() function involves the use of floating-point arithmetic.
Syntax:
pinv(A)
Where A is a Matrix of Order M x N.
Example:
Matlab
% MatrixA = [1 2 3; 4 5 6; 7 8 9] % Using inv()pinv(A)
Output:
It is used to handle Non-Singular Matrices, it refers to inverse of a matrix.
The inv() function doesn’t involve use of floating-point arithmetic.
Syntax:
inv(A)
Where A is a Matrix of Order M x N.
Example:
Matlab
% MatrixA = [1 2 3; 4 5 6; 7 8 9] % Using inv()inv(A)
Output:
Let us Suppose there is a Matrix called A with some values in it is taken, we need to find the inverse of Matrix A using inbuilt Function, so both pinv(A) and inv(A) can be used to find the inverse of the Matrix. Consider the below program:
Matlab
% MatrixA = [1 2; 3 4] % Using inv()inv(A) % Using pinv()pinv(A)
Output: 
As we can see both functions produces the same results for a normal matrix. Now we will use a singular matrix and apply both the functions to find its inverse. 
Matlab
% MatrixA = [1 3; 2 6] % Using inv()inv(A) % Using pinv()pinv(A)
Output: 
So, we can’t use inv() in case if Matrix is singular. But using the same Matrix, the inverse can be calculated using the pinv() function.
Both pinv() and inv() are used to find the inverse of matrices in MATLAB. However, the difference is that pinv refers to pseudo inverse and inv refers to inverse. Below are some key differences between both the functions: 
 
sooda367
MATLAB-matrix
MATLAB
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Forward and Inverse Fourier Transform of an Image in MATLAB
How to Remove Noise from Digital Image in Frequency Domain Using MATLAB?
Boundary Extraction of image using MATLAB
How to Solve Histogram Equalization Numerical Problem in MATLAB?
How to Normalize a Histogram in MATLAB?
Double Integral in MATLAB
How to Remove Salt and Pepper Noise from Image Using MATLAB?
Classes and Object in MATLAB
What are different types of denoising filters in MATLAB?
How to Convert Three Channels of Colored Image into Grayscale Image in MATLAB?
ng-content in Angular - GeeksforGeeks

19 Jul, 2021
The ng-content is used when we want to insert the content dynamically inside the component that helps to increase component reusability. Using ng-content we can pass content inside the component selector and when angular parses that content that appears at the place of ng-content.
Syntax: 
<ng-content select=”.app”></ng-content>
Approach:
Create an angular app to be used.
Create a component “geek” using command “ng g c geek”.
Then we use this component inside the app component and provide the ng-content inside “geek” component.
Using ng-content we are passing two things in geek component first is person position and second is year of experience.
 
Example:
app.component.html
<app-geek>    <strong class="app">Senior Developer</strong>    <strong class="app1">Experience : 5 years</strong></app-geek><hr>  <app-geek>    <strong class="app">Application Developer</strong>    <strong class="app1">Experience : 2 years</strong></app-geek>
geek.component.html
<h3>    <span>Hello, I am </span>    <ng-content select=".app"></ng-content></h3>  <h4>    <ng-content select=".app1"></ng-content></h4>
When we need to pass multiple things inside the component selector then we have to provide them unique selector either any id or class so using that unique selector we can access particular content inside the ng-content. So here “select” inside the ng-content is used to take content with matching class name app or app1.
Output: Run this using “ng serve” command and then go to the browser and open “localhost:4200”.
AngularJS-Basics
AngularJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Angular PrimeNG Dropdown Component
Auth Guards in Angular 9/10/11
Angular PrimeNG Calendar Component
How to bundle an Angular app for production?
What is AOT and JIT Compiler in Angular ?
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 ?
Difference between var, let and const keywords in JavaScript
Python program to check if given string is vowel Palindrome

07 Jan, 2019
Given a string (may contain both vowel and consonant letters), remove all consonants, then check if the resulting string is palindrome or not.
Examples:
Input :  abcuhuvmnba
Output : YES
Explanation :
The consonants in the string "abcuhuvmnba"
are removed. Now the string becomes "auua".

Input : xayzuezyax
Output : NO

Input : bkldhgcj
Output : -1

Approach:Remove all the consonants in the string. Check if the vowel string is a palindrome. If it is a palindrome print YES, else print NO. If string contains no vowels, then print -1.
Below is the Python implementation:
# Python program to check if given # string is vowel Palindrome  # Function to check if a given string is a voweldef vowel(c):          # creating a list of vowels    v = list("aeiou")          # if the character is a vowel return True    if c in v: return True    return False  # Function to check if a vowel# string is palindromedef palindrome(s):          # create a empty list    v = []          # append all vowels into the list    for i in s:        if vowel(i):v.append(i)          # if the length of the vowel    # string is 0 then print -1    if len(v)== 0: print("-1")          # else check if it is a palindrome    else:        # create a reversed string        x = v[::-1]                  # initialize a flag        f = 1        for i in range(len(x)):                          # if the characters are not the same             if x[i]!= v[i]:                                  # set the flag to 0                f = 0                break                          if f == 1: print("YES")        else: print("NO")          # Driver Codes = 'abcuhuvmnba'  # calling the main functionpalindrome(s.strip())
YES

palindrome
vowel-consonant
Python Programs
School Programming
Strings
Technical Scripter
Strings
palindrome
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | Convert string dictionary to dictionary
Python program to add two numbers
Python Program for Binary Search (Recursive and Iterative)
Python Program for factorial of a number
Python program to find second largest number in a list
Python Dictionary
Reverse a string in Java
Arrays in C/C++
Introduction To PYTHON
Interfaces in Java
How to use Unicode and Special Characters in Tkinter ?

19 Aug, 2021
Prerequisite: Tkinter
Python offers multiple options for developing a GUI (Graphical User Interface). Out of all the GUI methods, Tkinter is the most commonly used method. It is a standard Python interface to the Tk GUI toolkit shipped with Python. Python with Tkinter is the fastest and easiest way to create GUI applications. 
In this article, we will learn how to use  Unicode & Special Characters in Tkinter.
Approach:
Make a list that contains Unicode values.
Iterate through all Unicode values and then pass in Label text
We will use the “u prefix” to display the Unicode value.
Syntax: u’\u {Unicode value}’
Example:
for "Not sign" unicode value is "00AC"

Input
u'\u00AC'

Output
¬
Below is the Implementation:-
Python3
# Import Tkinterfrom tkinter import * # Create Objectroot = Tk() # Set geometryroot.geometry("100x200") # Unicodes valuesunicodes_values = ['\u00A1','\u00A2','\u00A3','\u00A4','\u00A5','\u00A6','\u00A7'] # Iterate through all unicode valuesfor unicodes_value in unicodes_values:    Label(root, text = u'{unicodes_value}'.format(      unicodes_value = unicodes_value)).pack() # Execute Tkinterroot.mainloop()
  
Output:
 
 
kapoorsagar226
Python Tkinter-exercises
Python-tkinter
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Output of C++ Program | Set 15

27 Dec, 2016
Predict the output of following C++ programs.
Question 1
#include <iostream>using namespace std;  class A{public:    void print() { cout << "A::print()"; }};  class B : private A{public:    void print() { cout << "B::print()"; }};  class C : public B{public:    void print() { A::print(); }};  int main(){    C b;    b.print();}
Output: Compiler Error: ‘A’ is not an accessible base of ‘C’There is multilevel inheritance in the above code. Note the access specifier in “class B : private A”. Since private access specifier is used, all members of ‘A’ become private in ‘B’. Class ‘C’ is a inherited class of ‘B’. An inherited class can not access private data members of the parent class, but print() of ‘C’ tries to access private member, that is why we get the error.
Question 2
#include<iostream>using namespace std;  class base{public:    virtual void show()  { cout<<" In Base \n"; }};  class derived: public base{    int x;public:    void show() { cout<<"In derived \n"; }    derived()   { x = 10; }    int getX() const { return x;}};  int main(){    derived d;    base *bp = &d;    bp->show();    cout << bp->getX();    return 0;}
Output: Compiler Error: ‘class base’ has no member named ‘getX’In the above program, there is pointer ‘bp’ of type ‘base’ which points to an object of type derived. The call of show() through ‘bp’ is fine because ‘show()’ is present in base class. In fact, it calls the derived class ‘show()’ because ‘show()’ is virtual in base class. But the call to ‘getX()’ is invalid, because getX() is not present in base class. When a base class pointer points to a derived class object, it can access only those methods of derived class which are present in base class and are virtual.
Question 3
#include<iostream>using namespace std;  class Test{    int value;public:    Test(int v = 0) { value = v; }    int getValue()  { return value; }};  int main(){    const Test t;    cout << t.getValue();    return 0;}
Output: Compiler ErrorIn the above program, object ‘t’ is declared as a const object. A const object can only call const functions. To fix the error, we must make getValue() a const function.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above
CPP-Output
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 Programs | Set 3
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
Output of Java program | Set 15 (Inner Classes)
GATE | GATE-CS-2014-(Set-2) | Question 65

04 Oct, 2021
Let L1 = {w ∈ {0,1}∗ | w has at least as many occurrences
                                  of (110)’s as (011)’s}. 

Let L2 = { ∈ {0,1}∗ | w has at least as many occurrences
                                 of (000)’s as (111)’s}. 
Which one of the following is TRUE?(A) L1 is regular but not L2(B) L2 is regular but not L!(C) Both L2 and L1 are regular(D) Neither L1 nor L2 are regularAnswer: (A)Explanation: L1 is regularlet us consider the string 011011011011In this string, number of occurrences of 011 are 4 but when we see here 110 is also occurred and the number of occurrence of 110 is 3.
Note that if i add a 0 at the last of string we can have same number of occurrences of 011 and 110 so this string is accepted. We can say if the string is ending with 011 so by appending a 0 we can make 110 also.
Now string2: 110110110110 in this number of occurrences of 110 is 4 and 011 is 3 which already satisfy the condition
So we can observe here that whenever 110 will be there string will be accepted
So with this idea we can build an automata for this. Therefore, it is regular.
GATE PYQ's on Regular Languages with Praddyumn Shukla | GeeksforGeeks GATE - YouTubeGeeksforGeeks GATE Computer Science17.5K subscribersGATE PYQ's on Regular Languages with Praddyumn Shukla | GeeksforGeeks GATEWatch laterShareCopy linkInfoShoppingTap to unmuteIf playback doesn't begin shortly, try restarting your device.You're signed outVideos you watch may be added to the TV's watch history and influence TV recommendations. To avoid this, cancel and sign in to YouTube on your computer.CancelConfirmMore videosMore videosSwitch cameraShareInclude playlistAn error occurred while retrieving sharing information. Please try again later.Watch on0:000:0026:26 / 59:28•Live•<div class="player-unavailable"><h1 class="message">An error occurred.</h1><div class="submessage"><a href="https://www.youtube.com/watch?v=13C2qpmD9f8" target="_blank">Try watching this video on www.youtube.com</a>, or enable JavaScript if it is disabled in your browser.</div></div>Quiz of this Question
GATE-CS-2014-(Set-2)
GATE-GATE-CS-2014-(Set-2)
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | GATE-CS-2014-(Set-2) | Question 65
GATE | Sudo GATE 2020 Mock I (27 December 2019) | Question 33
GATE | GATE CS 2008 | Question 40
GATE | GATE CS 2008 | Question 46
GATE | GATE-CS-2015 (Set 3) | Question 65
GATE | GATE-CS-2014-(Set-3) | Question 65
GATE | GATE CS 2011 | Question 49
GATE | GATE CS 1996 | Question 38
GATE | GATE-CS-2004 | Question 31
GATE | GATE-CS-2016 (Set 1) | Question 45
iomanip setw() function in C++ with Examples

29 Jul, 2021
The setw() method of iomanip library in C++ is used to set the ios library field width based on the width specified as the parameter to this method.
Syntax: 
setw(int n)
Parameters: This method accepts n as a parameter which is the integer argument corresponding to which the field width is to be set.Return Value: This method does not returns anything. It only acts as stream manipulators.
Example 1: 
C++
// C++ code to demonstrate// the working of setw() function #include <iomanip>#include <ios>#include <iostream> using namespace std; int main(){     // Initializing the integer    int num = 50;     cout << "Before setting the width: \n"         << num << endl;     // Using setw()    cout << "Setting the width"         << " using setw to 5: \n"         << setw(5);     cout << num << endl;     return 0;}
Before setting the width: 
50
Setting the width using setw to 5: 
   50
 
Example 2:
C++
// C++ code to demonstrate// the working of setw() function #include <iomanip>#include <ios>#include <iostream> using namespace std; int main(){     // Initializing the integer    int num = 50;     cout << "Before setting the width: \n"         << num << endl;     // Using setw()    cout << "Setting the width"         << " using setw to 10: \n"         << setw(10);     cout << num << endl;     return 0;}
Before setting the width: 
50
Setting the width using setw to 10: 
        50
 
Reference: http://www.cplusplus.com/reference/iomanip/setw/ 
smd123
CPP-Functions
cpp-input-output
cpp-manipulators
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Bitwise Operators in C/C++
Set in C++ Standard Template Library (STL)
Priority Queue in C++ Standard Template Library (STL)
vector erase() and clear() in C++
Substring in C++
unordered_map in C++ STL
Inheritance in C++
Object Oriented Programming in C++
The C++ Standard Template Library (STL)
C++ Classes and Objects
How to Install Python sympy in Windows?

09 Sep, 2021
Sympy is a Python library for symbolic mathematics. It aims to become a full-featured computer algebra system (CAS) while keeping the code as simple as possible in order to be comprehensible and easily extensible. SymPy is written entirely in Python.  SymPy only depends on mpmath, a pure Python library for arbitrary floating-point arithmetic, making it easy to use. 
In this article, we will look into various methods of installing Sympy on Windows.
The only thing that you need for installing Sympy module on Windows are:
Python 
PIP or Conda (depending upon user preference)
If you want the installation to be done through conda, you can use the below command:
conda install sympy
Type y for yes when prompted.
You will get a similar message once the installation is complete
Make sure you follow the best practices for installation using conda as:
Use an environment for installation rather than in the base environment using the below command:
conda create -n my-env
conda activate my-env
Note: If your preferred method of installation is conda-forge, use the below command:
conda config --env --add channels conda-forge
Users who prefer to use pip can use the below command to install Sympy package on Windows:
pip install sympy
You will get a similar message once the installation is complete:
To verify if Sympy has been successfully installed in your system run the below code in a python IDE of your choice:
Python3
import sympysympy.__version__
If successfully installed you will get the following output.
Blogathon-2021
how-to-install
Picked
SymPy
Blogathon
How To
Installation Guide
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Import JSON Data into SQL Server?
SQL Query to Convert Datetime to Date
Python program to convert XML to Dictionary
Scrape LinkedIn Using Selenium And Beautiful Soup in Python
How to toggle password visibility in forms using Bootstrap-icons ?
How to Install PIP on Windows ?
How to Find the Wi-Fi Password Using CMD in Windows?
How to install Jupyter Notebook on Windows?
Java Tutorial
How to filter object array based on attributes?
Self Join and Cross Join in MS SQL Server

07 Aug, 2020
Prerequisite – Introduction of MS SQL Server
1. Self Join :Self-join allows us to join a table itself. It is useful when a user wants to compare the data (rows) within the same table.
Syntax –
select 
select_list
from T t1 [Inner|Left] Join on T t2 
on join_predicate.
Here T refers to the table we use for comparison and it is referred twice. To avoid errors and confusion, t1 and t2 are used along T for comparing two rows in the same table. Inner join or Left join is used for self join to avoid errors.2. Cross Join :Cross join allows us to join each and every row of both the tables. It is similar to the cartesian product that joins all the rows.
Syntax –
Chapters
descriptions off, selected
captions settings, opens captions settings dialog
captions off, selected
English
This is a modal window.
Beginning of dialog window. Escape will cancel and close the window.
End of dialog window.
select 
select_list 
from T1 cross join T2
Example –Student and Course tables are picked from the university database.
1. Self Join :A self-join is applied and the result set is the table below.
select n1.name, n2.name 
from Student n1 inner join Student n2 
on rollno n1 = rollno n2
2. Cross Join :Cross join is applied and the result set is the fourth table.
select *
from Student cross join Course
Additional Articles –
Full join and Inner join in MS SQL Server
Left join and Right join in MS SQL Server
DBMS-SQL
SQL-Server
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
MySQL | Regular expressions (Regexp)
Difference between OLAP and OLTP in DBMS
OLAP Guidelines (Codd's Rule)
What is Temporary Table in SQL?
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?
Window functions in SQL