code-rag-bench/online-tutorials huggingface dataset:
MySQL Tryit Editor v1.0

SELECT MID("SQL Tutorial", 5, 3) AS ExtractString;
​
        
Edit the SQL Statement, and click "Run SQL" to see the result.
This SQL-Statement is not supported in the WebSQL Database.
The example still works, because it uses a modified version of SQL.
Your browser does not support WebSQL.
Your are now using a light-version of the Try-SQL Editor, with a read-only Database.
If you switch to a browser with WebSQL support, you can try any SQL statement, and play with the Database as much as you like. The Database can also be restored at any time.
Our Try-SQL Editor uses WebSQL to demonstrate SQL.
A Database-object is created in your browser, for testing purposes.
You can try any SQL statement, and play with the Database as much as you like. The Database can be restored at any time, simply by clicking the "Restore Database" button.
WebSQL stores a Database locally, on the user's computer. Each user gets their own Database object.
WebSQL is supported in Chrome, Safari, and Opera.
If you use another browser you will still be able to use our Try SQL Editor, but a different version, using a server-based ASP application, with a read-only Access Database, where users are not allowed to make any changes to the data.
How can we call one constructor from another in the same class in C#?

Make use of this keyword in c# to call one constructor from another constructor
To call a constructor which is present in parent class make use of base keyword
class Demo{
   public Demo(){
      System.Console.WriteLine("Parameter less constructor called");
   }
   public Demo(int firstNumber, int secondNumber) : this(){
      System.Console.WriteLine($"{firstNumber} {secondNumber}");
   }
   public Demo(int firstNumber, int secondNumber, int thirdNumber) : this(firstNumber, secondNumber){
      System.Console.WriteLine($"{firstNumber} {secondNumber} {thirdNumber}");
   }
}
class Program{
   static void Main(){
      Demo obj = new Demo(1, 2, 3);
      Console.ReadLine();
   }
}
Parameter less constructor called
1 2
1 2 3
To call a constructor which is present in another class make use of base keyword
class DemoBase{
   public DemoBase(int firstNumber, int secondNumber, int thirdNumber){
      System.Console.WriteLine("Base class Constructor");
      System.Console.WriteLine($"{firstNumber} {secondNumber} {thirdNumber}");
   }
}
class Demo : DemoBase{
   public Demo(int firstNumber, int secondNumber, int thirdNumber) : base(firstNumber, secondNumber, thirdNumber){
      System.Console.WriteLine("Derived class Constructor");
      System.Console.WriteLine($"{firstNumber} {secondNumber} {thirdNumber}");
   }
}
class Program{
   static void Main(){
      Demo obj = new Demo(1, 2, 3);
      Console.ReadLine();
   }
}
Base class Constructor
1 2 3
Derived class Constructor
1 2 3
Java String replace() Method

❮ String Methods

Return a new string where all "l" characters are replaced with "p" characters:
String myStr = "Hello";
System.out.println(myStr.replace('l', 'p'));

Try it Yourself »

The replace() method searches a string for a specified 
character, and returns a new string where the specified character(s) are replaced.
public String replace(char searchChar, char newChar)

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.
Java Program to sort integers in unsorted array

Let us first create an unsorted array −
int[] arr = { 10, 14, 28, 11, 7, 16, 30, 50, 25, 18};
Now assign the unsorted array to the new array −
int[] res = arr;
Sorting the integers:
Arrays.sort(res);
 Live Demo
import java.util.Arrays;
public class Demo {
   public static void main(String[] args) {
      int[] arr = { 10, 14, 28, 11, 7, 16, 30, 50, 25, 18};
      System.out.println("The unsorted integer array = "+Arrays.toString(arr));
      int[] res = arr;
      Arrays.sort(res);
      System.out.println("The sorted integer array = "+Arrays.toString(res));
   }
}
The unsorted integer array = [10, 14, 28, 11, 7, 16, 30, 50, 25, 18]
The sorted integer array = [7, 10, 11, 14, 16, 18, 25, 28, 30, 50]
XSLT <choose>

<xsl:choose> tag specifies a multiple conditional tests against the content of nodes in conjunction with the <xsl:otherwise> and <xsl:when> elements.
Following is the syntax declaration of <xsl:choose> element.
<xsl:choose >
</xsl:choose>

Parent elements
xsl:attribute, xsl:comment, xsl:copy, xsl:element, xsl:fallback, xsl:for-each, xsl:if, xsl:message, xsl:otherwise, xsl:param, xsl:processing-instruction, xsl:template, xsl:variable, xsl:when, xsl:with-param, output elements
Child elements
xsl:otherwise, xsl:when
This example creates a table of <student> element with its attribute rollno and its child <firstname>, <lastname>, <nickname>, and <marks> by iterating over each student. It checks and then prints the grade details.
students.xml
<?xml version = "1.0"?> 
<?xml-stylesheet type = "text/xsl" href = "students.xsl"?> 
<class> 
   <student rollno = "393"> 
      <firstname>Dinkar</firstname>
      <lastname>Kad</lastname> 
      <nickname>Dinkar</nickname> 
      <marks>85</marks> 
   </student> 
   <student rollno = "493"> 
      <firstname>Vaneet</firstname> 
      <lastname>Gupta</lastname> 
      <nickname>Vinni</nickname> 
      <marks>95</marks> 
   </student> 
   <student rollno = "593"> 
      <firstname>Jasvir</firstname> 
      <lastname>Singh</lastname> 
      <nickname>Jazz</nickname> 
      <marks>90</marks> 
   </student> 
