code-rag-bench/online-tutorials huggingface dataset:
Pascal - Relational Operators

Following table shows all the relational operators supported by Pascal. Assume variable A holds 10 and variable B holds 20, then −
Try the following example to understand all the relational operators available in Pascal programming language −
program showRelations;
var
a, b: integer;

begin
   a := 21;
   b := 10;
   
   if a = b then
      writeln('Line 1 - a is equal to b' )
   else
      writeln('Line 1 - a is not equal to b' );
   
   if  a < b then
      writeln('Line 2 - a is less than b' )
   else
      writeln('Line 2 - a is not less than b' );
   
   if  a > b then
      writeln('Line 3 - a is greater than b' )
   else
      writeln('Line 3 - a is greater than b' );
  
   (* Lets change value of a and b *)
   a := 5;
   b := 20;
   
   if  a <= b then
      writeln('Line 4 - a is either less than or equal to b' );
   
   if ( b >= a ) then
      writeln('Line 5 - b is either greater than  or equal to ' );
end.
When the above code is compiled and executed, it produces the following result:
Line 1 - a is not equal to b
Line 2 - a is not less than b
Line 3 - a is greater than b
Line 4 - a is either less than or equal to b
Line 5 - b is either greater than or equal to b


    94 Lectures 
     8.5 hours 

 Stone River ELearning
 Print
 Add Notes
 Bookmark this page
MySQL query to skip the duplicate and select only one from the duplicated values

The syntax is as follows to skip the duplicate value and select only one from the duplicated values −
select min(yourColumnName1),yourColumnName2 from yourTableName group by
yourColumnName2;
To understand the above syntax, let us create a table. The query to create a table is as follows −
mysql> create table doNotSelectDuplicateValuesDemo
   -> (
   -> User_Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   -> User_Name varchar(20)
   -> );
Query OK, 0 rows affected (0.78 sec)
Now you can insert some records in the table using insert command. The query is as follows −
mysql> insert into doNotSelectDuplicateValuesDemo(User_Name) values('John');
Query OK, 1 row affected (0.15 sec)
mysql> insert into doNotSelectDuplicateValuesDemo(User_Name) values('Carol');
Query OK, 1 row affected (0.09 sec)
mysql> insert into doNotSelectDuplicateValuesDemo(User_Name) values('Carol');
Query OK, 1 row affected (0.17 sec)
mysql> insert into doNotSelectDuplicateValuesDemo(User_Name) values('Carol');
Query OK, 1 row affected (0.08 sec)
mysql> insert into doNotSelectDuplicateValuesDemo(User_Name) values('Sam');
Query OK, 1 row affected (0.28 sec)
mysql> insert into doNotSelectDuplicateValuesDemo(User_Name) values('Mike');
Query OK, 1 row affected (0.19 sec)
mysql> insert into doNotSelectDuplicateValuesDemo(User_Name) values('Bob');
Query OK, 1 row affected (0.16 sec)
mysql> insert into doNotSelectDuplicateValuesDemo(User_Name) values('David');
Query OK, 1 row affected (0.21 sec)
mysql> insert into doNotSelectDuplicateValuesDemo(User_Name) values('Maxwell');
Query OK, 1 row affected (0.13 sec)
mysql> insert into doNotSelectDuplicateValuesDemo(User_Name) values('Bob');
Query OK, 1 row affected (0.11 sec)
mysql> insert into doNotSelectDuplicateValuesDemo(User_Name) values('Ramit');
Query OK, 1 row affected (0.16 sec)
Display all records from the table using select statement. The query is as follows −
mysql> select *from doNotSelectDuplicateValuesDemo;
Here is the output −
+---------+-----------+
| User_Id | User_Name |
+---------+-----------+
| 1       | John      |
| 2       | Carol     |
| 3       | Carol     |
| 4       | Carol     |
| 5       | Sam       |
| 6       | Mike      |
| 7       | Bob       |
| 8       | David     |
| 9       | Maxwell   |
| 10      | Bob       |
| 11      | Ramit     |
+---------+-----------+
11 rows in set (0.00 sec)
Here is the query to skip the duplicate value and select only one from the duplicated values −
mysql> select min(User_Id),User_Name from doNotSelectDuplicateValuesDemo group by
User_Name;
Here is the output −
+--------------+-----------+
| min(User_Id) | User_Name |
+--------------+-----------+
| 1            | John      |
| 2            | Carol     |
| 5            | Sam       |
| 6            | Mike      |
| 7            | Bob       |
| 8            | David     |
| 9            | Maxwell   |
| 11           | Ramit     |
+--------------+-----------+
8 rows in set (0.07 sec)
How to delete lines from a Python tkinter canvas?

The Canvas widget has many use-cases in GUI application development. We can use a Canvas widget to draw shapes, creating graphics, images, and many other things. To draw a line in Canvas, we can use create_line(x,y,x1,y1, **options) method. In Tkinter, we can draw two types of lines − simple and dashed.
If you want your application to delete the created lines, then you can use the delete() method.
Let us have a look at the example where we will delete the line defined in the Canvas widget.
# Import the required libraries
from tkinter import *

# Create an instance of tkinter frame or window
win=Tk()

# Set the size of the tkinter window
win.geometry("700x350")

# Define a function to delete the shape
def on_click():
   canvas.delete(line)

# Create a canvas widget
canvas=Canvas(win, width=500, height=300)
canvas.pack()

# Add a line in canvas widget
line=canvas.create_line(100,200,200,35, fill="red", width=10)

