code-rag-bench/online-tutorials huggingface dataset:
3 NumPy Functions to Facilitate Data Analysis with Pandas | by Soner Yıldırım | Towards Data Science

Pandas and Numpy are the two most popular Python libraries used for data analysis and manipulation. Pandas is equipped with a lot of practical and handy functions.
Pandas also allows for using some Numpy functions which results in more functional and efficient operations with Pandas. In this article, we will go over 3 Numpy functions that are of great help when doing data analysis with Pandas.
Let’s start with importing the libraries and creating a sample data frame to work on.
import numpy as npimport pandas as pddf = pd.DataFrame({    "A": np.random.randint(10, size=6),    "B": np.random.randint(20, size=6),    "C": np.random.randint(10,20, size=6),    "D": np.random.random(6).round(2)})df
The first one we are interested in is the where function which provides a convenient way for creating conditional columns.
We pass a condition to the where function and determine a separate value for the rows that satisfy and do not satisfy the condition.
For instance, we can create a column “E” that takes the value 1 if both the values in columns “B” and “C” are higher than 10. Otherwise, the value in column “E” is 0.
df["E"] = np.where((df["B"] > 10) & (df["C"] > 10), 1, 0)df
We can combine as many conditions as needed using logical operators.
The select function is like an upgraded version of the where. We are able apply multiple conditions to determine a separate value for each.
With where function, we can only test a condition (or a set of conditions) and determine two values. What the select function does is take it one step further. We can test multiple conditions (or multiple sets of conditions) and assign a separate value for rows that meet each condition set. It also allows for specifying a default value to be used for rows that do not meet any of the conditions.
It will be more clear with an example.
conditions = [  (df["B"] >= 10) & (df["A"] == 0),  (df["B"] >= 10) & (df["A"] == 8)]values = [1, 2]df["F"] = np.select(conditions, values, default=0)df
The log function, as its name suggests, is used for taking the logarithm of a value.
np.log10(100)2.0np.log2(16)4.0np.log(1000)6.907755278982137
Thankfully, we can apply the log function to an entire column of a data frame. Taking the log of a column is a useful practice in many cases. For instance, if the target variable in a machine learning model includes outliers, it is better to use the log of the target variable in the model. Log linear models are commonly used in machine learning.
We have the following data frame:
The values 600 and 850 are quite large compared to the other values in the target column. Let’s take the log of this column to see the difference.
df["log_target"] = np.log(df["target"])df
The differences have become smaller due to the log function.
Numpy and Pandas go hand in hand. In fact, Pandas and some other Python libraries were built on top of Numpy.
In most cases, we are able to complete a task with Pandas functions. However, using Numpy functions in some cases provide additional benefits and functionality.
Thank you for reading. Please let me know if you have any feedback.
How to delete rows of R dataframe based on string match? - GeeksforGeeks

26 Apr, 2022
In this article, we will discuss how to delete rows of a dataframe based on string match in R Programming Language.
For this grep() function can be used. This function searches for matches of certain character patterns in a vector of character strings and returns a boolean value as TRUE if that string is present else it returns FALSE.
Syntax: grepl(pattern, string, ignore.case=FALSE)
Parameter:
pattern: regular expressions pattern
string: character vector to be searched
First with the help of grepl() we have obtained the rows which consist of specified substrings in it. Then with Not operator(!) we have removed those rows in our data frame and stored them in another data frame.
Data frame in use:
Data frame
Example 1:
R
Strings<-c("Geeks","For","Geeks","GFG","Ram",           "Ramesh","Gene","Siri")Id<-1:8 # df is our data frame namedf<-data.frame(Id,Strings)   print(df) # Removes the rows in Data frame# which consist "Ra" in itnew_df=df[!grepl("Ra",df$Strings),]print(new_df)
Output:
Example 2:
R
Strings<-c("Geeks","For","Geeks","GFG","Ram",           "Ramesh","Gene","Siri")Id<-1:8 # df is our data frame namedf<-data.frame(Id,Strings)   print(df) # Removes the rows in Data frame# which consist "Ge" in itnew_df=df[!grepl("Ge",df$Strings),]print(new_df)
Output:
vitapanekrsj
Picked
R DataFrame-Programs
R-DataFrame
R Language
R Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Change Color of Bars in Barchart using ggplot2 in R
Group by function in R using Dplyr
How to Change Axis Scales in R Plots?
How to Split Column Into Multiple Columns in R DataFrame?
Replace Specific Characters in String in R
How to Split Column Into Multiple Columns in R DataFrame?
Replace Specific Characters in String in R
How to filter R DataFrame by values in a column?
How to filter R dataframe by multiple conditions?
Convert Matrix to Dataframe in R
Bar Graph in MATLAB - GeeksforGeeks

