code-rag-bench/online-tutorials huggingface dataset:
Most frequent element in an array in C++

We are given a array and we need to find the most frequent element from it. Let's see an example.
Input
arr = [1, 2, 3, 3, 2, 2, 1, 1, 2, 3, 4]
Output
2
In the above array, 2 occurs 4 times which is most frequent than any other in the array.
Initialise the array.
Initialise the array.
Initialise a map to store the frequency of each element.
Initialise a map to store the frequency of each element.
Count the frequency of each element and store it in the map.
Count the frequency of each element and store it in the map.
Iterate over the map and find the element with most frequency.
Iterate over the map and find the element with most frequency.
Return the element.
Initialise the array.
Sort the given array.
Maintain the variables for max count, result and current element count.
Find the max count element by iterating over the array.
Same elements resides side by side.
Return the result.
Following is the implementation of the above algorithm in C++
#include <bits/stdc++.h>
using namespace std;
int getMostFrequentNumber(int arr[], int n) {
   unordered_map<int, int> elements;
   for (int i = 0; i < n; i++) {
      elements[arr[i]]++;
   }
   int maxCount = 0, res = -1;
   for (auto i : elements) {
      if (maxCount < i.second) {
         res = i.first;
         maxCount = i.second;
      }
   }
   return res;
}
int main() {
   int arr[] = { 1, 2, 3, 3, 2, 2, 1, 1, 2, 3, 4 };
   int n = 11;
   cout << getMostFrequentNumber(arr, n) << endl;
   return 0;
}
If you run the above code, then you will get the following result.
2
How to save a Librosa spectrogram plot as a specific sized image?

Librosa is a Python package that helps to analyse audio and music files. This package also helps to create music retrieval information systems. In this article, we will see how to save a Librosa spectrogram plot as an image of specific size.
Set the figure size and adjust the padding between and around the subplots..
Set the figure size and adjust the padding between and around the subplots..
Create a figure and a set of subplots.
Create a figure and a set of subplots.
Initialize three different variables, hl, hi, wi, to store samples per time in the spectrogram, height and width of the images.
Initialize three different variables, hl, hi, wi, to store samples per time in the spectrogram, height and width of the images.
Load a demo track.
Load a demo track.
Create a window, i.e., a list for audio time series..
Create a window, i.e., a list for audio time series..
Compute a mel-scaled spectrogram, using melspectrogram() with window and step 3 data.
Compute a mel-scaled spectrogram, using melspectrogram() with window and step 3 data.
Convert the power spectrogram (amplitude squared) to decibel (dB) units, using power_to_db() method..
Convert the power spectrogram (amplitude squared) to decibel (dB) units, using power_to_db() method..
Display the spectrogram as img (we can save it here).
Display the spectrogram as img (we can save it here).
Save the img using savefig().
Save the img using savefig().
Display the image using plt.show() method.
Display the image using plt.show() method.
import numpy as np
import matplotlib.pyplot as plt
import librosa.display

plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True

fig, ax = plt.subplots()

hl = 512 # number of samples per time-step in spectrogram
hi = 128 # Height of image
wi = 384 # Width of image

# Loading demo track
y, sr = librosa.load(librosa.ex('trumpet'))
window = y[0:wi*hl]

S = librosa.feature.melspectrogram(y=window, sr=sr, n_mels=hi, fmax=8000,
hop_length=hl)
S_dB = librosa.power_to_db(S, ref=np.max)
img = librosa.display.specshow(S_dB, x_axis='time', y_axis='mel', sr=sr, fmax=8000, ax=ax)

plt.savefig("out.png")
plt.show()
Explain Lifetime of a variable in C language.

Storage classes specify the scope, lifetime and binding of variables.
To fully define a variable, one needs to mention not only its ‘type’ but also its storage class.
A variable name identifies some physical location within computer memory, where a collection of bits are allocated for storing values of variable.
Storage class tells us the following factors −
Where the variable is stored (in memory or cpu register)?
What will be the initial value of variable, if nothing is initialized?
What is the scope of variable (where it can be accessed)?
What is the life of a variable?
The lifetime of a variable defines the duration for which the computer allocates memory for it (the duration between allocation and deallocation of memory).
In C language, a variable can have automatic, static or dynamic lifetime.
Automatic − A variable with automatic lifetime are created. Every time, their declaration is encountered and destroyed. Also, their blocks are exited.
Static − A variable is created when the declaration is executed for the first time. It is destroyed when the execution stops/terminates.
Dynamic − The variables memory is allocated and deallocated through memory management functions.
There are four storage classes in C language −
Following is the C program for automatic storage class −
 Live Demo
#include<stdio.h>
main ( ){
   auto int i=1;{
      auto int i=2;{
         auto int i=3;
         printf ("%d",i)
      }
      printf("%d", i);
   }
   printf("%d", i);
}
When the above program is executed, it produces the following output −
3 2 1
Following is the C program for external storage class −
 Live Demo
#include<stdio.h>
extern int i =1; /* this ‘i’ is available throughout program */
main ( ){
   int i = 3; /* this ‘i' available only in main */
   printf ("%d", i);
   fun ( );
}
fun ( ) {
   printf ("%d", i);
}
When the above program is executed, it produces the following output −
3 1
<mat-grid-list> in Angular Material - GeeksforGeeks

24 Sep, 2021

