code-rag-bench/online-tutorials huggingface dataset:
C# | How to get the HashCode of the tuple?

30 Apr, 2019
A tuple is a data structure which gives you the easiest way to represent a data set. You can also get the hash code of the tuple by using the GetHashCode Method. This method will return the hash code of the given tuple object.
Syntax:
public override int GetHashCode ();
Return Type: The return type of this method is System.Int32. It will return 32-bit signed integer hash code.
Example 1:
// C# program to illustrate the // use of GetHashCode methodusing System;  class GFG {      // Main Method    static public void Main()    {          // creating different tuples using Create Method        var tu1 = Tuple.Create(23, 45, 78, 89, 56);        var tu2 = Tuple.Create(34, 45);        var tu3 = Tuple.Create(45, 454, 454, 545, 4, 544, 54, 56);        var tu4 = Tuple.Create(44, 58, 66, 32);          // Get the hash code of the Tuples        // Using GetHashCode method        Console.WriteLine("HashCode for tu1: " + tu1.GetHashCode());        Console.WriteLine("HashCode for tu2: " + tu2.GetHashCode());        Console.WriteLine("HashCode for tu3: " + tu3.GetHashCode());        Console.WriteLine("HashCode for tu4: " + tu4.GetHashCode());    }}
HashCode for tu1: 712149
HashCode for tu2: 1103
HashCode for tu3: 1582758
HashCode for tu4: 45300

Example 2:
// C# program to illustrate the use // of the GetHashCode methodusing System;  class GFG {      // Main Method    static public void Main()    {          // Creating different Tuples        // using Create Method        var t1 = Tuple.Create(64, 76, 78, Tuple.Create(12, 34, 56, 78));          var t2 = Tuple.Create(78, 34, 86, Tuple.Create(23, 56));          var t3 = Tuple.Create(34, 78, Tuple.Create(12, 34, 56, 78));          var t4 = Tuple.Create(12, 34, 56, 34, 56, 65, 78,                   Tuple.Create(24, 45, 67, 78, 89, 88));          // Get the hash code of the Tuples        // Using GetHashCode method        Console.WriteLine("HashCode for t1: " + t1.GetHashCode());        Console.WriteLine("HashCode for t2: " + t2.GetHashCode());        Console.WriteLine("HashCode for t3: " + t3.GetHashCode());        Console.WriteLine("HashCode for t4: " + t4.GetHashCode());    }}
HashCode for t1: 78746
HashCode for t2: 83573
HashCode for t3: 47540
HashCode for t4: 672122

CSharp-Tuple
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | Pandas DataFrame.reset_index()

17 Sep, 2018
Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier.
Pandas reset_index() is a method to reset index of a Data Frame. reset_index() method sets a list of integer ranging from 0 to length of data as index.
Syntax:DataFrame.reset_index(level=None, drop=False, inplace=False, col_level=0, col_fill=”)
Parameters:level: int, string or a list to select and remove passed column from index.drop: Boolean value, Adds the replaced index column to the data if False.inplace: Boolean value, make changes in the original data frame itself if True.col_level: Select in which column level to insert the labels.col_fill: Object, to determine how the other levels are named.
Return type: DataFrame
To download the CSV file used, Click Here.Example #1: Resetting indexIn this example, to reset index, First name column have been set as index column first and then using reset index a new index have been generated.
# importing pandas packageimport pandas as pd   # making data frame from csv filedata = pd.read_csv("employees.csv")   # setting first name as index columndata.set_index(["First Name"], inplace = True,                    append = True, drop = True)   # resetting indexdata.reset_index(inplace = True)   # displaydata.head()
Output:As show in the output images, A new index label named level_0 has been generated.Before reset –After reset –
 
Example #2: Operation on Multi level IndexIn this example, 2 columns(First name and Gender) are added to the index column and later one level is removed by using reset_index() method.
# importing pandas packageimport pandas as pd   # making data frame from csv filedata = pd.read_csv("employees.csv")   # setting first name as index columndata.set_index(["First Name", "Gender"], inplace = True,                             append = True, drop = True)   # resetting indexdata.reset_index(level = 2, inplace = True, col_level = 1)   # displaydata.head()
Output:As shown in the output image, The gender column in the index column was replaced as it’s level was 2.
Before reset –After reset –
Python pandas-dataFrame
Python pandas-dataFrame-methods
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
How to Install PIP on Windows ?
*args and **kwargs in Python
Iterate over a list in Python
Python Classes and Objects
Convert integer to string in Python
Python | os.path.join() method
Python OOPs Concepts
Python | Merge two text files

19 Jul, 2019
Given two text files, the task is to merge the data and store in a new text file. Let’s see how can we do this task using Python.
To merge two files in Python, we are asking user to enter the name of the primary and second file and make a new file to put the unified content of the two data into this freshly created file.
In order to do this task, we have to import shutil & pathlib libraries. You can install the libraries using this command –
pip install shutil
pip install pathlib
Also, place the two text files on the Desktop.
First text file:
Second text file:
Below is the Python implementation –
import shutilfrom pathlib import Path   firstfile = Path(r'C:\Users\Sohom\Desktop\GFG.txt')secondfile = Path(r'C:\Users\Sohom\Desktop\CSE.txt')  newfile = input("Enter the name of the new file: ")print()print("The merged content of the 2 files will be in", newfile)  with open(newfile, "wb") as wfd:      for f in [firstfile, secondfile]:        with open(f, "rb") as fd:            shutil.copyfileobj(fd, wfd, 1024 * 1024 * 10)  print("\nThe content is merged successfully.!")print("Do you want to view it ? (y / n): ")  check = input()if check == 'n':    exit()else:    print()    c = open(newfile, "r")    print(c.read())    c.close()
Output:
The updated merged text file:
python-utility
Python
Python Programs
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
Python String | replace()
How to Install PIP on Windows ?
Python program to convert a list to string
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python | Convert string dictionary to dictionary
Python - Get the Index of first element greater than K

