code-rag-bench/online-tutorials huggingface dataset:
How to fire an event on file select using jQuery ? - GeeksforGeeks

17 Sep, 2019
Given an HTML document and the task to fire an event when a file is selected using jQuery. The JQuery change() method is used to fire an event when file is selected.
Using change() method: It is used to change the value of the input fields. This method works with “input, textarea and select” elements.
Syntax:
$(selector).change(function)
Example 1: The change() method is used to fire an event when file is selected.
<!DOCTYPE html><html>  <head>    <title>        How to fire event on        file select in jQuery?    </title>          <script src="https://code.jquery.com/jquery-1.12.4.min.js">    </script></head>  <body style = "text-align:center;">          <h1 style = "color:green;" >         GeeksForGeeks     </h1>           <h3>        How to fire event on file        select in jQuery?    </h3>          <p>Click on button to select the file</p>          <input type="file" id="Geeks" value="Click">          <script>        $(document).ready(function() {            $('input[type="file"]').change(function() {                alert("A file has been selected.");            });        });    </script></body>  </html>
Output:
Example 2: The change() method is used to fire an event when file is selected.
<!DOCTYPE html><html>  <head>    <title>        How to fire event on        file select in jQuery?    </title>          <script src="https://code.jquery.com/jquery-1.12.4.min.js">    </script></head>  <body style = "text-align:center;">          <h1 style = "color:green;" >         GeeksForGeeks     </h1>           <h3>How to fire event on file select in jQuery?</h3>          <p>Click on button to select the file</p>          <input type="file" id="Geeks" value="Click">          <h4></h4>          <script>        $(document).ready(function(){            $('input[type="file"]').change(function(){                $("h4").text("File is added!");            });        });    </script></body>  </html>
Output:
JQuery
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Form validation using jQuery
How to Dynamically Add/Remove Table Rows using jQuery ?
How to Show and Hide div elements using radio buttons?
Scroll to the top of the page using JavaScript/jQuery
jQuery | children() with Examples
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?
How to add a border around a NumPy array? - GeeksforGeeks

01 Oct, 2020
Sometimes we need to add a border around a NumPy matrix. Numpy provides a function known as ‘numpy.pad()’ to construct the border. The below examples show how to construct a border of ‘0’ around the identity matrix.
Syntax :
numpy.pad(array, pad_width, mode='constant', **kwargs)  

Example 1: Construct a border of 0s around 2D identity matrix
Python3
# importing Numpy packageimport numpy as np  # Creating a 2X2 Numpy matrixarray = np.ones((2, 2))  print("Original array")print(array)  print("\n0 on the border and 1 inside the array")  # constructing border of 0 around 2D identity matrix# using np.pad()array = np.pad(array, pad_width=1, mode='constant',               constant_values=0)  print(array)
Output:
In the above examples, we construct a border of 0s around the 2-D NumPy matrix.
Example 2: Construct a border of 0s around 3D identity matrix
Python3
# importing Numpy packageimport numpy as np  # Creating a 3X3 Numpy matrixarray = np.ones((3, 3))  print("Original array")print(array)  print("\n0 on the border and 1 inside the array")  # constructing border of 0 around 3D identity matrix# using np.pad()array = np.pad(array, pad_width=1, mode='constant',               constant_values=0)  print(array)
Output:
In the above examples, we construct a border of 0s around the 3-D NumPy matrix.
Example 3: Construct a border of 0s around 4D identity matrix
Python3
# importing Numpy packageimport numpy as np  # Creating a 4X4 Numpy matrixarray = np.ones((4, 4))  print("Original array")print(array)  print("\n0 on the border and 1 inside the array")  # constructing border of 0 around 4D identity matrix# using np.pad()array = np.pad(array, pad_width=1, mode='constant',               constant_values=0)  print(array)
Output:
In the above examples, we construct a border of 0s around the 4-D NumPy matrix.
Python numpy-arrayManipulation
Python-numpy
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?
Check if element exists in list in Python
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Python | os.path.join() method
Create a directory in Python
Python | Get unique values from a list
Python | Pandas dataframe.groupby()
Defaultdict in Python
How to implement an Interface using an Enum in Java