15 Nov, 2021
A Bar Graph is a diagrammatic representation of non-continuous or discrete variables. It is of 2 types vertical and horizontal. When the height axis is on the y-axis then it is a vertical Bar Graph and when the height axis is on the x-axis then it is a horizontal Bar Graph.
In MATLAB we have a function named bar() which allows us to plot a bar graph. 
Syntax:
bar(X,Y)where X and Y represent the x and the y axis of the plane. The X and Y both are vectors.
Now let’s move to some examples.
Example 1: A simple Bar graph:
MATLAB
% Coordinates of x-axisx=100:20:160;% Coordinates of y-axisy=[22 44 55 66];  % Bar function to plot the Bar graph% Set the width of each bar to 60 percent% of the total space available for each bar% Set the bar color greenbar(x,y,0.6,"green");
Output : 
Example 2: 3 groups of 4 bars:
MATLAB
% 3 groups are made with 4 bars% ";" is used to separate the groupsy=[2 5 4 1; 5 3 3 1; 2 8 4 6];  % bar function to plot the barbar(y);
Output : 
Example 3: Display Stacked bars:
MATLAB
% 3 groupsy=[2 5 4 1; 5 3 3 1; 2 8 4 6];  % stacked is used to stack the bars % on each otherbar(y,'stacked');
Output :  
Example 4: Display negative bars:
MATLAB
% bars with negative valuesy=[2 5 4 -1; 5 -3 3 1; -2 8 4 6];  % bar function to display barsbar(y);
Output :
Example 5: Display horizontal bar graph:
MATLAB
% Coordinates of y axisy=[2 5 4 1];  % barh() function is used to % display bar horizontallybarh(y);
Output :  
surinderdawra388
MATLAB
Picked
MATLAB
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Forward and Inverse Fourier Transform of an Image in MATLAB
Boundary Extraction of image using MATLAB
How to Remove Noise from Digital Image in Frequency Domain Using MATLAB?
How to Solve Histogram Equalization Numerical Problem in MATLAB?
How to Normalize a Histogram in MATLAB?
How to Remove Salt and Pepper Noise from Image Using MATLAB?
Double Integral in MATLAB
Classes and Object in MATLAB
What are different types of denoising filters in MATLAB?
How to Convert Three Channels of Colored Image into Grayscale Image in MATLAB?
How to align item to the flex-end in the container using CSS ? - GeeksforGeeks

06 Apr, 2021
In this article, we will learn how to align item flex-end at the end of the container using CSS. The align-items and display property of CSS is used to align items at the end of the container.
Approach: The align-items and display property of CSS are used to align items at the end of the container. To align items at the end of the container, we set the align-items value to flex-end and the display value to flex.
Syntax:
display:flex;
align-items: flex-end; 
Example:
HTML
<!DOCTYPE html><html lang="en">  <head>    <style>        .gfg {            border: solid 5px red;            width: 50vh;            height: 50vh;            font-size: 50px;            color: rgb(0, 167, 0);            display: flex;            align-items: flex-end;        }    </style></head>  <body>    <div class="gfg">        <div>GeeksforGeeks</div>    </div></body>  </html>
Output:
Before applying display and align-items property:
After applying display and align-items property:
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
CSS-Properties
CSS-Questions
HTML-Tags
Picked
CSS
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Design a web page using HTML and CSS
How to set space between the flexbox ?
Form validation using jQuery
Search Bar using HTML, CSS and JavaScript
How to style a checkbox using 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 ?
Recursion in Perl - GeeksforGeeks

27 Jun, 2021
Recursion is a mechanism when a function calls itself again and again till the required condition is met. When the function call statement is written inside the same function then such a function is referred to as a recursive function.The argument passed to a function is retrieved from the default array @_ whereas each value can be accessed by $_[0], $_[1] and so on.Example 1: The example below finds factorial of a number.  
Factorial of any number n is (n)*(n-1)*(n-2)*....*1.
e.g.:
4! = 4*3*2*1 = 24
3! = 3*2*1 = 6
2! = 2*1 = 2
1! = 1
0! = 0
 
Perl
#!/usr/bin/perl # Perl Program to calculate Factorialsub fact{     # Retrieving the first argument# passed with function callingmy $x = $_[0]; # checking if that value is 0 or 1if ($x == 0 || $x == 1){    return 1;} # Recursively calling function with the next value# which is one less than current oneelse{    return $x * fact($x - 1);}} # Driver Code$a = 5; # Function call and printing result after returnprint "Factorial of a number $a is ", fact($a);
Here is how the program works : Step 1- When the value of scalar a is 0 or 1, the function will return 1 because the value of both 0! and 1! is 1. Step 2- When the value of scalar a is 2 then fac(x-1) makes a call to fac(1) and this function returns 1. So, it is 2*factorial(1) = 2*1 = 2.So, it will return 2. Step 3- Similarly when higher values are passed to function at every call argument value decreases by 1 and computes till the value reaches 1.Example 2: Example below computes the Fibonacci series till a given number.  
Perl
#!/usr/bin/perl # Perl Program to print Fibonacci seriessub fib{    # Retrieving values from the parameter    my $x = shift;    my $y = shift;         # Number till which the series is to be printed    my $n = shift;         # Check for the end value    if ($y > $n)    {        return 1;    }         # Printing the number    print " $y";     # Recursive Function Call    fib($y, $x + $y, $n);    } # Driver Code # Number till which series is to be printed$a = 5; # First two elements of the series$c = 0;$d = 1; print "$c"; # Function call with required parametersfib($c, $d, $a);
Here is how the program works : Step 1- Function fib() is called with 3 parameters starting values which will be 0 and 1 while $n is a number till which a series is to be printed Step 2- These values are transferred in the form of an array whose values are retrieved with the use of shift. Step 3- At each call first two values are retrieved using shift and these values are stored in scalars x and y. Now these two values are added to get the next value in the series. This step continues till the value reaches the ending value provided by the user 
akshaysingh98088
Algorithms-Recursion
Picked
Perl
Perl
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Perl | Arrays (push, pop, shift, unshift)
Perl | Polymorphism in OOPs
Perl | Arrays
Perl Tutorial - Learn Perl With Examples
Use of print() and say() in Perl
Perl | length() Function
Perl | join() Function
Perl | Basic Syntax of a Perl Program
Perl | substitution Operator
Perl | Regex Cheat Sheet
HackerRank Interview Experience for SDE (Bangalore) - GeeksforGeeks