The values of items in a python list are not necessarily in any sorted order. More over there may be situation when we are interested only in certain values greater than a specific value. In this article we will see how we can get the
Using enumeration we get both the index and value of the elements in the list. Then we apply the greater than condition to get only the first element where the condition is satisfied. The next function goes through each list element one by one.
 Live Demo
List = [21,10,24,40.5,11]
print("Given list: " + str(List))
#Using next() + enumerate()
result = next(k for k, value in enumerate(List)
if value > 25)print("Index is: ",result)
Running the above code gives us the following result
Given list: [21, 10, 24, 40.5, 11]
Index is: 3
In the next example we take a lambda function to compare the given value with value at each index and then filter out those which satisfy the required condition. From the list of elements satisfying the required condition, we choose the first element at index 0 for our answer.
 Live Demo
List = [21,10,24,40.5,11]
print("Given list: " + str(List))
#Using filter() + lambda
result = list(filter(lambda k: k > 25, List))[0]
print("Index is: ",List.index(result))
Running the above code gives us the following result
Given list: [21, 10, 24, 40.5, 11]
Index is: 3
In the next example we take a similar approach but use map instead of filter. The map function is used to loop through each of the elements. Whenever the condition becomes true that index is captured.
 Live Demo
List = [21,10,24,40.5,11]
print("Given list: " + str(List))
result = list(map(lambda k: k > 25, List)).index(True)
print("Index is: ",(result))
Running the above code gives us the following result
Given list: [21, 10, 24, 40.5, 11]
Index is: 3
Storage Management

19 Jun, 2019
Storage Management is defined as it refers to the management of the data storage equipment’s that are used to store the user/computer generated data. Hence it is a tool or set of processes used by an administrator to keep your data and storage equipment’s safe.
Storage management is a process for users to optimize the use of storage devices and to protect the integrity of data for any media on which it resides and the category of storage management generally contain the different type of subcategories covering aspects such as security, virtualization and more, as well as different types of provisioning or automation, which is generally made up the entire storage management software market.
Storage management key attributes:Storage management has some key attribute which is generally used to manage the storage capacity of the system. These are given below:
1. Performance
2. Reliability
3. Recoverability
4. Capacity 
Feature of Storage management:There is some feature of storage management which is provided for storage capacity. These are given below:
Storage management is a process that is used to optimize the use of storage devices.Storage management must be allocated and managed as a resource in order to truly benefit a corporation.Storage management is generally a basic system component of information systems.It is used to improve the performance of their data storage resources.
Storage management is a process that is used to optimize the use of storage devices.
Storage management must be allocated and managed as a resource in order to truly benefit a corporation.
Storage management is generally a basic system component of information systems.
It is used to improve the performance of their data storage resources.
Advantage of storage management:There are some advantage of storage management which are given below:
It is very simple to managed a storage capacity.
It is generally take a less time.
It is improve the performance of system.
In virtualization and automation technologies can help an organization improve its agility.
Misc
Misc
Misc
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Introduction to Electronic Mail
Advantages and Disadvantages of OOP
Communication Models in IoT (Internet of Things )
Cloud Computing
Analog to Digital Conversion
Hypervisor
Characteristics of Cloud Computing
Introduction to Deep Learning
array::size() in C++ STL
Bubble Sort algorithm using JavaScript
Set Aspect Ratio of Scatter Plot and Bar Plot in R Programming - Using asp in plot() Function - GeeksforGeeks

30 Jun, 2020
asp is a parameter of the plot() function in R Language is used to set aspect ratio of plots (Scatterplot and Barplot). Aspect ratio is defined as proportional relationship between width and height of the plot axes.
Syntax: plot(x, y, asp )
Parameters:x, y: Coordinates of x and y axisasp: Aspect ratio
Example 1:
# Set seed for reproducibilityset.seed(86000)       # Create random x variablex <- runif(120)       # Create y variable correlated with xy <- x + runif(120)        # Plot without setting aspect ratioplot(x, y)         # Plot with asp = 5plot(x, y, asp = 5)         
Output:
Plot Without Aspect Ratio:
Plot with Aspect Ratio:
Example 2:
# Set seed for reproducibilityset.seed(86000)                # Create random x variablex <- runif(120)                # Create y variable correlated with xy <- x + runif(120)   # Regular barplotbarplot(x)                     # Barplot with aspect ratio of 5barplot(x, asp = 5)         
Output:
Bar Plot Without Aspect Ratio:
Bar Plot with Aspect Ratio:
Here, the asp option increases the width of the y-axis.
R Plot-Function
R Statistics-Function
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Change Color of Bars in Barchart using ggplot2 in R
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 filter R DataFrame by values in a column?
How to import an Excel File into R ?
Time Series Analysis in R
R - if statement
How to filter R dataframe by multiple conditions?
exp() function C++ - GeeksforGeeks