21 Jun, 2020
Enumerations serve the purpose of representing a group of named constants in a programming language. For example, the 4 suits in a deck of playing cards may be 4 enumerators named Club, Diamond, Heart, and Spade, belonging to an enumerated type named Suit. We have already discussed the basics of enum, how its declared in the previous article. In this article, we will understand how an enum implements an interface.
We primarily use enums when a method parameter can only take the value out of a small set of possible values means the input values are fixed and it takes from that fixed set of values. Java enum type is a special kind of java class which can contain constants and methods like normal java classes where the values are the only possible instances of this class. This enum extends the abstract class java.lang.Enum. Consider a situation when we have to implement some business logic which is tightly coupled with a discriminatory property of a given object or class at that time we implement an interface with enum. Think about a case where we need to merge the values of two enums into one group and treat them similarly, there Enum implements the interface.
Since an enum is implicitly extending the abstract class java.lang.Enum, it can not extend any other class or enum and also any class can not extend enum. So it’s clear that enum can not extend or can not be extended. But when there is a need to achieve multiple inheritance enum can implement any interface and in java, it is possible that an enum can implement an interface. Therefore, in order to achieve extensibility, the following steps are followed:
Create an interface.After creating an interface, implement that interface by Enum.
Create an interface.
After creating an interface, implement that interface by Enum.
The following is the code which demonstrates the implementation of an interface in an enum:
// Java program to demonstrate// how an enum implements an// interface  // Defining an interfaceinterface week {      // Defining an abstract method    public int day();}  // Initializing an enum which// implements the above interfaceenum Day implements week {      // Initializing the possible    // days    Monday,    Tuesday,    Wednesday,    Thursday,    Friday,    Saturday,    Sunday;      public int day()    {        return ordinal() + 1;    }}  // Main Classpublic class Daycount {    public static void main(String args[])    {        System.out.println("It is day number "                           + Day.Wednesday.day()                           + " of a week.");    }}
It is day number 3 of a week.

Java-Enumeration
java-interfaces
How To
Java
Write From Home
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Java Tutorial
How to filter object array based on attributes?
How to Align Text in HTML?
How to Install FFmpeg on Windows?
How to Set Git Username and Password in GitBash?
Arrays.sort() in Java with examples
Reverse a string in Java
Object Oriented Programming (OOPs) Concept in Java
How to iterate any Map in Java
Interfaces in Java
MongoDB – findOneAndDelete() Method

08 Feb, 2021
The findOneAndDelete() method deletes a single document based on the selection criteria from the collection. It deletes the first document from the collection that matches the given filter query expression. It takes five parameters the first parameter is the selection criteria and the others are optional. 
Syntax:
db.Collection_name.findOneAndDelete(
 Selection_criteria,
{
    projection: <document>,
    sort: <document>,
    maxTimeMS: <number>,
    collation: <document>
})
Parameters:
The first parameter is a selection criteria. The type of this parameter is a document.
The second parameter is optional.
Optional Parameters:
projection: It allows you to select only the necessary data rather than selecting whole data from the document.
sort: It specifies the sorting order for the documents matched by the selection criteria. The value 1 sort in increasing order and -1 sort in decreasing order.
maxTimeMs: It is the maximum amount of time to allow the query to run.
collation: It specifies the use of the collation for operations. It allows users to specify the language-specific rules for string comparison like rules for lettercase and accent marks. The type of this parameter is a document.
Return:
If a document matches the given filter query then this method returns the deleted document.
If no document matches the given filter query then this method return null.
Examples:
In the following examples, we are working with:
Database: gfg
Collections: student
Document: Four documents contains name and age of the students
Find and Delete the first document according to the selection criteria:
db.student.findOneAndDelete({name:"Bablue"})
Here we find and delete the document whose name is Bablue.
After deletion:
Find and Delete the document according to the selection criteria:
db.student.findOneAndDelete({age:17},{sort:{age:-1}})
Here, we first sort the documents according to the age field in decreasing order and then delete the first document whose age is 17.
After deletion:
When no document matches the filter query:
db.student.findOneAndDelete({name: "Sumit"})
Here, no sumit named document is present in the student collection. So, this method return null.
MongoDB-method
Picked
MongoDB
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Convert image to binary using Python

17 Dec, 2020
In this article, we are going to convert the image into its binary form. A binary image is a monochromatic image that consists of pixels that can have one of exactly two colors, usually black and white. Binary images are also called bi-level or two-level. This means that each pixel is stored as a single bit—i.e., 0 or 1.
The most important library needed for image processing in Python is OpenCV. Make sure you have installed the library into your Python. For steps for installing OpenCV refers to this article: Set up Opencv with anaconda environment
Approach:
Read the image from the location.As a colored image has RGB layers in it and is more complex, convert it to its Grayscale form first.Set up a Threshold mark, pixels above the given mark will turn white, and below the mark will turn black.
Read the image from the location.
As a colored image has RGB layers in it and is more complex, convert it to its Grayscale form first.
Set up a Threshold mark, pixels above the given mark will turn white, and below the mark will turn black.
Below is the implementation:
Python3
import cv2  # read the image fileimg = cv2.imread('ff.jpg', 2)  ret, bw_img = cv2.threshold(img, 127, 255, cv2.THRESH_BINARY)  # converting to its binary formbw = cv2.threshold(img, 127, 255, cv2.THRESH_BINARY)  cv2.imshow("Binary", bw_img)cv2.waitKey(0)cv2.destroyAllWindows()
Output:
Original Image
Binary Form
Picked
Python-OpenCV
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
How to drop one or multiple columns in Pandas Dataframe
Python | os.path.join() method
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python | Get unique values from a list
Create a directory in Python
Python String splitlines() Method

Python string  method splitlines() returns a list with all the lines in string, optionally including the line breaks (if num is supplied and is true)
Following is the syntax for splitlines() method −
str.splitlines()

Keepends − This is an optional parameter, if its value as true, line breaks need are also included in the output.
Keepends − This is an optional parameter, if its value as true, line breaks need are also included in the output.
The following example shows the usage of splitlines() method.
#!/usr/bin/python

