code-rag-bench/online-tutorials huggingface dataset:
How to build an array of all combinations of two NumPy arrays?

05 Sep, 2020
Sometimes we need to find the combination of elements of two or more arrays. Numpy has a function to compute the combination of 2 or more Numpy arrays named as “numpy.meshgrid()“. This function is used to create a rectangular grid out of two given one-dimensional arrays representing the Cartesian indexing or Matrix indexing.
Syntax:
numpy.meshgrid(*xi, copy=True, sparse=False, indexing='xy')

Example 1: Computing combinations of elements of Two NumPy arrays
Python3
# importing Numpy packageimport numpy as np  # creating 2 numpy arraysarray_1 = np.array([1, 2])array_2 = np.array([4, 6])  print("Array-1")print(array_1)  print("\nArray-2")print(array_2)  # combination of elements of array_1 and array_2# using numpy.meshgrid().T.reshape()comb_array = np.array(np.meshgrid(array_1, array_2)).T.reshape(-1, 2)  print("\nCombine array:")print(comb_array)
Output:
In the above example, we combine elements of ‘array_1‘ and ‘array_2‘ using numpy.meshgrid().T.reshape() 
Example 2: Computing combinations of elements of Three NumPy arrays
Python3
# importing Numpy packageimport numpy as np  # creating 3 numpy arraysarray_1 = np.array([1, 2, 3])array_2 = np.array([4, 6, 4])array_3 = np.array([3, 6])  print("Array-1")print(array_1)  print("Array-2")print(array_2)  print("Array-3")print(array_3)    # combination of elements of array_1,# array_2 and array_3 using # numpy.meshgrid().T.reshape()comb_array = np.array(  np.meshgrid(array_1, array_2, array_3)).T.reshape(-1, 3)  print("\nCombine array:")print(comb_array)
Output:
In the above example, we combine elements of ‘array_1‘, ‘array_2‘ and ‘array_3‘ using numpy.meshgrid().T.reshape()
Example 3: Computing combinations of elements of Four NumPy arrays
Python3
# importing Numpy packageimport numpy as np  # creating 4 numpy arraysarray_1 = np.array([50, 21])array_2 = np.array([4, 4])array_3 = np.array([1, 10])array_4 = np.array([7, 14])    print("Array-1")print(array_1)  print("Array-2")print(array_2)  print("Array-3")print(array_3)  print("Array-4")print(array_4)    # combination of elements of array_1, # array_2, array_3 and array_4# using numpy.meshgrid().T.reshape()comb_array = np.array(np.meshgrid(    array_1, array_2, array_3, array_4)).T.reshape(-1, 4)  print("\nCombine array:")print(comb_array)
Output:
In the above example, we combine elements of ‘array_1‘, ‘array_2‘, ‘array_3‘ and ‘array_4‘ using numpy.meshgrid().T.reshape()
Python numpy-arrayCreation
Python-numpy
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 | os.path.join() method
Introduction To PYTHON
Python OOPs Concepts
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 | Get unique values from a list
Create a directory in Python
Python | Replace multiple occurrence of character by single

29 Dec, 2020
Given a string and a character, write a Python program to replace multiple occurrences of the given character by a single character.
Examples:
Input : Geeksforgeeks, ch = 'e'
Output : Geksforgeks

Input : Wiiiin, ch = 'i'
Output : Win

 
Approach #1 : Naive ApproachThis method is a brute force approach in which we take another list ‘new_str’. Use a for loop to check if the given character is repeated or not. If repeated multiple times, append the character single time to the list. Other characters(Not the given character) are simply appended to the list without any alteration.
# Python program to replace multiple # occurrences of a character by a single character  def replace(s, ch):    new_str = []    l = len(s)          for i in range(len(s)):        if (s[i] == ch and i != (l-1) and           i != 0 and s[i + 1] != ch and s[i-1] != ch):            new_str.append(s[i])                      elif s[i] == ch:            if ((i != (l-1) and s[i + 1] == ch) and               (i != 0 and s[i-1] != ch)):                new_str.append(s[i])                          else:            new_str.append(s[i])              return ("".join(i for i in new_str))    # Driver code s = 'Geeksforgeeks'char = 'e'print(replace(s, char))
Geksforgeks

 Approach #2 : Using Python Regex
import re  # Function to replace multiple occurrences  # of a character by a single characterdef replace(string, char):    pattern = char + '{2,}'    string = re.sub(pattern, char, string)    return string  # Driver code string = 'Geeksforgeeks'char = 'e'print(replace(string, char))
Geksforgeks

Python Regex-programs
python-regex
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Floating point error in Python

11 Nov, 2019
As it is know that 1.2 - 1.0 = 0.2 . But when you try to the same in python you will surprised by results:
>>> 1.2 - 1.0

