code-rag-bench/online-tutorials huggingface dataset:
Lodash _.strContains() Method - GeeksforGeeks

30 Sep, 2020
The Lodash _.strContains() method checks whether the given string contains the searched string or not and returns the corresponding boolean value.
Syntax:
_.strContains( string, searched_str);

Parameters: This method accepts two parameters as mentioned above and described below:
String: This method takes String in which search string is to be searched.
Searched_str: This method takes a string to be searched.
Return Value: This method returns a boolean value.
Note: This will not work in normal JavaScript because it requires the lodash.js contrib library to be installed. Lodash.js contrib library can be installed using npm install lodash-contrib –save.
Example 1:
Javascript
// Defining lodash contrib variable var _ = require('lodash-contrib');   var bool  = _.strContains("GeeksforGeeks", "Geeks");     console.log("The String contains the "    + "searched String : ", bool);
Output:
The String contains the searched String : true

Example 2:
Javascript
// Defining lodash contrib variable var _ = require('lodash-contrib');   var bool  = _.strContains("abc", "d");     console.log("The String contains the "    + "searched String : ", bool);
Output:
The String contains the searched String : false

Example 3:
Javascript
// Defining lodash contrib variable var _ = require('lodash-contrib');   var bool  = _.strContains("abc", "a");     console.log("The String contains the "    + "searched String : ", bool);
Output:
The String contains the searched String : true

JavaScript-Lodash
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
How to create a link in JavaScript ?
How to Show Images on Click using HTML ?
Remove elements from a JavaScript Array
How to remove an HTML element using JavaScript ?
Express.js express.Router() Function
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 ?
Difference between var, let and const keywords in JavaScript
How to check version of python modules?

When you install Python, you also get the Python package manager, pip. You can use pip to get the versions of python modules. If you want to list all installed Python modules with their version numbers, use the following command:
$ pip freeze
You will get the output:
asn1crypto==0.22.0
astroid==1.5.2
attrs==16.3.0
Automat==0.5.0
backports.functools-lru-cache==1.3
cffi==1.10.0
...
To individually find the version number you can grep on this output on *NIX machines. For example:
$ pip freeze | grep PyMySQL
PyMySQL==0.7.11
On windows, you can use findstr instead of grep. For example:
PS C:\> pip freeze | findstr PyMySql
PyMySQL==0.7.11
If you want to know the version of a module within a Python script, you can use the __version__ attribute of the module to get it. Note that not all modules come with a __version__ attribute. For example,
>>> import pylint
>>> pylint.__version__
'1.7.1'
Python program to convert time from 12 hour to 24 hour format

Given a PC's time and it converted to 24 hour format. Here we are applying string slicing.
Here we follow the rules if time is PM then add 12 with hour part and if time is AM then don't add.
Input: 12:20:20 PM
Output: 24:20:20
Step 1: Input current datetime.
Step 2: Extract only time from datetime format.
Step 3: Using string slicing check last two words PM or AM.
Step 4: if last two word is PM then add 12 and if word are AM then don't add it.
import datetime
   def timeconvert(str1):
      if str1[-2:] == "AM" and str1[:2] == "12":
         return "00" + str1[2:-2]
      elif str1[-2:] == "AM":
         return str1[:-2]
      elif str1[-2:] == "PM" and str1[:2] == "12":
         return str1[:-2]
      else:
      return str(int(str1[:2]) + 12) + str1[2:8]
   dt=datetime.datetime.now()
print("Conversion Of Time ::",timeconvert(dt.strftime("%H:%M:%S")))
Conversion Of Time :: 24:04:53
Javascript | Window confirm() Method

01 Jun, 2022
The confirm() method is used to display a modal dialog with an optional message and two buttons, OK and Cancel. It returns true if the user clicks “OK”, and false otherwise. It prevents the user from accessing other parts of the page until the box is closed. 
Syntax:
confirm(message)
message is the optional string to be displayed in the dialog. It returns a boolean value indicating whether OK or Cancel was selected (true means OK and false means that the user clicked cancel). 
Example-1: 
HTML
<!DOCTYPE html><html> <head>    <title>        Window confirm() Method    </title></head> <body style="text-align: center;">    <h1 style="color:green;">            GeeksforGeeks        </h1>    <h2>            Window confirm() Method        </h2>    <p>Click the button to display a confirm box.</p>     <button onclick="geek()">Click me!</button>     <script>        function geek() {            confirm("Press OK to close this option");        }    </script></body> </html>
Output: Before clicking the button:
  
After clicking the button:
  
Example-2: 
HTML
<!DOCTYPE html><html> <head>    <title>        Window confirm() Method    </title></head> <body style="text-align: center;">    <h1 style="color:green;">            GeeksforGeeks        </h1>    <h2>            Window confirm() Method        </h2>     <button onclick="geek()">Click me!</button>     <p id="g"></p>     <script>        function geek() {            var doc;            var result = confirm("Press a button!");            if (result == true) {                doc = "OK was pressed.";            } else {                doc = "Cancel was pressed.";            }            document.getElementById("g").innerHTML = doc;        }    </script></body> </html>
Output: Before clicking the button:
  
After clicking the button:
  
Supported Browsers: The browser supported by window confirm() method are listed below:
Google Chrome 1 and above
Edge 12 and above
Internet Explorer 4 and above
Firefox 1 and above
Opera 3 and above
Safari 1 and above
kumargaurav97520
javascript-functions
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
How to append HTML code to a div using JavaScript ?
Difference Between PUT and PATCH Request
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Installation of Node.js on Linux
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
How to create a line chart with mean and standard deviation using ggplot2 in R?