Angular Material is a UI component library that is developed by the Angular team to build design components for desktop and mobile web applications. In order to install it, we need to have angular installed in our project, once you have it you can enter the below command and can download it. mat-grid-list tag is used for styling the content in grids form.
Installation syntax:
ng add @angular/material
Approach:
First, install the angular material using the above-mentioned command.
After completing the installation, Import ‘MatGridListModule’ from ‘@angular/material/grid-list’ in the app.module.ts file.
Then use <mat-grid-list> tag to group all the items inside this group tag.
Inside the <mat-grid-list> tag we need to use <mat-grid-tile tag for every item.
We also have properties like cols and rowHeight which we can use for styling. cols property is used to display number of grids in a row.
Once done with the above steps then serve or start the project.
Code Implementation:
app.module.ts
 

 
 










import { CommonModule } from '@angular/common';  
import { NgModule } from '@angular/core';  
import { FormsModule } from '@angular/forms';  
import { MatGridListModule } from '@angular/material';  
    
import { AppComponent } from './example.component';  
    
@NgModule({  
  declarations: [AppComponent],  
  exports: [AppComponent],  
  imports: [  
    CommonModule,  
    FormsModule,  
    MatGridListModule 
  
  ],  
})  
export class AppModule {}






app.component.html
 

 
 










<mat-grid-list cols="3" rowHeight="2:1"> 
    
  <mat-grid-tile>First Grid</mat-grid-tile> 
  <mat-grid-tile>Second Grid</mat-grid-tile> 
  <mat-grid-tile>Third Grid</mat-grid-tile> 
  <mat-grid-tile>Fourth Grid</mat-grid-tile> 
  <mat-grid-tile>Fifth Grid</mat-grid-tile> 
  <mat-grid-tile>Sixth Frid</mat-grid-tile> 
  
</mat-grid-list> 






app.component.scss :
mat-grid-tile {
  background: lightsalmon;
}
Output:
 
 
simmytarika5

Angular-material


Picked


AngularJS


Web Technologies

Writing code in comment? 
                                    Please use ide.geeksforgeeks.org, 
                                    generate link and share the link here.
                                
Top 10 Angular Libraries For Web Developers
Angular 10 (blur) Event
Angular PrimeNG Dropdown Component
How to make a Bootstrap Modal Popup in Angular 9/8 ?
How to create module with Routing in Angular 9 ?
Roadmap to Become a Web Developer in 2022
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to fetch data from an API in ReactJS ?
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How can I show figures separately in Matplotlib?

To show multiple figures in matplotlib, we can take the following Steps −
To create a new figure, or activate an existing figure, use the figure() method. (Create two figures namely, Figure1 and Figure2).
To create a new figure, or activate an existing figure, use the figure() method. (Create two figures namely, Figure1 and Figure2).
Plot the lines with the same lists (colors red and green and linewidth 2 and 5).
Plot the lines with the same lists (colors red and green and linewidth 2 and 5).
Set the title of the plot over both the figures.
Set the title of the plot over both the figures.
To display the figure, use the show() method.
To display the figure, use the show() method.
from matplotlib import pyplot as plt
plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True
fig1 = plt.figure("Figure 1")
plt.plot([1, 3, 7, 3, 1], c="red", lw=2)
plt.title("I am the part of figure 1")
fig2 = plt.figure("Figure 2")
plt.plot([1, 3, 7, 3, 1], c="green", lw=5)
plt.title("I am the part of figure 2")
plt.show()
How to find difference between 2 files in Python?

The Python standard library has a module specifically for the purpose of finding diffs between strings/files. To get a diff using the difflib library, you can simply call the united_diff function on it.
For example, Lets say you have 2 files, file1 and file2 with the following content:
file1:
Hello
People
of
the
world
file2:
Hello
People
from
India
Now to take their diff use the following code:
import difflib
with open('file1') as f1:
    f1_text = f1.read()
with open('file2') as f2:
    f2_text = f2.read()
# Find and print the diff:
for line in difflib.unified_diff(f1_text, f2_text, fromfile='file1', tofile='file2', lineterm=''):
    print line
This will give the output:
--- file1
+++ file2
@@ -1,5 +1,4 @@
 Hello
 People
-of
-the
-world
+from
+India
ByteBuffer toString() method in Java with Examples

06 Aug, 2021
The toString() method of ByteBuffer class is the inbuilt method used to returns a string representing the data contained by ByteBuffer Object. A new String object is created and initialized to get the character sequence from this ByteBuffer object and then String is returned by toString(). Subsequent changes to this sequence contained by Object do not affect the contents of the String.Syntax: 
public abstract String toString()
Return Value: This method returns the String representing the data contained by ByteBuffer Object.Below programs illustrate the ByteBuffer.toString() method:Example 1: 
Java
// Java program to demonstrate// toString() method import java.nio.*;import java.util.*; public class GFG {     public static void main(String[] args)    {         // Declaring the capacity of the ByteBuffer        int capacity = 5;         // creating object of ByteBuffer        // and allocating size capacity        ByteBuffer bb1 = ByteBuffer.allocate(capacity);         // putting the value in ByteBuffer        bb1.put((byte)10);        bb1.put((byte)20);         // print the ByteBuffer        System.out.println("Original ByteBuffer: "                           + Arrays.toString(bb1.array()));         // Creating a shared subsequence buffer of given ByteBuffer        // using toString() method        String value = bb1.toString();         // print the ByteBuffer        System.out.println("\nstring representation of ByteBuffer:  "                           + value);    }}
Original ByteBuffer: [10, 20, 0, 0, 0]

string representation of ByteBuffer:  java.nio.HeapByteBuffer[pos=2 lim=5 cap=5]
 