Output:
0.199999999999999996
This can be considered as a bug in Python, but it is not. This has little to do with Python, and much more to do with how the underlying platform handles floating-point numbers. It’s a normal case encountered when handling floating-point numbers internally in a system. It’s a problem caused when the internal representation of floating-point numbers, which uses a fixed number of binary digits to represent a decimal number. It is difficult to represent some decimal number in binary, so in many cases, it leads to small roundoff errors.
We know similar cases in decimal math, there are many results that can’t be represented with a fixed number of decimal digits,Example
10 / 3 = 3.33333333.......
In this case, taking 1.2 as an example, the representation of 0.2 in binary is 0.00110011001100110011001100...... and so on.It is difficult to store this infinite decimal number internally. Normally a float object’s value is stored in binary floating-point with a fixed precision (typically 53 bits).
So we represent 1.2 internally as,
1.0011001100110011001100110011001100110011001100110011  
Which is exactly equal to :
1.1999999999999999555910790149937383830547332763671875
Still, you thinking why python is not solving this issue, actually it has nothing to do with python. It happens because it is the way the underlying c platform handles floating-point numbers and ultimately with the inaccuracy, we’ll always have been writing down numbers as a string of fixed number of digits.
Note that this is in the very nature of binary floating-point: this is not a bug either in Python or C, and it is not a bug in your code either. You’ll see the same kind of behaviors in all languages that support our hardware’s floating-point arithmetic although some languages may not display the difference by default, or in all output modes). We have to consider this behavior when we do care about math problems with needs exact precisions or using it inside conditional statements.Check floating point section in python documentation for more such behaviours.
Compiler Design
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Directed Acyclic graph in Compiler Design (with examples)
Type Checking in Compiler Design
Data flow analysis in Compiler
S - attributed and L - attributed SDTs in Syntax directed translation
Runtime Environments in Compiler Design
Read JSON file using Python
Adding new column to existing DataFrame in Pandas
Python map() function
How to get column names in Pandas dataframe
How to populate XDocument from String in C#?

XML is a self-describing language and it gives the data as well as the rules to identify what information it contains. Like HTML, XML is a subset of SGML - Standard
Generalized Markup Language.
The XDocument class contains the information necessary for a valid XML document.
This includes an XML declaration, processing instructions, and comments.
Note that we only have to create XDocument objects if we require the specific
functionality provided by the XDocument class. In many circumstances, we can work
directly with XElement. Working directly with XElement is a simpler programming
model.
XDocument derives from XContainer. Therefore, it can contain child nodes. However, XDocument objects can have only one child XElement node. This reflects the XML standard that there can be only one root element in an XML document. The XDocument is available in System.Xml.Linq namespace.
Let us consider below string which is in XML format and need to be populated as
XML.
<Departments>
   <Department>Account</Department>
   <Department>Sales</Department>
   <Department>Pre-Sales</Department>
   <Department>Marketing</Department>
</Departments>
using System;
using System.Xml.Linq;
namespace DemoApplication{
   public class Program{
      public static void Main(){
         string xmlString = @"<Departments>
            <Department>Account</Department>
            <Department>Sales</Department>
            <Department>Pre-Sales</Department>
            <Department>Marketing</Department>
         </Departments>";
         XDocument xml = XDocument.Parse(xmlString);
         Console.ReadLine();
      }
   }
}
Similarly, if we want to convert a file containing xml to XDocument we can use XDocument.Load(path).
using System;
using System.Xml.Linq;
namespace DemoApplication{
   public class Program{
      public static void Main(){
         string xmlPath = @"D:\DemoXml.txt";
         XDocument xml = XDocument.Load(xmlPath);
         Console.ReadLine();
      }
   }
}
In both the above cases the xmlString is converted to Xdocumet like below.
time.Month.String() Function in Golang With Examples - GeeksforGeeks

21 Apr, 2020
In Go language, time packages supplies functionality for determining as well as viewing time. The Month.String() function in Go language is used to find the English name of the month. Moreover, this function is defined under the time package. Here, you need to import the “time” package in order to use these functions.
Syntax:
func (m Month) String() string

Here, “m” is the type Month.
Return Value: It returns a string which is the English name of the month.
Example 1:
// Golang program to illustrate the usage of// (Month) String() function  // Including main packagepackage main  // Importing fmt and timeimport "fmt"import "time"  // Calling mainfunc main() {      // Calling time.Month    // with its parameter    // of type int    var m = time.Month(2)      // Prints the English     // name of the month    fmt.Println(m.String())}
Output:
February

Example 2:
// Golang program to illustrate the usage of// (Month) String() function  // Including main packagepackage main  // Importing fmt and timeimport "fmt"import "time"  // Calling mainfunc main() {      // Calling time.Month    // with its parameter    // of type int    var m = time.Month(12)      // Prints the English name of     // the month    fmt.Println(m.String())}
Output:
December

GoLang-time
Go Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Strings in Golang
Time Durations in Golang
How to Parse JSON in Golang?
6 Best Books to Learn Go Programming Language
Structures in Golang
Defer Keyword in Golang
How to iterate over an Array using for loop in Golang?
Rune in Golang
Class and Object in Golang
Loops in Go Language
HTML | DOM toggleAttribute() Method - GeeksforGeeks

29 May, 2020
The toggleAttribute() method of the element interface toggles a Boolean attribute on the given element. Attributes of an element can be changed using this method.
Syntax:
Element.toggleAttribute("attribute_name");