Sometimes we have mean and standard deviation given for groups or factors, these are generally obtained from previous research studies and is referred to as the secondary data. In this case. the line chart with mean and standard deviation using ggplot2 can be created by defining the minimum and maximum inside geom_error function of ggplot2 package, where the difference between mean and standard deviation defines the standard deviation if the minimum is set as mean minus one standard deviation and the maximum is set as mean plus one standard deviation.
Consider the below data frame −
 Live Demo
Group<−c("G1","G2","G3","G4")
Mean<−c(25,27,23,26)
SD<−c(3.24,2.25,3.6,4.1)
df<−data.frame(Group,Mean,SD)
df
Group Mean SD
1 G1 25 3.24
2 G2 27 2.25
3 G3 23 3.60
4 G4 26 4.10
Loading ggplot2 package and creating the plot with mean and standard deviation −
library(ggplot2)
ggplot(df,aes(Group,Mean))+geom_errorbar(aes(ymin=Mean-SD,ymax=Mean+SD),width=0.2)+geom_line(group=1)+geom_point()
PLSQL | REMAINDER Function

18 Oct, 2019
The REMAINDER function is an inbuilt function in PLSQL which is used to return the remainder of a divided by b.
Syntax:
REMAINDER(a, b)
Parameters Used:This function accepts two parameters a and b which is used in calculating the remainder when a is divided by b.
Return Value:This function returns a numeric value when the input number a is divided by b.
Supported Versions of Oracle/PLSQL is given below:
Oracle 12cOracle 11gOracle 10gOracle 9iOracle 8i
Oracle 12c
Oracle 11g
Oracle 10g
Oracle 9i
Oracle 8i
Let’s see some examples which illustrate the REMAINDER function:
Example-1:
DECLARE 
   Test_Number number1 := 15;
   Test_Number number2 := 5;
   
BEGIN 
   dbms_output.put_line(REMAINDER(Test_Number number1, 
                                  Test_Number number2)); 
   
END; 
Output:
0
In the above example, when 15 is divided by 5 then it returns a remainder of 0.
Example-2:
DECLARE 
   Test_Number number1 := 11.6;
   Test_Number number2 := 2;
   
BEGIN 
   dbms_output.put_line(REMAINDER(Test_Number number1, 
                                  Test_Number number2)); 
   
END; 
Output:
-0.4
In the above example, when 11.6 is divided by 2 then it returns a remainder of -0.4
Example-3:
DECLARE 
   Test_Number number1 := -15;
   Test_Number number2 := 4;
   
BEGIN 
   dbms_output.put_line(REMAINDER(Test_Number number1, 
                                  Test_Number number2)); 
   
END; 
Output:
1
In the above example, when -15 is divided by 4 then it returns a remainder of 1.
Advantage:This function is used to find out the remainder when a is divided by b.
SQL-PL/SQL
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Merge multiple CSV files using R

06 Jun, 2021
In this article, we will be looking at the approach to merge multiple CSV files in the R programming language.
In this approach to merge multiple CSV files, the user needs to install and import three different packages namely- dplyr,plyr, and readr in the R programming language console to call the functions which are list.files(), lapply(), and bind_rows() from these packages and pass the required parameters to these functions to merge the given multiple CSV files to a single data frame in the R programming language.
list.files() function produces a character vector of the names of files or directories in the named directory.
Syntax:
list.files(path = “.”, pattern = NULL, all.files = FALSE,full.names = FALSE, recursive = FALSE, ignore.case = FALSE, include.dirs = FALSE, no.. = FALSE)
lapply() function returns a list of the same length as X, each element of which is the result of applying FUN to the corresponding element of X.
Syntax:
lapply(X, FUN, ...)
bind_rows() function is an efficient implementation of the common pattern of do.call(rbind, dfs) or do.call(cbind, dfs) for binding many data frames into one.
Syntax:
bind_rows(..., .id = NULL)
Folder in Use:
To actually merge multiple CSV/Excel files as one dataframe first the required packages are imported and then list of files are read and joined together.
Example:
R
library("dplyr")                                                library("plyr")                                                 library("readr")    gfg_data <- list.files(path = "C:/Users/Geetansh Sahni/Documents/R/Data",                           pattern = "*.csv", full.names = TRUE) %>%   lapply(read_csv) %>%                                             bind_rows                                                        gfg_data 
Output:
Picked
R-CSV
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?
How to filter R DataFrame by values in a column?
R - if statement
Logistic Regression in R Programming
Replace Specific Characters in String in R
How to import an Excel File into R ?
Joining of Dataframes in R Programming
Lodash _.chain() Method

16 Sep, 2020
The Lodash _.chain() method used to wrap the value with explicit method chain sequences enabled. 
Syntax:
_.chain(value)

Parameter: This method accept a single a parameter as mentioned above and described below:
value: This parameter holds the value to wrap.
Return value: This method returns the wrapped value.
Below example illustrate the Lodash _.chain() method in JavaScript:
Example 1:
Javascript
const _ = require('lodash');   var person = [  { 'user': 'Tommy',  'income': 2600 },  { 'user': 'Asmita',    'income': 2400 },  { 'user': 'Hiyan', 'income': 2200 }];   var Earcning = _  .chain(person)  .sortBy('income')  .map(function(gfg) {    return gfg.user + ' earn is ' + gfg.income;  })  .value();console.log(Earcning)
Output:
Hiyan earn is 2200,
Asmita earn is 2400,
Tommy earn is 2600