12 May, 2022
The exp() function in C++ returns the exponential (Euler’s number) e (or 2.71828) raised to the given argument.
Syntax for returning exponential e: result=exp()
Parameter: The function can take any value i.e, positive, negative or zero in its parameter and returns result in int, double or float or long double. Return Value: The exp() function returns the value in the range of [0, inf]. Error: It shows error when we pass more than one argument in exp function Application: Given below is an example of application of exp() function 
CPP
#include <bits/stdc++.h>using namespace std; // function to explain use of exp() functiondouble application(double x){    double result = exp(x);    cout << "exp(x) = " << result << endl;    return result;} // driver programint main(){    double x = 10;    cout << application(x);    return 0;}
Output:
exp(x) = 22026.5
Applications of e (mathematical constant):
Compound Interest : An account that starts at $1 and offers an annual interest rate of R will, after t years, yield eRt dollars with continuous compounding (Here R is the decimal equivalent of the rate of interest expressed as a percentage, so for 5% interest, R = 5/100 = 0.05)
Value of below expression is e. 
The probability that a gambler never wins if he/she tries million times in a game where chances of winning in every trial is one by million is close to 1/e.
The number e is the sum of the infinite series 
Source : Wiki
solankinilesh61
surinderdawra388
CPP-Library
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Inheritance in C++
Map in C++ Standard Template Library (STL)
C++ Classes and Objects
Bitwise Operators in C/C++
Virtual Function in C++
Constructors in C++
Templates in C++ with Examples
Operator Overloading in C++
Socket Programming in C/C++
vector erase() and clear() in C++
CSS | ::first-line Selector - GeeksforGeeks

04 Jan, 2019
The ::first-line selector in CSS is used to apply style to the first line of a block-level element. The length of the first line depends on many factors, including the width of the element, the width of the document, font-size of the text, etc.
Syntax:
::first-line {
    //CSS Property
}

Example:
<!DOCTYPE html><html>  <head>    <title>        CSS ::first-line selector    </title>    <style>        p {            width: 25%;        }                  p::first-line {            color: white;            background: green;        }    </style></head>  <body style="text-align: center;">    <h1 style="color:green;">            GeeksforGeeks        </h1>    <h2>            CSS ::first-line selector        </h2>      <p>        A computer science portal for geeks.    </p>  </body>  </html>
Output:Supported Browsers: The browser supported by ::first-line selector are listed below:
Apple Safari 1.0
Google Chrome 1.0
Firefox 1.0
Opera 7.0 Partial from 3.5
Internet Explorer 9.0 Partial from 5.5
CSS-Selectors
CSS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to insert spaces/tabs in text using HTML/CSS?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to update Node.js and NPM to next version ?
How to create footer to stay at the bottom of a Web page?
How to apply style to parent if it has child with CSS?
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
MySQL | DATABASE() and CURRENT_USER() Functions - GeeksforGeeks

21 Jun, 2021
DATABASE() Function
The DATABASE() Function in MySQL returns the name of the default or current database. The string or name returned by DATABASE() function uses the utf8 character set. If there is no default database,the Database function returns NULL. In the older versions than MySQL 4.1.1,The Database function used to return an empty string, if there is no default database. 
Syntax :  
SELECT DATABASE();
The DATABASE() function is easy to use and does not accept any parameters. We can easily get the name of default database using the above syntax on MySQL console. 
Example : Let us consider the name of the default database is “Employees”. Therefore to know the name of the default database, the database function can be executed in the following way:  
Output:  
'Employees'
 
CURRENT_USER() Function
The CURRENT_USER() Function in MySQL is used to return the user name and host name for the MySQL account which is used by the server to authenticate the current client. 
As of MySQL 4.1.,the CURRENT_USER() function uses the utf8 character set. 
Syntax:  
SELECT CURRENT_USER();
CURRENT_USER() function also does not accepts any parameters. 
Example : Let us consider the username of MySQL account used by the server to authenticate the current client is ‘root’ and the hostname is ‘localhost’. Therefore to know the username and hostname for the MySQL account used by the server to authenticate the current client, the CURRENT_USER() function can be executed in the following way:  
Output:  
'root@localhost'
 
rajeev0719singh
Functions
mysql
SQL
Functions
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Update Multiple Columns in Single Update Statement in SQL?
SQL | Subquery
How to Create a Table With Multiple Foreign Keys in SQL?
What is Temporary Table in SQL?
SQL Query to Find the Name of a Person Whose Name Starts with Specific Letter
SQL using Python
SQL Query to Convert VARCHAR to INT
How to Write a SQL Query For a Specific Date Range and Date Time?
How to Select Data Between Two Dates and Times in SQL Server?
SQL Query to Compare Two Dates
Non-generic Vs Generic Collection in Java

Errors appear at compile time than at run time.
Code reusability: Generics help in reusing the code already written, thereby making it usable for other types (for a method, or class, or an interface).
If a data structure is generic, say a list, it would only take specific type of objects and return the same specific type of object as output. This eliminates the need to typecast individually.
Algorithms can be implemented with ease, since they can be used to work with different types of objects, and maintaining type safety as well as code reusability.
Following is an example −
 Live Demo