str = "Line1-a b c d e f\nLine2- a b c\n\nLine4- a b c d";
print str.splitlines( )
print str.splitlines( 0 )
print str.splitlines( 3 )
print str.splitlines( 4 )
print str.splitlines( 5 )
When we run above program, it produces following result −
['Line1-a b c d e f', 'Line2- a b c', '', 'Line4- a b c d']
['Line1-a b c d e f', 'Line2- a b c', '', 'Line4- a b c d']
['Line1-a b c d e f\n', 'Line2- a b c\n', '\n', 'Line4- a b c d']
['Line1-a b c d e f\n', 'Line2- a b c\n', '\n', 'Line4- a b c d']
['Line1-a b c d e f\n', 'Line2- a b c\n', '\n', 'Line4- a b c d']

If you pass “True” as a parameter to this method this includes the line breaks in the output.
#!/usr/bin/python

str = "Line1-a b c d e f\nLine2- a b c\n\nLine4- a b c d";
print str.splitlines(True)
print str.splitlines( 0 )
print str.splitlines( 3 )
print str.splitlines( 4 )
print str.splitlines( 5 )
When we run above program, it produces following result −
['Line1-a b c d e f\n', 'Line2- a b c\n', '\n', 'Line4- a b c d']
['Line1-a b c d e f', 'Line2- a b c', '', 'Line4- a b c d']
['Line1-a b c d e f\n', 'Line2- a b c\n', '\n', 'Line4- a b c d']
['Line1-a b c d e f\n', 'Line2- a b c\n', '\n', 'Line4- a b c d']
['Line1-a b c d e f\n', 'Line2- a b c\n', '\n', 'Line4- a b c d']
Final variable in Java

A final variable can be explicitly initialized only once. A reference variable declared final can never be reassigned to refer to a different object. 
However, the data within the object can be changed. So, the state of the object can be changed but not the reference.
With variables, the final modifier often is used with static to make the constant a class variable.
public class Test {
   final int value = 10;
   // The following are examples of declaring constants:
   public static final int BOXWIDTH = 6;
   static final String TITLE = "Manager";
   public void changeValue() {
      value = 12; // will give an error
   }
}
Character.isLetterOrDigit() in Java with examples

06 Dec, 2018
The java.lang.Character.isLetterOrDigit(char ch) is an inbuilt method in java which determines if the specified character is a letter or digit.
Syntax:
public static boolean isLetterOrDigit(char ch)

Parameters: The function accepts a single mandatory parameter ch which signifies the character to be tested.
Return value: This function returns a boolean value. The boolean value is true if the character is a letter or digit else it false.
Below programs illustrate the above method:
Program 1:
// Java program to illustrate the// Character.isLetterOrDigit() method  import java.lang.*;  public class GFG {      public static void main(String[] args)    {          // two characters        char c1 = 'Z', c2 = '2';          // Function to check if the character is letter or digit        boolean bool1 = Character.isLetterOrDigit(c1);        System.out.println(c1 + " is a letter/digit ? " + bool1);          // Function to check if the character is letter or digit        boolean bool2 = Character.isLetterOrDigit(c2);        System.out.println(c2 + " is a letter/digit ? " + bool2);    }}
Z is a letter/digit ? true
2 is a letter/digit ? true

Program 2:
// Java program to illustrate the// Character.isLetterOrDigit() method  import java.lang.*;  public class GFG {      public static void main(String[] args)    {          // assign character        char c1 = 'D', c2 = '/';          // Function to check if the character is letter or digit        boolean bool1 = Character.isLetterOrDigit(c1);        System.out.println(c1 + " is a letter/digit ? " + bool1);          // Function to check if the character is letter or digit        boolean bool2 = Character.isLetterOrDigit(c2);        System.out.println(c2 + " is a letter/digit ? " + bool2);    }}
D is a letter/digit ? true
/ is a letter/digit ? false

Reference: https://docs.oracle.com/javase/7/docs/api/java/lang/Character.html#isLetterOrDigit(char)
Java-Character
Java-Functions
Java-lang package
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Stream In Java
Introduction to Java
Constructors in Java
Exceptions in Java
Generics in Java
Functional Interfaces in Java
Java Programming Examples
Strings in Java
Differences between JDK, JRE and JVM
Abstraction in Java
Graph - GeeksforGeeks

19 Nov, 2018
I. 7, 6, 5, 4, 4, 3, 2, 1
II. 6, 6, 6, 6, 3, 3, 2, 2
III. 7, 6, 6, 4, 4, 3, 2, 2
IV. 8, 7, 7, 6, 4, 2, 1, 1 
Writing code in comment? Please use ide.geeksforgeeks.org, generate link and share the link here.
Must Do Coding Questions for Product Based Companies
How to Replace Values in Column Based on Condition in Pandas?
How to Fix: SyntaxError: positional argument follows keyword argument in Python
C Program to read contents of Whole File
How to Download and Install Spring Tool Suite (Spring Tools 4 for Eclipse) IDE?
How to Append Pandas DataFrame to Existing CSV File?
How to Replace Values in a List in Python?
Spring - REST Controller
How to Read Text Files with Pandas?
How to Calculate Moving Averages in Python?
How to clear Tkinter Canvas? - GeeksforGeeks

