code-rag-bench/online-tutorials huggingface dataset:
Get the Last parts of a Data Set in R Programming - tail() Function - GeeksforGeeks

30 Jun, 2020
tail() function in R Language is used to get the last parts of a vector, matrix, table, data frame or function.
Syntax: tail(x, n)
Parameters:x: specified data typesn: number of row need to be printed
Example 1:
# R program to illustrate# tail function  # Calling the tail() function to # get the last iris demo datasettail(iris)
Output:
    Sepal.Length Sepal.Width Petal.Length Petal.Width   Species
145          6.7         3.3          5.7         2.5 virginica
146          6.7         3.0          5.2         2.3 virginica
147          6.3         2.5          5.0         1.9 virginica
148          6.5         3.0          5.2         2.0 virginica
149          6.2         3.4          5.4         2.3 virginica
150          5.9         3.0          5.1         1.8 virginica

Example 2:
# R program to illustrate# tail function  # Calling the tail() function to # get the last iris demo dataset# in 4 rowstail(iris, 4)
Output:
    Sepal.Length Sepal.Width Petal.Length Petal.Width   Species
147          6.3         2.5          5.0         1.9 virginica
148          6.5         3.0          5.2         2.0 virginica
149          6.2         3.4          5.4         2.3 virginica
150          5.9         3.0          5.1         1.8 virginica

R DataFrame-Function
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Filter data by multiple conditions in R using Dplyr
Loops in R (for, while, repeat)
How to change Row Names of DataFrame in R ?
Change Color of Bars in Barchart using ggplot2 in R
Group by function in R using Dplyr
How to Change Axis Scales in R Plots?
How to Split Column Into Multiple Columns in R DataFrame?
K-Means Clustering in R Programming
Replace Specific Characters in String in R
Remove rows with NA in one column of R DataFrame
Set remove() method in Java with Examples - GeeksforGeeks

31 Dec, 2018
The java.util.Set.remove(Object O) method is used to remove a particular element from a Set.
Syntax:
boolean remove(Object O)
Parameters: The parameter O is of the type of element maintained by this Set and specifies the element to be removed from the Set.
Return Value: This method returns True if the specified element is present in the Set otherwise it returns False.
Below program illustrate the java.util.Set.remove(Object O) method:
// Java code to illustrate Set.remove() method  import java.util.*;  public class SetDemo {    public static void main(String args[])    {        // Creating an empty Set        Set<String> set = new HashSet<String>();          // Use add() method to add elements into the Set        set.add("Welcome");        set.add("To");        set.add("Geeks");        set.add("4");        set.add("Geeks");          // Displaying the Set        System.out.println("Set: " + set);          // Removing elements using remove() method        set.remove("Geeks");        set.remove("4");        set.remove("Welcome");          // Displaying the Set after removal        System.out.println("Set after removing elements: "                           + set);    }}
Set: [4, Geeks, Welcome, To]
Set after removing elements: [To]

Reference: https://docs.oracle.com/javase/7/docs/api/java/util/Set.html#remove(java.lang.Object)
Java-Collections
Java-Functions
java-set
Java
Java
Java-Collections
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Object Oriented Programming (OOPs) Concept in Java
HashMap in Java with Examples
Stream In Java
Interfaces in Java
How to iterate any Map in Java
ArrayList in Java
Initialize an ArrayList in Java
Stack Class in Java
Singleton Class in Java
Multidimensional Arrays in Java
Docker - Using Image Tags - GeeksforGeeks

31 Oct, 2020
You can use Image tags to describe an image using simple labels and aliases. Tags can simply be the version of the project, features of the Image or simply your name, pretty much anything that can describe the Image. It helps you in managing the version of the project and allows you to keep track of the overall development process. 
In this article, we will discuss almost everything related to tags that would help you get started with Image Tagging.
Before diving into this article, let’s discuss something called the latest tag. If you don’t specify a tag to an image, it automatically gets tagged with the latest tag meaning that this Image is of the latest version.
The three most common scenarios where tagging is mostly used that are described below:
You can specify a tag to the image right at the time when you are building it using the -t flag. If you don’t specify a tag, it is automatically tagged with the latest tag.
sudo docker build -t <image-name>:<tag-name>

You can also specify the tag of the Image which you want to pull in the Dockerfile. Let’s say you have a Dockerfile to pull an Ubuntu Image with the latest version.
FROM ubuntu:latest

Now, if you want to build the Image with a custom tag called my-ubuntu, you can use the following command.
sudo docker build -t tag-demo:my-ubuntu .

You can also tag an Image directly using the tag sub-command.
sudo docker tag <imageId> <imageName>/<tagName>

You can see that the new tag has been assigned to the Image.
You can pull a Docker Image using the pull sub-command. You can specify the tag of the Image that you want to pull. Note that if you don’t specify a tag, it will automatically pull the latest version of the Image by appending the “latest” tag to the Image.
sudo docker pull alpine:3.6

Docker Container
linux
Advanced Computer Subject
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Copying Files to and from Docker Containers
Markov Decision Process
Fuzzy Logic | Introduction
Q-Learning in Python
Principal Component Analysis with Python
Basics of API Testing Using Postman
ML | What is Machine Learning ?
OpenCV - Overview
Deep Learning | Introduction to Long Short Term Memory
Getting Started with System Design
unordered_map clear in C++ STL - GeeksforGeeks