Parameters: 
Name_of_attribute: Name of the attribute to be toggled. The attribute name is automatically converted to all lower-case when toggleAttribute() is called on an HTML element in an HTML document.
Return Value: It returns true if attribute name is present, false otherwise.
Example: In this example, we will toggle attribute of input element to readonly. The attribute name is automatically converted to all lower-case when toggleAttribute() is called on an HTML element in an HTML document.
<!DOCTYPE html><html lang="en">  <head>    <meta charset="UTF-8">    <title>ToggleAttribute</title>    <script>          function change() {            var input =             document.querySelector("input");                          input.toggleAttribute("readonly");        }    </script></head>  <body>    <h1>GeeksforGeeks</h1>    <input class="input"         value="This is editable">      <button onclick="change()">        Click to change attribute    </button></body>  </html>
Output:
In this output, you can see that after clicking on button , attribute of input element changes to “readonly”, Hence it becomes uneditable.
Supported Browsers: The browsers supported by DOM toggleAttribute() method are listed below:
Google Chrome
Firefox
Apple Safari
Opera
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
HTML-DOM
HTML-Methods
HTML
JavaScript
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to update Node.js and NPM to next version ?
REST API (Introduction)
How to Insert Form Data into Database using PHP ?
CSS to put icon inside an input element in a form
Types of CSS (Cascading Style Sheet)
Remove elements from a JavaScript Array
Convert a string to an integer in JavaScript
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
How to calculate the number of days between two dates in javascript?
Month of() method in Java - GeeksforGeeks

22 Mar, 2019
The of() method is a built-in method of the Month ENUM which is used to generate a Month instance from an integer value. The integer value should be in the range 1-12 representing any of the 12 months and the method generates a Month instance from it representing a month-of-year.
Syntax:
public static Month of(int month)