22 Feb, 2021
I applied for this role at hackerrank.com/careers
Round 1(Online coding round in HackerRank): I got a Hackerrank test link. I had 2 questions asked in the test
Given an array of elements, Find the count of unique elements in an array.Encrypt a string, as below
Given an array of elements, Find the count of unique elements in an array.
Encrypt a string, as below
Original string - saaavvvvvqql (given)
Encrypted string - s3v5q2l (need to return this string)
I solved both the questions successfully
After 1 week, I got an email saying that I will be moved to the next round. I was asked about my current CTC and my expected CTC. I didn’t have an expected CTC in my mind, rather I was looking out for what they offered. I didn’t get an answer
Round 2: I was how I would design a system that will convert long urls to tiny urls. They told me to design tables for the same. They also asked me questions on load balancing, I answered them fairly well. 
After 2 days, I got an email saying that they have decided to move forward with other candidates. 
HackerRank
Marketing
Interview Experiences
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Amazon Interview Experience for SDE-1 (Off-Campus)
Amazon AWS Interview Experience for SDE-1
Amazon Interview Experience
Amazon Interview Experience for SDE-1
Infosys Interview Experience for DSE 2022
Amazon Interview Experience (Off-Campus) 2022
Amazon Interview Experience for SDE-1 (On-Campus)
JPMorgan Chase & Co. Code for Good Internship Interview Experience 2021
Infosys Interview Experience for Digital Specialist Engineer Through InfyTQ
Google Interview Experience SDE-1 (Off-Campus) 2022
GATE | GATE-CS-2003 | Question 5 - GeeksforGeeks

28 Jun, 2021
n couples are invited to a party with the condition that every husband should be accompanied by his wife. However, a wife need not be accompanied by her husband. The number of different gatherings possible at the party is(A) A(B) B(C) C(D) DAnswer: (B)Explanation: There are three options for every couple.
1) Nobody goes to gathering
2) Wife alone goes
2) Both go
Since there are n couples, total possible ways of gathering are 3nQuiz of this Question
GATE-CS-2003
GATE-GATE-CS-2003
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | GATE-IT-2004 | Question 66
GATE | GATE CS 2019 | Question 27
GATE | GATE-CS-2006 | Question 49
GATE | GATE-CS-2014-(Set-3) | Question 65
GATE | GATE-CS-2004 | Question 3
GATE | GATE-CS-2016 (Set 2) | Question 48
GATE | GATE-CS-2000 | Question 43
GATE | GATE-CS-2017 (Set 2) | Question 42
GATE | Gate IT 2007 | Question 30
GATE | GATE CS 2010 | Question 24
Function that returns the minimum and maximum value of an array in JavaScript

We are required to write a JavaScript function that takes in an array and return another array, the first element of this array should be the smallest element of input array and second should be the greatest element of the input array.
Following is the code −
 Live Demo
const arr = [56, 34, 23, 687, 2, 56, 567];
const findMinMax = (arr = []) => {
   const creds = arr.reduce((acc, val) => {
   let [smallest, greatest] = acc;
      if(val > greatest){
         greatest = val;
      };
      if(val < smallest){
         smallest = val;
      };
      return [smallest, greatest];
   }, [Infinity, -Infinity]);
   return creds;
};
console.log(findMinMax(arr));
[2, 687]
Ruby on Rails - Routes

The routing module provides URL rewriting in native Ruby. It's a way to redirect incoming requests to controllers and actions. It replaces the mod_rewrite rules. Best of all, Rails' Routing works with any web server. Routes are defined in app/config/routes.rb.
Think of creating routes as drawing a map for your requests. The map tells them where to go based on some predefined pattern −
Rails.application.routes.draw do
   Pattern 1 tells some request to go to one place
   Pattern 2 tell them to go to another
   ...
end

Let us consider our library management application contains a controller called BookController. We have to define the routes for those actions which are defined as methods in the BookController class.
Open routes.rb file in library/config/ directory and edit it with the following content.
Rails.application.routes.draw do
   get 'book/list'
   get 'book/new'
   post 'book/create'
   patch 'book/update'
   get 'book/list'
   get 'book/show'
   get 'book/edit'
   get 'book/delete'
   get 'book/update'
   get 'book/show_subjects'
end

The routes.rb file defines the actions available in the applications and the type of action such as get, post, and patch.
Use the following command to list all your defined routes, which are useful for tracking down routing problems in your application, or giving you a good overview of the URLs in an application you're trying to get familiar with.
library> rake routes