</class>
students.xsl
<?xml version = "1.0" encoding = "UTF-8"?> 
<xsl:stylesheet version = "1.0" 
   xmlns:xsl = "http://www.w3.org/1999/XSL/Transform">   
   <xsl:template match = "/"> 
      <html> 
         <body> 
            <h2>Students</h2> 
            <table border = "1"> 
               <tr bgcolor = "#9acd32"> 
                  <th>Roll No</th> 
                  <th>First Name</th> 
                  <th>Last Name</th> 
                  <th>Nick Name</th> 
                  <th>Marks</th> 
                  <th>Grade</th> 
               </tr> 
					
               <xsl:for-each select = "class/student"> 
					
                  <tr> 
                     <td><xsl:value-of select = "@rollno"/></td> 
                     <td><xsl:value-of select = "firstname"/></td> 
                     <td><xsl:value-of select = "lastname"/></td> 
                     <td><xsl:value-of select = "nickname"/></td> 
                     <td><xsl:value-of select = "marks"/></td> 
							
                     <td> 
                        <xsl:choose> 
                           <xsl:when test = "marks > 90"> 
                              High 
                           </xsl:when> 
									
                           <xsl:when test = "marks > 85"> 
                              Medium 
                           </xsl:when> 
									
                           <xsl:otherwise> 
                              Low 
                           </xsl:otherwise> 
                        </xsl:choose> 
                     </td> 
                  </tr> 
               </xsl:for-each> 
            </table> 
         </body> 
      </html> 
   </xsl:template>  
</xsl:stylesheet>
 Print
 Add Notes
 Bookmark this page
Maximum value of long long int in C++ - GeeksforGeeks

18 Dec, 2020
In this article, we will discuss the long long int data type in C++. long long int data type in C++ is used to store 64-bit integers. It is one of the largest data types to store integer values, unlike unsigned long long int both positive as well as negative.
Some properties of the long long int data type are:
Being a signed data type, it can store positive values as well as negative values.
Takes a size of 64 bits where 1 bit is used to store the sign of the integer.
A maximum integer value that can be stored in a long long int data type is typically 9, 223, 372, 036, 854, 775, 807 around 263 – 1(but is compiler dependent).
The maximum value that can be stored in long long int is stored as a constant in <climits> header file. Whose value can be used as LLONG_MAX.
A minimum integer value that can be stored in a long long int data type is typically –9, 223, 372, 036, 854, 775, 808, around –263 (but is compiler dependent).
In case of overflow or underflow of data type, the value is wrapped around. For example, if –9, 223, 372, 036, 854, 775, 808 is stored in an long long int data type and 1 is subtracted from it, the value in that variable will become equal to 9, 223, 372, 036, 854, 775, 807. Similarly, in the case of overflow, the value will round back to –9, 223, 372, 036, 854, 775, 808.
Below is the program to get the highest value that can be stored in long long int in C++:
C++
// C++ program to illustrate the maximum// value that can be stored in long long int#include <climits>#include <iostream>using namespace std;  // Driver Codeint main(){    // From the constant of climits    // header file    long long int valueFromLimits = LLONG_MAX;    cout << "Value from climits "         << "constant (maximum): ";    cout << valueFromLimits         << "\n";      valueFromLimits = LLONG_MIN;    cout << "Value from climits "         << "constant (minimum): ";    cout << valueFromLimits         << "\n";      return 0;}
Value from climits constant (maximum): 9223372036854775807
Value from climits constant (minimum): -9223372036854775808

C Basics
C-Data Types
C++
C++ Programs
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Iterators in C++ STL
Operator Overloading in C++
Friend class and function in C++
Polymorphism in C++
Inline Functions in C++
Header files in C/C++ and its uses
How to return multiple values from a function in C or C++?
C++ Program for QuickSort
C++ program for hashing with chaining
delete keyword in C++
Get count of values that only appear once in a MySQL column?