Example 2:
Java
// Java program to demonstrate// toString() method import java.nio.*;import java.util.*; public class GFG {     public static void main(String[] args)    {         // Declaring the capacity of the ByteBuffer        int capacity = 4;         // creating object of ByteBuffer        // and allocating size capacity        ByteBuffer bb1 = ByteBuffer.allocate(capacity);         // putting the value in ByteBuffer        bb1.put((byte)10)            .put((byte)20)            .put((byte)30)            .put((byte)40);         // print the ByteBuffer        System.out.println("Original ByteBuffer: "                           + Arrays.toString(bb1.array()));         // Creating a shared subsequence buffer of given ByteBuffer        // using toString() method        String value = bb1.toString();         // print the ByteBuffer        System.out.println("\nstring representation of ByteBuffer:  "                           + value);    }}
Original ByteBuffer: [10, 20, 30, 40]

string representation of ByteBuffer:  java.nio.HeapByteBuffer[pos=4 lim=4 cap=4]
 
Reference: https://docs.oracle.com/javase/9/docs/api/java/nio/ByteBuffer.html#toString– 
ruhelaa48
Java-ByteBuffer
Java-Functions
Java-NIO package
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | math.ceil() function

11 Mar, 2019
In Python, math module contains a number of mathematical operations, which can be performed with ease using the module. math.ceil() function returns the smallest integral value greater than the number. If number is already integer, same number is returned.
Syntax: math.ceil(x)

Parameter:
x: This is a numeric expression.

Returns:  Smallest integer not less than x.
Code #1:
# Python code to demonstrate the working of ceil()    # importing "math" for mathematical operations import math     x = 33.7    # returning the ceil of 33.7print ("The ceil of 33.7 is : ", end ="") print (math.ceil(x))
The ceil of 33.7 is : 34

 Code #2:
# Python code to demonstrate the working of ceil()    # importing "math" for mathematical operations import math     # prints the ceil using ceil() method print ("math.ceil(-13.1) : ", math.ceil(-13.1))print ("math.ceil(101.96) : ", math.ceil(101.96))
math.ceil(-13.1) :  -13
math.ceil(101.96) :  102

Python math-library-functions
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | Pandas dataframe.melt()

09 Dec, 2021
Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier.
Pandas dataframe.melt() function unpivots a DataFrame from wide format to long format, optionally leaving identifier variables set. This function is useful to message a DataFrame into a format where one or more columns are identifier variables (id_vars), while all other columns, considered measured variables (value_vars), are “unpivoted” to the row axis, leaving just two non-identifier columns, ‘variable’ and ‘value’.
Syntax:DataFrame.melt(id_vars=None, value_vars=None, var_name=None, value_name=’value’, col_level=None)Parameters :frame : DataFrameid_vars : Column(s) to use as identifier variablesvalue_vars : Column(s) to unpivot. If not specified, uses all columns that are not set as id_vars.var_name : Name to use for the ‘variable’ column. If None it uses frame.columns.name or ‘variable’.value_name : Name to use for the ‘value’ columncol_level : If columns are a MultiIndex then use this level to melt.
Returns: DataFrame into a format where one or more columns are identifier variables
Example #1: Use melt() function to set column “A” as the identifier variable and column “B” as value variable.
Python3
# importing pandas as pdimport pandas as pd  # Creating the dataframe df = pd.DataFrame({"A":[12, 4, 5, 44, 1],                    "B":[5, 2, 54, 3, 2],                    "C":[20, 16, 7, 3, 8],                    "D":[14, 3, 17, 2, 6]})  # Print the dataframedf
Lets use the dataframe.melt() function to set column “A” as identifier variable and column “B” as the value variable.
Python3
# function to unpivot the dataframedf.melt(id_vars =['A'], value_vars =['B'])
Output : Example #2: Use melt() function to set column “A” as the identifier variable and column “B” and “C” as value variable. Also customize the names of both the value and variable column.
Python3
# importing pandas as pdimport pandas as pd  # Creating the dataframe df = pd.DataFrame({"A":[12, 4, 5, 44, 1],                   "B":[5, 2, 54, 3, 2],                    "C":[20, 16, 7, 3, 8],                    "D":[14, 3, 17, 2, 6]})  # Print the dataframedf
Lets use the dataframe.melt() function to set column “A” as identifier variable and column “B” and “C” as the value variable.
Python3
# function to unpivot the dataframe# We will also provide a customized name to the value and variable column  df.melt(id_vars =['A'], value_vars =['B', 'C'],         var_name ='Variable_column', value_name ='Value_column')
Output :
surindertarika1234
Python pandas-dataFrame
Python pandas-dataFrame-methods
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
PyQt5 - Tri-state Check Box - GeeksforGeeks

22 Apr, 2020
When we create a check box, by default there are two state which are either checked i.e True and other is False. But we can add third state to it which is neither True or False with the help of setTristate method.
Below is how all three states looks like.
Syntax : checkbox.setTristate(True)
Argument : It takes bool as argument.
Action performed : It will add third state to the check box.
Below is the implementation.
# importing librariesfrom PyQt5.QtWidgets import * from PyQt5 import QtCore, QtGuifrom PyQt5.QtGui import * from PyQt5.QtCore import * import sys    class Window(QMainWindow):      def __init__(self):        super().__init__()          # setting title        self.setWindowTitle("Python ")          # setting geometry        self.setGeometry(100, 100, 600, 400)          # calling method        self.UiComponents()          # showing all the widgets        self.show()      # method for widgets    def UiComponents(self):          # creating the check-box        checkbox = QCheckBox('Check Box', self)          # setting geometry of check box        checkbox.setGeometry(200, 150, 100, 30)          # creating the third state        checkbox.setTristate(True)    # create pyqt5 appApp = QApplication(sys.argv)  # create the instance of our Windowwindow = Window()  # start the appsys.exit(App.exec())
Output :
Python-gui
Python-PyQt
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Read a file line by line in Python
How to Install PIP on Windows ?
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
Convert integer to string in Python
float keyword in C# - GeeksforGeeks