18 Dec, 2018
unordered_map::clear() function is used to remove all elements from the container. When this function is applied to unordered_map its size becomes zero.Syntax:
 unordered_map_name.clear()

Parameters: This function does not accepts any parameterReturn type: This function return nothing.
Examples:
Input: ump = { {1, 2}, {3, 4}, {5, 6}, {7, 8}}ump.clear();Output: ump = { };
// CPP program to illustrate// Implementation of unordered_map clear() function#include <bits/stdc++.h>using namespace std;  int main(){    // Take any two unordered_map    unordered_map<int, int> ump1, ump2;      // Inserting values    ump1[1] = 2;    ump1[3] = 4;    ump1[5] = 6;    ump1[7] = 8;      // Print the size of container    cout << "Unordered_map size before calling clear function: \n";    cout << "ump1 size = " << ump1.size() << endl;    cout << "ump2 size = " << ump2.size() << endl;      // Deleting the  elements    ump1.clear();    ump2.clear();      // Print the size of container    cout << "Unordered_map size after calling clear function: \n";    cout << "ump1 size = " << ump1.size() << endl;    cout << "ump2 size = " << ump2.size() << endl;      return 0;}
Unordered_map size before calling clear function: 
ump1 size = 4
ump2 size = 0
Unordered_map size after calling clear function: 
ump1 size = 0
ump2 size = 0

What is the application?clear is used when we wish to delete old elements and start from fresh, especially in loops. We can achieve same functionality by creating a new map, but clearing same map is better performance wise as we do not have to create new object.
cpp-unordered_map
cpp-unordered_map-functions
Picked
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Operator Overloading in C++
Polymorphism in C++
Sorting a vector in C++
Friend class and function in C++
std::string class in C++
Pair in C++ Standard Template Library (STL)
Queue in C++ Standard Template Library (STL)
Inline Functions in C++
Array of Strings in C++ (5 Different Ways to Create)
Convert string to char array in C++
destroy() method in Tkinter | Python

24 Nov, 2021
Tkinter supports a variety of methods to perform various tasks. It also offers some universal method.
destroy() is a universal widget method i.e we can use this method with any of the available widgets as well as with the main tkinter window.
Syntax:
widget_object = Widget(parent, command = widget_class_object.destroy)

This method can be used with after() method.
Code #1: destroy() method passed as command
# importing only those functions# which are neededfrom tkinter import * from tkinter.ttk import *  # creating tkinter windowroot = Tk()  # Creating button. In this destroy method is passed# as command, so as soon as button 1 is pressed root# window will be destroyedbtn1 = Button(root, text ="Button 1", command = root.destroy)btn1.pack(pady = 10)  # Creating button. In this destroy method is passed# as command, so as soon as button 2 is pressed# button 1 will be destroyedbtn2 = Button(root, text ="Button 2", command = btn1.destroy)btn2.pack(pady = 10)  # infinite loopmainloop()
Output:
As you may observe, in above code that the command that is passed in button-2 is to destroy button-1 so as soon as you press button-2, button-2 will get destroyed.
Code #2:destroy() method with after() method
# importing only those functions# which are neededfrom tkinter import * from tkinter.ttk import *  # creating tkinter windowroot = Tk()  # Creating button. In this destroy method is passed# as command, so as soon as button 1 is pressed root# window will be destroyedbtn1 = Button(root, text ="Button 1")btn1.pack(pady = 10)  # Creating button. In this destroy method is passed# as command, so as soon as button 2 is pressed# button 1 will be destroyedbtn2 = Button(root, text ="Button 2")btn2.pack(pady = 10)  # after method destroying button-1# and button-2 after certain timebtn1.after(3000, btn1.destroy)btn2.after(6000, btn2.destroy)  # infinite loopmainloop()
Output:From output you may see that both the widgets are destroyed after a certain time limit and only root window will be left empty.
Note: There is another method available quit() which do not destroy widgets but it exits the tcl/tk interpreter i.e it stops the mainloop().
Python-gui
Python-tkinter
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Find the node with minimum value in a Binary Search Tree in C++

Suppose we have one binary search tree. We have to find the minimum element in binary search tree. So if the BST is like below −
The minimum element will be 1.
As we know that the left subtree always holds the smaller elements. So if we traverse through the left subtree again and again until left is null, we can find the smallest element.
 Live Demo
#include<iostream>
using namespace std;
class node{
   public:
      node *left;
      int val;
      node *right;
};
node *bst = NULL;
node *getNode(){
   node *newNode;
   newNode = new node;
   return newNode;
}
void insert(node **root, int key){
   node *newNode;
   newNode = getNode();
   newNode->val = key; newNode->left = NULL; newNode->right = NULL;
   if(*root == NULL){
      *root = newNode;
      return;
   } else {
      if(key < (*root)->val)
      insert(&((*root)->left), key);
   else
      insert(&((*root)->right), key);
   }
}
int minElement(){
   node* current = bst;
   while (current->left != NULL) {
      current = current->left;
   }
   return(current->val);
}
main(){
   int item[] = {3, 2, 1, 6, 5, 8};
   int n = sizeof(item)/sizeof(item[0]);
   int i;
   for(i = 0; i<8; i++){
      insert(&bst, item[i]);
   }
   cout << "Minimum element is: " << minElement();
}
Minimum element is: 1
MongoEngine - Advanced Queries