11 Dec, 2020
Tkinter is a Python Package for creating effective GUI applications. Tkinter’s Canvas widget is nothing but a rectangular area that is used for drawing pictures, simple shapes, or any complex graph. We can place any widgets like text, button, or frames on the canvas.
The task here is to generate a Python script that can clear Tkinter Canvas. For that delete function of this module will be employed. This method has a special parameter all which represents all the component on the canvas. To clear this canvas give this special parameter to the delete method. Thus, the line below is sufficient to clear the canvas:
delete('all')
If you want to delete any specific item then you can assign a tag to that item and instead of all pass that tag to the delete method.  
Given below is the code to achieve this specific functionality:
Program:
Before clearing canvas
Python3
# import tkinterfrom tkinter import *  # make an object of Tk interfacewindow = Tk()  # Give the title to out windowwindow.title('GFG')  # creating canvascanvas = Canvas(window, width=300, height=200)canvas.pack()  # draw line to out canvascanvas.create_line(0, 0, 300, 200)canvas.create_line(0, 200, 300, 0)  # draw oval to out canvascanvas.create_oval(50, 25, 250, 175, fill="yellow")  window.mainloop()
Output:
Simple canvas Example
After clearing canvas
Python3
# import tkinterfrom tkinter import *  # make an object of Tk interfacewindow = Tk()  # Give the title to out windowwindow.title('GFG')  # creating canvascanvas = Canvas(window, width=300, height=200)canvas.pack()  # draw line to out canvascanvas.create_line(0, 0, 300, 200)canvas.create_line(0, 200, 300, 0)  # draw oval to out canvascanvas.create_oval(50, 25, 250, 175, fill="yellow")  # clear the canvascanvas.delete('all')  window.mainloop()
Output:
Cleared canvas
Python-tkinter
Technical Scripter 2020
Python
Technical Scripter
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Python | os.path.join() method
Python | Pandas dataframe.groupby()
Create a directory in Python
Defaultdict in Python
Python | Get unique values from a list
How to Check if Android EditText is empty in Kotlin?

This example demonstrates how to Check if Android EditText is empty in Kotlin.
Step 1 − Create a new project in Android Studio, go to File? New Project and fill all required details to create a new project.
Step 2 − Add the following code to res/layout/activity_main.xml.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:tools="http://schemas.android.com/tools"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:padding="2dp"
   tools:context=".MainActivity">
   <EditText
      android:id="@+id/editText"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_centerHorizontal="true"
      android:layout_marginTop="45dp"
      android:textSize="24sp" />
   <Button
      android:id="@+id/buttonCheck"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_below="@id/editText"
      android:layout_centerInParent="true"
      android:layout_marginTop="25sp"
      android:text="Check Edit" />
</RelativeLayout>
Step 3 − Add the following code to src/MainActivity.kt
import android.os.Bundle
import android.text.TextUtils
import android.widget.Button
import android.widget.EditText
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
class MainActivity : AppCompatActivity() {
   lateinit var editText: EditText
   lateinit var button: Button
   override fun onCreate(savedInstanceState: Bundle?) {
      super.onCreate(savedInstanceState)
      setContentView(R.layout.activity_main)
      title = "KotlinApp"
      button = findViewById(R.id.buttonCheck)
      button.setOnClickListener {
         if (TextUtils.isEmpty(editText.text.toString())) {
            Toast.makeText(this, "Empty field not allowed!", Toast.LENGTH_SHORT).show()
         } else {
            Toast.makeText(this, "Proceed..", Toast.LENGTH_SHORT).show()
         }
      }
   }
}
Step 4 − Add the following code to androidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="app.com.q1">
   <application
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:supportsRtl="true"
      android:theme="@style/AppTheme">
      <activity android:name=".MainActivity">
         <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
         </intent-filter>
      </activity>
   </application>
</manifest>
Let's try to run your application. I assume you have connected your actual Android Mobile device with your computer. To run the app from android studio, open one of your project's activity files and click the Run icon from the toolbar. Select your mobile device as an option and then check your mobile device which will display your default screen
Write your own len() in Python - GeeksforGeeks

01 Feb, 2018
The method len() returns the number of elements in the list or length of the string depending upon the argument you are passing.
How to implement without using len():
1. Take input and pass the string/list into
   a function which return its length.
2. Initialize a count variable to 0, this count 
   variable count character in the string.
3. Run a loop till length if the string and increment 
   count by 1.
4. When loop is completed return count.

Python implementation:
# Function which return length of stringdef findLength(string):      # Initialize count to zero    count = 0      # Counting character in a string    for i in string:        count+= 1    # Returning count    return count  # Driver codestring = "geeksforgeeks"print(findLength(string))
Output:
13

This article is contributed by Sahil Rajput. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@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.
Python-Built-in-functions
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Python | os.path.join() method
Python | Get unique values from a list
Create a directory in Python
Defaultdict in Python
Python | Pandas dataframe.groupby()
How To Merge Two DataFrames in R ? - GeeksforGeeks