import java.util.*;
public class Demo {
   public static void main(String[] args) {
      ArrayList<String> my_list = new ArrayList<String>();
      my_list.add("Joe");
      my_list.add("Rob");
      my_list.add("John");
      my_list.add("Billy");
      String s1 = my_list.get(0);
      String s2 = my_list.get(1);
      String s3 = my_list.get(3);
      System.out.println(s1);
      System.out.println(s2);
      System.out.println(s3);
   }
}
Joe
Rob
Billy
A class named Demo contains the main function. Here, an arraylist of strings is defined. Elements are added to this list with the help of the ‘add’ function. The ‘get’ function is used to store the element at a specific index. The println function is used to print the specific element on the console.
When the data structure is non-generic, it causes issues when the data is tried to be retrieved from the collection/data structure.
Every time an element from the collection is retrieved, it needs to be explicitly type-casted to its required type, which is a problem when there are too many elements.
The above code, when implemented using non-generic collection yields the following output.
 Live Demo
import java.util.*;
public class Demo {
   public static void main(String[] args) {
      ArrayList my_list = new ArrayList();
      my_list.add("Joe");
      my_list.add("Rob");
      my_list.add("Nate");
      my_list.add("Bill");
      String s1 = (String)my_list.get(0);
      String s2 = (String)my_list.get(1);
      String s3 = (String)my_list.get(3);
      System.out.println(s1);
      System.out.println(s2);
      System.out.println(s3);
   }
}
:
Joe
Rob
Bill
A class named Demo contains the main function. Here, an arraylist of strings is defined. Elements are added to this list with the help of the ‘add’ function. The ‘get’ function is used to store the element at a specific index. Here, every element of the list is explicitly typecasted to String type before being stored in another string variable. The println function is used to print the specific element on the console.
Program to find maximum number of boxes we can fit inside another boxes in python

Suppose we have a list of boxes where each row represents the height and width of given boxes. We can put a box in another box if first box is smaller than the second one (when both of its width and height are smaller than the other box), we have to find the maximum number of boxes we can fit into a box.
So, if the input is like
then the output will be 3, as we can fit the box [6, 6] inside [10, 10] which we can be put into [12, 12] box.
To solve this, we will follow these steps −
Define a function insert_index() . This will take arr, this_h
l := 0
r := size of arr - 1
res := 0
while l <= r, dom := l +(r - l) // 2cur_h := arr[m]if cur_h < this_h is non-zero, thenres := ml := m + 1otherwise,r := m - 1
m := l +(r - l) // 2
cur_h := arr[m]
if cur_h < this_h is non-zero, thenres := ml := m + 1
res := m
l := m + 1
otherwise,r := m - 1
r := m - 1
return res + 1
From the main method, do the following:
sort the matrix based on width, if widths are same sort them based on height
n := number of items in matrix
heights := a list of size (n + 1) and fill it with inf
heights[0] := -inf
res := 0
for each box in matrix, do[cur_w, cur_h] := boxindex := insert_index(heights, cur_h)if heights[index] >= cur_h, thenheights[index] := cur_hres := maximum of res and index
[cur_w, cur_h] := box
index := insert_index(heights, cur_h)
if heights[index] >= cur_h, thenheights[index] := cur_h
heights[index] := cur_h
res := maximum of res and index
return res
Let us see the following implementation to get better understanding −
Live Demo
class Solution:
   def solve(self, matrix):
      matrix = sorted(matrix, key=lambda x: (x[0], -x[1]))
      n = len(matrix)

      heights = [float("inf")] * (n + 1)
      heights[0] = float("-inf")
      res = 0

      for box in matrix:
         cur_w, cur_h = box
         index = self.insert_index(heights, cur_h)

         if heights[index] >= cur_h:
            heights[index] = cur_h
         res = max(res, index)
      return res

   def insert_index(self, arr, this_h):
      l = 0
      r = len(arr) - 1
      res = 0
      while l <= r:
         m = l + (r - l) // 2
         cur_h = arr[m]
         if cur_h < this_h:
            res = m
            l = m + 1
         else:
            r = m - 1
      return res + 1

ob = Solution()
matrix = [
   [12, 12],
   [10, 10],
   [6, 6],
   [5, 10]
]
print(ob.solve(matrix))
matrix = [  
[12, 12],  
[10, 10],  
[6, 6],  
[5, 10] ]
3
JavaScript Array find() function

The find() method of JavaScript is used to return the first elements value in an array, if the condition is passed, otherwise the return value is undefined. The syntax is as follows −
array.find(function(val, index, arr),thisValue)
Here, function is a function with val, which is the value of the current element. The index is the array index, and arr is the array. The this value parameter is the value to be passed to the function.
 Live Demo
<!DOCTYPE html>
<html>
<body>
   <h2>Ranking Points</h2>
   <p>Get the points (first element) above 400...</p>
   <button onclick="display()">Result</button>
   <p id="demo"></p>
   <script>
      var pointsArr = [50, 100, 200, 300, 400, 500, 600];
      function pointsFunc(points) {
         return points > 400;
      }
      function display() {
         document.getElementById("demo").innerHTML = pointsArr.find(pointsFunc);
      }
   </script>