In order to get more efficiency in retrieving a subset of fields in a document, use only() method of Objects attribute. This will significantly improve performance especially for fields with extremely large length such as ListField. Pass the required field to only() function. If other fields are accessed after executing only() query, default value is returned.
from mongoengine import *
con=connect('newdb')
class person (Document):
name=StringField(required=True)
city=StringField(default='Mumbai')
pin=IntField()
p1=person(name='Himanshu', city='Delhi', pin=110012).save()
doc=person.objects.only('name').first()
print ('name:',doc.name)
print ('city:', doc.city)
print ('PIN:', doc.pin)
name: Himanshu
city: Mumbai
PIN: None

Note − The value of city attribute is used as default. As default is not specified for PIN, it prints None.
You may call reload() function if you need missing fields.
When a document class has a ListField or DictField, while iterating through it, any DBREf objects are automatically dereferenced. To increase the efficiency further, especially if the document has ReferenceField, number of queries can be limited by using select_related() function which converts QuerySet in a list and effects dereferencing.
MongoEngine API contains Q class which is useful for constructing advanced queries consisting of number of constraints. Q represents a part of query which can be initialized by keyword argument syntax and binary & and | operators.
person.objects(Q(name__startswith=’H’) &Q(city=’Mumbai’))

 Print
 Add Notes
 Bookmark this page
How to get the exponent power of a number in JavaScript?

To get the exponent power of a number, use the Math.pow (base, exponent ) method. This method returns the base to the exponent power, that is, base exponent. 
The following are the parameters used in Math.pow() method −
base − The base number. 
exponents − The exponent to which to raise base.
You can try to run the following code to get the exponent power −
<html>
   <head>
      <title>JavaScript Math pow() Method</title>
   </head>
   <body>
      <script>
         var value = Math.pow(7, 2);
         document.write("First Test Value : " + value );

         var value = Math.pow(8, 8);
         document.write("<br />Second Test Value : " + value );

         var value = Math.pow(-1, 2);
         document.write("<br />Third Test Value : " + value );

         var value = Math.pow(0, 10);
         document.write("<br />Fourth Test Value : " + value );
      </script>
   </body>
</html>
Format date in MySQL SELECT * query uisng FORMATDATE() method?

Use the DATE_FORMAT(), not FORMATDATE() in MySQL to format date. The correct syntax is as follows −
SE LECT *, DATE_FORMAT(yourDateCoumnName,’yourFormat’) as anyAliasName FROM yourTableName
To understand the above syntax, let us create a table. The query to create a table is as follows −
mysql> create table DateFormatDemo
   -> (
   -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   -> UserName varchar(10),
   -> UserLoginDate date
   -> );
Query OK, 0 rows affected (0.94 sec)
Insert some records in the table using insert command. The query is as follows −
mysql> insert into DateFormatDemo(UserName,UserLoginDate) values('Mike',curdate());
Query OK, 1 row affected (0.21 sec)
mysql> insert into DateFormatDemo(UserName,UserLoginDate) values('Sam','2018-05-09');
Query OK, 1 row affected (0.17 sec)
mysql> insert into DateFormatDemo(UserName,UserLoginDate) values('Carol','2016-01-15');
Query OK, 1 row affected (0.17 sec)
mysql> insert into DateFormatDemo(UserName,UserLoginDate) values('Bob','2015-12-31');
Query OK, 1 row affected (0.17 sec)
mysql> insert into DateFormatDemo(UserName,UserLoginDate) values('David','2012-08-19');
Query OK, 1 row affected (0.09 sec)
Display all records from the table using select statement. The query is as follows −
mysql> select *from DateFormatDemo;
The following is the output −
+----+----------+---------------+
| Id | UserName | UserLoginDate |
+----+----------+---------------+
|  1 | Mike     | 2019-02-06    |
|  2 | Sam      | 2018-05-09    |
|  3 | Carol    | 2016-01-15    |
|  4 | Bob      | 2015-12-31    |
|  5 | David    | 2012-08-19    |
+----+----------+---------------+
5 rows in set (0.00 sec)
Let us format date using DATE_FORMAT() with SELECT *. The query is as follows −
mysql> select *,DATE_FORMAT(UserLoginDate,'%d-%m-%Y') as NewFormatOfDate from DateFormatDemo;
The following is the output −
+----+----------+---------------+-----------------+
| Id | UserName | UserLoginDate | NewFormatOfDate |
+----+----------+---------------+-----------------+
|  1 | Mike     | 2019-02-06    | 06-02-2019      |
|  2 | Sam      | 2018-05-09    | 09-05-2018      |
|  3 | Carol    | 2016-01-15    | 15-01-2016      |
|  4 | Bob      | 2015-12-31    | 31-12-2015      |
|  5 | David    | 2012-08-19    | 19-08-2012      |
+----+----------+---------------+-----------------+
5 rows in set (0.00 sec)
Bokeh - Exporting Plots