Next, we will create the code to generate screens to display data and to take input from the user.
 Print
 Add Notes
 Bookmark this page
C# Enum Format Method

The Format method converts value of a specified enumerated type to its equivalent string representation. Here you can also set the format i.e. d for Decimal, x for HexaDecimal, etc.
We have the following enumeration.
enum Stock { PenDrive, Keyboard, Speakers };
The default value gets assigned (initialize).
PenDrive = 0
Keyboard = 1
Speakers = 2
Now, let’s say you want the value of “Keyboard” name.
Stock st = Stock.Keyboard;
For that, try the following and get the constant value for Keyboard name.
Enum.Format(typeof(Stock), st, "d")
The following is the entire example.
 Live Demo
using System;
class Demo {
   enum Stock { PenDrive, Keyboard, Speakers };
   static void Main() {
      Stock st = Stock.Keyboard;
      Console.WriteLine("Product I need is {0}", st);
      Console.WriteLine("Product value: {0}", Enum.Format(typeof(Stock), st, "d"));
   }
}
Product I need is Keyboard
Product value: 1
How to get the lifecycle of a S3 bucket using Boto3 and AWS Client?

Problem Statement: Use boto3 library in Python to get lifecycle of a S3 bucket. For example, find the lifecycle of Bucket_1 in S3.
Step 1 − Import boto3 and botocore exceptions to handle exceptions.
Step 2 − bucket_name is the parameter in the function.
Step 3 − Create an AWS session using boto3 library.
Step 4 − Create an AWS client for S3.
Step 5 − Now, use the function get_bucket_lifecycle_configuration and pass the bucket name.
Step 6 − It returns the dictionary containing the details about S3.
Step 7 − Handle the generic exception if something went wrong while deleting the file.
Use the following code to get the bucket lifecycle −
import boto3
from botocore.exceptions import ClientError

def get_bucket_lifecycle_of_s3(bucket_name):
   session = boto3.session.Session()
   s3_client = session.client('s3')
   try:
      result = s3_client.get_bucket_lifecycle_configuration(Bucket=bucket_name,)
   except ClientError as e:
      raise Exception( "boto3 client error in get_bucket_lifecycle_of_s3 function: " + e.__str__())
   except Exception as e:
      raise Exception( "Unexpected error in get_bucket_lifecycle_of_s3 function: " + e.__str__())
return result

print(get_bucket_lifecycle_of_s3("Bucket_1"))
{
   'Rules': [
      {
         'ID': 'Rule for TaxDocs/',
         'Prefix': 'TaxDocs',
         'Status': 'Enabled',
         'Transitions': [
            {
               'Days': 365,
               'StorageClass': 'STANDARD_IA',
            },
         ],
      },
   ],
   'ResponseMetadata': {
      '...': '...',
   },
}
Calculate Correlation Matrix Only for Numeric Columns in R - GeeksforGeeks

29 Jun, 2021
A correlation matrix is a tabular representation of the relation between numeric attributes of a dataframe. The values present in the table are correlation coefficients between the attributes. 
Dataset used: bestsellers
To create a correlation matrix cor() function is called with the dataframe as an argument.
Syntax: cor(dataframe)
Example:
R
df<-read.csv("bestsellers.csv")  cor(df)
Output:
Error in cor(df) : 'x' must be numeric
This function fails when the dataframe consists of values apart from numeric values. Creating a correlation matrix in such a situation can be done by any of the methods given below.
Here cor() is called as above in the dataframe but this time only numeric columns are given to it. To filter out numeric columns, an operation to check numeric values is applied on the data frame using sapply().
sapply() function in R Language takes to list, vector, or data frame as input and gives output in a vector or matrix. It is useful for operations on list objects and returns a list object of the same length as the original set.
Syntax: sapply(X, FUN)
Parameters:
X: A vector or an object
FUN: Function applied to each element of x
Example:
R
df<-read.csv("bestsellers.csv")  cor(df[sapply(df,is.numeric)])
Output:
Similarly, lapply can also be applied to filter out the numeric values. lapply() function R Language is used to apply a function over a list of elements.
Syntax: lapply(list, func)
Parameters:
list: list of elements
func: operation to be applied
After the required data is selected, the list is converted to a vector using unlist(), and then this dataframe is passed to cor() to produce a correlation matrix.
unlist() function in R Language is used to convert a list to a vector. It simplifies to produce a vector by preserving all components.
Syntax: unlist(list)
Parameters:list: It is a list or Vectoruse.name: Boolean value to prserve or not the position names
Example:
R
df<-read.csv("bestsellers.csv")  cor(df[, unlist(lapply(df, is.numeric))])
Output:
Picked
R-Matrix
R-Statistics
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Change Color of Bars in Barchart using ggplot2 in R
How to Change Axis Scales in R Plots?
Group by function in R using Dplyr
How to Split Column Into Multiple Columns in R DataFrame?
Logistic Regression in R Programming
How to import an Excel File into R ?
How to filter R DataFrame by values in a column?
How to change the order of bars in bar chart in R ?
R - if statement
Replace Specific Characters in String in R
p5.js | createFileInput() Function - GeeksforGeeks