</body>
</html>
Now, click on the “Result” button −
Let us see another example, wherein the result would be undefined −
 Live Demo
<!DOCTYPE html>
<html>
<body>
   <h2>Ranking Points</h2>
   <p>Get the points (first element) above 400...</p>
   <button onclick="display()">Result</button>
   <p id="demo"></p>
   <script>
      var pointsArr = [50, 100, 200, 300, 400];
      function pointsFunc(points) {
         return points > 400;
      }
      function display() {
         document.getElementById("demo").innerHTML = pointsArr.find(pointsFunc);
      }
   </script>
</body>
</html>
Now, click on the “Result” button −
Find the minimum number of steps to reach M from N in C++

Suppose we have two integers N and M. We have to find minimum number of steps to reach M from N, by performing given operations −
Multiply the number x by 2, so x will be 2*x
Subtract one from the number x, so the number will be x – 1
If N = 4 and M = 6, then output will be 2. So if we perform operation number 2 on N, then N becomes 3, then perform operation number one on updated value of N, so it becomes 2 * 3 = 6. So the minimum number of steps will be 2.
To solve this problem, we will follow these rules −
We can reverse the problem, like we take the number N starting from M, so new two operations will be
Divide the number by 2, when it is even,add 1 with the number
Divide the number by 2, when it is even,
add 1 with the number
Now the minimum number of operations will beif N > M, return the difference between them, so number of steps will be adding 1 to M, until it becomes equal to NOtherwise when N < M, keep dividing M by 2, until it becomes less than N. If M is odd, then add 1 to it first, then divide by 2, Once M is less than N, add the difference between them to the count along with the count of above operations.
if N > M, return the difference between them, so number of steps will be adding 1 to M, until it becomes equal to N
Otherwise when N < M, keep dividing M by 2, until it becomes less than N. If M is odd, then add 1 to it first, then divide by 2, Once M is less than N, add the difference between them to the count along with the count of above operations.
 Live Demo
#include<iostream>
using namespace std;
int countMinimumSteps(int n, int m) {
   int count = 0;
   while(m > n) {
      if(m % 2 == 1) {
         m++;
         count++;
      }
      m /= 2;
      count++;
   }
   return count + n - m;
}
int main() {
   int n = 4, m = 6;
   cout << "Minimum number of operations required: " << countMinimumSteps(n, m);
}
Minimum number of operations required: 2
MathML - Overview

MathML stands for Mathematical Markup Language and is an XML based application. It is used to describe mathematical and scientific notations. It's 1 and 2 version were created and developed by The Math Working Group which is one of the oldest W3C Working Groups during 1996-2004. MathML version 3 was created during Math Working Group's second activity period (2006-2016)and is an ISO standard.
MathML is XML based and have limited number of tags which can be used to mark up a mathematical equation in terms of format and its semantics. MathML intends to capture meaning of syntax as well as formatting of the equation. Considering the fact the mathematical equations are often meaningful to many applications so writing them using MathML handles formatting as well as meaning of an equation. MathML provides low-level format to describing mathematics as a basis taken for machine to machine communication.
Various applications like algebra systems, print typesetters can use MathML to encode mathematical notation for high-quality visual display, and mathematical content and scientific software, voice synthesizers can use MathML for semantics.
MathML provides two ways to represent a mathematical notation.
Presentational Way − It uses mark up tags like mrow, mi, mo along with mathematical operators etc.
Presentational Way − It uses mark up tags like mrow, mi, mo along with mathematical operators etc.
Semantic Way − It uses mark up tags like apply, eq, power etc.
Semantic Way − It uses mark up tags like apply, eq, power etc.
We are using MathJax library to render MathML syntax so that it can run on all major browsers. It currently supports presentational way only.
<math xmlns = "http://www.w3.org/1998/Math/MathML">
   <mrow>
      <mrow>
         <msup> <mi>x</mi> <mn>2</mn> </msup> <mo>+</mo>
         <mrow>
            <mn>4</mn>
            <mo>⁢</mo>
            <mi>x</mi>
         </mrow>
         <mo>+</mo>
         <mn>4</mn>
      </mrow>
      
      <mo>=</mo>
      <mn>0</mn>
   </mrow>
</math>
 Print
 Add Notes
 Bookmark this page
Math.Round() Method in C#

The Math.Round() method in C# rounds a value to the nearest integer or to the specified number of fractional digits.
The following are the methods overloaded by Math.Round() −
Math.Round(Double)
Math.Round(Double, Int32)
Math.Round(Double, Int32, MidpointRounding)
Math.Round(Double, MidpointRounding)
Math.Round(Decimal)
Math.Round(Decimal, Int32)
Math.Round(Decimal, Int32, MidpointRounding)
Math.Round(Decimal, MidpointRounding)
Let us now see an example to implement Math.Round() method i.e. Math.Round(Decimal) −
using System;
public class Demo {
   public static void Main(){
      Decimal val1 = 78.12m;
      Decimal val2 = 30.675m;
      Console.WriteLine("Decimal Value = " + val1);
      Console.WriteLine("Rounded value = " + Math.Round(val1));
      Console.WriteLine("Decimal Value = " + val2);
      Console.WriteLine("Rounded value = " + Math.Round(val2));
   }
}
This will produce the following output −
Decimal Value = 78.12
Rounded value = 78
Decimal Value = 30.675
Rounded value = 31
Let us see another example to implement Math.Round() method i.e. Math.Round(Double) −
using System;
public class Demo {
   public static void Main(){
      Double val1 = 23.10;
      Double val2 = 90.98;
      Console.WriteLine("Double Value = " + val1);
      Console.WriteLine("Rounded value = " + Math.Round(val1));
      Console.WriteLine("Double Value = " + val2);
      Console.WriteLine("Rounded value = " + Math.Round(val2));
   }
}
This will produce the following output −
Double Value = 23.1
Rounded value = 23
Double Value = 90.98
Rounded value = 91
Filling byte array in Java