In addition to subcommands described above, Bokeh plots can be exported to PNG and SVG file format using export() function. For that purpose, local Python installation should have following dependency libraries.
PhantomJS is a JavaScript API that enables automated navigation, screenshots, user behavior and assertions. It is used to run browser-based unit tests. PhantomJS is based on WebKit providing a similar browsing environment for different browsers and provides fast and native support for various web standards: DOM handling, CSS selector, JSON, Canvas, and SVG. In other words, PhantomJS is a web browser without a graphical user interface.
Pillow, a Python Imaging Library (earlier known as PIL) is a free library for the Python programming language that provides support for opening, manipulating, and saving many different image file formats. (including PPM, PNG, JPEG, GIF, TIFF, and BMP.) Some of its features are per-pixel manipulations, masking and transparency handling, image filtering, image enhancing, etc.
The export_png() function generates RGBA-format PNG image from layout. This function uses Webkit headless browser to render the layout in memory and then capture a screenshot. The generated image will be of the same dimensions as the source layout. Make sure that the Plot.background_fill_color and Plot.border_fill_color are properties to None.
from bokeh.io import export_png
export_png(plot, filename = "file.png")

It is possible that HTML5 Canvas plot output with a SVG element that can be edited using programs such as Adobe Illustrator. The SVG objects can also be converted to PDFs. Here, canvas2svg, a JavaScript library is used to mock the normal Canvas element and its methods with an SVG element. Like PNGs, in order to create a SVG with a transparent background,the Plot.background_fill_color and Plot.border_fill_color properties should be to None.
The SVG backend is first activated by setting the Plot.output_backend attribute to "svg".
plot.output_backend = "svg"

For headless export, Bokeh has a utility function, export_svgs(). This function will download all of SVG-enabled plots within a layout as distinct SVG files.
from bokeh.io import export_svgs
plot.output_backend = "svg"
export_svgs(plot, filename = "plot.svg")

 Print
 Add Notes
 Bookmark this page
array at() function in C++ STL - GeeksforGeeks

29 Aug, 2018
The array::at() is a built-in function in C++ STL which returns a reference to the element present at location i in given array.
Syntax:
array_name.at(i)
Parameters: The function accepts a single mandatory parameter i which specifies the location.
Return value: The function returns an element present at index i in given array if i is valid index otherwise it throws out_of_range exception.
Time Complexity: O(1)
Below programs demonstrate the array::at() function:
Program 1:
// CPP program to illustrate// the array::at() function#include <bits/stdc++.h>using namespace std;  int main(){    // array initialisation    array<int, 5> arr = { 1, 5, 2, 4, 7 };      // prints the element at ith index    // index starts from zero    cout << "The element at index 2 is " << arr.at(2) << endl;      return 0;}
The element at index 2 is 2

// CPP program to illustrate// the array::at() function#include <bits/stdc++.h>using namespace std;  int main(){    // array initialisation    array<int, 5> arr = { 1, 5, 2, 4, 7 };      // it is an exception    cout << "The element at index 2 is " << arr.at(7) << endl;      return 0;}
Abort signal from abort(3) (SIGABRT)

cpp-array
CPP-Functions
STL
C++
STL
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++
Sorting a vector in C++
Inline Functions in C++
Convert string to char array in C++
List in C++ Standard Template Library (STL)
std::string class in C++
Exception Handling in C++
Bell Numbers - Number of ways to Partition a Set in C++

A bell number is used to denote the number of ways a set of n elements can be partitioned into subsets that are not empty (i.e. have at least one element).
In this program, we are given a set of n elements and we have to find the number of ways to partition the set into non-empty subsets.
Input : 3
Output : 5
Explanation − let the set of three elements {1, 2, 3}.
The subsets are {{1} , {2} , {3}} ; {{1} , {2,3}} ; {{1 , 2} , {3}} ; {{2} , {1 , 3}} ; {1 , 2 , 3}.
Bell number: A bell number bell(n) gives the value of sum of s(n,k) for all values of k ranging from 1 to n. Here s(n,k) is the number of partitions of n elements into k subsets.
The formula would be −
bell(n)=∑k=0nS(n,k)
The function s(n,k) is recursively as −
s(n+1,k) = k*s(n,k) + s(n,k-1).
On adding (n+1)th element to k partitions, there are two possibilities −
It adds one to the k partitions of existing partitions i.e. s(n,k-1).
It adds one to the k partitions of existing partitions i.e. s(n,k-1).
Adding value to all sets of partition, i.e. k*s(n,k).
Adding value to all sets of partition, i.e. k*s(n,k).
First few Bell numbers are 1 , 1 , 2 ,5 ,15 , 52 , 205
For finding the Bells number, we have a few methods,
Simple method is to one by one compute s(n,k) for k = 1 to n and add sum of all values of the number.
Simple method is to one by one compute s(n,k) for k = 1 to n and add sum of all values of the number.
Using bell triangle is to use bell’s triangle as given below −
Using bell triangle is to use bell’s triangle as given below −
1
1  2
2  3  5
5  7  10  15
15 20 27  37 52
#include<iostream>
using namespace std;
int bellNumber(int n) {
   int bell[n+1][n+1];
   bell[0][0] = 1;
   for (int i=1; i<=n; i++) {
      bell[i][0] = bell[i-1][i-1];
      for (int j=1; j<=i; j++)
      bell[i][j] = bell[i-1][j-1] + bell[i][j-1];
   }
   return bell[n][0];
}
int main() {
   for (int n=0; n<=5; n++)
   cout<<"Bell Number "<<n<<" is "<< bellNumber(n)<<endl;
   return 0;
}
Java String toUpperCase() Method