26 Mar, 2021
In this article, We are going to see how to merge two R dataFrames. Merging of Data frames in R can be done in two ways.
Merging columns
Merging rows
In this way, we merge the database horizontally. We use the merge function to merge two frames by one or more common key variables(i.e., an inner join).
dataframe_AB = merge(dataframe_A, dataframe_B, by="ID")
Below is the implementation:
R
# merging two datasetsauthors <- data.frame(  name = c("kapil", "sachin", "Rahul","Nikhil","Rohan"),  nationality = c("US","Australia","US","UK","India"),  retired = c("Yes","No","Yes","No","No"))  books <-data.frame(   name = c("C", "C++","Java","php",".net","R"),  title = c("Intro to C","Intro to C++",             "Intro to java", "Intro to php",             "Intro to .net", "Intro to R"),  author = c("kapil", "kapil","sachin", "Rahul",             "Nikhil","Nikhil"))      merge(authors, books, by.x = "name", by.y = "author")
Output:
In this way, we merge the data frames vertically and use the rbind() function. rbind stands for row binding. The two data frames must have the same variables but need not be in the same order.
Note: If dataframe_A has variables that dataframe_B doesn’t have, either Delete the extra variables in dataframe_A or create the additional variables in dataframe_B and set them to NA.
As we can see from the below diagram, it combines rows of two dataframes.
Below is the implementation:
R
# merging two datasetsauthors_A <- data.frame(  name = c("kapil", "sachin", "Rahul"),  nationality = c("US", "Australia", "US"),  retired = c("Yes", "No", "Yes"))  authors_B <- data.frame(  name = c("Nikhil", "Rohan"),  nationality = c("UK", "India"),  retired = c("No", "No"))  rbind(authors_A, authors_B)
Output:
Picked
R DataFrame-Programs
R-DataFrame
R Language
R Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Change Color of Bars in Barchart using ggplot2 in R
Group by function in R using Dplyr
How to Change Axis Scales in R Plots?
How to Split Column Into Multiple Columns in R DataFrame?
Replace Specific Characters in String in R
How to Split Column Into Multiple Columns in R DataFrame?
Replace Specific Characters in String in R
How to filter R DataFrame by values in a column?
How to filter R dataframe by multiple conditions?
Convert Matrix to Dataframe in R
Remove end characters from strings in Julia - strip(), lstrip() and rstrip() Methods - GeeksforGeeks

01 Apr, 2020
The strip() is an inbuilt function in julia which is used to remove leading and trailing characters from the specified string str. These removing elements is specified by given characters chars.
Syntax:strip(str::AbstractString, chars)
Parameters:
str::AbstractString: Specified string.
chars: Specified characters.
Returns: It returns a stripped part of the given string.
Example:
# Julia program to illustrate # the use of strip() method   # Getting a stripped part of the given string.println(strip("Geeks", ['s']))println(strip("GFG", ['G']))println(strip("1 + 2+3 + 4", ['+']))println(strip("+1 + 2+3 + 4+", ['+']))
Output:
Geek
F
1+2+3+4
1+2+3+4

The lstrip() is an inbuilt function in julia which is used to remove leading characters from the specified string str. These removing elements is specified by given characters chars.
Syntax:lstrip(str::AbstractString, chars)
Parameters:
str::AbstractString: Specified string.
chars: Specified characters.
Returns: It returns a stripped part of the given string.
Example:
# Julia program to illustrate # the use of lstrip() method   # Getting a stripped part of the given string.println(lstrip("Geek", ['G']))println(lstrip("GFG", ['G']))println(lstrip("1 + 2+3 + 4+", ['+']))println(lstrip("+1 + 2+3 + 4", ['+']))
Output:
eek
FG
1+2+3+4+
1+2+3+4

The rstrip() is an inbuilt function in julia which is used to remove trailing characters from the specified string str. These removing elements is specified by given characters chars.
Syntax:rstrip(str::AbstractString, chars)
Parameters:
str::AbstractString: Specified string.
chars: Specified characters.
Returns: It returns a stripped part of the given string.
Example:
# Julia program to illustrate # the use of rstrip() method   # Getting a stripped part of the given string.println(rstrip("Geek", ['G']))println(rstrip("GFG", ['G']))println(rstrip("1 + 2+3 + 4+", ['+']))println(rstrip("+1 + 2+3 + 4", ['+']))
Output:
Geek
GF
1+2+3+4
+1+2+3+4

Julia
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Vectors in Julia
Getting rounded value of a number in Julia - round() Method
Decision Making in Julia (if, if-else, Nested-if, if-elseif-else ladder)
Storing Output on a File in Julia
Formatting of Strings in Julia
Reshaping array dimensions in Julia | Array reshape() Method
Manipulating matrices in Julia
Creating array with repeated elements in Julia - repeat() Method
while loop in Julia
Get array dimensions and size of a dimension in Julia - size() Method
HTML <pre> Tag - GeeksforGeeks