26 Feb, 2020
The createFileInput() function is used to create an input element with the type of ‘file’ that can be used by the user to select local files to be used in the sketch. It also supports the selection of multiple files if required.
Syntax:
createFileInput(callback, multiple)
Parameters: This function accepts two parameters as mentioned above and described below:
callback: It is the callback function that would be used when the file is loaded. It is an optional parameter.
multiple: It is a string which specifies if multiple files are allowed to be selected at once. It can be set to “true” or “false”. It is an optional parameter.
Return Value: It returns a pointer to the p5.Element holding the created file object.
Below examples illustrate the createFileInput() function in p5.js:
Example 1: In this example, we will take one file as an input.
function setup() {  createCanvas(400, 200);    textSize(18);  text("Click on the file input and select a file.", 20, 20);    inputbtn = createFileInput(processFile);  inputbtn.position(30, 40);}  function processFile(file) {  console.log(file);  text("The name of the file selected is: "+                                file.name, 20, 80);  text("The extension of the file selected is: "+                                file.subtype, 20, 100);  text("The type of the file selected is: "+                                  file.type, 20, 120);  text("The size of the file selected is: "+                                   file.size, 20, 140);}
Output:
Example 2: In this example, we will take multiple files as an input.
let i = 0;  function setup() {  createCanvas(500, 200);    textSize(18);  text("The file input below allows"+          " selecting of multiple files.", 20, 20);    inputBtn = createFileInput(processFiles, "true");  inputBtn.position(30, 60);}  function processFiles(file) {  text("The name of the file selected is: " +                              file.name, 20, 120 + i);  i = i + 20;}
Output:
Online editor: https://editor.p5js.org/
Environment Setup: https://www.geeksforgeeks.org/p5-js-soundfile-object-installation-and-methods/
Reference: https://p5js.org/reference/#/p5/createFileInput
JavaScript-p5.js
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Difference between var, let and const keywords in JavaScript
Difference Between PUT and PATCH Request
How to get character array from string in JavaScript?
How to detect browser or tab closing in JavaScript ?
How to get selected value in dropdown list using JavaScript ?
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
What are the steps of SQL Query processing in DBMS?

Query Processing is a translation of high-level queries into low-level expression. It is a step wise process that can be used at the physical level of the file system, query optimization and actual execution of the query to get the result.
It requires the basic concepts of relational algebra and file structure. It refers to the range of activities that are involved in extracting data from the database. It includes translation of queries in high-level database languages into expressions that can be implemented at the physical level of the file system.
Given below is the diagram that shows the steps of the structured query language (SQL) query processing −
Steps for SQL processing in database management system (DBMS) are as follows −
Parser − While parsing, the database performs the checks like, Syntax check, Semantic check and Shared pool check, after converting the query into relational algebra.
The syntax check concludes SQL is syntactically correct or not, that means it checks SQL syntactic validity.
The syntax check concludes SQL is syntactically correct or not, that means it checks SQL syntactic validity.
The syntax for parser to do syntax check is −
SELCT * FROM student;
The output is as follows −
error
Here error of wrong spelling of SELECT is given by this check.
Semantic check It determines whether the statement has meaning or not. Example: query contains a table name which does not exist is checked by this check.
Semantic check It determines whether the statement has meaning or not. Example: query contains a table name which does not exist is checked by this check.
Shared Pool check This check determines existence of written hash code in shared pool, suppose if code exists in shared pool then database will not take additional steps for optimization and execution because every query possess a hash code during its execution
Shared Pool check This check determines existence of written hash code in shared pool, suppose if code exists in shared pool then database will not take additional steps for optimization and execution because every query possess a hash code during its execution
Optimizer − In this stage, the database has to perform a hard parse at least for one unique DML statement and it has to do optimization during this parse. This database never optimizes DDL unless it includes a DML component.
It is a process where multiple query execution plans for satisfying a query are examined and the most efficient query plan is satisfied for execution.
Database catalogue stores the execution plans and then optimizer passes the lowest cost plan for execution.
Row Source Generation − The Row Source Generation is software which receives an optimal execution plan from the optimizer and produces an iterative execution plan which is used by the rest of the database. The iterative plan is the binary program that when executed by the sql engine produces the result set.
Execution Engine − Execution engine is helpful to run the query and display the required result.
Create list of numbers with given range in Python

Python can handle any requirement in data manipulation through its wide variety of libraries and methods. When we need to generate all the numbers between a pair of given numbers, we can use python’s inbuilt functions as well as some of the libraries. This article describes such approaches.
The range() function returns a sequence of numbers, starting from 0 by default, and increments by 1 ending at a specified number. We can of curse change the starting, ending as well as increment steps to suit our need.
 Live Demo
def getnums(s, e,i):
   return list(range(s, e,i))

# Driver Code
start, end, intval = -3, 6,2
print(getnums(start, end,intval))
Running the above code gives us the following result −
[-3, -1, 1, 3, 5]
The random module can also generate a random number between in a similar way as above. It involves calling the randrange method and supplying the parameters for start, end and interval values.
 Live Demo
import random
def getnums(s, e,i):
   return (random.randrange(s, e,i))

# Driver Code
start, end, intval = 3, 16,2
print(getnums(start, end,intval))
Running the above code gives us the following result −
7
The numpy library also provides a very wide range of functions for these requirements. We use arrange function which will also take the required parameters and give the output as a list.
 Live Demo