❮ String Methods

Convert a string to upper case and lower case letters:
String txt = "Hello World";
System.out.println(txt.toUpperCase());
System.out.println(txt.toLowerCase());

Try it Yourself »

The toUpperCase() method converts a string to upper case letters.
Note: The toLowerCase() method converts a string to lower case letters.
public String toUpperCase()

None.
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.
Find out the current working directory in C/C++

In this section, we will see how to get the current working directory using C or C++. We have defined some flags for the current operating system.
 Live Demo
#ifdef WINDOWS
#include <direct.h>
#define GetCurrentDir _getcwd
#else
#include <unistd.h>
#define GetCurrentDir getcwd
#endif

#include<iostream>
using namespace std;

std::string get_current_dir() {
   char buff[FILENAME_MAX]; //create string buffer to hold path
   GetCurrentDir( buff, FILENAME_MAX );
   string current_working_dir(buff);
   return current_working_dir;
}

main() {
   cout << get_current_dir() << endl;
}
D:\C++ Programs\section 53
How to exclude particular class name from CSS selector ?

30 Jul, 2021
In CSS, to exclude a particular class, we can use the pseudo-class :not selector also known as negation pseudo-class or not selector. This selector is used to set the style to every element that is not the specified by given selector. Since it is used to prevent a specific items from list of selected items.
Syntax:
:not(element) {
    // CSS Property
}
Example:
<!DOCTYPE html> <html>   <head>     <title>        How to exclude particular class        name from CSS selector ?    </title>           <meta charset="utf-8">     <meta name="viewport" content=            "width=device-width, initial-scale=1">           <link rel="stylesheet" href= "https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">           <style>         h1, h3 {            text-align: center;         }        .todo {            color: gray;        }                  /* Style to all li element except todo class name */        li:not(.todo) {            text-decoration: line-through;            color: green;        }    </style> </head>   <body>     <div class="container">                   <h1 class="text-success">            GeeksforGeeks        </h1>         <hr/>                   <h3>To-Do List:</h3>                  <ul class="list-group">            <li class="list-group-item">                Complete The Online Course            </li>                           <li class="list-group-item">                Goto Kolkata On Wednesday            </li>                          <li class="todo list-group-item">                Write Another Article For GeeksforGeeks            </li>                          <li class="todo list-group-item">                Complete Java Assignment            </li>                          <li class="todo list-group-item">                Buy Books On JavaScript            </li>             </ul>    </div> </body>   </html>
Output:
CSS is the foundation of webpages, is used for webpage development by styling websites and web apps.You can learn CSS from the ground up by following this CSS Tutorial and CSS Examples.
Picked
CSS
Technical Scripter
Web Technologies
Web technologies Questions
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
C# | Thread(ParameterizedThreadStart) Constructor

14 Sep, 2021
Thread(ParameterizedThreadStart) Constructor is used to initialize a new instance of the Thread class. It defined a delegate which allows an object to pass to the thread when the thread starts. This constructor gives ArgumentNullException if the parameter of this constructor is null. 
Syntax:  
public Thread(ParameterizedThreadStart start);
Here, start is a delegate which represents a method to be invoked when this thread begins executing.Below programs illustrate the use of Thread(ParameterizedThreadStart) Constructor:Example 1: 
CSharp
// C# program to illustrate the// use of Thread(ParameterizedThreadStart)// constructor with non-static methodusing System;using System.Threading; public class MYTHREAD {     // Non-static method    public void Job()    {        for (int z = 0; z < 3; z++) {             Console.WriteLine("My thread is "+                          "in progress...!!");        }    }} // Driver Classpublic class GFG {     // Main Method    public static void Main()    {        // Creating object of MYTHREAD class        MYTHREAD obj = new MYTHREAD();         // Creating a thread which        // calls a parameterized instance method        Thread thr = new Thread(obj.Job);        thr.Start();    }}
Output: 
My thread is in progress...!!
My thread is in progress...!!
My thread is in progress...!!
Example 2:
CSharp
// C# program to illustrate the use of// Thread(ParameterizedThreadStart)// constructor with static methodusing System;using System.Threading; // Driver Classpublic class GFG {     // Main Method    public static void Main()    {        // Creating a thread which calls        // a parameterized static-method        Thread thr = new Thread(Job);        thr.Start();    }     // Static method    public static void Job()    {        Console.WriteLine("My thread is"+                    " in progress...!!");         for (int z = 0; z < 3; z++) {            Console.WriteLine(z);        }    }}
Output: 
My thread is in progress...!!
0
1
2
Reference: 
https://docs.microsoft.com/en-us/dotnet/api/system.threading.thread.-ctor?view=netframework-4.7.2#System_Threading_Thread__ctor_System_Threading_ParameterizedThreadStart_
gulshankumarar231
CSharp Multithreading
CSharp Thread Class
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
C# | Multiple inheritance using interfaces
Differences Between .NET Core and .NET Framework
Extension Method in C#
C# | List Class
HashSet in C# with Examples
C# | .NET Framework (Basic Architecture and Component Stack)
Switch Statement in C#
Partial Classes in C#
Lambda Expressions in C#
Hello World in C#
Python | How to put limits on Memory and CPU Usage