The byte array in Java can be filled by using the method java.util.Arrays.fill(). This method assigns the required byte value to the byte array in Java. The two parameters required for java.util.Arrays.fill() are the array name and the value that is to be stored in the array elements.
A program that demonstrates this is given as follows −
 Live Demo
import java.util.Arrays;
public class Demo {
   public static void main(String[] a) {
      byte arr[] = new byte[] {5, 1, 9, 2, 6};
      System.out.print("Byte array elements are: ");
      for (int num : arr) {
         System.out.print(num + " ");
      }
      Arrays.fill(arr, (byte) 7);
      System.out.print("\nByte array elements after Arrays.fill() method are: ");
      for (int num : arr) {
         System.out.print(num + " ");
      }
   }
}
Byte array elements are: 5 1 9 2 6
Byte array elements after Arrays.fill() method are: 7 7 7 7 7
Now let us understand the above program.
First, the elements of the byte array arr are printed. A code snippet which demonstrates this is as follows −
byte arr[] = new byte[] {5, 1, 9, 2, 6};
System.out.print("Byte array elements are: ");
for (int num : arr) {
   System.out.print(num + " ");
}
After this, the Arrays.fill() method is used to assign the byte value 7 to all the elements in the array. Then this array is printed. A code snippet which demonstrates this is as follows −
Arrays.fill(arr, (byte) 7);
System.out.print("\nByte array elements after Arrays.fill() method are: ");
for (int num : arr) {
   System.out.print(num + " ");
}
Lodash - toString method

_.toString(value)

Converts value to a string. An empty string is returned for null and undefined values. The sign of -0 is preserved.
value (*) − The value to convert.
value (*) − The value to convert.
(string) − Returns the converted string.
(string) − Returns the converted string.
var _ = require('lodash');
 
console.log(_.toString(-0));
console.log(_.toString([1, 2, 3]));
Save the above program in tester.js. Run the following command to execute this program.
\>node tester.js

-0
1,2,3

 Print
 Add Notes
 Bookmark this page
What is C++ Standard Output Stream (cout)?

std::cout is an object of class ostream that represents the standard output stream oriented to narrow characters (of type char). It corresponds to the C stream stdout. The standard output stream is the default destination of characters determined by the environment. This destination may be shared with more standard objects (such as cerr or clog).
As an object of class ostream, characters can be written to it either as formatted data using the insertion operator (operator<<) or as unformatted data, using member functions such as write. The object is declared in the header <iostream> with external linkage and static duration: it lasts the entire duration of the program.
You can use this object to write to the screen. For example, if you want to write "Hello" to the screen, you'd write −
Live Demo
#include<iostream>
int main() {
   std::cout << "Hello";
   return 0;
}
Then save this program to hello.cpp file. Finally navigate to the saved location of this file in the terminal/cmd and compile it using −
$ g++ hello.cpp
Run it using −
$ ./a.out
This will give the output −
Hello
CSS - z-index

The z-index sets the stacking level of an element.
auto − The stack level of the element is the same as that of its parent element.
auto − The stack level of the element is the same as that of its parent element.
integer − The stack level of the element is set to the given value, and it establishes a new stacking context for any descendant elements.
integer − The stack level of the element is set to the given value, and it establishes a new stacking context for any descendant elements.
All the positioned elements.
object.style.zindex = "1";

Following is the example which shows how to create layers in CSS.
<html>
   <head>
   </head>
   
   <body>
      <div style = "background-color:red;
         width:300px;
         height:100px;
         position:relative;
         top:10px;
         left:80px;
         z-index:2">
      </div>
      
      <div style = "background-color:yellow;
         width:300px;
         height:100px;
         position:relative;
         top:-60px;
         left:35px;
         z-index:1;">
      </div>
      
      <div style = "background-color:green;
         width:300px;
         height:100px;
         position:relative;
         top:-220px;
         left:120px;
         z-index:3;">
      </div>
   </body>
</html> 
This will produce following result −

    33 Lectures 
     2.5 hours 

 Anadi Sharma

    26 Lectures 
     2.5 hours 

 Frahaan Hussain

    44 Lectures 
     4.5 hours 

 DigiFisk (Programming Is Fun)

    21 Lectures 
     2.5 hours 

 DigiFisk (Programming Is Fun)

    51 Lectures 
     7.5 hours 

 DigiFisk (Programming Is Fun)

    52 Lectures 
     4 hours 

 DigiFisk (Programming Is Fun)
 Print
 Add Notes
 Bookmark this page
Python | sympy.apart() method - GeeksforGeeks