Parameters: This method accepts a single parameter month, which is of integer type.
Return Value: This method returns the corresponding Month instance generated using the parameter passed.
Exception: This method throws a DateTimeException if the month of year passed to the parameter is not valid.
Below programs illustrate the above method:
Program 1:
import java.time.*;import java.time.Month;import java.time.temporal.ChronoField;  class monthEnum {    public static void main(String[] args)    {        // Create a month instance        Month month = Month.of(2);          // Print the month Instance        System.out.println(month);    }}
FEBRUARY

Program 2:
import java.time.*;import java.time.Month;import java.time.temporal.ChronoField;  class monthEnum {    public static void main(String[] args)    {        // Create a month instance        Month month = Month.of(12);          // Print the month Instance        System.out.println(month);    }}
DECEMBER

Reference: https://docs.oracle.com/javase/8/docs/api/java/time/Month.html#of-int-
Java-Functions
Java-Month
Java-time package
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Object Oriented Programming (OOPs) Concept in Java
HashMap in Java with Examples
Stream In Java
Interfaces in Java
How to iterate any Map in Java
ArrayList in Java
Initialize an ArrayList in Java
Stack Class in Java
Multidimensional Arrays in Java
Singleton Class in Java
ASP Full Form - GeeksforGeeks

20 Oct, 2021
ASP stands for active server pages and it is a server-side script engine for building web pages. ASP is basically a server page that contains embedded programs in it. The programs in it are processed on the Microsoft server. The ASP server-side engine basically performs the task of reading and executing the ASP file and then return the file to the browser. It is basically a web-based framework that helps programmers to build dynamic web pages. ASP can contain scripts as well as standard HTML.History: ASP was firstly introduced in December 1996 as part of IIS (Internet information services) 3.0 which was called ASP 1.0. Then its subsequent versions came in 1997 and 2000 named ASP 2.0 and ASP 3.0 respectively. ASP 3.0 had some additional features so ASP 3.0 increased its performance.Syntax:  
html
<html>    <head>        <title>ASP page</title>    </head>    <body>        <% response.write("Welcome to GeeksForGeeks!") %>    </body></html>
Output 
Welcome to GeeksForGeeks
Characteristics: 
User Control: The creation of user controls supports the making of reusable components.
Custom Controls: We can make custom controls from ASP. Here the code is compiled into a Dynamic Link Library file.
Rendering Techniques: ASP uses visited composite rendering technique in which composite tree is built.
Code-Behind Model: Microsoft recommends to use the code-behind model for dealing with dynamic program code.
Use of ASP: ASP is mainly used because of its high speed, language-independent nature, and low cost. We can make ASP pages in any language so it is not dependent on a particular language. It is used to develop dynamic websites in a more efficient way. 
Advantages:  
ASP reduces the line of code for building the complex applications.
It has smart caching technologies.
ASP is language independent so any language can be used for coding it.
ASP is much faster than other applications.
ASP is more used now-a-days.
Disadvantages: 
There is a lot of complexity in pages and there are many performance issues.
It is dependent on IIS(Internet information services) so it is problematic.
It has limited development and debugging tools.
There is no real state management in ASP.
 
pp_pankaj
hritikbhatnagar2182
Full Form
Web Technologies
Web technologies Questions
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
CDMA Full Form
SCTP Full Form
RSA Full Form
Peripheral Component Interconnect (PCI)
FDDI Full Form
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?
Python | Custom List slicing Sum - GeeksforGeeks

18 Feb, 2020
The problem of slicing a list has been dealt earlier, but sometimes we need to perform the slicing in variable lengths and its summation according to the input given in other list. This problem has its potential application in web development. Let’s discuss certain ways in which this can be done.
Method #1 : Using itertools.islice() + sum() + list comprehensionThe list comprehension can be used to iterate through the list and the component issue is solved using the islice function. Summation is performed by sum().
# Python3 code to demonstrate# Custom List slicing Sum# using itertools.islice() + sum() + list comprehensionfrom itertools import islice  # initializing test listtest_list = [1, 5, 3, 7, 8, 10, 11, 16, 9, 12]  # initializing slice list slice_list = [2, 1, 3, 4]  # printing original list print("The original list : " + str(test_list))  # printing slice list print("The slice list : " + str(slice_list))  # using itertools.islice() + sum() + list comprehension# Custom List slicing Sumtemp = iter(test_list)res = [sum(list(islice(temp, part))) for part in slice_list]  # print resultprint("The variable sliced sum list is : " + str(res))
The original list : [1, 5, 3, 7, 8, 10, 11, 16, 9, 12]
The slice list : [2, 1, 3, 4]
The variable sliced sum list is : [6, 3, 25, 48]

 
Method #2 : Using zip() + accumulate() + sum() + list slicingApart from using the list comprehension to perform the task of binding, this method uses zip function to hold sublist element together, accumulate function joins the elements, and slicing is used to construct the required slicing. Summation is performed by sum().
# Python3 code to demonstrate# Custom List slicing Sum# using zip() + accumulate() + sum() + list slicingfrom itertools import accumulate  # initializing test listtest_list = [1, 5, 3, 7, 8, 10, 11, 16, 9, 12]  # initializing slice list slice_list = [2, 1, 3, 4]  # printing original list print("The original list : " + str(test_list))  # printing slice list print("The slice list : " + str(slice_list))  # using zip() + accumulate() + sum() + list slicing# Custom List slicing Sumres = [sum(test_list[i - j: i]) for i, j in zip(accumulate(slice_list), slice_list)]  # print resultprint("The variable sliced sum list is : " + str(res))
The original list : [1, 5, 3, 7, 8, 10, 11, 16, 9, 12]
The slice list : [2, 1, 3, 4]
The variable sliced sum list is : [6, 3, 25, 48]

Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Read a file line by line in Python
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Python program to convert a list to string
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Split string into list of characters
Python | Convert a list to dictionary
Get number of elements of array in Julia - length() Method - GeeksforGeeks

26 Mar, 2020
The length() is an inbuilt function in julia which is used to return the number of elements present in the specified array.
Syntax: length(A::AbstractArray)
Parameters:
A: Specified array
Returns: It returns the number of elements present in the specified array.
Example 1:
# Julia program to illustrate # the use of Array length() method   # Finding the number of elements present in# the specified 1D array A.A = [5, 10, 15, 20]println(length(A))   # Finding the number of elements present in# the specified 2D array B of size 2 * 2B = [5 10; 15 20]println(length(B))   # Finding the number of elements present in# the specified 3D array C of size 2 * 2*2C = cat([1 2; 3 4], [5 6; 7 8],        [9 10; 11 12], dims = 3)println(length(C))
Output:
Example 2:
# Julia program to illustrate # the use of Array length() method    # Finding the number of elements present in# the specified 1D array A.A = [1, 2, 3];println(length(A))    # Finding the number of elements present in# the specified 2D array B of size 2 * 2B = [2 4; 6 8; 10 12];println(length(B))    # Finding the number of elements present in# the specified 3D array C of size 2 * 2*2C = cat([1 2; 3 4], [5 6; 7 8],         [9 10; 11 12], [13 14; 15 16], dims = 4);println(length(C))
Output:
Julia
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Decision Making in Julia (if, if-else, Nested-if, if-elseif-else ladder)
Get array dimensions and size of a dimension in Julia - size() Method
Exception handling in Julia
Searching in Array for a given element in Julia
Find maximum element along with its index in Julia - findmax() Method
Join an array of strings into a single string in Julia - join() Method
Working with Excel Files in Julia
File Handling in Julia
Getting last element of an array in Julia - last() Method
Getting the maximum value from a list in Julia - max() Method
PLSQL | RTRIM Function - GeeksforGeeks

04 Feb, 2021
The PLSQL RTRIM function is used for removing all specified characters from the right-hand side of a string. The PLSQL RTRIM function accepts two parameters which are input_string and trim_string. 
If the user does not specify trim_string, it defaults to a single blank. 
If char is a character literal, then you must enclose it in single quotes. 
Oracle Database begins scanning char from its first character and removes all characters that appear in trim_string until reaching a character not in trim_string and then returns the result. 
Syntax:  
RTRIM( input_string [, trim_string] )
Parameters Used:  
input_string – It is used to specify the string whose characters need to be trimmed from the right hand side.trim_string – It is an optional parameter which is used to specify the string that will be removed from the right-hand side of input_string. If this parameter is omitted, the RTRIM function removes all leading spaces from input_string. 
input_string – It is used to specify the string whose characters need to be trimmed from the right hand side.
trim_string – It is an optional parameter which is used to specify the string that will be removed from the right-hand side of input_string. If this parameter is omitted, the RTRIM function removes all leading spaces from input_string. 
Supported Versions of Oracle/PLSQL:  
Oracle 12cOracle 11gOracle 10gOracle 9iOracle 8i
Oracle 12c
Oracle 11g
Oracle 10g
Oracle 9i
Oracle 8i
Example-1:  
DECLARE 
   Test_String string(25) := 'Geeksforgeeks    ';
   
BEGIN 
   dbms_output.put_line(RTRIM(Test_String)); 
   
END;   
Output:  
Geeksforgeeks 
Example-2:  
DECLARE 
   Test_String string(25) := 'Geeksforgeeks      ';
   
BEGIN 
   dbms_output.put_line(RTRIM(Test_String, ' ')); 
   
END;   
Output:  
Geeksforgeeks 
Example-3:  
DECLARE 
   Test_String string(25) := 'Geeksforgeeks123';
   
BEGIN 
   dbms_output.put_line(RTRIM(Test_String, '123')); 
   
END; 
Output:  
Geeksforgeeks 
Example-4:  
DECLARE 
   Test_String string(25) := 'Geeksforgeeks123123';
   
BEGIN 
   dbms_output.put_line(RTRIM(Test_String, '123')); 
   
END;   
Output:  
Geeksforgeeks 
Example-5:  
DECLARE 
   Test_String string(25) := 'Geeks123forgeeks123';
   
BEGIN 
   dbms_output.put_line(RTRIM(Test_String, '123')); 
   
END;    
Output:  
Geeks123forgeeks 
 
simranarora5sos
SQL-PL/SQL
SQL
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?
How to Create a Table With Multiple Foreign Keys in SQL?
What is Temporary Table in SQL?
SQL | Subquery
SQL Query to Find the Name of a Person Whose Name Starts with Specific Letter
SQL Query to Convert VARCHAR to INT
SQL using Python
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
map::size() in C++ STL - GeeksforGeeks

27 Dec, 2018
Maps are associative containers that store elements in a mapped fashion. Each element has a key value and a mapped value. No two mapped values can have same key values.
map::size()In C++, size() function is used to return the total number of elements present in the map.
Syntax:
map_name.size()

Return Value: It returns the number of elements present in the map.
Examples:
Input : map1 = { 
                {1, "India"},
                {2, "Nepal"},
                {3, "Sri Lanka"},
                {4, "Myanmar"}
               }
        map1.size();
Output: 4

Input : map2 = {};
        map2.size();
Output: 0

// C++ program to illustrate// implementation of size() function#include <bits/stdc++.h>using namespace std;  int main(){    // Take any two maps    map<int, string> map1, map2;          // Inserting values    map1.insert(make_pair(1, "India"));    map1.insert(make_pair(2, "Nepal"));    map1.insert(make_pair(3, "Sri Lanka"));    map1.insert(make_pair(4, "Myanmar"));          // Printing the size    cout << "map1 size: " << map1.size();    cout << endl;    cout << "map2 size: " << map2.size();    return 0;}
Output:
map1 size: 4
map2 size: 0

Time complexity: Constant i.e. O(1)
vaibhavch9876
cpp-map
STL
C++
STL
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Operator Overloading in C++
Polymorphism in C++
Friend class and function in C++
Sorting a vector in C++
std::string class in C++
Pair in C++ Standard Template Library (STL)
Inline Functions in C++
Queue in C++ Standard Template Library (STL)
Array of Strings in C++ (5 Different Ways to Create)
Convert string to char array in C++
numpy.lcm() in Python - GeeksforGeeks

29 Nov, 2018
numpy.lcm(arr1, arr2, out = None, where = True, casting = ‘same_kind’, order = ‘K’, dtype = None) : This mathematical function helps user to calculate lcm value of |arr1| and |arr2| elements.
Parameters :arr1 / arr2 : [array_like]Input array.
Return : LCM of two or more numbers.
Code :
# Python program illustrating # lcm() method import numpy as np   arr1 = [120, 24, 42, 10]arr2 = [2250, 12, 20, 50]  print ("arr1 : ", arr1)print ("arr2 : ", arr2)  print ("\nlcm of arr1 and arr2 : ", np.lcm(arr1, arr2))print ("\nlcm of arr1 and 10   : ", np.lcm(arr1, 10))                     
Output :
arr1 : [120, 24, 42, 10]
arr2 : [2250, 12, 20, 50]

lcm of arr1 and arr2 : [9000,   24,  420,   50]

lcm of arr1 and 10   : [120, 120, 210,  10]

Python numpy-Mathematical Function
Python-numpy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Python String | replace()
*args and **kwargs in Python
Reading and Writing to text files in Python
Create a Pandas DataFrame from Lists
Convert integer to string in Python
Check if element exists in list in Python
Count number of ways to divide a number in parts in C++

We are given a positive number N. The goal is to count the number of ways in which the number N can be divided into 3 parts. The parts may or may not be equal. N lies in range [1,5000].
We will do this by using three for loops for 3 parts of the number. Check at the innermost loop that the sum of all three is equal to N. If true, then increment the count of ways.
Let’s understand with examples.
Input − N=5
Output − Number of ways to divide N in 3 parts: 2
Explanation − 5 can be shown as sum of (1,1,3) and (1,2,2)
Input − N=9
Output − Number of ways to divide N in 3 parts: 7
Explanation − 9 can be shown as sum of : (1, 1, 7), (1, 2, 6), (1, 3, 5), (1, 4, 4), (2, 2, 5), (2, 3,4) and (3, 3, 3).
We take an integer N initialized with a value between 1 and 5000.
We take an integer N initialized with a value between 1 and 5000.
Function divideN(int n) takes n and returns the number of ways in which n can be divided into 3 parts.
Function divideN(int n) takes n and returns the number of ways in which n can be divided into 3 parts.
Take the initial variable count as 0 for the number of ways.
Take the initial variable count as 0 for the number of ways.
Traverse using three for loops for each part of the number.
Traverse using three for loops for each part of the number.
Outermost loop from 1<=i<n, inner loop i<=j<n , innermost j<=k<n.
Outermost loop from 1<=i<n, inner loop i<=j<n , innermost j<=k<n.
Check if the sum of i, j and k is equal to n . If true then increment count.
Check if the sum of i, j and k is equal to n . If true then increment count.
At the end of all loops count will have a total number of ways to divide n in three parts.
At the end of all loops count will have a total number of ways to divide n in three parts.
Return the count as result.
Return the count as result.
 Live Demo
#include <bits/stdc++.h>
using namespace std;
int divideN(int n){
   int count = 0;
   for (int i = 1; i < n; i++){
      for (int j = i ; j < n; j++){
         for (int k = j; k < n; k++){
            int sum=i+j+k;
            if(sum==n)
               { count++; }
         }
      }
   }
   return count;
}
int main(){
   int N=500;
   cout <<endl<< "Number of ways to divide N in 3 parts : "<<divideN(N);
   return 0;
}
If we run the above code it will generate the following output −
Number of ways to divide N in 3 parts: 20833
Check if a doubly linked list of characters is palindrome or not in C++

Here we will see how to check a string is a palindrome or not using a Doubly linked list. Here we will push each character of a string inside one doubly linked list. There will be two pointers, left and right. Then start scanning from both sides. If a left character is the same as right character, then move the left pointer to the next node, and move the right pointer to the previous node. Otherwise, return false. This process will be continued until the left and right are pointing at the same node, or the right pointer is pointing to the previous element of the left pointer.
 Live Demo
#include <iostream>
using namespace std;
class Node {
   public:
   char data;
   Node *next;
   Node *prev;
};
void getNode(Node** start, char new_data) {
   struct Node* newNode = new Node;
   newNode->data = new_data;
   newNode->next = (*start);
   newNode->prev = NULL;
   if ((*start) != NULL)
      (*start)->prev = newNode ;
      (*start) = newNode;
}
bool isPalindrome(Node *left) {
   if (left == NULL)
      return true;
   Node *right = left;
   while (right->next != NULL)
      right = right->next;
   while (left != right && right != left->prev) {
      if (left->data != right->data)
         return false;
      left = left->next;
      right = right->prev;
   }
return true;
}
int main() {
   Node* head = NULL;
   string str = "madam";
   for(int i = 0; i< str.length(); i++){
      getNode(&head, str[i]);
   }
   if (isPalindrome(head))
      cout << "This is Palindrome";
   else
      cout << "This is Not a Palindrome";
}
This is Palindrome
jQuery - load() Method

The load( url, data, callback ) method loads data from the server and places the returned HTML into the matched element.
Here is the simple syntax to use this method −
[selector].load( url, [data], [callback] )

Here is the description of all the parameters used by this method −
url − A string containing the URL to which the request is sent.
url − A string containing the URL to which the request is sent.
data − This optional parameter represents a map of data that is sent with the request.
data − This optional parameter represents a map of data that is sent with the request.
callback − This optional parameter represents a function that is executed if the request succeeds
callback − This optional parameter represents a function that is executed if the request succeeds
Assuming we have following HTML content in result.html file −
<h1>THIS IS RESULT...</h1>

Following is a simple example a simple showing the usage of this method.
<html>
   <head>
      <title>The jQuery Example</title>
      <script type = "text/javascript" 
         src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js">
      </script>
		
      <script type = "text/javascript" language = "javascript">
         $(document).ready(function() {
            $("#driver").click(function(event){
               $('#stage').load('result.html');
            });
         });
      </script>
   </head>
	
   <body>
      <p>Click on the button to load result.html file:</p>
		
      <div id = "stage" style = "background-color:cc0;">
         STAGE
      </div>
		
      <input type = "button" id = "driver" value = "Load Data" />
   </body>
</html>
This should produce following result −
Click on the button to load result.html file −

    27 Lectures 
     1 hours 

 Mahesh Kumar

    27 Lectures 
     1.5 hours 

 Pratik Singh

    72 Lectures 
     4.5 hours 

 Frahaan Hussain

    60 Lectures 
     9 hours 

 Eduonix Learning Solutions

    17 Lectures 
     2 hours 

 Sandip Bhattacharya

    12 Lectures 
     53 mins

 Laurence Svekis
 Print
 Add Notes
 Bookmark this page
bitset::flip() in C++ STL - GeeksforGeeks

06 Jun, 2020
bitset::flip() is a built-in STL in C++ which flips the bits. If no parameter is passed in the function, then it flips all the bit values converting zeros to ones and ones to zeros. If a parameter position is passed, it flips the bit at the position only.
Syntax:
bitset_name.flip(int pos)

Parameter: The function accepts a parameter pos which is not mandatory. If a parameter pos is passed, it flips the bit at the index pos only(the index pos is calculated starting from the right). In case no parameter is passed, it flips all the bit values converting zeros to ones and ones to zeros.
Return Value: The function flips all the bit values according to the parameter passed or not and returns the new binary representation of the number.
Below programs illustrates the bitset::flip() function.
Program 1:
// CPP program to illustrate the// bitset::flip() function// when no parameter is passed#include <bits/stdc++.h>using namespace std;  int main(){    // Initialization of bitset    bitset<4> b1(string("1100"));    bitset<6> b2(string("010010"));      // Printing the bitset after flipping the bits    cout << b1 << " after applying flip() function returns ";    cout << b1.flip() << endl;      cout << b2 << " after applying flip() function returns ";    cout << b2.flip();      return 0;}
0011 after applying flip() function returns 1100
101101 after applying flip() function returns 010010

Program 2:
// CPP program to illustrate the// bitset::flip() function// when parameter is passed  #include <bits/stdc++.h>using namespace std;  int main(){      // Initialization of bitset    bitset<4> b1(string("1100"));    bitset<7> b2(string("0100100"));      // Printing the bitset after flipping the bits    cout << b1 << " after applying flip(3) function returns ";    cout << b1.flip(3) << endl;      cout << b2 << " after applying flip(6) function returns ";    cout << b2.flip(6);      return 0;}
0100 after applying flip(3) function returns 1100
1100100 after applying flip(6) function returns 0100100

koen1
CPP-bitset
CPP-Functions
STL
C++
STL
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Operator Overloading in C++
Polymorphism in C++
Sorting a vector in C++
Friend class and function in C++
Pair in C++ Standard Template Library (STL)
Convert string to char array in C++
List in C++ Standard Template Library (STL)
Iterators in C++ STL
std::string class in C++
Inline Functions in C++
Bootstrap page-header class

Page header is used to add appropriate spacing around the headings on a page.
To use a page header, wrap your heading in a <div> with a class of .page-header −
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <title>Bootstrap Example</title>
      <link href = "/bootstrap/css/bootstrap.min.css" rel = "stylesheet">
      <script src = "/scripts/jquery.min.js"></script>
      <script src = "/bootstrap/js/bootstrap.min.js"></script>
   </head>
   <body>
      <div class = "page-header">
         <h1>
            Header
            <small>Subtext for header</small>
         </h1>
      </div>
      <p>Demo text! Demo text! Demo text! Demo text! Demo text!
         Demo text! Demo text! Demo text! Demo text!
      </p>
   </body>
</html>
How to embed Lua codes in Java?

Lua is probably the most commonly used embedding language that can be integrated or embedded into different major programming languages. There are different projects that does this work of embedding for us, Lua has been embedded into C, C# and Java also.
In this article, we will explore how the embedding of Lua in Java works, and we will also explore the most commonly used project that does this for us.
Embedding Lua with Java simply means the fact we should be able to run the code inside the Lua file with the help of the java commands. Just like how we run a normal Java file with the following command
javac HelloWorld.java
java HelloWorld
or
java HelloWorld
We should be able to replace the .java file with the .lua one.
The most commonly used project for embedding Lua in Java is luaj. The source code is present on this link.
You can clone the repository on your local machine with the help of the following command −
git clone https://github.com/luaj/luaj.git
After cloning, you will be able to find several examples present inside the examples/ directory.
Inside that directory a folder named lua is present and we will use one example from that which is the hello.lua one.
Just type the following command in the terminal −
java -cp luaj-jse-3.0.2.jar lua examples/lua/hello.lua
hello, world

This is how easy it is to embed Lua in Java.
How does the repetition operator work on a tuple in Python?

We are accustomed to using the * symbol to represent multiplication, but when the operand on the left side of the * is a tuple, it becomes the repetition operator. The repetition operator makes multiple copies of a tuple and joins them all together. Tuples can be created using the repetition operator, *. 
numbers = (0,) * 5  # we use the comma to denote that this is a single valued tuple and not an #expression
print numbers
This will give the output −
(0, 0, 0, 0, 0)
[0] is a tuple with one element, 0.  The repetition operator makes 5 copies of this tuple and joins them all together into a single tuple. Another example using multiple elements in the tuple.
numbers = (0, 1, 2) * 3
print numbers
This will give the output −
(0, 1, 2, 0, 1, 2, 0, 1, 2)
What is ROW_NUMBER() in MySQL?

Row_NUMBER() included from MySQL version 8.0. It is a type of window function. This can be
used to assign a sequence number for rows. To understand, create a table with the help of CREATE pcommand −
mysql> CREATE table rowNumberDemo
-> (
-> FirstName varchar(100)
-> );
Query OK, 0 rows affected (0.92 sec)
mysql> INSERT into rowNumberDemo values('john');
Query OK, 1 row affected (0.17 sec)

mysql> INSERT into rowNumberDemo values('john');
Query OK, 1 row affected (0.29 sec)

mysql> INSERT into rowNumberDemo values('Bob');
Query OK, 1 row affected (0.13 sec)

mysql> INSERT into rowNumberDemo values('Smith');
Query OK, 1 row affected (0.17 sec)
We can display all the records with the help of SELECT statement −
mysql> SELECT * from rowNumberDemo;

The following is the output −
+-----------+
| FirstName |
+-----------+
| john      |
| john      |
| Bob       |
| Smith     |
+-----------+
4 rows in set (0.00 sec)
Now, we can use the row_number() to assign a incrementing value for every record −
mysql> SELECT row_number() over ( order by firstName) RowNumberSqeuence,FirstName from rowNumberDemo
-> order by FirstName;
The following is the output −
+-------------------+-----------+
| RowNumberSqeuence | FirstName |
+-------------------+-----------+
| 1                 | Bob       |
| 2                 | john      |
| 3                 | john      |
| 4                 | Smith     |
+-------------------+-----------+
4 rows in set (0.00 sec)
Look at the output, we have assigned a number to every record with the help of row_number().
Is there a difference between copy initialization and direct initialization in C++?

The Copy initialization can be done using the concept of copy constructor. As we know that the constructors are used to initialize the objects. We can create our copy constructor to make a copy of some other object, or in other words, initialize current object with the value of another object. On the other hand, the direct initialization can be done using assignment operation.
The main difference between these two types of initialization is that the copy initialization creates a separate memory block for the new object. But the direct initialization does not make new memory space. It uses reference variable to point to the previous memory block.
classname (const classname &obj) {
   // body of constructor
}
classname Ob1, Ob2;
Ob2 = Ob1;
Let us see the detailed differences between Copy initialization and Direct initialization.
Write a program to calculate pow(x,n) in C++

In this problem, we are given two integers x and n. Our task is to write a program to calculate the pow(x,n).
Let’s take an example to understand the problem,
x = 5 , n = 3
125
Program to calculate the pow(x,n),
 Live Demo
#include <iostream>
using namespace std;
float myPow(float x, int y) {
   if(y == 0)
      return 1;
   float temp = myPow(x, y / 2);
   if (y % 2 == 0)
      return temp*temp;
   else {
      if(y > 0)
         return x*temp*temp;
      else
         return (temp*temp)/x;
   }
}
int main() {
   float x = 5;
   int n = 7;
   cout<<x<<" raised to the power "<<n<<" is "<<myPow(x, n);
   return 0;
}
5 raised to the power 7 is 78125
The program shows an efficient approach by dividing the power into half and then multipling the two half and also considers the negative cases.
How to add a PHP page to WordPress? - GeeksforGeeks

05 Aug, 2020
WordPress is one of the best blogging platforms. This is the scenario, we have a custom PHP page which we want to integrate with the WordPress blog. Our PHP file which we are getting to integrate might not use any of the WordPress APIs. Integrating PHP files with WordPress is very important for the back-end development of web design.
Step 1: Login to Microsoft Web Matrix The following screen appears. Open or create your WordPress template.
Step 2: Create WordPress Template Page We can start with a sample file and copy page.php, rename it on your choice and put it inside the theme folder ../wp-content/themes/mytheme/
<?php/*Template Name: GFG*/  /* Rest PHP code here */?>
This new file should start with the following content and then followed by the custom PHP content. This is the WordPress template. Remember to upload this to the theme folder. Now the WordPress template is ready.
Step 3: Create WordPress PageClick the “Pages” link from the WordPress Dashboard. The template we created can be used to create this new page. We can give the Page name and choose the “Template” from the drop-down from the “Page Attributes” section. There the PHP-page we uploaded will come with the “GeeksfoGeeks” listed in the dropdown. Now publish. Here we go, we have created a WordPress PHP page using our custom code. Whenever this page is linked, our custom PHP code will get executed. Various types of templates can be created through it.
Example: In functions, you need to implement it as follows:
function simple_function_1() {    return "Hello World!";}  add_shortcode( 'own_shortcode1', 'simple_function_1' );
In post/page:
[own_shortcode1]
Output:
Hello World!
A real-time scenario is we will construct a sitemap page using this WordPress template option.
PHP-Misc
Picked
PHP
Web Technologies
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to fetch data from localserver database and display on HTML table using PHP ?
How to create admin login page using PHP?
Different ways for passing data to view in Laravel
How to generate PDF file using PHP ?
Create a drop-down list that options fetched from a MySQL database in PHP
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
Date getTimezoneOffset() Method

Javascript date getTimezoneOffset() method returns the time-zone offset in minutes for the current locale. The time-zone offset is the minutes in difference, the Greenwich Mean Time (GMT) is relative to your local time.
For example, if your time zone is GMT+10, -600 will be returned. Daylight savings time prevents this value from being a constant.
Its syntax is as follows −
Date.getTimezoneOffset()

Returns the time-zone offset in minutes for the current locale.
Try the following example.
<html>
   <head>
      <title>JavaScript getTimezoneOffset Method</title>
   </head>
   
   <body>   
      <script type = "text/javascript">
         var dt = new Date();
         var tz = dt.getTimezoneOffset(); 
         document.write("getTimezoneOffset() : " + tz ); 
      </script>      
   </body>
</html>

    25 Lectures 
     2.5 hours 

 Anadi Sharma

    74 Lectures 
     10 hours 

 Lets Kode It

    72 Lectures 
     4.5 hours 

 Frahaan Hussain

    70 Lectures 
     4.5 hours 

 Frahaan Hussain

    46 Lectures 
     6 hours 

 Eduonix Learning Solutions

    88 Lectures 
     14 hours 

 Eduonix Learning Solutions
 Print
 Add Notes
 Bookmark this page
DAX Filter - RELATEDTABLE function

Evaluates a table expression in a context modified by the given filters.
RELATEDTABLE (<tableName>) 

tableName
The name of an existing table.
It cannot be an expression.
A table of values.
DAX RELATEDTETABLE function changes the context in which the data is filtered, and evaluates the expression in the new context that you specify.
DAX RELATEDTABLE function is equivalent to DAX CALCULATETABLE function with no logical expression.
= SUMX (RELATEDTABLE (East_Sales),East_Sales[Sales Amount]) 

    53 Lectures 
     5.5 hours 

 Abhay Gadiya

    24 Lectures 
     2 hours 

 Randy Minder

    26 Lectures 
     4.5 hours 

 Randy Minder
 Print
 Add Notes
 Bookmark this page