24 Jun, 2019
This article aims to show how to put limits on the memory or CPU use of a program running. Well to do so, Resource module can be used and thus both the task can be performed very well as shown in the code given below:
Code #1 : Restrict CPU time
# importing librariesimport signalimport resourceimport os  # checking time limit exceeddef time_exceeded(signo, frame):    print("Time's up !")    raise SystemExit(1)  def set_max_runtime(seconds):    # setting up the resource limit    soft, hard = resource.getrlimit(resource.RLIMIT_CPU)    resource.setrlimit(resource.RLIMIT_CPU, (seconds, hard))    signal.signal(signal.SIGXCPU, time_exceeded)  # max run time of 15 millisecondif __name__ == '__main__':    set_max_runtime(15)    while True:        pass
SIGXCPU signal is generated when the time expires on running this code and the program can clean up and exit. Code #2 : In order to restrict memory use, the code puts a limit on the total address space
# using resource import resource  def limit_memory(maxsize):    soft, hard = resource.getrlimit(resource.RLIMIT_AS)    resource.setrlimit(resource.RLIMIT_AS, (maxsize, hard))
When no more memory is available then the program will start generating MemoryError exceptions with a memory limit.
How it works ?
To set a soft and hard limit on a particular resource, setrlimit() function is used.
The soft limit is a value upon which the operating system will notify the process via a signal or typically restrict it.
An upper bound on the values is defined by the hard limit and it may be used for the soft limit.
Although the hard limit can be lowered, it can never be raised by user processes and is controlled by a system-wide parameter set by the system administrator. (even if the process lowered itself).
The setrlimit() function can additionally be used to set limits on things such as the number of child processes, number of open files, and similar system resources.
The code in this article only works on Unix systems, and that it might not work on all of them.
python-utility
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
Python String | replace()
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
Create a Pandas DataFrame from Lists
Python | os.path.join() method
Mathematical Functions in SQL

Mathematical functions are very important in SQL to implement different mathematical concepts in queries.
Some of the the major mathematical functions in SQL are as follows −
This function returns the absolute value of X. For example −
Select abs(-6);
This returns 6.
The variable X is divided by Y and their remainder is returned. For example −
Select mod(9,5);
This returns 4.
This method returns 1 if X is positive, -1 if it is negative and 0 if the value of X is 0. For example −
Select sign(10);
This returns 1.
This returns the largest integer value that is either less than X or equal to it. For example −
Select floor(5.7);
This returns 5.
This returns the smallest integer value that is either more than X or equal to it. For example −
Select ceil(5.7);
This returns 6.
This function returns the value of x raised to the power of Y  For example −
Select power(2,5);
This returns 32.
This function returns the value of X rounded off to the whole integer that is nearest to it.  For example −
Select round(5.7);
This returns 6.
This function returns the square root of X. For example −
Select sqrt(9);
This returns 3.
This function accepts a Sin value as the input and returns the angle in radians.  For example −
Select asin(0);
This returns 0.
This function accepts a Cos value as the input and returns the angle in radians. For example −
Select acos(1);
This returns 0.
This function accepts a Tan value as the input and returns the angle in radians. For example −
Select atan(0);
This returns 0.
This function accepts an angle in radians as its parameter and returns its Sine value. For example −
Select sin(0);
This returns 0.
This function accepts an angle in radians as its parameter and returns its Cosine value. For example −
Select cos(0);
This returns 1.
This function accepts an angle in radians as its parameter and returns its Tan value. For example −
Select tan(0);
This returns 0.
What are the rules for a functional interface in Java?

A functional interface is a special kind of interface with exactly one abstract method in which lambda expression parameters and return types are matched. It provides target types for lambda expressions and method references.
A functional interface must have exactly one abstract method.
A functional interface has any number of
default methods because they are not abstract and implementation already provided by the same.
A functional interface declares an abstract method overriding one of the public methods from java.lang.Object still considered as functional interface. The reason is any implementation class to this interface can have implementation for this abstract method either from a superclass or defined by the implementation class itself.
@FunctionalInterface
interface <interface-name> {
 // only one abstract method
 // static or default methods
}
import java.util.Date;

@FunctionalInterface
interface DateFunction {
   int process();
   static Date now() {
      return new Date();
   }
   default String formatDate(Date date) {
     return date.toString();
   }
   default int sum(int a, int b) {
      return a + b;
   }
}
public class LambdaFunctionalInterfaceTest {
   public static void main(String[] args) {
      DateFunction dateFunc = () -> 77; // lambda expression
      System.out.println(dateFunc.process());
   }
}
77
Difference between Yield and Return in Python - GeeksforGeeks