22 Jun, 2020
Keywords are the words in a language that are used for some internal process or represent some predefined actions. float is a keyword that is used to declare a variable which can store a floating point value from the range of ±1.5 x 10-45 to ±3.4 x 1038. It is an alias of System.Single.
Syntax:
float variable_name = value;
float keyword occupies 4 bytes (32 bits) space in the memory. We use a suffix f or F with the value to represent a float value.
Example:
Input: -3629.4586F

Output: num: -3629.458
        Size of a float variable: 4

Input: 16345.6456f

Output: Type of num: System.Single
        num: 16345.65
        Size of a float variable: 4
        Min value of float: -3.402823E+38
        Max value of float: 3.402823E+38

Example 1:
// C# program for float keywordusing System;using System.Text;  class GFG {      static void Main(string[] args)    {        // variable declaration        float num = -3629.4586F;          // to print value        Console.WriteLine("num: " + num);          // to print size        Console.WriteLine("Size of a float variable: " + sizeof(float));    }}
Output:
num: -3629.458
Size of a float variable: 4

Example 2:
// C# program for float keywordusing System;using System.Text;  namespace geeks {  class GFG {      static void Main(string[] args)    {        // variable declaration        float num = 16345.6456f;          // to print type of variable        Console.WriteLine("Type of num: " + num.GetType());          // to print value        Console.WriteLine("num: " + num);          // to print size        Console.WriteLine("Size of a float variable: " + sizeof(float));          // to print minimum & maximum value of float        Console.WriteLine("Min value of float: " + float.MinValue);        Console.WriteLine("Max value of float: " + float.MaxValue);    }}}
Output:
Type of num: System.Single
num: 16345.65
Size of a float variable: 4
Min value of float: -3.402823E+38
Max value of float: 3.402823E+38

CSharp-keyword
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Extension Method in C#
HashSet in C# with Examples
C# | Inheritance
Partial Classes in C#
C# | Generics - Introduction
Top 50 C# Interview Questions & Answers
Switch Statement in C#
Lambda Expressions in C#
Convert String to Character Array in C#
C# | How to insert an element in an Array?
AngularJS | angular.equals() Function - GeeksforGeeks

16 Apr, 2019
The angular.equals() Function in AngularJS is used to compare two objects or two values whether these are same or not. If the two values are same, it returns TRUE else it will return FALSE.
Syntax:
angular.equals(val1, val2)
Where val1 and val2 are the values or the objects to be compared.Return Value: Returns TRUE or FALSE
Example 1:
<html><head> <script src= "//ajax.googleapis.com/ajax/libs/angularjs/1.3.2/angular.min.js"> </script> <title>angular.equals()</title> </head>  <body ng-app="app" style="text-align:Center">  <h1 style="color:green">GeeksforGeeks</h1>  <h2>angular.equals()</h2>  <div ng-controller="geek">  Input A: <input type="number" ng-model="val1" ng-change="check()" />  <br /><br>  Input B: <input type="number" ng-model="val2" ng-change="check()" />  <br /><br>  {{msg}}</div>    <script>  var app = angular.module("app", []);  app.controller('geek', ['$scope', function ($scope) {    $scope.val1 = 0;    $scope.val2 = 0;    $scope.check = function () {      if (angular.equals($scope.val1, $scope.val2))        $scope.msg = "Input values are equal.";      else        $scope.msg = "Input values are not equal.";      }    }]);  </script></body></html>
Output:Before Input:After Input:
Example 2:
<html><head> <script src= "//ajax.googleapis.com/ajax/libs/angularjs/1.3.2/angular.min.js"> </script> <title>angular.equals()</title> </head>   <body ng-app="app" style="text-align:Center">   <h1 style="color:green">GeeksforGeeks</h1>   <h2>angular.equals()</h2>  <body ng-app="app"> <div ng-controller="geek">    Password: <br>    <input type="password" ng-model="pass" />    <br><br>    Confirm  Password: <br>    <input type="password" ng-model="PASS" ng-change="match()" /><br />    <p ng-show="isMatch" style="color:green">Password matched</p>    <p ng-hide="isMatch || PASS==null" style="color:red">     Password does not match</p>  </div>  <script>  var app = angular.module("app", []);  app.controller('geek', ['$scope', function ($scope) {   $scope.match = function () {   $scope.isMatch = angular.equals($scope.pass, $scope.PASS);}}]);     </script></body></html>
Output:Initially:Incorrect Input:Correct Input:
AngularJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Angular File Upload
Angular | keyup event
Angular PrimeNG Dropdown Component
Auth Guards in Angular 9/10/11
Angular PrimeNG Calendar Component
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 Draw a Semi-Circle using HTML and CSS ? - GeeksforGeeks