# Create a button to delete the button
Button(win, text="Delete Shape", command=on_click).pack()

win.mainloop()
If we run the above code, it will display a window with a button and a shape in the canvas.
Now, click the "Delete Shape" button to delete the displayed line from the canvas.
Python OpenCV – waitKey() Function

17 Oct, 2021
waitkey() function of Python OpenCV allows users to display a window for given milliseconds or until any key is pressed. It takes time in milliseconds as a parameter and waits for the given time to destroy the window, if 0 is passed in the argument it waits till any key is pressed. 
Using waitKey() method we show the image for 5 seconds before it automatically closes. The code will be as follows:
Python
# importing cv2 moduleimport cv2  # read the imageimg = cv2.imread("gfg_logo.png")  # showing the imagecv2.imshow('gfg', img)  # waiting using waitKey methodcv2.waitKey(5000)
Output:
Now we can see one example of passing 0 as the parameter. This time instead of automatically closing the window would wait till any key is pressed. The code will be:
Python
# importing cv2 moduleimport cv2  # read the imageimg = cv2.imread("gfg_logo.png")  # showing the imagecv2.imshow('gfg', img)  # waiting using waitKey methodcv2.waitKey(0)
Output:
Picked
Python-OpenCV
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Program to print all permutations of a given string

13 Jan, 2022
A permutation also called an “arrangement number” or “order,” is a rearrangement of the elements of an ordered list S into a one-to-one correspondence with S itself. A string of length n has n! permutation. 
Source: Mathword(http://mathworld.wolfram.com/Permutation.html)
Below are the permutations of string ABC. ABC ACB BAC BCA CBA CAB
Here is a solution that is used as a basis in backtracking.
Python3
# Python program to print all permutations# with duplicates alloweddef toString(List):    return ''.join(List) # Function to print permutations# of string# This function takes three parameters:# 1. String# 2. Starting index of the string# 3. Ending index of the string.def permute(a, l, r):    if l == r:        print (toString(a))    else:        for i in range(l, r + 1):            a[l], a[i] = a[i], a[l]            permute(a, l + 1, r)             # backtrack            a[l], a[i] = a[i], a[l] # Driver codestring = "ABC"n = len(string)a = list(string)permute(a, 0, n-1)# This code is contributed by Bhavya Jain
Output: 
ABC
ACB
BAC
BCA
CBA
CAB
Algorithm Paradigm: Backtracking 
Time Complexity: O(n*n!) Note that there are n! permutations and it requires O(n) time to print a permutation.
Auxiliary Space: O(r – l)
Note: The above solution prints duplicate permutations if there are repeating characters in the input string. Please see the below link for a solution that prints only distinct permutations even if there are duplicates in input.Print all distinct permutations of a given string with duplicates. Permutations of a given string using STL
Another approach:
Python3
# Python program to implement# the above approachdef permute(s, answer):    if (len(s) == 0):        print(answer, end = "  ")        return         for i in range(len(s)):        ch = s[i]        left_substr = s[0:i]        right_substr = s[i + 1:]        rest = left_substr + right_substr        permute(rest, answer + ch) # Driver Codeanswer = ""s = input("Enter the string : ")print("All possible strings are : ")permute(s, answer)# This code is contributed by Harshit Srivastava
Output:
Enter the string : abc
All possible strings are : abc  acb  bac  bca  cab  cba
Time Complexity: O(n*n!) The time complexity is the same as the above approach, i.e. there are n! permutations and it requires O(n) time to print a permutation.
Auxiliary Space: O(|s|)
viditvarshney
amartyaghoshgfg
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | Convert string dictionary to dictionary
Python program to add two numbers
Python Program for Binary Search (Recursive and Iterative)
Python Program for factorial of a number
Python program to find second largest number in a list
Iterate over characters of a string in Python
Python program to interchange first and last elements in a list
Python | Convert set into a list
Appending to list in Python dictionary
Python | Convert a list into a tuple
List View Search list on typing with filter like keyword search using jQuery?

Let’s the following is our input type, wherein the user will search −
<input type="text" class="txtInput" id="searchTheKey" placeholder="Enter the keywords to search.....">
Now, use hide() and show() to display only relevant search and hide rest. For example, on
typing “Ja”, related keywords like “Java” and “JavaScript” should be visible because it begins
with “Ja”.
 Live Demo
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initialscale=1.0">
<title>Document</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
</head>
<body>
<label>
Enter the keyword..
<input type="text" class="txtInput" id="searchTheKey" placeholder="Enter the keywords to search.....">
</label>
<ul id="matchKey">
<li id="subjectName">JavaScript</li>
<li id="teacherName"><a href="#">John Smith</a></li>
<li id="subjectName">Java</li>
<li id="teacherName"><a href="#">David Miller</a</li>
<li id="subjectName">MongoDB</li>
<li id="teacherName"><a href="#">Carol Taylor</a></li>
</ul>
<script>
   $("#searchTheKey").on('keyup', function(){
      var value = $(this).val().toLowerCase();
      $("#matchKey li").each(function () {
         if ($(this).text().toLowerCase().search(value) > -1) {
            $(this).show();
            $(this).prev('.subjectName').last().show();
         } else {
            $(this).hide();
         }
      });
   })
</script>
</body>
</html>
To run the above program, save the file name “anyName.html(index.html)” and right click on the
file. Select the option “Open with Live Server” in VS Code editor.
This will produce the following output −
Now, I am entering the only Java and getting the search result. The screenshot is as follows −
Look at the above snapshot, remaining list of items are hiding.
How to extract the last row from list of a data frame in R?

Suppose we have two frames each having 5 columns that are stored in a list in R and we want to extract the last row from each data frame then we can use the lapply function. For example, if we have a list called LIST that contains the data frames described above then we can extract the last row from each data frame using the command lapply(LIST,tail,1).
Consider the below list of data frames −
Live Demo
> x1<-rpois(20,5)
> x2<-rpois(20,5)
> df1<-data.frame(x1,x2)
> y1<-rnorm(20)
> y2<-rnorm(20)
> df2<-data.frame(y1,y2)
> z1<-runif(20,2,5)
> z2<-runif(20,2,5)
> df3<-data.frame(z1,z2)
> List<-list(df1,df2,df3)
> List
[[1]]
   x1 x2
1   6  5
2   6  5
3   1  6
4   3  7
5   3  2
6   1  5
7   2  4
8   4  9
9   3  7
10  6  4
11  3  3
12  7  6
13  5  4
14  6  3
15  3  7
16  6  3
17  6  4
18  6  2
19  2  5
20  4  2
 
[[2]]
             y1         y2
1  -0.122804668 -1.6121924
2   0.368791187 -0.1544747
3   0.609177511 -0.1826137
4  -1.203014907  0.2230573
5   0.635002355 -1.8070089
6   1.859925346 -0.7883239
7  -0.031825058 -0.3458682
8  -2.096244574  0.9227411
9  -1.580421379  1.2784456
10  1.110385489 -0.2452274
11  0.336772170 -0.8106806
12 -0.957564919  0.3096939
13 -0.686361808 -0.9769511
14 -1.828680903 -1.3923749
15 -1.455614755  0.6422880
16  1.300948577  1.3421038
17 -0.002059289  0.3392104
18  0.577102561  0.8994493
19 -0.908456903  0.5898572
20  1.085195168  0.5538230
 
[[3]]
         z1       z2
1  2.890933 4.918197
2  3.810215 3.869794
3  4.229115 2.709872
4  2.418676 4.464096
5  3.854820 4.876632
6  4.585025 4.080327
7  2.982565 3.604979
8  3.060728 4.523820
9  3.173745 2.203814
10 2.814365 2.806997
11 3.115635 3.032836
12 3.464063 3.498520
13 4.565387 2.021247
14 3.150363 3.273335
15 3.371670 4.497002
16 3.291873 4.102787
17 2.930217 3.962004
18 4.222483 4.428542
19 4.078323 3.199733
20 2.430997 4.328706
Extracting the last row of data frames in List −
> lapply(List,tail,1)
[[1]]
   x1 x2
20  4  2
 
[[2]]
         y1       y2
20 1.085195 0.553823
 
[[3]]
         z1       z2
20 2.430997 4.328706
Tailwind CSS Resize

23 Mar, 2022
This class accepts lots of value in tailwind CSS in which all the properties are covered as a class form. This class is used to resize the element according to user requirements. It does not apply to inline elements or to block elements where overflow is visible. In CSS, we do that by using the CSS resize property. 
Resize
resize-none: This class is to prevent an element from being resizable.
resize-y: This class is to make an element vertically resizable.
resize-x: This class is to make an element horizontally resizable.
resize: This class is to make an element horizontally and vertically resizable.
Syntax:
<element class="pointer-{axis-boolean}">...</element>
Example:
HTML
<!DOCTYPE html><html><head>     <link href= "https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css"        rel="stylesheet"> </head>   <body class="text-center">     <h1 class="text-green-600 text-5xl font-bold">         GeeksforGeeks     </h1>     <b>Tailwind CSS Resize Class</b>     <div id="main" class="p-2 justify-around ml-32 h-26 w-2/3 flex                           items-stretch                           bg-green-200 border-solid border-4                           border-green-900 gap-4">         <textarea class="resize border rounded-md                         w-24 h-12"></textarea>        <textarea class="resize-y border rounded-md                         w-24 h-12"></textarea>        <textarea class="resize-x border rounded-md                         w-24 h-12"></textarea>        <textarea class="resize-none border rounded-md                         w-24 h-12"></textarea>      </div> </body>   </html>
Output:
Tailwind CSS resize class
surinderdawra388
Tailwind CSS
Tailwind-Interactivity
CSS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to update Node.js and NPM to next version ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
How to create footer to stay at the bottom of a Web page?
CSS to put icon inside an input element in a form
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Installation of Node.js on Linux
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
What is the difference between Python’s Module, Package and Library?

10 Jul, 2020
Module: The module is a simple Python file that contains collections of functions and global variables and with having a .py extension file. It is an executable file and to organize all the modules we have the concept called Package in Python.
Example: Save the code in file called demo_module.py
def myModule(name):    print("This is My Module : "+ name)
Import module named demo_module and call myModule function inside it.
import demo_module  demo_module.myModule("Math")
Output:
This is My Module : Math
Package: The package is a simple directory having collections of modules. This directory contains Python modules and also having __init__.py file by which the interpreter interprets it as a Package. The package is simply a namespace. The package also contains sub-packages inside it.
Example:
Student(Package)
| __init__.py (Constructor)
| details.py (Module)
| marks.py (Module)
| collegeDetails.py (Module)
Library: The library is having a collection of related functionality of codes that allows you to perform many tasks without writing your code. It is a reusable chunk of code that we can use by importing it in our program, we can just use it by importing that library and calling the method of that library with period(.).
Example: Importing pandas library and call read_csv method using alias of pandas i.e. pd.
import pandas as pd  df = pd.read_csv("file_name.csv")
python-basics
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Iterate over a list in Python
Python OOPs Concepts
How to find index of a given element in a Vector in C++

06 Jul, 2022
Given a vector V consisting of N integers and an element K, the task is to find the index of element K in the vector V. If the element does not exist in vector then print -1.
Examples: 
Input: V = {1, 45, 54, 71, 76, 17}, K = 54 Output: 2 Explanation : The index of 54 is 2, hence output is 2.Input: V = {3, 7, 9, 11, 13}, K = 12 Output: -1 
Approach: Follow the steps below to solve the problem:  
find(): Used to find the position of element in the vector.
Subtract from the iterator returned from the find function, the base iterator of the vector .
Finally return the index returned by the subtraction.
Below is the implementation of the above approach :  
C++
// C++ program to find the index// of an element in a vector#include <bits/stdc++.h>using namespace std;  // Function to print the// index of an elementvoid getIndex(vector<int> v, int K){    auto it = find(v.begin(), v.end(), K);      // If element was found    if (it != v.end())     {              // calculating the index        // of K        int index = it - v.begin();        cout << index << endl;    }    else {        // If the element is not        // present in the vector        cout << "-1" << endl;    }}// Driver Codeint main(){    // Vector    vector<int> v = { 1, 45, 54, 71, 76, 17 };    // Value whose index    // needs to be found    int K = 54;    getIndex(v, K);    return 0;}
2




 
Time Complexity: O(N) Auxiliary Space: O(1)
sethaditya35
cpp-vector
STL
C++
STL
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Bitwise Operators in C/C++
Set in C++ Standard Template Library (STL)
vector erase() and clear() in C++
unordered_map in C++ STL
Priority Queue in C++ Standard Template Library (STL)
Inheritance in C++
Object Oriented Programming in C++
The C++ Standard Template Library (STL)
C++ Classes and Objects
Sorting a vector in C++
Minimum number of Appends needed to make a string palindrome in C++

Given a string, find minimum characters to be appended to make a string palindrome.
If string is abcac then we can make string palindrome by appending 2 highlighed characters i.e. abcacba
Check if string is already palindrome, if yes then no need to append any characters.
One by one remove a character from string and check whether remaining string is palindrome or not
Repeat above process until string becomes palidrome
Return the number of characters removed so far as a final answer
#include <iostream>
#include <cstring>
using namespace std;
bool isPalindrome(char *str) {
   int n = strlen(str);
   if (n == 1) {
      return true;
   }
   int start = 0, end = n - 1;
   while (start < end) {
      if (str[start] != str[end]) {
         return false;
      }
      ++start;
      --end;
   }
   return true;
}
int requiredAppends(char *str) {
   if (isPalindrome(str)) {
      return 0;
   }
   return 1 + requiredAppends(str + 1);
}
int main() {
   char *str = "abcac";
   cout << "Characters to be appended = " << requiredAppends(str) << endl;
   return 0;
}
When you compile and execute above program. It generates following output −
Characters to be appended = 2
How to Create Engraved Text Effect using HTML and CSS ? - GeeksforGeeks

08 Jun, 2020
The engraved text effect is an effect that you can use in your websites as a heading or a sub-heading to make it look more pleasing and attractive.
Approach: The engraved text effect can be easily generated using HTML and CSS. First we will create a basic text using HTML and then by using the CSS text-shadow property we will generate the desired effect.
Example 1:
<!DOCTYPE html><html lang="en" dir="ltr">  <head>    <meta charset="utf-8">    <title>Engraved Text Effect</title>    <style>        body {            margin: 0;            padding: 0;            font-family: serif;            justify-content: center;            align-items: center;            display: flex;            background-color: #65E73C;        }          div {            content: '';            font-size: 3em;            position: absolute;            top: 50%;            left: 50%;            transform: translate(-50%, -50%);            color: transparent;            background: #008000;            -webkit-background-clip: text;            text-shadow: 2px 5px 5px                 rgba(255, 255, 255, 0.3);        }    </style></head>  <body>    <div>        <h2>GeeksforGeeks</h2>    </div></body>  </html>
In the above example, we first create a div tag that contains some text inside of it, then we design text using CSS basic properties. Then we will use the text-shadow property to generate the engraved effect.
Output:
Example 2:
<!DOCTYPE html><html lang="en" dir="ltr">  <head>    <meta charset="utf-8">    <title>Engraved Text Effect</title>    <style>        body {            margin: 0;            padding: 0;            font-family: serif;            justify-content: center;            align-items: center;            display: flex;            background-color: gray;        }          div {            content: '';            font-size: 3em;            position: absolute;            top: 50%;            left: 50%;            transform: translate(-70%, -90%);            color: transparent;            background: black;            -webkit-background-clip: text;            text-shadow: 2px 5px 5px                 rgba(255, 255, 255, 0.3);        }    </style></head>  <body>    <div>        <h2>GeeksforGeeks</h2>    </div></body>  </html>
Output:
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
CSS-Misc
HTML-Misc
CSS
HTML
Web Technologies
Web technologies Questions
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to apply style to parent if it has child with CSS?
Types of CSS (Cascading Style Sheet)
How to position a div at the bottom of its container using CSS?
How to set space between the flexbox ?
Design a web page using HTML and CSS
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 ?
DateFormat setLenient() Method in Java with Examples - GeeksforGeeks

01 Apr, 2019
The setLenient(boolean leniency) method in DateFormat class is used to specify whether the interpretation of the date and time of this DateFormat object is to be lenient or not.
Syntax:
public void setLenient(boolean leniency)
Parameters: The method takes one parameter leniency of the boolean type that refers to the mode of the calendar of the DateFormat object. The boolean value true turns on the leniency mode and false turns off the leniency mode.
Return Value: The method does not return any value.
Below programs illustrate the working of setLenient() Method of Calendar class:Example 1:
// Java code to illustrate// setLenient() method  import java.text.*;import java.util.*;  public class DateFormat_Demo {    public static void main(String[] args)    {        // Initializing the first formatter        DateFormat DFormat            = DateFormat.getDateTimeInstance();        System.out.println("Object: " + DFormat);          // String formatting        String str = DFormat.format(new Date());          // Displaying the string time        System.out.println(str);          System.out.println("Leniency: "                           + DFormat.isLenient());          // Changing the leniency        DFormat.setLenient(false);          // Displaying the modified leniency        System.out.println("New Leniency: "                           + DFormat.isLenient());    }}
Object: java.text.SimpleDateFormat@7945516e
Mar 28, 2019 6:03:48 PM
Leniency: true
New Leniency: false

Example 2:
// Java code to illustrate// setLenient() method  import java.text.*;import java.util.*;  public class DateFormat_Demo {    public static void main(String[] args)    {        // Initializing the first formatter        DateFormat DFormat            = DateFormat.getDateInstance();          System.out.println("Object: " + DFormat);          // String formatting        String str = DFormat.format(new Date());          // Displaying the string time        System.out.println(str);          System.out.println("Leniency: "                           + DFormat.isLenient());          // Changing the leniency        DFormat.setLenient(false);          // Displaying the modified leniency        System.out.println("New Leniency: "                           + DFormat.isLenient());    }}
Object: java.text.SimpleDateFormat@ce9bf0a5
Mar 28, 2019
Leniency: true
New Leniency: false

Reference: https://docs.oracle.com/javase/7/docs/api/java/text/DateFormat.html#setLenient(boolean)
Java-DateFormat
Java-Functions
Java-text package
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Object Oriented Programming (OOPs) Concept in Java
HashMap in Java with Examples
Interfaces in Java
Stream In Java
How to iterate any Map in Java
ArrayList in Java
Initialize an ArrayList in Java
Stack Class in Java
Multidimensional Arrays in Java
Singleton Class in Java
Python Program for Insertion Sort - GeeksforGeeks

30 Dec, 2020
Insertion sort is a simple sorting algorithm that works the way we sort playing cards in our hands.
# Python program for implementation of Insertion Sort  # Function to do insertion sortdef insertionSort(arr):      # Traverse through 1 to len(arr)    for i in range(1, len(arr)):          key = arr[i]          # Move elements of arr[0..i-1], that are        # greater than key, to one position ahead        # of their current position        j = i-1        while j >=0 and key < arr[j] :                arr[j+1] = arr[j]                j -= 1        arr[j+1] = key    # Driver code to test abovearr = [12, 11, 13, 5, 6]insertionSort(arr)print ("Sorted array is:")for i in range(len(arr)):    print ("%d" %arr[i])  # This code is contributed by Mohit Kumra
Output:
Sorted array is:
5
6
11
12
13


Please refer complete article on Insertion Sort for more details!
python sorting-exercises
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | Convert string dictionary to dictionary
Iterate over characters of a string in Python
Python Program for factorial of a number
Python | Convert set into a list
Python | Convert a list into a tuple
Python | Check if a variable is string
Add a key:value pair to dictionary in Python
Appending to list in Python dictionary
Python program to find sum of elements in list
Python program to find largest number in a list
Python Set | Pairs of complete strings in two sets - GeeksforGeeks

03 Jan, 2018
Two strings are said to be complete if on concatenation, they contain all the 26 English alphabets. For example, “abcdefghi” and “jklmnopqrstuvwxyz” are complete as they together have all characters from ‘a’ to ‘z’.We are given two sets of sizes n and m respectively and we need to find the number of pairs that are complete on concatenating each string from set 1 to each string from set 2.
Examples:
Input : set1[] = {"abcdefgh", "geeksforgeeks",
                 "lmnopqrst", "abc"}
        set2[] = {"ijklmnopqrstuvwxyz", 
                 "abcdefghijklmnopqrstuvwxyz", 
                 "defghijklmnopqrstuvwxyz"} 
Output : 7
The total complete pairs that are forming are:
"abcdefghijklmnopqrstuvwxyz"
"abcdefghabcdefghijklmnopqrstuvwxyz"
"abcdefghdefghijklmnopqrstuvwxyz"
"geeksforgeeksabcdefghijklmnopqrstuvwxyz"
"lmnopqrstabcdefghijklmnopqrstuvwxyz"
"abcabcdefghijklmnopqrstuvwxyz"
"abcdefghijklmnopqrstuvwxyz"

We have existing solution for this problem please refer Pairs of complete strings in two sets of strings link. We can solve this problem quickly in python using Set data structure. Approach is very simple,
Consider all pairs of strings, concatenate them one by one and converts it into set.Now one by one add all alphabets in concatenated string into set. Since set contains unique values so if length of set is equal to 26 that means set contains all 26 english alphabets.
Consider all pairs of strings, concatenate them one by one and converts it into set.
Now one by one add all alphabets in concatenated string into set. Since set contains unique values so if length of set is equal to 26 that means set contains all 26 english alphabets.
# Function to find pairs of complete strings# in two sets of strings  def completePair(set1,set2):          # consider all pairs of string from    # set1 and set2    count = 0    for str1 in set1:        for str2 in set2:            result = str1 + str2              # push all alphabets of concatenated             # string into temporary set            tmpSet = set([ch for ch in result if (ord(ch)>=ord('a') and ord(ch)<=ord('z'))])            if len(tmpSet)==26:                count = count + 1    print (count)  # Driver programif __name__ == "__main__":    set1 = ['abcdefgh', 'geeksforgeeks','lmnopqrst', 'abc']    set2 = ['ijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz','defghijklmnopqrstuvwxyz']    completePair(set1,set2)
Output:
7

python-set
python-string
Python
python-set
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()
*args and **kwargs in Python
Reading and Writing to text files in Python
Create a Pandas DataFrame from Lists
malloc() vs new() in C/C++

The function malloc() is used to allocate the requested size of bytes and it returns a pointer to the first byte of allocated memory. It returns null pointer, if fails.
Here is the syntax of malloc() in C++ language,
pointer_name = (cast-type*) malloc(size);
Here,
pointer_name − Any name given to the pointer.
cast-type − The datatype in which you want to cast the allocated memory by malloc().
size − Size of allocated memory in bytes.
Here is an example of malloc() in C language,
 Live Demo
#include <stdio.h>
#include <stdlib.h>
int main() {
   int n = 4, i, *p, s = 0;
   p = (int*) malloc(n * sizeof(int));
   if(p == NULL) {
      printf("\nError! memory not allocated.");
      exit(0);
   }
   printf("\nEnter elements of array : ");
   for(i = 0; i < n; ++i) {
      scanf("%d", p + i);
      s += *(p + i);
   }
   printf("\nSum : %d", s);
   return 0;
}
Here is the output,
Enter elements of array : 32 23 21 8
Sum : 84
In the above program, four variables are declared and one of them is a pointer variable *p which is storing the memory allocated by malloc. We are printing the sum of elements.
int n = 4, i, *p, s = 0;
p = (int*) malloc(n * sizeof(int));
if(p == NULL) {
   printf("\nError! memory not allocated.");
   exit(0);
}
printf("\nEnter elements of array : ");
for(i = 0; i < n; ++i) {
   scanf("%d", p + i);
   s += *(p + i);
}
printf("\nSum : %d", s);
The new operator requests for the memory allocation in heap. If the sufficient memory is available, it initializes the memory to the pointer variable and returns its address.
Here is the syntax of new operator in C++ language,
pointer_variable = new datatype;
Here is the syntax to initialize the memory,
pointer_variable = new datatype(value);
Here is the syntax to allocate a block of memory,
pointer_variable = new datatype[size];
Here is an example of new operator in C++ language,
 Live Demo
#include <iostream>
using namespace std;
int main () {
   int *ptr1 = NULL;
   ptr1 = new int;
   float *ptr2 = new float(223.324);
   int *ptr3 = new int[28];
   *ptr1 = 28;
   cout << "Value of pointer variable 1 : " << *ptr1 << endl;
   cout << "Value of pointer variable 2 : " << *ptr2 << endl;
   if (!ptr3)
   cout << "Allocation of memory failed\n";
   else {
      for (int i = 10; i < 15; i++)
      ptr3[i] = i+1;

      cout << "Value to store in block of memory: ";
      for (int i = 10; i < 15; i++)
      cout << ptr3[i] << " ";
   }
   return 0;
}
Value of pointer variable 1 : 28
Value of pointer variable 2 : 223.324
Value to store in block of memory: 11 12 13 14 15
In the above program, three pointer variables are declared as ptr1, ptr2 and ptr3. The pointer variables ptr1 and ptr2 are initialized with the value using new() and ptr3 is storing the allocated block of memory by new() function.
ptr1 = new int;
float *ptr2 = new float(223.324);
int *ptr3 = new int[28];
*ptr1 = 28;
TypeScript | String toLowerCase() Method - GeeksforGeeks

03 Mar, 2021
The toLowerCase() is an inbuilt function in TypeScript which is used to convert the characters within a string to lowercase.
Syntax:
string.toLowerCase( ) 
Parameter: This methods does not accepts any parameter. Return Value: This method returns the string in lowercase. Below examples illustrate the String toLowerCase() Method in TypeScript.
Example : 
TypeScript
// Original stringsvar str = "Geeksforgeeks - Best Platform";  // use of String toLowerCase() Methodvar newstr = str.toLowerCase() console.log(newstr);
Output: 
geeksforgeeks - best platform
Example 2: 
TypeScript
// Original stringsvar str = "TypeScript - String toLowerCase()";  // use of String toLowerCase() Methodvar newstr = str.toLowerCase() console.log(newstr);
Output: 
typescript - string tolowercase()
 
 
 
pratikraut0000
TypeScript
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Remove elements from a JavaScript Array
Convert a string to an integer in JavaScript
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
How to append HTML code to a div using JavaScript ?
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
How to convert right linear grammar to left linear grammar?

For every finite automata (FA) there exists a regular grammar and for every regular grammar there is a left linear and right linear regular grammar.
Consider a regular grammar −
   a(a+b)*
A → aB
B → aB|bB|e
For the given regular expression, the above grammar is right linear grammar.
Now, convert the above right linear grammar to left linear grammar.
The rule to follow for conversion is,
Finite Automata → Right linear
The reverse of right linear →left linear grammar.
So,
A → BaB → Ba|Bb|e
A → Ba
B → Ba|Bb|e
Finally for every right linear there is a
Consider a language {bnabma| n>=2, m>=2}
The right linear grammar for the given language is −
bn ⇒ A→bA|b       A is on right side
bm ⇒ B→bB|b       B is on right side
The complete expression grammar is −
S→AaBa
A→bA|b
B→bB|b.
The left grammar for the above right linear grammar is,
bn ⇒ A→Ab|b
bm ⇒ B→Bb|b
The complete expression grammar is as follows −
S→AaBa
A→Ab|b
B→Bb|b
Random setSeed() method in Java with Examples - GeeksforGeeks

07 Jan, 2019
The setSeed() method of Random class sets the seed of the random number generator using a single long seed.
Syntax:
public void setSeed() 

Parameters: The function accepts a single parameter seed which is the initial seed.
Return Value: This method has no return value.
Exception: The function does not throws any exception.
Program below demonstrates the above mentioned function:
Program 1:
// program to demonstrate the// function java.util.Random.setSeed()  import java.util.*;public class GFG {    public static void main(String[] args)    {          // create random object        Random r = new Random();          // return the next pseudorandom integer value        System.out.println("Random Integer value : "                           + r.nextInt());          // setting seed        long s = 24;          r.setSeed(s);          // value after setting seed        System.out.println("Random Integer value : " + r.nextInt());    }}
Random Integer value : -2053473769
Random Integer value : -1152406585

Program 2:
// program to demonstrate the// function java.util.Random.setSeed()  import java.util.*;public class GFG {    public static void main(String[] args)    {          // create random object        Random r = new Random();          // return the next pseudorandom integer value        System.out.println("Random Integer value : "                           + r.nextInt());          // setting seed        long s = 29;          r.setSeed(s);          // value after setting seed        System.out.println("Random Integer value : "                           + r.nextInt());    }}
Random Integer value : -388369680
Random Integer value : -1154330330

Java-Functions
Java-Random
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Initialize an ArrayList in Java
Object Oriented Programming (OOPs) Concept in Java
HashMap in Java with Examples
Interfaces in Java
How to iterate any Map in Java
ArrayList in Java
Multidimensional Arrays in Java
Stream In Java
Stack Class in Java
Singleton Class in Java
How do we add a single-line input field in HTML?

Use the <isindex> tag to add a single-line input field. The HTML <isindex> tag is used for querying a document through a text field. The tag can be used anywhere but head tag is preferable. Note: It is a deprecated tag and should not be used.
The following are the attributes −
Try the following code −
<!Doctype html>
<html>
   <head>
      <title>HTML isindex Tag</title>
      <isindex prompt = "Search" />
   </head>
</html>
How to use StringBuilder in C#?

With StringBuilder, you can expand the number of characters in the string. String cannot be changed once it is created, but StringBuildercan be expanded. It does not create a new object in the memory.
Initialize StringBuilder.
StringBuilder str = new StringBuilder();
Let us see an example to learn how to work with StringBuilder in C#.
 Live Demo
using System;
using System.Text;
public class Program {
   public static void Main() {
      StringBuilder str = new StringBuilder("Web World!!",30);
      str.Replace("World", "Arena");
      Console.WriteLine(str);
   }
}
Web Arena!!
Above the Replace() method of StringBuilder is used to to replace a string in C#.
Interactive map using Geographical Information in Plotly Express | by Tamjid Ahsan | Towards Data Science

Visualizations are very powerful tools for any data science project. It helps the reader to understand what is happening. For some dataset it is very helpful to be able to see the data on a map for presenting insights also while doing the analysis.
There are a lot of packages out there which can achieve this goal, all with their respective strengths and weaknesses. Namely Folium, Plotly, Mapbox, Bokeh and so on.
In this post, I am showing how I plot my data on maps when doing analysis of data with geographic information using Plotly.
For this demonstration, I am using a house rental price dataset of San Francisco, California. This dataset contains following features to begin with.
After initial cleaning I wanted to get zip code information of the individual houses. I used uszipcode package to get those information from latitude and longitude data. Additionally pandas and Plotly express is used. Code for this is following:
# data manipulationimport pandas as pd# data cleaningimport reimport missingno# data visualizationimport plotly.express as px
I used this to group data by zip codes to get average rental price per zip code, and visualize on a map. This is the end result.
Code:
This approach utilizes geojason file that contains zip code boundaries of zip codes in the USA. Those are courtesy of OpenDataDE, files can be found here. To get those information useful for using in plotly, this line is used.
for feature in zipcode_data['features']:            feature['id'] = feature['properties']['ZCTA5CE10']
More on this from plotly documentation can be found here.
To get the location of each house on a interactive map, I used following code:
More on this from plotly documentation can be found here.
For a static output use this instead of showing the object by using fig.show(). You can also save this as image by tinkering the output type.
import plotly.io as plyIoimg_bytes = fig.to_image(format="png", width=1200, height=700, scale=1)from IPython.display import Imagedisplay(Image(img_bytes))
All the workings and files can be found here on GitHub. An extension of this project on House price prediction using these data can be found here on Github.
That’s all for today. Until next time!
Use Iterator to remove an element from a Collection in Java

An element can be removed from a Collection using the Iterator method remove(). This method
removes the current element in the Collection. If the remove() method is not preceded by the
next() method, then the exception IllegalStateException is thrown.
A program that demonstrates this is given as follows.
 Live Demo
import java.util.ArrayList;
import java.util.Iterator;
public class Demo {
   public static void main(String[] args) {
      ArrayList<String> aList = new ArrayList<String>();
      aList.add("Apple");
      aList.add("Mango");
      aList.add("Guava");
      aList.add("Orange");
      aList.add("Peach");
      System.out.println("The ArrayList elements are: ");
      for (String s: aList) {
         System.out.println(s);
      }
      Iterator i = aList.iterator();
      String str = "";
      while (i.hasNext()) {
         str = (String) i.next();
         if (str.equals("Orange")) {
            i.remove();
            System.out.println("\nThe element Orange is removed");
            break;
         }
      }
      System.out.println("\nThe ArrayList elements are: ");
      for (String s: aList) {
         System.out.println(s);
      }
   }
}
The output of the above program is as follows
The ArrayList elements are:
Apple
Mango
Guava
Orange
Peach

The element Orange is removed

The ArrayList elements are:
Apple
Mango
Guava
Peach
Creating Slide to Shut Down Shortcut in Windows 10 - GeeksforGeeks

31 Aug, 2021
If you’re looking for a smart and interactive way to Shut down your PC, then this trick is going very useful for you. Instead of that traditional long process of shutting down the PC, the ‘Slide to Shut down’ feature allows you to shut down your Windows 10 PC by sliding, or dragging the window down. Let’s understand how we can create a ‘Slide to Shut down’ shortcut.
Slide to Shut down Window.
Below are the steps mentioned on how to add the shortcut for Slide To Shut Down. 
Step 1: Right-click on an empty space on the desktop, select ‘New’ and click the ‘Shortcut’.  
Create New shortcut on the Desktop.
Step 2: Paste the following path in the location section.
 %windir%\System32\SlideToShutDown.exe
Step 3: Click ‘Next’.
Paste this path to the location section.
Step 4: Give the name for the shortcut (Ex. SlideToShutDown) and Click on ‘Finish’.
Give a name to the shortcut.
Step 5: Right-click on the newly created shortcut and select ‘Properties’.
Shortcut Properties.
Step 6: In the Shortcut tab, select the ‘Change icon’ button.
Step 7: After clicking ‘Change Icon’, one pop-up will appear on the screen. Click ‘OK’ to confirm that the file path you specified doesn’t contain icons. 
Step 8: You can choose the icon from the list provided by windows, Select the icon from the list which is most relevant to your shortcut and then click ‘OK’.
Step 9: To apply this icon to our shortcut, click on ‘Apply’ and again Click on ‘OK’.
Now the Setup for this shortcut is completed, and the shortcut is created on your desktop. When you double-click on this icon, it will launch Slide to Shut down your PC, then you can click and drag the window down, or also you can press Enter key to shut down your PC.
Also, you can right-click on the shortcut and “Pin to the taskbar” for faster access to the Shutdown experience.
user282
Technical Scripter 2020
Technical Scripter
TechTips
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Find the Wi-Fi Password Using CMD in Windows?
How to Run a Python Script using Docker?
Docker - COPY Instruction
Running Python script on GPU.
Setting up the environment in Java
How to setup cron jobs in Ubuntu
How to set up Command Prompt for Python in Windows10 ?
How to Add External JAR File to an IntelliJ IDEA Project?
Top Programming Languages for Android App Development
'dd' command in Linux
How to animate a pcolormesh in Matplotlib?

To animate pcolormesh in matplotlib, we can take the following steps −
Create a figure and a set of subplots.
Create a figure and a set of subplots.
Create x, y and t data points using numpy.
Create x, y and t data points using numpy.
Create X3, Y3 and T3, return coordinate matrices from coordinate vectors using meshgrid.
Create X3, Y3 and T3, return coordinate matrices from coordinate vectors using meshgrid.
Create a pseudocolor plot with a non-regular rectangular grid using pcolormesh() method.
Create a pseudocolor plot with a non-regular rectangular grid using pcolormesh() method.
Make a colorbar with colormesh axis.
Make a colorbar with colormesh axis.
Animate pcolormesh using Animation() class method.
Animate pcolormesh using Animation() class method.
To display the figure, use show() method.
To display the figure, use show() method.
import numpy as np
from matplotlib import pyplot as plt, animation
plt.rcParams["figure.figsize"] = [7.00, 3.50]
plt.rcParams["figure.autolayout"] = True

fig, ax = plt.subplots()
x = np.linspace(-3, 3, 91)
t = np.linspace(0, 25, 30)
y = np.linspace(-3, 3, 91)
X3, Y3, T3 = np.meshgrid(x, y, t)
sinT3 = np.sin(2 * np.pi * T3 / T3.max(axis=2)[..., np.newaxis])
G = (X3 ** 2 + Y3 ** 2) * sinT3
cax = ax.pcolormesh(x, y, G[:-1, :-1, 0], vmin=-1, vmax=1, cmap='Blues')
fig.colorbar(cax)

def animate(i):
   cax.set_array(G[:-1, :-1, i].flatten())

anim = animation.FuncAnimation(fig, animate, interval=100, frames=len(t) - 1)
anim.save('517.gif')
plt.show()
Dart Programming - toString Method

Returns a string representation of an object.
val.toString()

Returns a string.
void main() { 
   int n = 12; 
   var res = n.toString(); 
   print("New String: ${res}");
}   
It will produce the following output −.
New String: 12


    44 Lectures 
     4.5 hours 

 Sriyank Siddhartha

    34 Lectures 
     4 hours 

 Sriyank Siddhartha

    69 Lectures 
     4 hours 

 Frahaan Hussain

    117 Lectures 
     10 hours 

 Frahaan Hussain

    22 Lectures 
     1.5 hours 

 Pranjal Srivastava

    34 Lectures 
     3 hours 

 Pranjal Srivastava
 Print
 Add Notes
 Bookmark this page