17 Mar, 2022
The <pre> tag in HTML is used to define the block of preformatted text which preserves the text spaces, line breaks, tabs, and other formatting characters which are ignored by web browsers. Text in the <pre> element is displayed in a fixed-width font, but it can be changed using CSS. The <pre> tag requires a starting and end tag.Syntax:  
<pre> Contents... </pre>
Below examples illustrate the <pre> tag in HTML:Example 1:  
HTML
<html>    <body>        <!-- html pre tag starts here -->        <pre>            GeeksforGeeks            A Computer   Science Portal   For Geeks        </pre>        <!-- html pre tag ends here -->    </body></html>                   
Output:  
Example 2:  
HTML
<html>    <head>        <title>pre tag with CSS</title>        <style>            pre {                font-family: Arial;                color: #009900;                margin: 25px;            }        </style>    </head>    <body>        <!-- html pre tag starts here -->        <pre>            GeeksforGeeks            A Computer   Science Portal   For Geeks        </pre>        <!-- html pre tag ends here -->    </body></html>
Output:  
Supported Browsers:  
Google Chrome
Internet Explorer
Firefox
Opera
Safari
 
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
shubhamyadav4
HTML-Tags
HTML
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to insert spaces/tabs in text using HTML/CSS?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to update Node.js and NPM to next version ?
How to set the default value for an HTML <select> element ?
Hide or show elements in HTML using display property
How to set input type date in dd-mm-yyyy format using HTML ?
REST API (Introduction)
How to Insert Form Data into Database using PHP ?
CSS to put icon inside an input element in a form
Types of CSS (Cascading Style Sheet)
How to compile 32-bit program on 64-bit gcc in C and C++ - GeeksforGeeks

11 Oct, 2021
Mostly compiler(gcc or clang) of C and C++, nowadays come with default 64-bit version. Well it would be a good option in terms of speed purposes. But it would lead to problem, if someone wants to run their program as a 32-bit rather than 64-bit for testing or debugging purposes. Therefore we must have a knowledge about this.Before proceeding forward, let’s confirm which bit-version of gcc is currently installed in our system. Just type the following command on Linux terminal.  
Command: gcc -v
Output 
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper
Target: x86_64-linux-gnu
......................
......................
Hence the fourth line Target: x86_64-linux-gnu confirms that we are running 64-bit gcc.Now in order to compile with 32-bit gcc, just add a flag -m32 in the command line of compiling the ‘C’ language program. For instance, to compile a file of geek.c through Linux terminal, you must write the following command with -m32 flag.  
Command: gcc -m32 geek.c -o geek
If you get an error as follows:  
fatal error: bits/predefs.h: No such file or directory
Then it indicates that a standard library of gcc is been missing. In that case you must install gcc-multlib by using the following command:  
For C language:
sudo apt-get install gcc-multilib
For C++ language:
sudo apt-get install g++-multilib
After that you will be able to compile a 32-bit binary on a 64-bit system.How to check whether a program is compiled with 32-bit after adding a “-m32” flag? Well we can easily check this by the following program.  
CPP
// C program to demonstrate difference// in output in 32-bit and 64-bit gcc// File name: geek.c#include<stdio.h>int main(){    printf("Size = %lu", sizeof(size_t));}
Compile the above program in Linux by these two different commands, Default 64-bit compilation,  
Input: gcc -m64 geek.c -o out
Output: ./out
Size = 8
Forced 32-bit compilation,  
Input: gcc -m32 geek.c -o out
Output: ./out
Size = 4
Can we conclude anything from above program. Yes maybe, let’s try to understand more. Since the size of data types like long, size_t, pointer data type(int*, char* etc) is compiler dependent, therefore it will generate a different output according to bit of compiler.This article is contributed by Shubham Bansal. 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. 
vaibhavsinghtanwar
abhishek0719kadiyan
CPP-Basics
C Language
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Multidimensional Arrays in C / C++
Left Shift and Right Shift Operators in C/C++
Substring in C++
Core Dump (Segmentation fault) in C/C++
rand() and srand() in C/C++
Vector in C++ STL
Inheritance in C++
Initialize a vector in C++ (6 different ways)
Map in C++ Standard Template Library (STL)
C++ Classes and Objects
Java Program for Insertion Sort - GeeksforGeeks

06 Aug, 2018
Insertion sort is a simple sorting algorithm that works the way we sort playing cards in our hands.
// Java program for implementation of Insertion Sortclass InsertionSort{    /*Function to sort array using insertion sort*/    void sort(int arr[])    {        int n = arr.length;        for (int i=1; i<n; ++i)        {            int key = arr[i];            int j = i-1;              /* Move elements of arr[0..i-1], that are               greater than key, to one position ahead               of their current position */            while (j>=0 && arr[j] > key)            {                arr[j+1] = arr[j];                j = j-1;            }            arr[j+1] = key;        }    }      /* A utility function to print array of size n*/    static void printArray(int arr[])    {        int n = arr.length;        for (int i=0; i<n; ++i)            System.out.print(arr[i] + " ");          System.out.println();    }      // Driver method    public static void main(String args[])    {                int arr[] = {12, 11, 13, 5, 6};          InsertionSort ob = new InsertionSort();                ob.sort(arr);                  printArray(arr);    }} /* This code is contributed by Rajat Mishra. */
Please refer complete article on Insertion Sort for more details!
Java Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Iterate Over the Characters of a String in Java
How to Get Elements By Index from HashSet in Java?
Java Program to Write into a File
Java Program to Find Sum of Array Elements
How to Replace a Element in Java ArrayList?
Java Program to Read a File to String
Tic-Tac-Toe Game in Java
Removing last element from ArrayList in Java
How to Write Data into Excel Sheet using Java?
Java Program to Write an Array of Strings to the Output Console
PYGLET – Drawing Circle - GeeksforGeeks

25 Aug, 2021
In this article we will see how we can draw circles on window in PYGLET module in python. Pyglet is easy to use but powerful library for developing visually rich GUI applications like games, multimedia etc. A window is a “heavyweight” object occupying operating system resources. Windows may appear as floating regions or can be set to fill an entire screen (fullscreen). A circle is a shape consisting of all points in a plane that are a given distance from a given point, the centre; equivalently it is the curve traced out by a point that moves in a plane so that its distance from a given point is constant. Circle is drawn with the help of shapes module in pyglet.We can create a window with the help of command given below  
# creating a window
window = pyglet.window.Window(width, height, title)
 
In order to create window we use Circle method with pyglet.shapesSyntax : shapes.Circle(x, y, size, color)Argument : It takes first two integer i.e circle position, third integer as size of circle and forth is tuple i.e color of circle as argumentReturn : It returns Circle object  
Below is the implementation  
Python3
# importing pyglet moduleimport pyglet # importing shapes from the pygletfrom pyglet import shapes # width of windowwidth = 500   # height of windowheight = 500   # caption i.e title of the windowtitle = "Geeksforgeeks"   # creating a windowwindow = pyglet.window.Window(width, height, title) # creating a batch objectbatch = pyglet.graphics.Batch()  # properties of circle# co-ordinates of circlecircle_x = 250circle_y = 250 # size of circle# color = greensize_circle = 100 # creating a circlecircle1 = shapes.Circle(circle_x, circle_y, size_circle, color =(50, 225, 30), batch = batch) # changing opacity of the circle1# opacity is visibility (0 = invisible, 255 means visible)circle1.opacity = 250  # creating another circle with other properties# new position = circle1_position - 50# new size = previous radius -20# new color = redcircle2 = shapes.Circle(circle_x-50, circle_y-50, size_circle-20, color =(250, 25, 30), batch = batch) # changing opacity of the circle2circle2.opacity = 150 # window draw event@window.eventdef on_draw():         # clear the window    window.clear()         # draw the batch    batch.draw() # run the pyglet applicationpyglet.app.run()
sumitgumber28
Python-gui
Python-Pyglet
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python Classes and Objects
How to drop one or multiple columns in Pandas Dataframe
Defaultdict in Python
Python | Get unique values from a list
Python | os.path.join() method
Create a directory in Python
Python | Pandas dataframe.groupby()
List retainAll() Method in Java with Examples - GeeksforGeeks

02 Jan, 2019
This method is used to retain all the elements present in the collection from the specified collection into the list.
Syntax:
boolean retainAll(Collection c)
Parameters: This method has only argument, collection of which elements are to be retained in the given list.
Returns: This method returns True if elements are retained and list changes.
Below programs show the implementation of this method.
Program 1:
// Java code to show the implementation of// retainAll method in list interfaceimport java.util.*;public class GfG {      // Driver code    public static void main(String[] args)    {          // Initializing a list of type Linkedlist        List<Integer> l = new LinkedList<>();        l.add(1);        l.add(3);        l.add(5);        l.add(7);        l.add(9);        System.out.println(l);          ArrayList<Integer> arr = new ArrayList<>();        arr.add(3);        arr.add(5);        l.retainAll(arr);          System.out.println(l);    }}
[1, 3, 5, 7, 9]
[3, 5]

Program 2: Below is the code to show implementation of list.retainAll() using Linkedlist.
// Java code to show the implementation of// retainAll method in list interfaceimport java.util.*;public class GfG {      // Driver code    public static void main(String[] args)    {          // Initializing a list of type Linkedlist        List<String> l = new LinkedList<>();        l.add("10");        l.add("30");        l.add("50");        l.add("70");        l.add("90");        System.out.println(l);          ArrayList<String> arr = new ArrayList<>();        arr.add("30");        arr.add("50");        l.retainAll(arr);          System.out.println(l);    }}
[10, 30, 50, 70, 90]
[30, 50]

Reference:Oracle Docs
Java - util package
Java-Collections
Java-Functions
java-list
Java
Java
Java-Collections
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Stream In Java
Constructors in Java
Exceptions in Java
Functional Interfaces in Java
Different ways of Reading a text file in Java
Generics in Java
Introduction to Java
Comparator Interface in Java with Examples
Internal Working of HashMap in Java
Strings in Java
Count of all even numbers in the range [L, R] whose sum of digits is divisible by 3 in C++

We are given two numbers L and R that define a range [L,R]. The goal is to find all numbers between L and R that are even, and sum of whose digits is divisible by 3.
We will do this by calculating the sum of digits of all even numbers between L and R and increment count if that sum%3==0.
Let us understand with examples.
Input − L=10, R=20
Output − Count of all even numbers in the range [L, R] whose sum of digits is divisible by 3: 2
Explanation − Numbers between 10 and 20 that are even. 10,12,14,16,18,20. Sum of whose digits divisible by 3= 12 and 18.
Input − L=100, R=108
Output− Count of all even numbers in the range [L, R] whose sum of digits is divisible by 3: 2
Explanation − Numbers between 100 and 108 that are even. 100,102,104,106,108. Sum of whose digits divisible by 3= 102 and 108.
We take variables first and last to define range.
We take variables first and last to define range.
Function Digit_sum(int num) takes the number and returns the sum of its digits.
Function Digit_sum(int num) takes the number and returns the sum of its digits.
Using while loop, till num!=0, add num%10, (unit digit) to total.
Using while loop, till num!=0, add num%10, (unit digit) to total.
Divide num by 10 to reduce it.
Divide num by 10 to reduce it.
At the end total will have sum of all digits.
At the end total will have sum of all digits.
Function divisible_3(int first, int last) takes the range of numbers and returns the count of even numbers that have digit sum divisible by 3.
Function divisible_3(int first, int last) takes the range of numbers and returns the count of even numbers that have digit sum divisible by 3.
Starting from index i=first to i<=last. Check if number i is even. (i%2==0).
Starting from index i=first to i<=last. Check if number i is even. (i%2==0).
If true, then calculate sum of digits of i by calling Digit_sum(i). If that sum%3==0. Then increment count.
If true, then calculate sum of digits of i by calling Digit_sum(i). If that sum%3==0. Then increment count.
At the end of for loop return count as result.
At the end of for loop return count as result.
 Live Demo
#include <bits/stdc++.h>
using namespace std;
int Digit_sum(int num){
   int total = 0;
   while (num!= 0){
      total += num % 10;
      num = num / 10;
   }
   return total;
}
int divisible_3(int first, int last){
   int count = 0;
   for (int i = first; i <= last; i++){
      if (i % 2 == 0 && Digit_sum(i) % 3 == 0){
         count++;
      }
   }
   return count;
}
int main(){
   int first = 300, last = 500;
   cout<<"Count of all even numbers in the range [L, R] whose sum of digits is divisible by 3 are: "<<divisible_3(first, last);
   return 0;
}
If we run the above code it will generate the following output −
Count of all even numbers in the range [L, R] whose sum of digits is divisible by 3 are: 34
How to use a final or effectively final variable in lambda expression in Java?

The effectively final variables refer to local variables that are not declared final explicitly and can't be changed once initialized. A lambda expression can use a local variable in outer scopes only if they are effectively final.
(optional) (Arguments) -> body
In the below example, the "size" variable is not declared as final but it's effective final because we are not modifying the value of the "size" variable.
interface Employee {
   void empData(String empName);
}
public class LambdaEffectivelyFinalTest {
   public static void main(String[] args) {
      int size = 100;
      Employee emp = name -> {        // lambda expression
               System.out.println("The employee strength is: " + size);
               System.out.println("The employee name is: " + name);
      };
      emp.empData("Adithya");
   }
}
The employee strength is: 100
The employee name is: Adithya
Change Legend background using facecolor in MatplotLib - GeeksforGeeks

22 Jan, 2021
In this article, we will see how can we can change the background color of a legend in our graph using MatplotLib, Here we will take two different examples to showcase different background colors of a legend in our graph.
Requirements:
pip install matplotlib
Approach:
Import required module.
Create data.
Change the background color of a legend.
Normally plot the data.
Display plot.
Implementation:
Example 1:
In this example, we will draw different lines with the help of matplotlib and Use the facecolor argument to plt.legend() to specify the legend background color.
Python3
# importing package import matplotlib.pyplot as plt import numpy as np   # create data X = [1,2,3,4,5] Y = [3,3,3,3,3]   # plot lines plt.plot(X, Y, label = "Line-1") plt.plot(Y, X, label = "Line-2") plt.plot(X, np.sin(X), label = "Curve-1") plt.plot(X, np.cos(X), label = "Curve-2")   #Change the background color of a  legend.plt.legend(facecolor="gray")plt.title("Line Graph - Geeksforgeeks")  plt.show()
Output:
Example 2:
In this example, we will draw a Vertical line with the help of matplotlib and Use the facecolor argument to plt.legend() to specify the legend background color.
Python3
# importing package import matplotlib.pyplot as plt   #Create data and plot lines.plt.plot([0, 1], [0, 2.0], label='Label-1')plt.plot([1, 2], [0, 2.1], label='Label-2')plt.plot([2, 3], [0, 2.2], label='Label-3')  #Change the background color of a  legend.plt.legend(facecolor="pink")plt.title("Line Graph - Geeksforgeeks")  plt.show()
Output:
Python-matplotlib
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
Python | os.path.join() method
Defaultdict in Python
Selecting rows in pandas DataFrame based on conditions
Python | Get unique values from a list
Create a directory in Python
Python | Pandas dataframe.groupby()