Example 2:
Javascript
const _ = require('lodash');   var users = [  { 'user': 'Tommy',  'age': 23 },  { 'user': 'Asmita',    'age': 24 },  { 'user': 'Hiyan', 'age': 22 }];   var youngest = _  .chain(users)  .sortBy('age')  .map(function(o) {    return o.user + ' is ' + o.age;  })  .tail()  .value();console.log(youngest)
Output:
Tommy is 23,Asmita is 24

Reference: https://docs-lodash.com/v4/chain/
JavaScript-Lodash
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
Hide or show elements in HTML using display property
Difference Between PUT and PATCH Request
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
Python program to convert meters in yards and vice versa

03 Jan, 2021
Given the distance in either meter or yard, the task here is to generate a Python program that converts distance given in meters to yards and vice versa.
Examples:
Input: Length in Meter: 245
       Length in Yard : 100

Output: 245 Meter in Yard = 267.9344 
        100 Yards in Meter = 91.4403


Input: Length in Meter: 5
       Length in Yard : 20

Output: 5 Meter in Yard = 5.4680 
        20 Yards in Meter = 18.2881
Formula used – 
1 Meter = 1.09361 Yard
So from the above formula, 1 Meter is equivalent to 1.09361 yards, hence to convert meters to yards, simply multiply the distance given in meters by 1.09361, and to convert Yard to meter, we just have to divide length in Yard by 1.09361.
Below is the implementation.
Python3
meter = 5  # Length in Meteryard = 20  # Length in Yard  # converting Meter to Yardmeter_to_yard = meter * 1.09361  # converting Yard to meteryard_to_meter = yard / 1.09361  # printing the outputprint("%d Meter in Yard = %.4f " % (meter, meter_to_yard))print("%d Yard in Meter = %.4f " % (yard, yard_to_meter))
Output:
5 Meter in Yard = 5.4680  
20 Yard in Meter = 18.2881
Picked
school-programming
Technical Scripter 2020
Python
Python Programs
Technical Scripter
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
How to drop one or multiple columns in Pandas Dataframe
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python Program for Fibonacci numbers
Python | Split string into list of characters
Python | Visualize missing values (NaN) values using Missingno Library

04 Jul, 2019
In the case of a real-world dataset, it is very common that some values in the dataset are missing. We represent these missing values as NaN (Not a Number) values. But to build a good machine learning model our dataset should be complete. That’s why we use some imputation techniques to replace the NaN values with some probable values. But before doing that we need to have a good understanding of how the NaN values are distributed in our dataset.
Missingno library offers a very nice way to visualize the distribution of NaN values. Missingno is a Python library and compatible with Pandas.
Install the library –
pip install missingno

To get the dataset used in the code, click here.
Using this matrix you can very quickly find the pattern of missingness in the dataset. In our example, the columns AAWhiteSt-4 and SulphidityL-4 have a similar pattern of missing values while UCZAA shows a different pattern.
# Program to visualize missing values in dataset  # Importing the librariesimport pandas as pdimport missingno as msno  # Loading the datasetdf = pd.read_csv("kamyr-digester.csv")  # Visualize missing values as a matrixmsno.matrix(df)
Output:
This bar chart gives you an idea about how many missing values are there in each column. In our example, AAWhiteSt-4 and SulphidityL-4 contain the most number of missing values followed by UCZAA.
# Program to visualize missing values in dataset  # Importing the librariesimport pandas as pdimport missingno as msno  # Loading the datasetdf = pd.read_csv("kamyr-digester.csv")  # Visualize the number of missing# values as a bar chartmsno.bar(df)
Output:
Heatmap shows the correlation of missingness between every 2 columns. In our example, the correlation between AAWhiteSt-4 and SulphidityL-4 is 1 which means if one of them is present then the other one must be present.
A value near -1 means if one variable appears then the other variable is very likely to be missing.A value near 0 means there is no dependence between the occurrence of missing values of two variables.A value near 1 means if one variable appears then the other variable is very likely to be present.
# Program to visualize missing values in dataset  # Importing the librariesimport pandas as pdimport missingno as msno  # Loading the datasetdf = pd.read_csv("kamyr-digester.csv")    # Visualize the correlation between the number of# missing values in different columns as a heatmapmsno.heatmap(df)
Output:
Reference : https://github.com/ResidentMario/missingno
Python-pandas
Machine Learning
Python
Machine Learning
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Selenium – Search for text on page

03 Mar, 2021
Prerequisite:- Selenium
Selenium is a powerful tool for controlling web browsers through programs and performing browser automation. It is functional for all browsers, works on all major OS and its scripts are written in various languages i.e Python, Java, C#, etc, we will be working with Python.
In this article, we will learn how to know whether the text is on a web page or not using selenium in python.
Approach:
First, we will open the chrome driver using the Chrome() method in the Selenium web driver
Assign the Web URL.
Then the driver will open the Give Web URL
Get Web Page Source Code using page_source property.
Assign the text to be searched.
After getting the web page text, we will search whether the text is present or not.
Below is the implementation:
Python3
# import webdriver from selenium import webdriver  # create webdriver object driver = webdriver.Chrome()  # URL of the website url = "https://www.geeksforgeeks.org/"  # Opening the URL driver.get(url)   # Getting current URL source code get_source = driver.page_source  # Text you want to searchsearch_text = "Floor"  # print True if text is present else Falseprint(search_text in get_source)
Output:
True
Demonstration:
Picked
Python Selenium-Exercises
Python-selenium
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
How to drop one or multiple columns in Pandas Dataframe
Python | os.path.join() method
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python | Get unique values from a list
Python | datetime.timedelta() function
Python Program to Sort the list according to the column using lambda