import numpy as np
def getnums(s, e,i):
   return (np.arange(s, e,i))

# Driver Code
start, end, intval = 3, 16,2
print(getnums(start, end,intval))
Running the above code gives us the following result −
[ 3 5 7 9 11 13 15]
PostgreSQL - MAX Function

PostgreSQL MAX function is used to find out the record with maximum value among a record set.
To understand the MAX function, consider the table COMPANY having records as follows −
testdb# select * from COMPANY;
 id | name  | age | address   | salary
----+-------+-----+-----------+--------
  1 | Paul  |  32 | California|  20000
  2 | Allen |  25 | Texas     |  15000
  3 | Teddy |  23 | Norway    |  20000
  4 | Mark  |  25 | Rich-Mond |  65000
  5 | David |  27 | Texas     |  85000
  6 | Kim   |  22 | South-Hall|  45000
  7 | James |  24 | Houston   |  10000
(7 rows)
Now, based on the above table, suppose you want to fetch maximum value of SALARY, then you can do so by simply using the following command −
testdb=# SELECT MAX(salary) FROM COMPANY;
The above given PostgreSQL statement will produce the following result −
  max
-------
 85000
(1 row)

You can find all the records with maximum value for each name using the GROUP BY clause as follows −
testdb=# SELECT id, name, MAX(salary) FROM COMPANY GROUP BY id, name;
The above given PostgreSQL statement will produce the following result −
 id | name  |  max
----+-------+-------
  4 | Mark  | 65000
  7 | James | 10000
  6 | Kim   | 45000
  3 | Teddy | 20000
  2 | Allen | 15000
  5 | David | 85000
  1 | Paul  | 20000

You can use the MIN Function along with the MAX function to find out minimum value as well. Try out the following example −
testdb=# SELECT MIN(salary), MAX(salary) max FROM company;
The above given PostgreSQL statement will produce the following result −
  min  |  max
-------+-------
 10000 | 85000
(1 row)


    23 Lectures 
     1.5 hours 

 John Elder

    49 Lectures 
     3.5 hours 

 Niyazi Erdogan

    126 Lectures 
     10.5 hours 

 Abhishek And Pukhraj

    35 Lectures 
     5 hours 

 Karthikeya T

    5 Lectures 
     51 mins

 Vinay Kumar

    5 Lectures 
     52 mins

 Vinay Kumar
 Print
 Add Notes
 Bookmark this page
Regular Expression "\Z" Metacharacter in Java

The subexpression/metacharacter “\Z” matches the end of the entire string except allowable final line terminator.
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class RegexExample {
   public static void main( String args[] ) {
      String regex = "Tutorialspoint\\z";
      String input = "Hi how are you welcome to Tutorialspoint";
      Pattern p = Pattern.compile(regex);
      Matcher m = p.matcher(input);
      int count = 0;
      while(m.find()) {
         count++;
      }
      System.out.println("Number of matches: "+count);
   }
}
Number of matches: 1
The following Java program verifies whether the given input text ends with a digit.
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Data {
   public static void main( String args[] ) {
      String regex = "[0-9]\\z";
      String input = "Hi how are you \n this is sample text \n this is third line 554";
      Pattern p = Pattern.compile(regex);
      Matcher m = p.matcher(input);
      if(m.find()) {
         System.out.println("Given input ends with a digit");
      } else {
         System.out.println("Given input doesn’t end with a digit");
      }
   }
}
Given input ends with a digit
Draw a circle in using Tkinter Python

Tkinter Canvas are generally used for creating shapes such as arc, rectangle, triangle, freeform shapes, etc. All these shapes can be drawn using the inbuilt function available in tkinter library.
In this example, we will create a Circle using the create_oval(x0,y0,x1,y1) method by passing the following values of coordinates (x0,y0, x1, y1)
#Import the library
from tkinter import *

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

#Define the geometry of window
win.geometry("600x400")

#Create a canvas object
c= Canvas(win,width=400, height=400)
c.pack()

#Draw an Oval in the canvas
c.create_oval(60,60,210,210)

win.mainloop()
Running the above code will draw a circle in the canvas. In this example, we have defined the coordinates for (x0, y0, x1, y1) as (60,60,210,210). Thus, it will draw and display a circle in the window.
Java program to find all duplicate characters in a string

The duplicate characters in a string are those that occur more than once. These characters can be found using a nested for loop. An example of this is given as follows −
String = Apple

In the above string, p is a duplicate character as it occurs more than once.
A program that demonstrates this is given as follows.
 Live Demo
public class Example {
   public static void main(String argu[]) {
      String str = "beautiful beach";
      char[] carray = str.toCharArray();
      System.out.println("The string is:" + str);
      System.out.print("Duplicate Characters in above string are: ");
      for (int i = 0; i < str.length(); i++) {
         for (int j = i + 1; j < str.length(); j++) {
            if (carray[i] == carray[j]) {
               System.out.print(carray[j] + " ");
               break;
            }
         }
      }
   }
}
The string is:beautiful beach
Duplicate Characters in above string are: b e a u