30 Jul, 2021
A Semi-Circle or a Half-Circle shape can be easily created using HTML and CSS. We will use the border-radius property to draw the desired output.
HTML Code: In this section we will create a simple “div” element using the <div> tag.
HTML
<!DOCTYPE html><html lang="en">  <head>    <meta charset="UTF-8">    <meta name="viewport" content=        "width=device-width, initial-scale=1.0">    <title>Semi Circle</title></head>  <body>    <div></div></body>  </html>
CSS Code: In this section we will first design the “div” box using simple CSS properties and then draw the semi-circle using the border-radius property.
CSS
<style>    * {        margin: 0;        padding: 0;        background-color: white;      }      /* Using the "border-radius" property       to draw the semi-circle*/      div {        position: absolute;        top: 50%;        left: 50%;        transform: translate(-50%, -50%);        height: 100px;        width: 200px;        border-radius: 150px 150px 0 0;        background-color: green;    }</style>
Final Code: It is the combination of the above two code sections.
HTML
<!DOCTYPE html><html lang="en">  <head>    <meta charset="UTF-8">    <meta name="viewport" content=        "width=device-width, initial-scale=1.0">      <title>Semi Circle</title>      <style>        * {            margin: 0;            padding: 0;            background-color: white;          }          /* Using the border-radius property            to draw the semi-circle*/        div {            position: absolute;            top: 50%;            left: 50%;            transform: translate(-50%, -50%);            height: 100px;            width: 200px;            border-radius: 150px 150px 0 0;            background-color: green;        }    </style></head>  <body>    <div></div></body>  </html>
Output:
CSS is the foundation of webpages, is used for webpage development by styling websites and web apps.You can learn CSS from the ground up by following this CSS Tutorial and CSS Examples.
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 set space between the flexbox ?
How to apply style to parent if it has child with CSS?
Design a web page using HTML and CSS
Create a Responsive Navbar using ReactJS
Form validation using jQuery
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)
HTML Cheat Sheet - A Basic Guide to HTML
SQL Query to Display Nth Record from Employee Table

13 Apr, 2021
Here. we are going to see how to retrieve and display Nth records from a Microsoft SQL Server’s database table using an SQL query. We will first create a database called “geeks” and then create “Employee” table in this database and will execute our query on that table.
Use the below SQL statement to create a database called geeks:
CREATE DATABASE geeks;
USE geeks;
We have the following Employee table in our geeks database :
CREATE TABLE Employee(
ID INT PRIMARY KEY AUTO_INCREMENT,
NAME VARCHAR(30) NOT NULL,
PHONE INT(10) NOT NULL UNIQUE,
EMAIL VARCHAR(30) NOT NULL UNIQUE,
DATE_OF_JOINING DATE);
You can use the below statement to query the description of the created table:
EXEC SP_COLUMNS Employee;
Chapters
descriptions off, selected
captions settings, opens captions settings dialog
captions off, selected
English
This is a modal window.
Beginning of dialog window. Escape will cancel and close the window.
End of dialog window.
Use the below statement to add data to the Employee table:
INSERT INTO Employee (NAME, PHONE, EMAIL, DATE_OF_JOINING)
VALUES
('Yogesh Vaishnav', 0000000001, 'yogesh@mail.com', '2019-10-03'),
('Vishal Vishwakarma', 0000000002, 'chicha@mail.com', '2019-11-07'),
('Ajit Yadav', 0000000003, 'ppa@mail.com', '2019-12-12'),
('Ashish Yadav', 0000000004, 'baba@mail.com', '2019-12-25'),
('Tanvi Thakur', 0000000005, 'tanvi@mail.com', '2020-01-20'),
('Sam', 0000000006, 'sam@mail.com', '2020-03-03'),
('Ron', 0000000007, 'ron@mail.com', '2020-05-16'),
('Sara', 0000000008, 'sara@mail.com', '2020-07-01'),
('Zara', 0000000009, 'zara@mail.com', '2020-08-20'),
('Yoji', 0000000010, 'yoji@mail.com', '2020-03-10');
To verify the contents of the table use the below statement:
SELECT * FROM Employee;
Now let’s display the Nth record of the table.
Syntax :  SELECT * FROM <table_name> LIMIT  N-1,1;

Here N refers to the row which is to be retrieved.
Example : 
Let’s retrieve the 6th row from the start from the Employee table we have created.
SELECT * FROM Employee 
ORDER BY <column_name>     --column name is the name according to which the rows are to be ordered.Here it's ID.
OFFSET 5 ROWS              --since N - 1 = 6 - 1 = 5 
FETCH NEXT 1 ROWS ONLY;
Output :
Picked
SQL-Query
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
CTE in SQL
SQL Trigger | Student Database
SQL Interview Questions
How to Update Multiple Columns in Single Update Statement in SQL?
SQL | Views
Difference between DELETE, DROP and TRUNCATE
Window functions in SQL
SQL | GROUP BY
MySQL | Group_CONCAT() Function
Difference between DELETE and TRUNCATE
Python | Merging two strings with Suffix and Prefix

25 Nov, 2019
Given two strings A and B and these strings contain lower case letters. The task is to tell the length of the merged strings. For example, given A is “abcde” and B is “cdefg”, then merging the two strings results in “abcdefg”. The merge operation is performed in such a manner that the joining characters are both the suffix of A and Prefix of B.Before merging you are allowed to do any ONE of the following operations:
Reverse string AReverse string B
Reverse string A
Reverse string B
Examples:
Input :
A = "ababc"
B = "bcabc" 
Output :
Length is 8

the suffix of string A i.e "bc" and prefix of B i.e "bc" is the same
so the merged string will be "ababcabc" and length is 8.

Input :
A = "cdefg"
B = "abhgf"
Output :
Length is 8