11 May, 2020
Given a list, the task is to sort the list according to the column using the lambda approach.
Examples:
Input :array = [[1, 3, 3], [2, 1, 2], [3, 2, 1]]Output :Sorted array specific to column 0, [[1, 3, 3], [2, 1, 2], [3, 2, 1]]Sorted array specific to column 1, [[2, 1, 2], [3, 2, 1], [1, 3, 3]]Sorted array specific to column 2, [[3, 2, 1], [2, 1, 2], [1, 3, 3]]
Input :array = [[‘java’, 1995], [‘c++’, 1983], [‘python’, 1989]]Output :Sorted array specific to column 0, [[‘c++’, 1983], [‘java’, 1995], [‘python’, 1989]]Sorted array specific to column 1, [[‘c++’, 1983], [‘python’, 1989], [‘java’, 1995]]
Approach:
sorted() built-in function in Python gives a new sorted list from an iterable.
key parameter to specify a function to be called on each list element prior to making comparisons.
lambda is used as a function to iterate on each element.
key = lambda x:x[i] here i is the column on which respect to sort the whole list.
Below is the implementation.
# Python code to sorting list # according to the column  # sortarray function is defineddef sortarray(array):          for i in range(len(array[0])):                  # sorting array in ascending         # order specific to column i,        # here i is the column index        sortedcolumn = sorted(array, key = lambda x:x[i])                  # After sorting array Column 1        print("Sorted array specific to column {}, \        {}".format(i, sortedcolumn))      # Driver code if __name__ == '__main__':           # array of size 3 X 2     array = [['java', 1995], ['c++', 1983],             ['python', 1989]]          # passing array in sortarray function    sortarray(array)
Sorted array specific to column 0, [[‘c++’, 1983], [‘java’, 1995], [‘python’, 1989]]Sorted array specific to column 1, [[‘c++’, 1983], [‘python’, 1989], [‘java’, 1995]]
Python list-programs
python-list
Python-sort
Python
Python Programs
python-list
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
Python | os.path.join() method
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python Program for Fibonacci numbers
Python | Convert string dictionary to dictionary
What are jQuery string methods?

jQuery string methods helps in string manipulation and makes your work easier while using strings. String methods find the length of the string, a string in a string, extract string parts, etc. jQuery is a JavaScript library, so using JavaScript String functions in it is perfectly fine.
You can try to run the following code to learn how to find the length of a string with string method −
Live Demo
<!DOCTYPE html>
<html>
<body>

<p>Finding the number of characters in "Tutorialspoint"</p>

<button onclick="myFunc()">Get Length</button>

<p id="example"></p>

<script>
function myFunc() {
    var str1 = "Tutorialspoint";
    var num = str1.length;
    document.getElementById("example").innerHTML = num;
}
</script>

</body>
</html>
Extract Video Frames from Webcam and Save to Images using Python - GeeksforGeeks

19 Aug, 2021
OpenCV library can be used to perform multiple operations on videos. Let’s try to do something interesting using CV2. Le’s record a video as form webcam and break the video into the frame by frame and save those frames. 
This module does not come built-in with Python. To install it type the below command in the terminal.
pip install opencv-python
Steps Required.
Open the Video file using cv2.VideoCapture(<path_of_video>) or If you do not have any video you can directly use your inbuilt camera using  cv2.VideoCapture(0)  command.Read frame by frameSave each frame using cv2.imwrite()Release the VideoCapture and destroy all windows
Open the Video file using cv2.VideoCapture(<path_of_video>) or If you do not have any video you can directly use your inbuilt camera using  cv2.VideoCapture(0)  command.
Read frame by frame
Save each frame using cv2.imwrite()
Release the VideoCapture and destroy all windows
Below is the implementation.
Python3
import cv2 # Opens the inbuilt camera of laptop to capture video.cap = cv2.VideoCapture(0)i = 0 while(cap.isOpened()):    ret, frame = cap.read()         # This condition prevents from infinite looping    # incase video ends.    if ret == False:        break         # Save Frame by Frame into disk using imwrite method    cv2.imwrite('Frame'+str(i)+'.jpg', frame)    i += 1 cap.release()cv2.destroyAllWindows()
Output: 
 
sagartomar9927
Picked
Python-OpenCV
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Python | os.path.join() method
Create a directory in Python
Defaultdict in Python
Python | Get unique values from a list
Python | Pandas dataframe.groupby()
How to plot a Histogram in MATLAB ? - GeeksforGeeks

06 Sep, 2021
A Histogram is a diagrammatic representation of a group of data over user-specified ranges. Basically, the histogram contains several bins. Bins are non-overlapping intervals in which the data is spread. In MATLAB we have a function named hist() which allows us to plot a bar graph. 
Syntax:
hist(X)
where X represents the data. The X is a vector.
The histogram function uses an algorithm that returns bins and bins width are equal. And these bins spread according to the data given in vector. The interesting thing is that the height of each bin represents the number of points in that bin.
Now let’s move to some examples.
Example 1: A simple Histogram:
MATLAB
% generate 10,000 random numbersy=randn(10000,1) % hist() function to plot the histogram% if the value of bins is not given then% this function choose appropriate numbers% of binhist(y)
 
 
Output: 
 
 
Example 2: Histogram with a given number of bins:
 