To get number of values that only appear once in a column, use GROUP BY HAVING. Let us first create a table:
mysql> create table DemoTable
(
   Name varchar(20)
);
Query OK, 0 rows affected (0.55 sec)
Following is the query to insert some records in the table using insert command:
mysql> insert into DemoTable values('Larry');
Query OK, 1 row affected (0.13 sec)
mysql> insert into DemoTable values('Larry');
Query OK, 1 row affected (0.11 sec)
mysql> insert into DemoTable values('Sam');
Query OK, 1 row affected (0.14 sec)
mysql> insert into DemoTable values('Chris');
Query OK, 1 row affected (0.14 sec)
mysql> insert into DemoTable values('Sam');
Query OK, 1 row affected (0.12 sec)
mysql> insert into DemoTable values('Mike');
Query OK, 1 row affected (0.13 sec)
mysql> insert into DemoTable values('Sam');
Query OK, 1 row affected (0.11 sec)
mysql> insert into DemoTable values('Larry');
Query OK, 1 row affected (0.21 sec)
mysql> insert into DemoTable values('Mike');
Query OK, 1 row affected (0.32 sec)
mysql> insert into DemoTable values('Mike');
Query OK, 1 row affected (0.16 sec)
mysql> insert into DemoTable values('Carol');
Query OK, 1 row affected (0.27 sec)
mysql> insert into DemoTable values('Robert');
Query OK, 1 row affected (0.27 sec)
Following is the query to display records from the table using select command:
mysql> select *from DemoTable;
This will produce the following output
+--------+
| Name |
+--------+
| Larry |
| Larry |
| Sam |
| Chris |
| Sam |
| Mike |
| Sam |
| Larry |
| Mike |
| Mike |
| Carol |
| Robert |
+--------+
12 rows in set (0.00 sec)
Following is the query to count the values that only appear once in a column i.e. the count of the
names that appears only once in the “Name” column:
mysql> SELECT COUNT(Name)
FROM (
   SELECT Name
   FROM DemoTable
   GROUP BY Name
   HAVING COUNT(*) = 1
) AS APPEAR_FIRST_TIME;
This will produce the following output
+-------------+
| COUNT(Name) |
+-------------+
|           3 |
+-------------+
1 row in set (0.00 sec)
How to install Selenium WebDriver on Mac OS?

We can install Selenium on Mac OS. We shall take the help of Homebrew package manager for installation in Mac OS. Let us follow the step by step process −
Install Selenium by running the command −
Install Selenium by running the command −
pip install selenium
Install the Chrome driver with the homebrew by running the command −
Install the Chrome driver with the homebrew by running the command −
brew cask install chromedriver
Verify the version of the Chrome driver, by running the command −
Verify the version of the Chrome driver, by running the command −
chromedriver −−version
Create a test script and try to execute after save.
Create a test script and try to execute after save.
from selenium import webdriver
# driver initialization
driver = webdriver.Chrome(executable_path="C:\\chromedriver.exe")
# launch URL
driver.get("https://www.tutorialspoint.com/index.htm")
If the below error is triggered −
If the below error is triggered −
unknown error: cannot find chrome binary
It means the version of the Chrome driver is not compatible with the Chrome browser version we are using. We have to uninstall the Chrome and then downgrade or upgrade the browser as per the driver we have.
C# program to display factors of entered number

Firstly, enter the number for which you want the factors −
Console.WriteLine("Enter the Number:");
n = int.Parse(Console.ReadLine());
After that, loop through to find the factors −
for (i = 1; i <= n; i++) {
   if (n % i == 0) {
      Console.WriteLine(i);
   }
}
You can try to run the following code to display factors of a number −
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Demo {
   class ApplicationOne {
      static void Main(string[] args) {
         int n, i;
         Console.WriteLine("Enter the Number:");
         n = int.Parse(Console.ReadLine());
         Console.WriteLine("Factors:");
         for (i = 1; i <= n; i++) {
            if (n % i == 0) {
               Console.WriteLine(i);
            }
         }
         Console.ReadLine();
      }
   }
}
Changing the colour of Tkinter Menu Bar - GeeksforGeeks