25 Jun, 2019
With the help of sympy.apart() method, we can performs a partial fraction decomposition on a rational mathematical expression.
Syntax: apart(expression)
Parameters:expression – It is a rational mathematical expression.
Returns: Returns an expression after the partial decomposition.
Example #1:In this example we can see that by using sympy.apart() method, we can get a partial fraction decomposition of a given mathematical expression.
# import sympyfrom sympy import *  x = symbols('x')expr = (4 * x**3 + 21 * x**2 + 10 * x + 12) / (x**4 + 5 * x**3 + 5 * x**2 + 4 * x)  print("Mathematical expression : {}".format(expr))    # Use sympy.apart() methodpd = apart(expr)     print("After Partial Decomposition : {}".format(pd)) 
Output:
Mathematical expression : (4*x**3 + 21*x**2 + 10*x + 12)/(x**4 + 5*x**3 + 5*x**2 + 4*x)
After Partial Decomposition : (2*x - 1)/(x**2 + x + 1) - 1/(x + 4) + 3/x

Example #2:
# import sympyfrom sympy import *   x = symbols('x')expr = 1/(x + 3)(x + 2)  print("Mathematical expression : {}".format(expr))    # Use sympy.factor_list() methodpd = apart(expr)     print("After Partial Decomposition : {}".format(pd)) 
Output:
Mathematical expression : 1/((x + 2)*(x + 3))
After Partial Decomposition : -1/(x + 3) + 1/(x + 2)

SymPy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Install PIP on Windows ?
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | Pandas dataframe.groupby()
Defaultdict in Python
Python | Get unique values from a list
Python Classes and Objects
Python | os.path.join() method
Create a directory in Python
JavaScript string.slice() Method - GeeksforGeeks

06 Oct, 2021
Below is the example of the string.slice() Method.  
Example:  
javascript
<script>                        var A = 'Geeks for Geeks';     b = A.slice(0,5);    c = A.slice(6,9);    d = A.slice(10);      document.write(b +"<br>");    document.write(c +"<br>");    document.write(d +"<br>");     </script>
Output:  
Geeks
for
Geeks
The string.slice() is an inbuilt method in javascript which is used to return a part or slice of the given input string.Syntax:  
string.slice(startingindex, endingindex)
Parameter: This method uses two-parameter startingindex( from which index, the string should be started) and endingindex (before which index, the string should be included).Return Values: It returns a part or a slice of the given input string.JavaScript code to show the working of the string.slice() method: Code #1:  
javascript
<script>                        // Taking a string as input.   var A = 'Ram is going to school';       // Calling of slice() function.   b = A.slice(0, 5);    // Here starting index is 1 given   // and ending index is not given to it so   // it takes to the end of the string    c = A.slice(1);       // Here endingindex is -1 i.e, second last character   // of the given string.   d = A.slice(3, -1);   e = A.slice(6);   document.write(b +"<br>");   document.write(c +"<br>");   document.write(d +"<br>");   document.write(e);       </script>
Output:  
Ram i
am is going to school
is going to schoo
going to school
Code #2:  
javascript
<script>       // Taking a string as input.    var A = 'Geeks for Geeks';     // Calling of slice() function.    // Here starting index is -1 given    b = A.slice(-1,5);    // Here endingindex is -1 i.e    c = A.slice(0,-1);     document.write(b +"<br>");    document.write(c +"<br>");     </script>
Output:  
Geeks for Geek
 
Supported Browser:
Chrome 1 and above
Edge 12 and above
Firefox 1 and above
Internet Explorer 4 and above
Opera 4 and above
safari 1 and above
ysachin2314
JavaScript-Methods
javascript-string
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
Convert a string to an integer in JavaScript
Differences between Functional Components and Class Components in React
Difference Between PUT and PATCH Request
How to Use the JavaScript Fetch API to Get Data?
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?
Math.DivRem() Method in C#

The Math.DivRem() method in C# is used to divide and calculate the quotient of two numbers and also returns the remainder in an output parameter.
public static int DivRem (int dividend, int divisor, out int remainder);
public static long DivRem (long dividend, long divisor, long remainder);
Let us now see an example to implement Math.DivRem() method −
using System;
public class Demo {
   public static void Main(){
      int dividend = 30;
      int divisor = 7;
      int remainder;
      int quotient = Math.DivRem(dividend, divisor, out remainder);
      Console.WriteLine("Quotient = "+quotient);
      Console.WriteLine("Remainder = "+remainder);
   }
}
This will produce the following output −
Quotient = 4
Remainder = 2
Let us see another example to implement Math.DivRem() method −
using System;
public class Demo {
   public static void Main(){
      long dividend = 767676765765765;
      long divisor = 7;
      long remainder;
      long quotient = Math.DivRem(dividend, divisor, out remainder);
      Console.WriteLine("Quotient = "+quotient);
      Console.WriteLine("Remainder = "+remainder);
   }
}
This will produce the following output −
Quotient = 109668109395109
Remainder = 2
numpy.swapaxes

This function interchanges the two axes of an array. For NumPy versions after 1.10, a view of the swapped array is returned. The function takes the following parameters.
numpy.swapaxes(arr, axis1, axis2)

Where,
arr
Input array whose axes are to be swapped
axis1
An int corresponding to the first axis
axis2
An int corresponding to the second axis
# It creates a 3 dimensional ndarray 
import numpy as np 
a = np.arange(8).reshape(2,2,2) 