MATLAB
% generate 10,000 random numbersy=randn(10000,1) % assign 50 to variable nbins for% number of binsnbins=50; % hist() function to plot the histogram% hist() function use the nbins variable% and spread the data in 50 binshist(y,nbins)
 
 
Output:
 
 
Example 3: Histogram of multiple columns:
 
MATLAB
% generate 10,000 random numbers in 4 groupsy=randn(10000,4) % hist() function to plot the histogram% hist() function use the nbins variable and% spread the data in 50 binshist(y)
 
 
Output : 
 
 
Example 4: Make Histogram of image:
 
MATLAB
% read the imageI = imread('ngc6543a.jpg'); % display the imageimshow(I)
  
 
MATLAB
% imhist() function is used to% draw histogram of imageimhist(I)
 
 
Output :
 
 
kk9826225
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
How to Remove Noise from Digital Image in Frequency Domain Using MATLAB?
Boundary Extraction of image 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?
Classes and Object in MATLAB
How to Convert Three Channels of Colored Image into Grayscale Image in MATLAB?
Double Integral in MATLAB
Adaptive Histogram Equalization in Image Processing Using MATLAB
Python os.unlink() Method

Python method unlink() removes (deletes) the file path.If the path is a directory, OSError is raised.
Following is the syntax for unlink() method −
os.unlink(path)

path − This is the path, which is to be removed.
path − This is the path, which is to be removed.
This method does not return any value.
The following example shows the usage of unlink() method.
# !/usr/bin/python

import os, sys

# listing directories
print "The dir is: %s" %os.listdir(os.getcwd())

os.unlink("aa.txt")

# listing directories after removing path
print "The dir after removal of path : %s" %os.listdir(os.getcwd())
When we run above program, it produces following result −
The dir is:
 [ 'a1.txt','aa.txt','resume.doc','a3.py','tutorialsdir','amrood.admin' ]
The dir after removal of path : 
[ 'a1.txt','resume.doc','a3.py','tutorialsdir','amrood.admin' ]


    187 Lectures 
     17.5 hours 

 Malhar Lathkar

    55 Lectures 
     8 hours 

 Arnab Chakraborty

    136 Lectures 
     11 hours 

 In28Minutes Official

    75 Lectures 
     13 hours 

 Eduonix Learning Solutions

    70 Lectures 
     8.5 hours 

 Lets Kode It

    63 Lectures 
     6 hours 

 Abhilash Nelson
 Print
 Add Notes
 Bookmark this page
Program to print Reverse Floyd’s triangle in C

Floyd's triangle is a right-angled triangular array of natural numbers, used in computer science education. It is named after Robert Floyd. It is defined by filling the rows of the triangle with consecutive numbers, starting with a 1 in the top left corner
1                               15 14 13 12 11
2 3                             10 9 8 7
4 5 6                         6 5 4
7 8 9 10                       3 2
11 12 13 14 15                 1
Floyd's Triangle                Reverse of Floyd's Triangle
To print the Floyd’s Triangle −
Accept the number of rows to print the Floyd’s Triangle
Print value 1 for the Row 1
Print two values 2 and 3 in the next row
Print three values 4, 5 and 6 in the next row
Repeat till the number of rows specified
To print the reverse of Floyd’s Triangle −
Accept the number of rows to print the reverse of Floyd’s Triangle
Print the values in the reverse order as specified in the reverse of Floyd’s Triangle
/*Program to print the Reverse of Floyd's Triangle*/
#include<stdio.h>
int main() {
   int r,c=1;
   int rows,revrows,r1,c1,d;
   clrscr();
   printf("Enter number of rows to print the Floyd's Triangle: ");
   scanf("%d", &rows);
   printf("\n");
   for (r=1;r<=(rows*(rows+1))/2;r++){
      printf("%d ",r);
      if(r==(c*(c+1))/2){
         printf("\n");
         c++;
      }
   }
   printf("\n\n");
   /*Printing the Reverse of Floyd's Triangle*/
   printf("Enter number of rows to print the reverse of Floyd's Triangle: ");
   scanf("%d",&revrows);
   printf("\n\n");
   printf("Reverse of Floyd's Triangle\n");
   printf("\n\n");
   d = (revrows*(revrows+1))/2;
   for(r1=revrows;r1>=1;r1--){
      for(c1=r1;c1>=1;c1--,d--){
         printf("%4d", d);
      }
      printf("\n");
   }
   getch();
   return 0;
}
How to add, delete, change ownership (of files) of a group in Linux?