the suffix of string A i.e "fg" and prefix of  reversed B i.e "fg" is the same
so the merged string will be "cdefghba" and length is 8

Input :
A = "wxyz"
B = "zyxw"
Output :
Length is 4

Below is the Python code implementation of the above mentioned approach.
# function to find the length of the# merged string  def mergedstring(x, y) :          k = len(y)    for i in range(len(x)) :                  if x[i:] == y[:k] :            break        else:            k = k-1      # uncomment the below statement to    # know what the merged string is    # print(a + b[k:])    return len(a + b[k:])  # function to find the minimum length# among the  merged stringdef merger(a, b):    # reverse b     b1 = b[::-1]       # function call to find the length    # of string without reversing string 'B'    r1 = mergedstring(a, b)      # function call to find the length    # of the string by reversing string 'B'    r2 = mergedstring(a, b1)      # compare between lengths    if r1 > r2 :        print("Length is", r2)    else :        print("Length is", r1)              # driver codea = "abcbc"b = "bcabc"  merger(a, b)
Output:
Length is 8

python-string
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to get the current Date and Time in PHP ?

14 Jan, 2021
The purpose of the article is to get the current Date and Time in PHP. It is performed by using a simple in-built PHP function date(). The Date is an inbuilt function used to format the timestamp. The computer stores date and time in UNIX timestamp. This time is measured as a number of seconds since Jan 1, 1970. As this is difficult for humans to read, PHP converts timestamps to format in such a way that it is readable and more understandable to humans.  
Syntax:  
date('d-m-y h:i:s');
Parameters :  The date() have different parameters. Each parameter represents some meaningful unit. 
d: It represents the day of the month which has two digits with leading zeros (01 or 31)m: It represents month in numbers with leading zeros (01 or 1)y: It represents a year in two digits (08 or 14).h: It represents the hour of the day in two digits with leading zeros (01 or 1)I: It represents the minute in the current time zone.s: It represents the number of seconds in the current timezone.
d: It represents the day of the month which has two digits with leading zeros (01 or 31)
m: It represents month in numbers with leading zeros (01 or 1)
y: It represents a year in two digits (08 or 14).
h: It represents the hour of the day in two digits with leading zeros (01 or 1)
I: It represents the minute in the current time zone.
s: It represents the number of seconds in the current timezone.
Example 1: 
PHP
<?php // PHP program to get the // current date and time   echo "Current date and time is :";   // Store the date and time  to // the variable $myDate = date("d-m-y h:i:s");  // Display the date and time echo $myDate;   ?> 
Output:
Current date and time is :03-01-21 04:49:52
Example 2: The following demonstrates other date() functions format which can be used by the developer as per the need.
PHP
<!DOCTYPE html><html><body><h2>Other ways of using date() function</h2><?phpecho "Date in Year.Month.Day format is: "     . date("Y.m.d") . "<br>";  echo "Date in Year-Month-day format is: "     . date("Y-m-d") . "<br>";  echo "Date in Year/Month/day format is: "     . date("Y/m/d") . "<br>";  ?></body></html>
Output:
PHP-date-time
PHP-Misc
PHP
PHP Programs
Web Technologies
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to execute PHP code using command line ?
PHP in_array() Function
How to delete an array element based on key in PHP?
How to Insert Form Data into Database using PHP ?
How to convert array to string in PHP ?
How to execute PHP code using command line ?
How to delete an array element based on key in PHP?
How to Insert Form Data into Database using PHP ?
How to convert array to string in PHP ?
How to pop an alert message box using PHP ?
Create Subsets of a Data frame in R Programming – subset() Function

22 Nov, 2021
subset() function in R Programming Language is used to create subsets of a Data frame. This can also be used to drop columns from a data frame.
Syntax: subset(df, expr)
Parameters: 
df: Data frame used
expr: Condition for subset
Here we will make subsets of dataframe using subset() methods in R language.
R
# R program to create# subset of a data frame   # Creating a Data Framedf<-data.frame(row1 = 0:2, row2 = 3:5, row3 = 6:8)print ("Original Data Frame")print (df)   # Creating a Subsetdf1<-subset(df, select = row2)print("Modified Data Frame")print(df1)
Output: 
[1] "Original Data Frame"
  row1 row2 row3
1    0    3    6
2    1    4    7
3    2    5    8
[1] "Modified Data Frame"
  row2
1    3
2    4
3    5
Here, in the above code, the original data frame remains intact while another subset of data frame is created which holds a selected row from the original data frame. 
Python3
# R program to create# subset of a data frame   # Creating a Data Framedf<-data.frame(row1 = 0:2, row2 = 3:5, row3 = 6:8)print ("Original Data Frame")print (df)   # Creating a Subsetdf<-subset(df, select = -c(row2, row3))print("Modified Data Frame")print(df)
Output: 
[1] "Original Data Frame"
  row1 row2 row3
1    0    3    6
2    1    4    7
3    2    5    8
[1] "Modified Data Frame"
  row1
1    0
2    1
3    2
Here, in the above code, the rows are permanently deleted from the original data frame.
kumar_satyam
R DataFrame-Function
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Change Color of Bars in Barchart using ggplot2 in R
How to Split Column Into Multiple Columns in R DataFrame?
Group by function in R using Dplyr
How to Change Axis Scales in R Plots?
R - if statement
Logistic Regression in R Programming
How to filter R DataFrame by values in a column?
Replace Specific Characters in String in R
How to import an Excel File into R ?
Joining of Dataframes in R Programming
How to pass PHP Variables by reference ?