print 'The original array:' 
print a 
print '\n'  
# now swap numbers between axis 0 (along depth) and axis 2 (along width) 

print 'The array after applying the swapaxes function:' 
print np.swapaxes(a, 2, 0)
Its output would be as follows −
The original array:
[[[0 1]
 [2 3]]

 [[4 5]
  [6 7]]]

The array after applying the swapaxes function:
[[[0 4]
 [2 6]]
 
 [[1 5]
  [3 7]]]


    63 Lectures 
     6 hours 

 Abhilash Nelson

    19 Lectures 
     8 hours 

 DATAhill Solutions Srinivas Reddy

    12 Lectures 
     3 hours 

 DATAhill Solutions Srinivas Reddy

    10 Lectures 
     2.5 hours 

 Akbar Khan

    20 Lectures 
     2 hours 

 Pruthviraja L

    63 Lectures 
     6 hours 

 Anmol
 Print
 Add Notes
 Bookmark this page
Matplotlib - PyLab module

PyLab is a procedural interface to the Matplotlib object-oriented plotting library. Matplotlib is the whole package; matplotlib.pyplot is a module in Matplotlib; and PyLab is a module that gets installed alongside Matplotlib.
PyLab is a convenience module that bulk imports matplotlib.pyplot (for plotting) and NumPy (for Mathematics and working with arrays) in a single name space. Although many examples use PyLab, it is no longer recommended.
Plotting curves is done with the plot command. It takes a pair of same-length arrays (or sequences) −
from numpy import *
from pylab import *
x = linspace(-3, 3, 30)
y = x**2
plot(x, y)
show()
The above line of code generates the following output −
To plot symbols rather than lines, provide an additional string argument.
Now, consider executing the following code −
from pylab import *
x = linspace(-3, 3, 30)
y = x**2
plot(x, y, 'r.')
show()
It plots the red dots as shown below −
Plots can be overlaid. Just use the multiple plot commands. Use clf() to clear the plot.
from pylab import *
plot(x, sin(x))
plot(x, cos(x), 'r-')
plot(x, -sin(x), 'g--')
show()
The above line of code generates the following output −

    63 Lectures 
     6 hours 

 Abhilash Nelson

    11 Lectures 
     4 hours 

 DATAhill Solutions Srinivas Reddy

    9 Lectures 
     2.5 hours 

 DATAhill Solutions Srinivas Reddy

    32 Lectures 
     4 hours 

 Aipython

    10 Lectures 
     2.5 hours 

 Akbar Khan

    63 Lectures 
     6 hours 

 Anmol
 Print
 Add Notes
 Bookmark this page
Python – Remove Duplicate Dictionaries characterized by Key

01 Aug, 2020
Given a list of dictionaries, remove all the dictionaries which are duplicate with respect to K key.
Input : test_list = [{“Gfg” : 6, “is” : 9, “best” : 10}, {“Gfg” : 8, “is” : 11, “best” : 10}, {“Gfg” : 2, “is” : 16, “best” : 10}], K = “best”Output : [{“Gfg” : 6, “is” : 9, “best” : 10}]Explanation : All keys have 10 value, only 1st record is retained.
Input : test_list = [{“Gfg” : 6, “is” : 9, “best” : 10}, {“Gfg” : 8, “is” : 11, “best” : 12}, {“Gfg” : 2, “is” : 16, “best” : 15}], K = “best”Output : [{“Gfg” : 6, “is” : 9, “best” : 10}, {“Gfg” : 8, “is” : 11, “best” : 12}, {“Gfg” : 2, “is” : 16, “best” : 15}]Explanation : All values of “best” are unique, hence no removal of dictionaries.
Method : Using loop 
This is brute way in which this task can be performed. In this, we iterate for each dictionary and memoize the Key, if similar key’s same value occur, then that dictionary is avoided in resultant list of dictionaries.
Python3
# Python3 code to demonstrate working of # Remove Duplicate Dictionaries characterized by Key# Using loop  # initializing liststest_list = [{"Gfg" : 6, "is" : 9, "best" : 10},              {"Gfg" : 8, "is" : 11, "best" : 19},             {"Gfg" : 2, "is" : 16, "best" : 10},             {"Gfg" : 12, "is" : 1, "best" : 8},             {"Gfg" : 22, "is" : 6, "best" : 8}]  # printing original listprint("The original list : " + str(test_list))  # initializing Key K = "best"  memo = set()res = []for sub in test_list:          # testing for already present value    if sub[K] not in memo:        res.append(sub)                  # adding in memo if new value        memo.add(sub[K])      # printing result print("The filtered list : " + str(res))
The original list : [{‘Gfg’: 6, ‘is’: 9, ‘best’: 10}, {‘Gfg’: 8, ‘is’: 11, ‘best’: 19}, {‘Gfg’: 2, ‘is’: 16, ‘best’: 10}, {‘Gfg’: 12, ‘is’: 1, ‘best’: 8}, {‘Gfg’: 22, ‘is’: 6, ‘best’: 8}]The filtered list : [{‘Gfg’: 6, ‘is’: 9, ‘best’: 10}, {‘Gfg’: 8, ‘is’: 11, ‘best’: 19}, {‘Gfg’: 12, ‘is’: 1, ‘best’: 8}]
Python dictionary-programs
Python
Python Programs
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