We know that Linux is a multiuser operating system so every file or directory belongs to an owner and group. To change ownership of files or directories we use chown (change ownership) command and to change the group ownership of files or directories we use the chgrp command.
The chgrp (change group) command is used to change group ownership of files or directories in the Linux/Unix operating system.
The general syntax of the chgrp command is as follow −
chgrp [OPTION]... GROUP FILE...
chgrp [OPTION]... --reference=RFILE FILE...
The brief description of options available in the chmod command:
To add a group in the Linux system, we need administrative permission or sudo privilege. If we want to add a new group, we use the addgroup command.
The general syntax of the addgroup command is as follows:
$ sudo addgroup <group name>...
Suppose we have to add a new group snow in the Linux system using the terminal.
$ sudo addgroup snow
To remove a group in the Linux system we need administrative permission or sudo privilege. If we want to remove an existing group, we use the groupdel command.
The general syntax of the groupdel command is as follows:
$ sudo groupdel <group name>...
Suppose we have to delete an existing group snow in the Linux system using the terminal.
$ sudo groupdel snow
To change the group ownership of a file using terminal, we use the chgrp command in the Linux system.
First, we will check the file associated with which group. To check this use below command.
$ ls -l <file name>
The below output is just an example output.
To change the group ownership of a file use below command.
$ sudo chgrp snow file.txt
Count ways to reach the nth stair using step 1, 2 or 3 in C++

We are given a total number of steps in a staircase that is n. A person can reach the next floor by skipping 1, 2 or 3 steps at a time. The goal is to find the number of ways in which the next floor can be reached by doing so.
We will use the recursive method by keeping in mind that to reach any i’th step, a person has to jump from i-1th step ( skip 1 step) , i-2th step (skip 2 steps ) or i-3th step ( skip 3 steps ).
Let’s understand with examples.
Input 
N=3 steps
Output 
Count of ways to reach the nth stair using step 1, 2 or 3 are: 4
Explanation 
There are total 3 steps
Jump from start ( skip 3 ) : 3 step
Jump from 1’st step (skip 2): 1+2
Jump from 2nd step (skip 1): 2+1
No skip 1+1+1
Input 
N=6 steps
Output 
Count of ways to reach the nth stair using step 1, 2 or 3 are: 24
Explanation 
There are total 6 steps
Ways: 1+1+1+1+1+1, 2+1+1+1+1, 3+1+1+1, 3+1+2, 3+2+1, 3+3 and so on.
We are taking integer steps as a total number of steps.
We are taking integer steps as a total number of steps.
Function stairs_step(int steps) takes all steps as input and returns a number of ways to reach the next floor by taking jumps or not..
Function stairs_step(int steps) takes all steps as input and returns a number of ways to reach the next floor by taking jumps or not..
Take the initial variable count as 0 for such ways.
Take the initial variable count as 0 for such ways.
If the number is 0 return 1.
If the number is 0 return 1.
If step count is 1 only 1 way.
If step count is 1 only 1 way.
If step count is 2 only 2 ways ( 1+1 or 2 ).
If step count is 2 only 2 ways ( 1+1 or 2 ).
Else the ways = stairs_step (step-3)+stair_step(step-2)+stair_step(step-1).
Else the ways = stairs_step (step-3)+stair_step(step-2)+stair_step(step-1).
 Live Demo
#include <iostream>
using namespace std;
int stairs_step(int steps){
   if(steps == 0){
      return 1;
   }
   else if(steps == 1){
      return 1;
   }
   else if (steps == 2){
      return 2;
   }
   else{
      return stairs_step(steps - 3) + stairs_step(steps - 2) + stairs_step(steps - 1);
   }
}
int main(){
   int steps = 5;
   cout<<"Count of ways to reach the nth stair using step 1, 2 or 3 are: "<<stairs_step(steps);
   return 0;
}
If we run the above code it will generate the following output −
Count of ways to reach the nth stair using step 1, 2 or 3 are: 13
How to set the grid color of a table in Java?

To set the grid color of a table, use the setGridColor() method.
table.setGridColor(Color.yellow);
Above, we have used the Color class to set the color.
The following is an example to set the grid color of a table −
package my;
import java.awt.Color;
import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.border.TitledBorder;
public class SwingDemo {
   public static void main(String[] args) {
      JFrame frame = new JFrame();
      JPanel panel = new JPanel();
      panel.setBorder(BorderFactory.createTitledBorder(
         BorderFactory.createEtchedBorder(), "ODI Rankings", TitledBorder.CENTER, TitledBorder.TOP));
      String[][] rec = {
         { "1", "Steve", "AUS" },
         { "2", "Virat", "IND" },
         { "3", "Kane", "NZ" },
         { "4", "David", "AUS" },
         { "5", "Ben", "ENG" },
         { "6", "Eion", "ENG" },
      };
      String[] header = { "Rank", "Player", "Country" };
      JTable table = new JTable(rec, header);
      table.setGridColor(Color.magenta);
      table.setRowSelectionAllowed(true);
      table.setShowGrid(true);
      panel.add(new JScrollPane(table));
      frame.add(panel);
      frame.setSize(550, 400);
      frame.setVisible(true);
   }
}
How to change the figsize for matshow() in Jupyter notebook using Matplotlib?

To change the figsize for mathshow, we can use figsize in figure method argument and use fignum in
matshow() method.
Create a new figure or activate an existing figure using figure() method.
Create a dataframe using Pandas.
Use matshow() method to display an array as a matrix in a new figure window.
The argument fignum can take the values None, int, or FalseIf *None*, create a new figure window with automatic numbering.If a nonzero integer, draw into the figure with the given number. Create one, if it does not exist.If 0, use the current axes (or create one if it does not exist).
If *None*, create a new figure window with automatic numbering.
If a nonzero integer, draw into the figure with the given number. Create one, if it does not exist.
If 0, use the current axes (or create one if it does not exist).
To display the figure, use show() method.
import pandas as pd
from matplotlib import pyplot as plt
plt.rcParams["figure.figsize"] = [7.00, 3.50]
plt.rcParams["figure.autolayout"] = True
plt.figure()
df = pd.DataFrame({"col1": [1, 3, 5, 7, 1], "col2": [1, 5, 7, 9, 1]})
plt.matshow(df.corr(), fignum=1)
plt.show()
How can we add a JSONArray within JSONObject in Java?