20 Dec, 2018
By default, PHP variables are passed by value as the function arguments in PHP. When variables in PHP is passed by value, the scope of the variable defined at function level bound within the scope of function. Changing either of the variables doesn’t have any effect on either of the variables.
Example:
<?php  // Function used for assigning new// value to $string variable and // printing itfunction print_string( $string ) {    $string = "Function geeksforgeeks"."\n";      // Print $string variable    print($string);}  // Driver code$string = "Global geeksforgeeks"."\n";print_string($string);print($string);?>
Function geeksforgeeks
Global geeksforgeeks

Pass by reference: When variables are passed by reference, use & (ampersand) symbol need to be added before variable argument. For example: function( &$x ). Scope of both global and function variable becomes global as both variables are defined by same reference. Therefore, whenever global variable is change, variable inside function also gets changed and vice-versa is applicable.
Example:
<?php  // Function used for assigning new value to // $string variable and printing itfunction print_string( &$string ) {          $string = "Function geeksforgeeks \n";      // Print $string variable    print( $string );}  // Driver code$string = "Global geeksforgeeks \n";print_string( $string );print( $string );?>
Function geeksforgeeks 
Function geeksforgeeks

PHP-basics
PHP-function
Picked
PHP
PHP Programs
Web Technologies
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to execute PHP code using command line ?
How to Insert Form Data into Database using PHP ?
PHP in_array() Function
How to delete an array element based on key in PHP?
How to pop an alert message box using PHP ?
How to Upload Image into Database and Display it using PHP ?
How to execute PHP code using command line ?
How to call PHP function on the click of a Button ?
How to Insert Form Data into Database using PHP ?
How to pop an alert message box using PHP ?
map find() function in C++ STL

In this article we will be discussing the working, syntax and examples of map::find() function in C++ STL.
Maps are the associative container, which facilitates to store the elements formed by a combination on key value and mapped value in a specific order. In a map container the data is internally always sorted with the help of its associated keys. The values in map container is accessed by its unique keys.
The map::find( ) is a function which comes under <map> header file. This function returns an iterator which points to an element of a given key which we want to search.
map_name.find(key_value k);
This function accepts the following
k: This is the key value which we want to search from the map container
It returns an iterator pointing to the element associated with key k.
map<char, int> newmap;
newmap[‘a’]
= 1;
newmap[‘b’] = 2;
newmap.find(b);
2
 Live Demo
#include <bits/stdc++.h>
using namespace std;
int main() {
   map<int, int> TP_Map;
   TP_Map.insert({3, 50});
   TP_Map.insert({2, 30});
   TP_Map.insert({1, 10});
   TP_Map.insert({4, 70});
   cout<<"TP Map is : \n";
   cout << "MAP_KEY\tMAP_ELEMENT\n";
   for (auto i = TP_Map.begin(); i!= TP_Map.end(); i++) {
      cout << i->first << "\t" << i->second << endl;
   }
   //to find the map values at position
   auto var = TP_Map.find(1);
   cout<<"Found element at position "<<var->first<<" is : "<<var->second;
   auto var_1 = TP_Map.find(2);
   cout<<"\nFound element at position "<<var_1->first<<" is : "<<var_1->second;
   return 0;
}
TP Map is:
MAP_KEY    MAP_ELEMENT
1             10
2             30
3             50
4             70
Found element at position 1 is : 10
Found element at position 2 is : 30
 Live Demo
#include <bits/stdc++.h>
using namespace std;
int main() {
   map<int, int> TP_Map;
   TP_Map.insert({3, 50});
   TP_Map.insert({2, 30});
   TP_Map.insert({1, 10});
   TP_Map.insert({4, 70});
   cout<<"TP Map is : \n";
   cout << "MAP_KEY\tMAP_ELEMENT\n";
   for (auto i = TP_Map.find(2); i!= TP_Map.end(); i++) {
      cout << i->first << "\t" << i->second << endl;
   }
   return 0;
}
TP Map is:
MAP_KEY    MAP_ELEMENT
2             30
3             50
4             70
What is the benefit of zerofill in MySQL?

ZEROFILL pads the displayed value of the field with zeros up to the display width set in the column definition. Let us understand the role of zero fill in MySQL using an example. Creating a table with two columns, one has zerofill and the second one does not. The query to create a table.
mysql> create table ZeroFillDemo
   -> (
   -> First int(18) zerofill,
   -> Second int(18)
   -> );
Query OK, 0 rows affected (0.63 sec)
We can insert records in the table with the help of INSERT command. The query is as follows.
mysql> insert into ZeroFillDemo values(1,1);
Query OK, 1 row affected (0.13 sec)

mysql>  insert into ZeroFillDemo values(12,12);
Query OK, 1 row affected (0.15 sec)

mysql>  insert into ZeroFillDemo values(123,123);
Query OK, 1 row affected (0.10 sec)

mysql>  insert into ZeroFillDemo values(123456789,123456789);
Query OK, 1 row affected (0.20 sec)
Now, we can check the benefits of zerofill column with the help of select command.
The query is as follows.
mysql> select *from ZeroFillDemo;
The following is the output.
+--------------------+-----------+
| First              | Second    |
+--------------------+-----------+
| 000000000000000001 |         1 |
| 000000000000000012 |        12 |
| 000000000000000123 |       123 |
| 000000000123456789 | 123456789 |
+--------------------+-----------+
4 rows in set (0.00 sec)