Now let us understand the above program.
First, the string str is defined. Then, str.toCharArray() converts the string into a sequence of characters. The original string is displayed. The code snippet that demonstrates this is given as follows −
String str = "beautiful beach";
char[] carray = str.toCharArray();
System.out.println("The string is:" + str);

The duplicate characters are found in the string using a nested for loop. Then these characters are displayed. The code snippet that demonstrates this is given as follows.
System.out.print("Duplicate Characters in above string are: ");
for (int i = 0; i < str.length(); i++) {
   for (int j = i + 1; j < str.length(); j++) {
      if (carray[i] == carray[j]) {
         System.out.print(carray[j] + " ");
         break;
      }
   }
}
Parsing and Formatting a Byte Array into Binary in Java

Set a BigInteger object.
BigInteger one;
Now, create a ByteArray.
byte byteArr[] = new byte[] { 0x1, 0x00, 0x00 };
one = new BigInteger(byteArr);
For Binary, we have used 2 as the toString() method parameter.
String strResult = one.toString(2);
The following is an example −
 Live Demo
import java.math.*;
public class Demo {
   public static void main(String[] args) {
      // BigInteger object
      BigInteger one;
      byte byteArr[] = new byte[] { 0x1, 0x00, 0x00 };
      one = new BigInteger(byteArr);
      String strResult = one.toString(2);
      System.out.println("ByteArray to Binary = "+strResult);
   }
}
ByteArray to Binary = 10000000000000000
Print system time in C++

The C++ standard library does not provide a proper date type. C++ inherits the structs and functions for date and time manipulation from C. To access date and time related functions and structures, you would need to include <ctime> header file in your C++ program.
There are four time-related types: clock_t, time_t, size_t, and tm. The types - clock_t, size_t and time_t are capable of representing the system time and date as some sort of integer.
The structure type tm holds the date and time in the form of a C structure having the following elements -
struct tm {
   int tm_sec; // seconds of minutes from 0 to 61
   int tm_min; // minutes of hour from 0 to 59
   int tm_hour; // hours of day from 0 to 24
   int tm_mday; // day of month from 1 to 31
   int tm_mon; // month of year from 0 to 11
   int tm_year; // year since 1900
   int tm_wday; // days since sunday
   int tm_yday; // days since January 1st
   int tm_isdst; // hours of daylight savings time
}
Suppose you want to retrieve the current system date and time, either as a local time or as a Coordinated Universal Time (UTC). Following is the example to achieve the same –
 Live Demo
#include <iostream>
#include <ctime>
using namespace std;
int main() {
   // current date/time based on current system
   time_t now = time(0);
   char* dt = ctime(&now); // convert now to string form
   cout << "The local date and time is: " << dt << endl;
   // convert now to tm struct for UTC
   tm *gmtm = gmtime(&now);
   dt = asctime(gmtm);
   cout << "The UTC date and time is:"<< dt << endl;
}
The local date and time is: Fri Mar 22 13:07:39 2019
The UTC date and time is:Fri Mar 22 07:37:39 2019
Java Examples - Adding Element to Linked List

How to add an element at first and last position of a linked list ?
Following example shows how to add an element at the first and last position of a linked list by using addFirst() and addLast() method of Linked List class.
import java.util.LinkedList;

public class Main {
   public static void main(String[] args) {
      LinkedList<String> lList = new LinkedList<String>();
      lList.add("1");
      lList.add("2");
      lList.add("3");
      lList.add("4");
      lList.add("5");
      System.out.println(lList);
      
      lList.addFirst("0");
      System.out.println(lList);
      
      lList.addLast("6");
      System.out.println(lList);
   }
}
The above code sample will produce the following result.
1, 2, 3, 4, 5
0, 1, 2, 3, 4, 5
0, 1, 2, 3, 4, 5, 6

The following is an another sample example to add an element at first and last position of a linked list?
import java.util.LinkedList;

public class Demo {
   public static final void main(String[] args) {
      LinkedList lList = new LinkedList();
      System.out.println("Number of items in the list: " + lList.size());
      String item1 = "foo";
      String item2 = "bar";
      String item3 = "sai";
      String item4 = "prasad";
      
      lList.add(item1);
      lList.add(item2);
      lList.addFirst(item3);
      System.out.println(lList);
      lList.addLast(item4);
      System.out.println(lList);
      System.out.println("Number of items in the list: " + lList.size());
   } 
}
The above code sample will produce the following result.
Number of items in the list: 0
[sai, foo, bar]
[sai, foo, bar, prasad]
Number of items in the list: 4

 Print
 Add Notes
 Bookmark this page
How to clear screen using python?

When we work with python interactive shell/terminal, we continuously get the output and the window looks very much clumsy, not to see any output clearly, most of the time we use ctrl+lto clear the screen.
But if we want to clear the screen while running a python script we have to do something for that because there’s no built-in keyword or function/method to clear the screen. So, we have to write some code for that.
So, we have to follow some steps
Step 1 − First we have to write from os import system.
Step 2 − Next Define a function.
Step 3 − Then make a system call with 'clear' in Linux and 'cls' in Windows as an argument.
Step 4 − Next we have to store the returned value in an underscore or whatever variable we want (an underscore is used because python shell always stores its last output in an underscore).
Step 6 − Lastly call the function.