A JSONObject can parse text from a String to produce a map-like object and a JSONArray can parse text from a String to produce a vector-like object. We can also add a JSONArray within JSONObject by first creating a JSONArray with few items and add these array of items to the put() method of JSONObject class.
public JSONObject put(java.lang.String key, java.util.Collection<?> value) throws JSONException
import org.json.*;
public class AddJSONArrayTest {
   public static void main(String[] args) throws JSONException {
      JSONArray array = new JSONArray();
      array.put("INDIA");
      array.put("AUSTRALIA");
      array.put("ENGLAND");
      JSONObject obj = new JSONObject();
      obj.put("COUNTRIES", array);
      System.out.println(obj);
   }
}
{"COUNTRIES":["INDIA","AUSTRALIA","ENGLAND"]}
Charset toString() method in Java with Examples - GeeksforGeeks

28 Mar, 2019
The toString() method is a built-in method of the java.nio.charset returns a string which describes the charset involved.
Syntax:
public final String toString()
Parameters: The function does not accepts any parameter.
Return Value: The function returns a string describing this charset.
Below is the implementation of the above function:
Program 1:
// Java program to demonstrate// the above function  import java.nio.charset.Charset;import java.nio.charset.CharsetDecoder;import java.nio.charset.CharsetEncoder;  public class GFG {      public static void main(String[] args)    {          // Gets charset        Charset Charset1 = Charset.forName("UTF8");          // Print        System.out.println(Charset1.toString());    }}
UTF-8

Program 2:
// Java program to demonstrate// the above function  import java.nio.charset.Charset;import java.nio.charset.CharsetDecoder;import java.nio.charset.CharsetEncoder;  public class GFG {      public static void main(String[] args)    {          // Gets charset        Charset Charset1 = Charset.forName("UTF16");          // Print        System.out.println(Charset1.toString());    }}
UTF-16

Reference: https://docs.oracle.com/javase/9/docs/api/java/nio/charset/Charset.html#toString–
Java-Charset
Java-Functions
Java-NIO package
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Initialize an ArrayList in Java
HashMap in Java with Examples
How to iterate any Map in Java
ArrayList in Java
Object Oriented Programming (OOPs) Concept in Java
Multidimensional Arrays in Java
Stack Class in Java
LinkedList in Java
Overriding in Java
Set in Java
C# program to Reverse words in a string

Let’s say the following is the string −
Hello World
After reversing the string, the words should be visible like −
olleH dlroW
Use the reverse() method and try the following code to reverse words in a string.
Live Demo
using System;
using System.Linq;
class Demo {
   static void Main() {
      // original string
      string str = "Hello World";
      // reverse the string
      string res = string.Join(" ", str.Split(' ').Select(s => new String(s.Reverse().ToArray())));
      Console.WriteLine(res);
   }
}
olleH dlroW
Modulus of two float or double numbers using C

Here we will see how to get the modulus of two floating or double type data in C. The modulus is basically finding the remainder. For this, we can use the remainder() function in C. The remainder() function is used to compute the floating point remainder of numerator/denominator.
So the remainder(x, y) will be like below.
remainder(x, y) = x – rquote * y
The rquote is the value of x/y. This is rounded towards the nearest integral value. This function takes two arguments of type double, float, long double, and returns the remainder of the same type, that was given as argument. The first argument is numerator, and the second argument is the denominator.
#include <stdio.h>
#include <math.h>
main() {
   double x = 14.5, y = 4.1;
   double res = remainder(x, y);
   printf("Remainder of %lf/%lf is: %lf\n",x,y, res);
   x = -34.50;
   y = 4.0;
   res = remainder(x, y);
   printf("Remainder of %lf/%lf is: %lf\n",x,y, res);
   x = 65.23;
   y = 0;
   res = remainder(x, y);
   printf("Remainder of %lf/%lf is: %lf\n",x,y, res);
}
Remainder of 14.500000/4.100000 is: -1.900000
Remainder of -34.500000/4.000000 is: 1.500000
Remainder of 65.230000/0.000000 is: -1.#IND00
Classes and Objects in C++

Classes are the prime features of C++ as they support OOPS concepts and are user defined data types. Classes provide the specification for an object and contain data variables as well as functions to manipulate the data in a single package.
A class definition starts with the keyword class and then the class name. After that the class body is defined. It is enclosed by curly braces. A class definition should either contain a semicolon or a list of definitions after it.
An example of a class definition in C++ is as follows.
class student {
   int rollno;
   char name[50];
   float marks;
};
The above class contains the details of a student, namely its roll number, name and marks.
When a class is defined, it is only a specification. There is no memory or storage allocated at that time. So the object is created from the class to access the data and functions defined in the class. A class can also be called the blueprint for an object.
The declaration of an object of class student is given as follows.
Student stu1;
A program that demonstrates classes and objects in C++ is given as follows.
 Live Demo