Look at the sample output,zero is filled at the beginning.
Packages in Perl - GeeksforGeeks

11 Feb, 2019
A Perl package is a collection of code which resides in its own namespace. Perl module is a package defined in a file having the same name as that of the package and having extension .pm. Two different modules may contain a variable or a function of the same name. Any variable which is not contained in any package belongs to the main package. Therefore, all the variables being used, belong to the ‘main’ package. With the declaration of additional packages, it is maintained that variables in different packages do not interfere with each other. 
Example : Calculator.pm
package Calculator;  # Defining sub-routine for Additionsub addition{    # Initializing Variables a & b    $a = $_[0];    $b = $_[1];          # Performing the operation    $a = $a + $b;          # Function to print the Sum    print "\n***Addition is $a";}  # Defining sub-routine for Subtractionsub subtraction{    # Initializing Variables a & b    $a = $_[0];    $b = $_[1];          # Performing the operation    $a = $a - $b;          # Function to print the difference    print "\n***Subtraction is $a";}1;
Here, the name of the file is “Calculator.pm” stored in the directory Calculator. Notice that 1; is written at the end of the code to return a true value to the interpreter. Perl accepts anything which is true instead of 1. 
Examples: Test.pl
#!/usr/bin/perl  # Using the Package 'Calculator'use Calculator;  print "Enter two numbers to add";  # Defining values to the variables$a = 10;$b = 20;  # Subroutine callCalculator::addition($a, $b);  print "\nEnter two numbers to subtract";  # Defining values to the variables$a = 30;$b = 10;  # Subroutine callCalculator::subtraction($a, $b);
Output: 
Examples: Test_out_package.pl outside Calculator directory
#!/usr/bin/perl  use GFG::Calculator; # Directory_name::module_name  print "Enter two numbers to add";  # Defining values to the variables$a = 10;$b = 20;  # Subroutine callCalculator::addition($a, $b);  print "\nEnter two numbers to subtract";  # Defining values to the variables$a = 30;$b = 10;  # Subroutine callCalculator::subtraction($a, $b);
Output: 
#!/usr/bin/perl  package Message;  # Variable Creation$username;  # Defining subroutinesub Hello{  print "Hello $username\n";}1;
Perl file to access the module is as belowExamples: variable.pl
#!/usr/bin/perl  # Using Message.pm packageuse Message;  # Defining value to variable$Message::username = "ABC";  # Subroutine callMessage::Hello();
Output: 
#!/usr/bin/perl  # Predefined BEGIN blockBEGIN{    print "In the begin block\n";}  # Predefined END blockEND{    print "In the end block\n";}  print "Hello Perl;\n";
Output:
In the begin block
Hello Perl;
In the end block
Picked
Perl
Perl
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Perl | split() Function
Perl | push() Function
Perl | chomp() Function
Perl | grep() Function
Perl | substr() function
Perl | exists() Function
Perl Tutorial - Learn Perl With Examples
Perl | Removing leading and trailing white spaces (trim)
Use of print() and say() in Perl
Perl | length() Function
matplotlib.pyplot.prism() in Python - GeeksforGeeks

22 Apr, 2020
Matplotlib is a library in Python and it is numerical – mathematical extension for NumPy library. Pyplot is a state-based interface to a Matplotlib module which provides a MATLAB-like interface.
The prism() function in pyplot module of matplotlib library is used to set the colormap to “prism”.
Syntax:
matplotlib.pyplot.prism()

Parameters: This method does not accepts any parameter.
Returns: This method does not return any value.
Below examples illustrate the matplotlib.pyplot.prism() function in matplotlib.pyplot:
Example #1:
# Implementation of matplotlib functionimport matplotlib.pyplot as pltimport matplotlib.tri as triimport numpy as np          ang = 40rad = 10radm = 0.35radii = np.linspace(radm, 0.95, rad)     angles = np.linspace(0, 4 * np.pi, ang)angles = np.repeat(angles[..., np.newaxis], rad, axis = 1)angles[:, 1::2] += np.pi / ang     x = (radii * np.cos(angles)).flatten()y = (radii * np.sin(angles)).flatten()z = (np.sin(4 * radii) * np.cos(4 * angles)).flatten()     triang = tri.Triangulation(x, y)triang.set_mask(np.hypot(x[triang.triangles].mean(axis = 1),                         y[triang.triangles].mean(axis = 1))                        < radm)     tpc = plt.tripcolor(triang, z, shading ='flat')plt.colorbar(tpc)plt.prism()plt.title('matplotlib.pyplot.prism() function Example',                                   fontweight ="bold")plt.show()
Output:
Example #2:
# Implementation of matplotlib functionimport matplotlib.pyplot as pltimport numpy as npfrom matplotlib.colors import LogNorm        dx, dy = 0.015, 0.05x = np.arange(-4.0, 4.0, dx)y = np.arange(-4.0, 4.0, dy)X, Y = np.meshgrid(x, y)     extent = np.min(x), np.max(x), np.min(y), np.max(y)          Z1 = np.add.outer(range(8), range(8)) % 2plt.imshow(Z1, cmap ="binary_r", interpolation ='nearest',                             extent = extent, alpha = 1)     def geeks(x, y):    return (1 - x / 2 + x**5 + y**6) * np.exp(-(x**2 + y**2))     Z2 = geeks(X, Y)     plt.imshow(Z2, alpha = 0.7, interpolation ='bilinear',                                    extent = extent)plt.prism()plt.title('matplotlib.pyplot.prism() function Example',                                   fontweight ="bold")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 ?
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()