20 Oct, 2020
Python YieldIt is generally used to convert a regular Python function into a generator. A generator is a special function in Python that returns a generator object to the caller. Since it stores the local variable states, hence overhead of memory allocation is controlled.
Example:
# Python3 code to demonstrate yield keyword   # Use of yielddef printresult(String) :     for i in String:         if i == "e":             yield i   # initializing string String = "GeeksforGeeks" ans = 0print ("The number of 'e' in word is : ", end = "" ) String = String.strip()   for j in printresult(String):     ans = ans + 1  print (ans) 
Output:
The number of 'e' in word is : 4
Python ReturnIt is generally used for the end of the execution and “returns” the result to the caller statement. It can return all type of values and it returns None when there is no expression with the statement “return”.
Example:
# A Python program to show return statement class Test:      def __init__(self):          self.str = "GeeksForGeeks"        self.x = "Shubham Singh"         # This function returns an object of Test  def fun():      return Test()            # Driver code to test above method  t = fun()   print(t.str)  print(t.x) 
Output:
GeeksForGeeks
Shubham Singh
python-basics
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Check if element exists in list in Python
Selecting rows in pandas DataFrame based on conditions
Python | os.path.join() method
Defaultdict in Python
Create a directory in Python
Python | Get unique values from a list
Python | Pandas dataframe.groupby()
Bootstrap .pager class

Get the pager links using the .pager Bootstrap class.
You can try to run the following code to implement the .pager class in Bootstrap
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <title>Bootstrap Example</title>
      <link href = "/bootstrap/css/bootstrap.min.css" rel = "stylesheet">
      <script src = "/scripts/jquery.min.js"></script>
      <script src = "/bootstrap/js/bootstrap.min.js"></script>
   </head>
   <body>
      <h2>Questions</h2>
      <br>
      <ul class = "pager">
         <li><a href = "#">Previous</a></li>
         <li><a href = "#">Next</a></li>
      </ul>
   </body>
</html>
Python | Pandas Timestamp.time - GeeksforGeeks

14 Jan, 2019
Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier.
Pandas Timestamp.time() function return time object with same time but with tzinfo equal to None.
Syntax :Timestamp.time()
Parameters : None
Return : datetime object
Example #1: Use Timestamp.time() function to return the time from the given Timestamp object.
# importing pandas as pdimport pandas as pd  # Create the Timestamp objectts = pd.Timestamp(year = 2011,  month = 11, day = 21,           hour = 10, second = 49, tz = 'US/Central')  # Print the Timestamp objectprint(ts)
Output :
Now we will use the Timestamp.time() function to return the time
# return timets.time()
Output :
As we can see in the output, the Timestamp.time() function has returned the time of the given Timestamp object. Notice the given object is not aware of the timezone. Example #2: Use Timestamp.time() function to return the time from the given Timestamp object.
# importing pandas as pdimport pandas as pd  # Create the Timestamp objectts = pd.Timestamp(year = 2009, month = 5, day = 31,       hour = 4, second = 49, tz = 'Europe/Berlin')  # Print the Timestamp objectprint(ts)
Output :
Now we will use the Timestamp.time() function to return the time
# return timets.time()
Output :
As we can see in the output, the Timestamp.time() function has returned the time of the given Timestamp object. Notice the given object is not aware of the timezone.
Python Pandas-Timestamp
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Read a file line by line in Python
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Iterate over a list in Python
Python String | replace()
Reading and Writing to text files in Python
*args and **kwargs in Python
Create a Pandas DataFrame from Lists
PostgreSQL - Subquery - GeeksforGeeks

28 Aug, 2020
In this article we will discuss the process of constructing complex queries using the PostgreSQL subquery. Subqueries in the simplest term can be defined as multiple queries disguised in a single PostgreSQL command.For the sake of this article we will be using the sample DVD rental database, which is explained here and can be downloaded by clicking on this link in our examples.Now, let’s look into a few examples of PostgreSQL subqueries.Example 1:Here we will query for all films whose rental rate is higher than the average rental rate from the “film” table of our sample database. For that we will need to find the average rental rate by using the SELECT statement and average function( AVG). Then use the result of the first query in the second SELECT statement to find the films that has higher rental rate than the average.
SELECT
    AVG (rental_rate)
FROM
    film;
Output:Now we will query for films whose rental rate is higher than the average rental rate.
SELECT
    film_id,
    title,
    rental_rate
FROM
    film
WHERE
    rental_rate > 2.98;
Output:
As you can observe the above query is not too elegant and requires an unnecessary amount of multiple queries.This can be avoided by using PostgreSQL subqueries as below.
SELECT
    film_id,
    title,
    rental_rate
FROM
    film
WHERE
    rental_rate > (
        SELECT
            AVG (rental_rate)
        FROM
            film
    );
Output:
A couple of this to notice about the sequence of execution of the above query:
First, executes the subquery.
Second, gets the result and passes it to the outer query.
Third, executes the outer query.
Example 2:Here we will query for all films that have the returned date between 2005-05-29 and 2005-05-30, using the IN operator in the “rental” table of our sample database.
SELECT
    film_id,
    title
FROM
    film
WHERE
    film_id IN (
        SELECT
            inventory.film_id
        FROM
            rental
        INNER JOIN inventory ON inventory.inventory_id = rental.inventory_id
        WHERE
            return_date BETWEEN '2005-05-29'
        AND '2005-05-30'
    );