#include <iostream>
using namespace std;
class Student {
   public:
   int rollno;
   char name[50];
   float marks;
   void display() {
      cout<<"Roll Number: "<< rollno <<endl;
      cout<<"Name: "<< name <<endl;
      cout<<"Marks: "<< marks <<endl;
   }
};
int main() {
   Student stu1 = {1, "Harry", 91.5};
   stu1.display();
   return 0;
}
Roll Number: 1
Name: Harry
Marks: 91.5
In the above program, first the class student is defined. It contains the details about the student such as roll number, name and marks. It also contains a member function display() that displays all the student details. The code snippet that demonstrates this is as follows.
class student {
   public:
   int rollno;
   char name[50];
   float marks;
   void display() {
      cout<<"Roll Number: "<< rollno <<endl;
      cout<<"Name: "<< name <<endl;
      cout<<"Marks: "<< marks <<endl;
   }
};
In the function main(), the object of the class student is defined with the student details. Then these details are displayed with a function call to display(). This can be seen as follows.
student stu1 = {1, "Harry", 91.5};
stu1.display();
Atbash cipher in Python

Suppose we have a lowercase alphabet string called text. We have to find a new string where every character in text is mapped to its reverse in the alphabet. As an example, a becomes z, b becomes y and so on.
So, if the input is like "abcdefg", then the output will be "zyxwvut"
To solve this, we will follow these steps −
N := ASCII of ('z') + ASCII of ('a')
N := ASCII of ('z') + ASCII of ('a')
return ans by joining each character from ASCII value (N - ASCII of s) for each character s in text
return ans by joining each character from ASCII value (N - ASCII of s) for each character s in text
Let us see the following implementation to get better understanding −
 Live Demo
class Solution:
   def solve(self, text):
      N = ord('z') + ord('a')
      ans=''
      return ans.join([chr(N - ord(s)) for s in text])
ob = Solution()
print(ob.solve("abcdefg"))
print(ob.solve("hello"))
"abcdefg"
"hello"
zyxwvut
svool
How to find the MySQL data directory from command line in Windows?

To find the MySQL data directory, we can simply use the variable datadir. Let us see how to use the variable with select statement.
The query is as follows −
mysql> select @@datadir;
Here is the output
+---------------------------------------------+
| @@datadir                                   |
+---------------------------------------------+
| C:\ProgramData\MySQL\MySQL Server 8.0\Data\ |
+---------------------------------------------+
1 row in set (0.00 sec)
Now we can reach the directory from the above sample output.
Here is the snapshot that displays the MySQL data directory.
Strings in Octave GNU

06 Jun, 2022
In Octave GNU, A string is basically the collection of characters enclosed between double quotes (“) or single quotes (‘).
Example of strings
“This is a string”
‘This is also a string’
In Octave, there is no limit for the length of the string. i.e. It can be of any size. Character array is used to represent a string in Octave
Escape Sequence : Some double-quoted(“) string containing backslash(‘\’), change the meaning of that string constant, these types of strings are special and are used for special purposes. The backslash (‘\’) character is known as Escape Character.
Below is the list of some Escape Sequences
Escape Sequence
Meaning
\\
\”
\’
\0
\a
\b
\f
\n
\r
\t
\v
\nnn
Represents the octal value nnn, where nnn are one to three digits between 0
and 7
\xhh...
Represents the hexadecimal value hh, where hh are hexadecimal digits (‘0’
through ‘9’ and either ‘A’ through ‘F’ or ‘a’ through ‘f’).
String creation in Octave
In the octave, a string can be generated by using the double quotes, single quotes, and blanks()
Using Double Quotes : varA = “String”;
Using Single Quotes : varB = ‘String’;
Using blanks() : varC = blanks(10), create a 10 size string of blank equivalent to ”          “
String concatenation in Octave
In the octave, there are two ways to concatenate strings
Using Square Brackett ‘[]’ :  newStr = [oldStr1 oldStr2];  or newStr = [oldStr1, oldStr2];
Using strcat() : newStr = strcat(oldStr1, oldStr2);
String comparison in Octave
In the octave, strcmp() is used to compare two strings
There are various versions of strcmp():
strcmp(s1, s2, n) : compares the first n characters of s1 with s2
strcmpi(s1, s2) : case insensitive strcmp()
Below is the octave code to demonstrate the above-mentioned functions and concepts
MATLAB
% String creation in Octavestr1 = "This is a string";str2 = 'This is also a string';str3 = blanks(10);printf("String created using \" is : %s .\n", str1);printf("String created using \' is : %s .\n", str2);printf("String created using blanks() is : %s .\n\n", str3);  % String Concatenation in Octavedisplay("String Concatenation")oldStr1 = "first";oldStr2 = "last";newStr1 = [oldStr1 oldStr2];newStr2 = [oldStr1, oldStr2];newStr3 = strcat(oldStr1, oldStr2);printf("String Concatenation using [ ] is : %s .\n", newStr1);printf("String Concatenation using [, ] is : %s .\n", newStr2);printf("String Concatenation using strcat() is : %s .\n\n", newStr3);  % String comparison in Octavedisplay("String Comparison")printf("Comparison using strcmp() : ");disp(strcmp(str1, str2));
Output:
String created using " is : This is a string .
String created using ' is : This is also a string .
String created using blanks() is :            .

String Concatenation
String Concatenation using [ ] is : firstlast .
String Concatenation using [, ] is : firstlast .
String Concatenation using strcat() is : firstlast .

String Comparison
Comparison using strcmp() : 0
simranarora5sos
Octave-GNU
Programming Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.