07 Apr, 2021
Prerequisites: Tkinter
Menus are an important part of any GUI. A common use of menus is to provide convenient access to various operations such as saving or opening a file, quitting a program, or manipulating data. Toplevel menus are displayed just under the title bar of the root or any other toplevel windows. 
Changing the color of menubar is not available on the Windows. This is because the menubar is not owned by Tkinter itself, but it is outsourced from other third-parties, hence providing the users limited options only. But if are using Linux, then you are all set to go. You can change the color of menubar by setting the background color and foreground color. Just read the article given below to know more in detail.
Syntax:
menubar = Menu(app, background=’#background color’, fg=’#text color’)
Here, the color to be added to the menubar is given as input to the background parameter. Given below is the proper example to do the same.
Program:
Python
# Import the library tkinterfrom tkinter import *  # Create a GUI appapp = Tk()  # Set the title and geometry to your appapp.title("Geeks For Geeks")app.geometry("800x500")  # Create menubar by setting the colormenubar = Menu(app, background='blue', fg='white')  # Declare file and edit for showing in menubarfile = Menu(menubar, tearoff=False, background='yellow')edit = Menu(menubar, tearoff=False, background='pink')  # Add commands in in file menufile.add_command(label="New")file.add_command(label="Exit", command=app.quit)  # Add commands in edit menuedit.add_command(label="Cut")edit.add_command(label="Copy")edit.add_command(label="Paste")  # Display the file and edit declared in previous stepmenubar.add_cascade(label="File", menu=file)menubar.add_cascade(label="Edit", menu=edit)  # Displaying of menubar in the appapp.config(menu=menubar)  # Make infinite loop for displaying app on screenapp.mainloop()
Output:
Picked
Python Tkinter-exercises
Python-tkinter
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
Python OOPs Concepts
Python | Get unique values from a list
Check if element exists in list in Python
Python Classes and Objects
Python | os.path.join() method
How To Convert Python Dictionary To JSON?
Python | Pandas dataframe.groupby()
Create a directory in Python
Explain Inheritance vs Instantiation for Python classes.

Being an Object Oriented language, Python supports inheritance, it even supports multiple inheritance. Classes can inherit from other classes. A class can inherit attributes and behaviour methods from another class, called the superclass. A class which inherits from a superclass is called a subclass, also called heir class or child class. In other words inheritance refers to defining a new class with little or no modification to an existing class.
class A:        # define your class A
pass
class B:         # define your class B
pass
class C(A, B):   # subclass of A and B
Instantiating a class is creating a copy of the class which inherits all class variables and methods. Instantiating a class in Python is simple. To instantiate a class, we simply call the class as if it were a function, passing the arguments that the __init__ method defines. The return value will be the newly created object.
class Foo():
        def __init__(self,x,y):
            print x+y
f = Foo(3,4)
7
Python – Check if String Contain Only Defined Characters using Regex

29 Dec, 2020
In this article, we are going to see how to check whether the given string contains only certain set of characters in Python. These defined characters will be represented using sets.
Examples:
Input: ‘657’ let us say regular expression contain following characters-(‘78653’)Output: Valid Explanation: The Input string only consist of characters present in the given string
Input: ‘7606’ let us say regular expression contain following characters-(‘102’) Output: Invalid
Approach:
Method or approach is simple we will define the character set using a regular expression. The regular expression is a special pattern or sequence of characters that will allow us to match and find other sets of characters or strings. 
Functions Used:
compile(): Regular expressions are compiled into pattern objects, which have methods for various operations such as searching for pattern matches or performing string substitutions.
search(): re.search() method either returns None (if the pattern doesn’t match), or a re.MatchObject that contains information about the matching part of the string. This method stops after the first match, so this is best suited for testing a regular expression more than extracting data.
Below is the implementation.
Python3
# _importing moduleimport re    def check(str, pattern):        # _matching the strings    if re.search(pattern, str):        print("Valid String")    else:        print("Invalid String")  # _driver codepattern = re.compile('^[1234]+$')check('2134', pattern)check('349', pattern)
Output:
Valid String
Invalid String

Python Regex-programs
python-regex
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Iterate over a list in Python
Python Classes and Objects
Convert integer to string in Python
z-score Standardization in R

24 Feb, 2021
In statistics, the task is to standardize variables which are called valvulating z-scores. Comparing two standardizing variables is the function of standardizing vector. By subtracting the vector by its mean and dividing the result by the vector’s standard deviation we can standardize a vector.
Formula:
Z= (x – mean)/standard deviation
Approach:
Declare a vector
Calculate its mean and standard deviation by the functions mean() and sd().
To create a standardized vector:Subtract mean from the vectorNow divide the above result with standard deviation
Subtract mean from the vector
Now divide the above result with standard deviation
R
a <- c(7, 8, 3, 2, 2, 10, 9)  # Finding Meanm<-mean(a)  # Finding Standard Deviations<-sd(a)  #standardized vectora.z<-(a-m)/s  a.z
Output:
[1]  0.3325644  0.6235582 -0.8314110 -1.1224048 -1.1224048  1.2055459  0.9145521
Now we can also check whether the vector has been correctly standardized or not by checking if its mean is zero and the standard deviation is one. The answer of mean is not coming exactly zero but almost zero. Which is acceptable since it is the result of computer laws.
Program:
R
a <- c(7, 8, 3, 2, 2, 10, 9)  # Finding Meanm<-mean(a)  # Finding Standard Deviations<-sd(a)  #standardized vectora.z<-(a-m)/s  mean(a.z)  sd(a.z)
Output:
[1] 1.427197e-16
[1] 1
Example 2: 
R
a <- c(10, 6, 3, 5, 4)b <- c(150, 200, 500, 600, 850)  a.z <- (a - mean(a)) / sd(a)  b.z <- (b - mean(b)) / sd(b)  average.z <- (a.z + (b.z)) / 2round(average.z, 1)
Output:
[1]  0.3 -0.4 -0.4  0.1  0.4
Picked
R-Statistics
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Change Color of Bars in Barchart using ggplot2 in R
How to Split Column Into Multiple Columns in R DataFrame?
Group by function in R using Dplyr
How to Change Axis Scales in R Plots?
How to filter R DataFrame by values in a column?
R - if statement
Logistic Regression in R Programming
Replace Specific Characters in String in R
How to import an Excel File into R ?
Joining of Dataframes in R Programming
sys.maxsize() in Python

23 Jun, 2021
maxsize attribute of the sys module fetches the largest value a variable of data type Py_ssize_t can store. It is the Python platform’s pointer that dictates the maximum size of lists and strings in Python. The size value returned by maxsize depends on the platform architecture:
32-bit: the value will be 2^31 – 1, i.e. 2147483647
64-bit: the value will be 2^63 – 1, i.e. 9223372036854775807
Syntax: sys.maxsize
Returns: maximum value of Py_ssize_t depending upon the architecture
Example 1: Let us fetch the maximum Py_ssize_t value on a 64-bit system.
Python3
# importing the moduleimport sys       # fetching the maximum valuemax_val = sys.maxsizeprint(max_val)
Output:
9223372036854775807
Example 2: Creating a list with the maximum size.
Python3
# importing the moduleimport sys       # fetching the maximum valuemax_val = sys.maxsize # creating list with max sizelist = range(max_val) # displaying the length of the listprint(len(list)) print("List successfully created")
9223372036854775807
List successfully created

Output:
9223372036854775807
List successfully created
Example 3: Trying to create a list with a size greater than the maximum size.
Python3
# importing the moduleimport sys       # fetching the maximum valuemax_val = sys.maxsize try:     # creating list with max size + 1    list = range(max_val + 1)     # displaying the length of the list    print(len(list))    print("List successfully created")     except Exception as e:     # displaying the exception    print(e)    print("List creation unsuccessful")
Python int too large to convert to C ssize_t
List creation unsuccessful

Output:
Python int too large to convert to C ssize_t
List creation unsuccessful
ruhelaa48
Python-sys
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Interfaces and Inheritance in C#

An interface is defined as a syntactical contract that all the classes inheriting the interface should follow. The interface defines the 'what' part of the syntactical contract and the deriving classes define the 'how' part of the syntactical contract.
Let us see an example of Interfaces in C#.
 Live Demo
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System;

namespace InterfaceApplication {

   public interface ITransactions {
      // interface members
      void showTransaction();
      double getAmount();
   }

   public class Transaction : ITransactions {
      private string tCode;
      private string date;
      private double amount;

      public Transaction() {
         tCode = " ";
         date = " ";
         amount = 0.0;
      }

      public Transaction(string c, string d, double a) {
         tCode = c;
         date = d;
         amount = a;
      }

      public double getAmount() {
         return amount;
      }

      public void showTransaction() {
         Console.WriteLine("Transaction: {0}", tCode);
         Console.WriteLine("Date: {0}", date);
         Console.WriteLine("Amount: {0}", getAmount());
      }
   }

   class Tester {

      static void Main(string[] args) {
         Transaction t1 = new Transaction("001", "8/10/2012", 78900.00);
         Transaction t2 = new Transaction("002", "9/10/2012", 451900.00);

         t1.showTransaction();
         t2.showTransaction();
         Console.ReadKey();
      }
   }
}
Transaction: 001
Date: 8/10/2012
Amount: 78900
Transaction: 002
Date: 9/10/2012
Amount: 451900
Inheritance allows us to define a class in terms of another class, which makes it easier to create and maintain an application. This also provides an opportunity to reuse the code functionality and speeds up implementation time.
The idea of inheritance implements the IS-A relationship. For example, mammal IS A animal, dog IS-A mammal hence dog IS-A animal as well, and so on.
The following is an example showing how to work with Inheritance in C#.
 Live Demo
using System;

namespace InheritanceApplication {
   class Shape {
      public void setWidth(int w) {
         width = w;
      }

      public void setHeight(int h) {
         height = h;
      }

      protected int width;
      protected int height;
   }

   // Derived class
   class Rectangle: Shape {
      public int getArea() {
         return (width * height);
      }
   }

   class RectangleTester {
      static void Main(string[] args) {
         Rectangle Rect = new Rectangle();
   
         Rect.setWidth(5);
         Rect.setHeight(7);

         // Print the area of the object.
         Console.WriteLine("Total area: {0}", Rect.getArea());
         Console.ReadKey();
      }
   }
}
Total area: 35
How to subset rows that do not contain NA and blank in one of the columns in an R data frame?

It is possible that we get data sets where a column contains NA as well as blank, therefore, it becomes necessary to deal with these values. One of the ways to deal with these values is selecting the rows where we do not have them. This can be done by subsetting through single square brackets.
Consider the below data frame −
> set.seed(1)
> x1<-sample(1:50,20)
> x2<-rep(c(1,"",3,4),times=5)
> x3<-rep(c(5,NA,10,"",20),each=4)
> df<-data.frame(x1,x2,x3)
> df
  x1 x2 x3
1 4 1 5
2 39 5
3 1 3 5
4 34 4 5
5 23 1 <NA>
6 43 <NA>
7 14 3 <NA>
8 18 4 <NA>
9 33 1 10
10 21 10
11 41 3 10
12 10 4 10
13 7 1
14 9
15 15 3
16 40 4
17 25 1 20
18 47 20
19 12 3 20
20 36 4 20
Subsetting rows where x3 is neither NA nor blank −
> df[!(is.na(df$x3) | df$x3==""), ]
x1 x2 x3
1 4 1 5
2 39 5
3 1 3 5
4 34 4 5
9 33 1 10
10 21 10
11 41 3 10
12 10 4 10
17 25 1 20
18 47 20
19 12 3 20
20 36 4 20
Subsetting rows where x2 is not blank −
> df[!(df$x2==""), ]
x1 x2 x3
1 4 1 5
3 1 3 5
4 34 4 5
5 23 1 <NA>
7 14 3 <NA>
8 18 4 <NA>
9 33 1 10
11 41 3 10
12 10 4 10
13 7 1
15 15 3
16 40 4
17 25 1 20
19 12 3 20
20 36 4 20
Mongoose mongoose.model() Function

05 Feb, 2021
The mongoose.model() function of the mongoose module is used to create a collection of a particular database of MongoDB. The name of the collection created by the model function is always in plural format mean GFG to gfss and the created collection imposed a definite structure.
Syntax:
mongoose.model(<Collectionname>, <CollectionSchema>)
Parameters: This function accepts the following two parameters:
Collection name: It is the name of the collection.
Collection Schema: It is the schema of the collection.
Return type: This function returns the Mongoose object.
Installing Module: Install the mongoose module using the following command:
npm install mongoose
Project Structure: Our project structure will look like this:
Running the server on Local IP: Data is the directory where MongoDB server is present.
mongod --dbpath=data --bind_ip 127.0.0.1
Filename- index.js:
Javascript
// Importing mongoose moduleconst mongoose = require("mongoose")  // Database Addressconst url = "mongodb://localhost:27017/GFG"  // Connecting to databasemongoose.connect(url).then((ans) => {  console.log("ConnectedSuccessful")}).catch((err) => {  console.log("Error in the Connection")})  // Calling Schema classconst Schema = mongoose.Schema;  // Creating Structure of the collectionconst collection_structure = new Schema({  name: {    type: String,    require: true  }  ,  marks: {    type: Number,    default: 0  }})  // Creating collectionconst collections = mongoose.model("GFG", collection_structure)  // Inserting one documentcollections.create({  name: "aayush",  marks: 10}).then((ans) => {  console.log("Document inserted")}).catch((err) => {  console.log(err.Message);})
Run index.js file using below command:
node index.js
Output:
MongoDB Database: Our database after executing the above command will look like this:
Mongoose
Technical Scripter 2020
MongoDB
Technical Scripter
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Scala Stack reverse() method with example

03 Nov, 2019
In Scala Stack class, the reverse() method is utilized to return a stack with the reverse order.
Method Definition: def reverse: Stack[A]
Return Type: It returns a stack with the reverse order.
Example #1:
// Scala program of reverse() // method   // Import Stack import scala.collection.mutable._  // Creating object object GfG {       // Main method     def main(args:Array[String])     {               // Creating stack        val s1 = Stack(1, 2, 3, 4, 5, 6)                   // Print the stack         println(s1)                    // Applying reverse method          val result = s1.reverse                  // Display output         print("Reversed stack: " + result)                } } 
Stack(1, 2, 3, 4, 5, 6)
Reversed stack: Stack(6, 5, 4, 3, 2, 1)

Example #2:
// Scala program of reverse() // method   // Import Stack import scala.collection.mutable._  // Creating object object GfG {       // Main method     def main(args:Array[String])     {               // Creating stack        val s1 = Stack(5, 2, 13, 7, 1, 3)                   // Print the stack         println(s1)                    // Applying reverse method          val result = s1.reverse                  // Display output         print("Reversed stack: " + result)                } } 
Stack(5, 2, 13, 7, 1, 3)
Reversed stack: Stack(3, 1, 7, 13, 2, 5)

Scala
scala-collection
Scala-Method
Scala
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
PostgreSQL – Insert Multiple Values in Various Rows

01 Feb, 2021
PostgreSQL is a type of relational database (RDBMS) similar to MySQL. Relational Database stores data in the form of a table in which each row is a record and each column is one attribute. In this article, we will look into the process of inserting multiple rows in a PostgreSQL database. In general, we use the INSERT statement to insert values in a database. Just an improvised version of the same statement can be used to insert multiple values in various rows of a database as shown in the syntax below:
Syntax :
##When specifying Column Names
Insert into tableName (col1, col2) values (value,value),(value,value),(value,value);

## when not specifying Column Names
Insert into tableName  values (value,value),(value,value),(value,value);
Approach :
Our database name is geeksforgeeks and the table name is gfg at the beginning there is no data inside the table. For selecting the database we will use query  \c databaseName.
For checking the data inside the table we will use query select *from tableName.
Now for inserting values, we will use the table name and the column names and the records to be inserted will be separated by comma(“‘”).
The query will be Insert into tableName (col1, col2) values (value,value),(value,value),(value,value).
If you want to insert without the column names then the query will be a different one than the above query.
Insert into tableName  values (value,value),(value,value),(value,value) . But one thing should be remembered here that in this case, the order of the values being inserted should be the same as that of in the database and all the mandatory columns must be inserted.
Now again we will check for records inside the table using select*from tableName.
Example 1 :
In this example, we first selected the database using the \c geeksforgeeks command, and then we looked into the database table records then we inserted the multiples record inside the table then again look inside the database tables. The steps followed are to select the database and then look into the table records then insert multiple values and then again look into the table records.
Example 2 :
Here in this example, we will insert the rows without using the column names but one thing to note about this approach is if you are not giving the column names the order of values being inserted will be the same as that of in the table and all the mandatory columns must be filled in the table otherwise there will be an exception. After inserting the data we will again look into the database table.
Picked
postgreSQL-managing-table
PostgreSQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
PostgreSQL - Psql commands
PostgreSQL - Change Column Type
PostgreSQL - For Loops
PostgreSQL - LIMIT with OFFSET clause
PostgreSQL - Function Returning A Table
PostgreSQL - ARRAY_AGG() Function
PostgreSQL - Copy Table
PostgreSQL - DROP INDEX
How to use PostgreSQL Database in Django?
PostgreSQL - Identity Column
isupper() and islower() and their application in C++

16 Jun, 2022
In C++, isupper() and islower() are predefined functions used for string and character handling. cstring.h is the header file required for string functions and cctype.h is the headerfile required for character functions.
isupper() Function This function is used to check if the argument contains any uppercase letters such as A, B, C, D, ..., Z. 
Syntax
int isupper(int x)
C++
// Program to check if a character is in// uppercase using isupper()#include <iostream>#include <cctype>using namespace std;int main(){    char x;    cin >> x;    if (isupper(x))        cout << "Uppercase";    else        cout << "Not uppercase.";       return 0;}
Input : A
Output : Uppercase
Input : a
Output : Not uppercase
islower() Function This function is used to check if the argument contains lowercase letters such as a, b, c, d, ..., z. 
Syntax
int islower(int x)
 
C++
// Program to check if a character is in// lowercase using islower()#include <iostream>#include <cctype>using namespace std;int main(){    char x;    cin >> x;    if (islower(x))        cout << "Lowercase";    else        cout << "Not Lowercase.";        return 0;}
Input:A
Output : Not Lowercase
Input : a
Output : Lowercase
Application of islower(), isupper(), tolower(), toupper() function. Given a string, task is to convert the characters in the string into opposite case, i.e. if a character is in lowercase, we need to convert it into uppercase and vice versa.
Syntax of tolower():

int tolower(int ch);
Syntax of toupper():

int toupper(int ch);
Examples: 
Input : GeekS
Output :gEEKs

Input :Test Case
Output :tEST cASE
1. Traverse the given string character by character upto its length, check if character is in lowercase or uppercase using predefined function. 3. If lowercase, convert it to uppercase using toupper() function, if uppercase, convert it to lowercase using tolower() function. 4. Print the final string.
C++
// C++ program to toggle cases of a given// string.#include <iostream>#include <cstring>using namespace std; // function to toggle cases of a stringvoid toggle(string& str){    int length = str.length();    for (int i = 0; i < length; i++) {        int c = str[i];        if (islower(c))            str[i] = toupper(c);        else if (isupper(c))            str[i] = tolower(c);           }} // Driver Codeint main(){    string str = "GeekS";    toggle(str);    cout << str;    return 0;}
Output: 
gEEKs
Time complexity : O(n) Auxiliary Space : O(1)
This article is contributed by Ayush Saxena. If you like GeeksforGeeks and would like to contribute, you can also write an article using write.geeksforgeeks.org or mail your article to review-team@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above. 
tk315
ManasChhabra2
code_29
likitarai1
youmailmahibagi
cpp-string
STL
Strings
Strings
STL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Convert Matrix to Vector in R

06 Sep, 2021
In this article, we are going to convert the given matrix into the vector in R programming language.
Simply passing the name of the matrix will do the job.
Syntax:
c(matrix_name)
Where matrix_name is the name of the input matrix
Example 1:
R
# create a matrix with 12 elements# with 4 rows and 3 columnsmatrix=matrix(1:12,nrow=4,ncol=3)print(matrix) # convert matrix to vector using c()# functiona=c(matrix) print(a)
  
Output:
 
 
Example 2:
 
R
# create a matrix with 16 elements# with 4 rows and 4 columnsmatrix=matrix(1:16,nrow=4,ncol=4)print(matrix) # convert matrix to vector using# c() functiona=c(matrix) print(a)
  
Output:
This function is used to convert matrix to vector so again simply passing the matrix name is enough.
Syntax: 
as.vector(matrix)
 
Example: 
R
# create a matrix with 12 elements# with 4 rows and 3 columnsmatrix=matrix(1:12,nrow=4,ncol=3)print(matrix) # convert matrix to vector using# as.vector() functiona=as.vector(matrix) print(a)
  
Output:
 
Example 2:
R
# create a matrix with 16 elements with 4 rows and 4 columnsmatrix=matrix(1:16,nrow=4,ncol=4)print(matrix) # convert matrix to vector using as.vector() functiona=as.vector(matrix) print(a)
  
Output 
 
t() function is used to transpose the given matrix. It will transpose rows as columns and columns as rows.
Syntax:
t(matrix)
where the matrix is the input matrix
 
After applying t() we can apply c() and as.vector() functions to convert the matrix to vector
 
Syntax:
c(t(matrix))
 
Example 1:
R
# create a matrix with 12 elements# with 4 rows and 3 columnsmatrix=matrix(1:12,nrow=4,ncol=3)print(matrix) # convert matrix to vector using# c() function along with t()a=c(t(matrix)) print(a)
  
Output:
 
Example 2:
R
# create a matrix with 12 elements# with 2 rows and 6 columnsmatrix=matrix(1:12,nrow=2,ncol=6)print(matrix) # convert matrix to vector using# c() function along with t()a=c(t(matrix)) print(a)
  
Output:
 
The work of t() is same as above. After the transpose has been taken, the matrix is converted to vector using as.vector().
Syntax:
as.vector(t(matrix))
 
Example
R
# create a matrix with 12 elements# with 2 rows and 6 columnsmatrix=matrix(1:12,nrow=2,ncol=6)print(matrix) # convert matrix to vector using# as.vector() function along with t()a=as.vector(t(matrix)) print(a)
  
Output:
 
Example 2:
R
# create a matrix with 4 elements# with 2 rows and 2 columnsmatrix=matrix(1:4,nrow=2,ncol=2)print(matrix) # convert matrix to vector using# as.vector() function along with t()a=as.vector(t(matrix)) print(a)
Output
 
as5853535
sweetyty
Picked
R Matrix-Programs
R Vector-Programs
R-Matrix
R-Vectors
R Language
R Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
PostgreSQL – Interval Data Type

30 Sep, 2021
In PostgreSQL the interval data type is used to store and manipulate a time period. It holds 16 bytes of space and ranging from -178, 000, 000 years to 178, 000, 000 years. It also has additional attribute called “precision (denoted by p)” that can be used to set the level of precision in the query results. 
 
Syntax:interval [ Data_fields ] [ (p) ]

Where,
Data_fields: Time period
p: precision
PostgreSQL stores the interval type value in the integer form of days and months whereas for values in seconds, it can be fractions. Now let’s jump into a few examples for demonstration. Example 1: In this example we will query to know the time of 4 hours 25 minutes ago at the current time of last year using the below commands:  
SELECT
    now(),
    now() - INTERVAL '1 year 4 hours 25 minutes' 
             AS "4 hours 25 minutes ago of last year";
Output:  
Example 2: In this example we will convert an interval value ta string format using the TO_CHAR() function.The TO_CHAR() function takes the first argument as an interval value, the second one as the format, and returns a string that represents the interval in the specified format.  
SELECT
    TO_CHAR(
        INTERVAL '15h 25m 12s',
        'HH24:MI:SS'
    );
Output:  
 
kashishsoda
postgreSQL
postgreSQL-dataTypes
PostgreSQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Variable Shadowing in Python

04 Jan, 2022
In this article, we will understand the concept of variable shadowing in a Python programming language. To understand this concept, we need to be well versed with the scope of a lifetime of variables in python. 
When we define a function, we can create variables that are scoped only to that function and are not accessible outside of the function. These variables are referred to as local variables ( as they are local to the function )
Python3
def fn():          # local variable a    a = 3      print(a)  # Error, variable a referenced before # assignmentprint(a) 
Output:
NameError: name 'a' is not defined
Variables are defined outside of any function and are potentially accessible anywhere in the program.
Python3
# global variablea = 3    def fn():      # print 3    print(a)    # print 3print(a)  
Output:
3
Note: For more information, refer to our Global and Local Variables in Python
Variable shadowing occurs when a variable defined in the inner scope has the same name as a variable in the outer scope. Consider the example below, here the variable inside the function has the same name as a global variable. In this program, there are two versions of variable a, one which is defined globally and the other which is defined within the context of the function. Python treats these variables as completely separate variables. The global variable a is said to be shadowed by the local variable a. The way outer and inner variables with the same name are handled depends upon the name resolution rules of the language.
Python3
# global variablea = 3 def fn():      # local variable  a = 5   print(a) # prints 5  fn()print(a) # prints 3
5
3

To modify a global variable, and avoid variable shadowing python provides global keyword which tells python to use the global version of the variable, instead of creating a new locally scoped variable.
Python3
# global variablea = 3 def fn():   global a       # global variable modified  a = 5   print(a) # prints 5  print(a) # prints 5fn()
Output:
3
5
To avoid variable shadowing at the function level, meaning if a variable in outer function has the same name as a variable in an inner function, python provides nonlocal keyword which tells python to use the variable defined in the outer function, instead of creating a new locally scoped variable
Python3
def outer():   a = 5   def inner():    nonlocal a    a = 3    print(a) # prints 3        inner()  print(a) # prints 3  outer()
Output:
3
3
python-basics
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
BufferedReader close() method in Java with Examples

05 Jun, 2020
The close() method of BufferedReader class in Java is used to close the stream and release all the system resources associated with the stream operations.
Syntax:
public void close() 
            throws IOException

Parameters: This method does not accept any parameter.
Return value: This method does not return any value.
Exception: This method throws IOException if an I/O error occurs.
Below programs illustrate close() method in BufferedReader class in IO package:
Program 1: Assume the existence of the file “c:/demo.txt”.
// Java program to illustrate// BufferedReader close() method  import java.io.*;public class GFG {    public static void main(String[] args)        throws IOException    {          // Read stream file 'demo.txt'        // containing text "GEEKSFORGEEKS"        FileReader fileReader            = new FileReader(                "c:/demo.txt");          // Convert fileReader to        // bufferedReader        BufferedReader buffReader            = new BufferedReader(                fileReader);          // Call read() method        while (buffReader.ready()) {            System.out.print(                (char)buffReader.read());        }          // Call close() method        buffReader.close();    }}
Program 2: Assume the existence of the file “c:/demo.txt”.
// Java program to illustrate// BufferedReader close() method  import java.io.*;public class GFG {    public static void main(String[] args)        throws IOException    {        try {              // Read stream file 'demo.txt'            // containing text "GEEKSFORGEEKS"            FileReader fileReader                = new FileReader(                    "c:/demo.txt");              // Convert fileReader to            // bufferedReader            BufferedReader buffReader                = new BufferedReader(                    fileReader);              // Call close() method            buffReader.close();              // Call read() method            System.out.print(                (char)buffReader.read());        }        catch (IOException e) {            // Exception is thrown            System.out.println(                "BufferedReader is closed");        }    }}
Reference: https://docs.oracle.com/javase/7/docs/api/java/io/BufferedReader.html#close()
Java-Functions
Java-IO package
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Object Oriented Programming (OOPs) Concept in Java
How to iterate any Map in Java
Interfaces in Java
HashMap in Java with Examples
ArrayList in Java
Collections in Java
Multidimensional Arrays in Java
Stream In Java
Singleton Class in Java
Set in Java