Output:
postgreSQL-basics
PostgreSQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
PostgreSQL - CREATE PROCEDURE
PostgreSQL - GROUP BY clause
PostgreSQL - DROP INDEX
PostgreSQL - Copy Table
PostgreSQL - REPLACE Function
PostgreSQL - TIME Data Type
PostgreSQL - CREATE SCHEMA
PostgreSQL - Cursor
PostgreSQL - SELECT
PostgreSQL - ROW_NUMBER Function
Tuple Division in Python

When it is required to perform tuple division in Python, the 'zip' method and generator expressions can be used.
The zip method takes iterables, aggregates them into a tuple, and returns it as the result.
Generator is a simple way of creating iterators. It automatically implements a class with '__iter__()' and '__next__()' methods and keeps track of the internal states, as well as raises 'StopIteration' exception when no values are present that could be returned.
Below is a demonstration of the same −
Live Demo
my_tuple_1 = ( 7, 8, 3, 4, 3, 2)
my_tuple_2 = (9, 6, 8, 2, 1, 4)

print ("The first tuple is : " )
print(my_tuple_1)
print ("The second tuple is : " )
print(my_tuple_2)

my_result = tuple(elem_1 // elem_2 for elem_1, elem_2 in zip(my_tuple_1, my_tuple_2))

print("The divided tuple value is : " )
print(my_result)
The first tuple is :
(7, 8, 3, 4, 3, 2)
The second tuple is :
(9, 6, 8, 2, 1, 4)
The divided tuple value is :
(0, 1, 0, 2, 3, 0)
Two tuples are defined, and displayed on the console.
The lists are iterated over, and they are zipped using the 'zip' method.
The first element is taken and 'divided' with the second element from both the tuples using the '//' operator.
This is then converted to a tuple.
This operation is assigned to a variable.
This variable is the output that is displayed on the console.
PHP | date_default_timezone_set() Function - GeeksforGeeks

14 Sep, 2018
The date_default_timezone_set() function is an inbuilt function in PHP which is used to set the default timezone used by all date/time functions in a script. This function returns False if the timezone is not valid, or True otherwise.
Syntax:
bool date_default_timezone_set( $timezone_identifier )
Parameters: This function accepts single parameter $timezone_identifier which is mandatory. This parameter set the timezone identifier, like UTC or Asia/Kolkata.
Return Value: This function returns False if the timezone_identifier is not valid, or True otherwise.
Below programs illustrate the date_default_timezone_set() function in PHP:
Program 1:
<?php  // Set timezonedate_default_timezone_set('Asia/Kolkata');  // Create $timezone_object = date_default_timezone_get();  // Compare the timezone with ini-set timezoneif (strcmp($timezone_object, ini_get('date.timezone'))){    echo 'Script timezone differs from ini-set timezone.';} else {    echo 'Script timezone and ini-set timezone match.';}?>
Script timezone differs from ini-set timezone.

Program 2:
<?php  // Set the timezonedate_default_timezone_set('Asia/Dubai');  // Create the timezone object$timezone_object = date_default_timezone_get();  // Compare the timezone with ini-set timezoneif (strcmp($timezone_object, ini_get('date.timezone'))){    echo 'Script timezone differs from ini-set timezone.';} else {    echo 'Script timezone and ini-set timezone match.';}?>
Script timezone differs from ini-set timezone.

Related Articles:
PHP | date_parse() Function
PHP | date_sunset() Function
PHP | date_sun_info() Function
Reference: http://php.net/manual/en/function.date-default-timezone-set.php
PHP-date-time
PHP-function
PHP
Web Technologies
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to execute PHP code using command line ?
How to Insert Form Data into Database using PHP ?
How to convert array to string in PHP ?
PHP in_array() Function
How to pop an alert message box using PHP ?
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
Sum of digits of a number in PL/ SQL - GeeksforGeeks

09 Jul, 2018
Prerequisite – PL/SQL introductionIn PL/SQL code groups of commands are arranged within a block. A block group related declarations or statements. In declare part, we declare variables and between begin and end part, we perform the operations.
Given a number and task is to find the sum of digits of the number.Examples:
Input: 123456
Output: 21

Input: 9874
Output: 28

Approach is to take a number and getting each digit with MOD function and summing it up.
Below is the required implementation:
DECLARE       --Declare variable n, temp_sum      -- and r of datatype number     n        INTEGER;     temp_sum INTEGER;     r        INTEGER; BEGIN     n := 123456;     temp_sum := 0;       -- here we check condition with the help of while loop     -- here <> symbol represent for not null     WHILE n <> 0 LOOP         r := MOD(n, 10);         temp_sum := temp_sum + r;         n := Trunc(n / 10);     END LOOP;     dbms_output.Put_line('sum of digits = '                          || temp_sum); END; -- Program End 
Output:
sum of digits = 21

SQL-PL/SQL
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
SQL Interview Questions
CTE in SQL
How to Update Multiple Columns in Single Update Statement in SQL?
Difference between SQL and NoSQL
Difference between DELETE, DROP and TRUNCATE
MySQL | Group_CONCAT() Function
Difference between DELETE and TRUNCATE
SQL | Subquery
How to Create a Table With Multiple Foreign Keys in SQL?
What is Temporary Table in SQL?