from os import system, name
from time import sleep
# define our clear function
def screen_clear():
   if name == 'nt':
      _ = system('cls')
   # for mac and linux(here, os.name is 'posix')
   else:
      _ = system('clear')
# print out some text
print('Hi !! I am Python\n'*10)
sleep(2)
# now call function we defined above
screen_clear()
Hi !! I am Python
Hi !! I am Python
Hi !! I am Python
Hi !! I am Python
Hi !! I am Python
Hi !! I am Python
Hi !! I am Python
Hi !! I am Python
Hi !! I am Python
Hi !! I am Python

import os
from subprocess import call
from time import sleep
def screen_clear():
   _ = call('clear' if os.name =='posix' else 'cls')
print('Hi !! I am Python\n'*10)
# sleep for 2 seconds after printing output
sleep(2)
# now call the function we defined above
screen_clear()
Hi !! I am Python
Hi !! I am Python
Hi !! I am Python
Hi !! I am Python
Hi !! I am Python
Hi !! I am Python
Hi !! I am Python
Hi !! I am Python
Hi !! I am Python
Hi !! I am Python
How to declare nullable type in TypeScript ? - GeeksforGeeks

29 Jun, 2020
In vanilla JavaScript, there are two primary data types, null and undefined. Previously in TypeScript, it was not possible to explicitly name these types as “null” and “undefined”. However, it can now be used regardless of the type checking mode.
To assign “undefined” to any property, the –strictNullChecks flag has to be turned off. Keeping this flag on won’t allow to assign “undefined” to members that has no nullable operator. 
The below example represents what happens if the –strictNullChecks flag is enabled and the following code is executed. 
interface Student { name:string; age:number;}  let s: Student = { name:'Ajay', age:null}
It will throw the below error:
Type 'null' is not assignable to type 'number'

This error won’t appear if we have –strictNullChecks flag turned off. The strictNullChecks flag protects from referencing nulls or undefined values in the code. It can be enabled by adding the -–strictNullChecks flag as an option to the command-line compiler or adding it to the tsconfig.json file. 
There is a difference between the Nullable type and “optional”. In “optional”, we provide some default value to the member or let it not be considered as a member. However if any member is assigned optional and then still assigned a value as “null” or “undefined”, then it will throw an error.
interface Student { name:string; age?:number;}  let s: Student = { name:'Ajay', age:null}
JavaScript-Misc
Picked
TypeScript
JavaScript
Web Technologies
Web technologies Questions
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Difference between var, let and const keywords in JavaScript
Convert a string to an integer in JavaScript
Differences between Functional Components and Class Components in React
How to append HTML code to a div using JavaScript ?
How to Open URL in New Tab using JavaScript ?
Top 10 Front End Developer Skills That You Need in 2022
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
Currying Function in Python

07 Feb, 2019
In problem solving and functional programming, currying is the practice of simplifying the execution of a function that takes multiple arguments into executing sequential single-argument functions. In simple terms, Currying is used to transform multiple-argument function into single argument function by evaluating incremental nesting of function arguments. Currying also mends one argument to another forms a relative pattern while execution.
Mathematical Illustration of Currying:In general currying of functions takes up any number of calculations and data to single real function that returns an expected output. Here we take,
f(x, y) = (x*x*x) + (y*y*y)
h(x) = (x*x*x)
h(y) = (y*y*y)
h(x)(y) = h(x)+h(y)
f(x, y) = h(x)(y)
Curry f = h(x)(y)
For example, we will take chaining the composition of function.
a(x) = b(c(d(x)))
def change(b, c, d):    def a(x):        return b(c(d(x)))    return a
v(a, b, c, d, e) = w(x(y(z(a, b, c, d, e))))
# Currying in Python - Many to Single Argument def change(a):    def w(b):        def x(c):            def y(d):                def z(e):                    print(a, b, c, d, e)                return z            return y        return x    return w   change(10)(20)(30)(40)(50)
Output:
10 20 30 40 50
Here, the concept is nesting of one function to another function and hence the result of one function gets recorded in the chain of functions. There by simplifying one huge block of manipulation to simpler sequential blocks.
Code #1: Change kilometer to meter and meter to centimeter.
# Demonstrate Currying of composition of functiondef change(b, c, d):    def a(x):        return b(c(d(x)))    return a      def kilometer2meter(dist):     """ Function that converts km to m. """    return dist * 1000      def meter2centimeter(dist):     """ Function that converts m to cm. """    return dist * 100      def centimeter2feet(dist):    """ Function that converts cm to ft. """    return dist / 30.48      if __name__ == '__main__':    transform = change(centimeter2feet, meter2centimeter, kilometer2meter )    e = transform(565)    print(e)     
Output:
1853674.5406824148
 Code #2:
# Demonstrate Currying of composition of function  def change(b, c, d):    def a(x):        return b(c(d(x)))    return a      def daystohour(time):     """ Function that converts days to hours. """    return time * 24      def hourstominutes(time):     """ Function that converts hours to minutes. """    return time * 60      def minutestoseconds(time):    """ Function that converts minutes to seconds. """    return time * 60      if __name__ == '__main__':    transform = change(minutestoseconds, hourstominutes, daystohour)    e = transform(10)    print(e)     
Output:
864000
Python-Functions
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
Convert integer to string in Python