code-rag-bench/online-tutorials huggingface dataset:
Python | Ways to merge strings into list

27 Feb, 2019
Given n strings, the task is to merge all strings into a single list.
While developing an application, there come many scenarios when we need to operate on the string and convert it as some mutable data structure, say list. There are multiple ways we can convert strings into list based on the requirement. Let’s understand it better with help of examples.
Method #1: Using ast
# Python code to merge all strings into a single list.  # Importingimport ast  # Initialization of stringsstr1 ="'Geeks', 'for', 'Geeks'"str2 ="'paras.j', 'jain.l'"str3 ="'india'"    # Initialization of listlist = []  # Extending into single listfor x in (str1, str2, str3):    list.extend(ast.literal_eval(x))  # printing outputprint(list)
['Geeks', 'for', 'Geeks', 'paras.j', 'jain.l', 'i', 'n', 'd', 'i', 'a']

Method #2: Using eval
# Python code to merge all strings into a single list.  # Initialization of stringsstr1 ="['Geeks', 'for', 'Geeks']"str2 ="['paras.j', 'jain.l']"str3 ="['india']"    out = [str1, str2, str3]  out = eval('+'.join(out))  # printing outputprint(out)
['Geeks', 'for', 'Geeks', 'paras.j', 'jain.l', 'india']

# Python code to merge all strings into a single list.  # Initialization of stringsstr1 ="'Geeks', 'for', 'Geeks'"str2 = "'121', '142'"str3 ="'extend', 'India'"    out = [str1, str2, str3]  out = eval('+'.join(out))  # printing outputprint(list(out))
['Geeks', 'for', 'Geeks121', '142extend', 'India']

Python list-programs
Python string-programs
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 ?
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python Program for Fibonacci numbers
Python | Convert string dictionary to dictionary
Matplotlib.figure.Figure.align_labels() in Python - GeeksforGeeks

30 Apr, 2020
Matplotlib is a library in Python and it is numerical – mathematical extension for NumPy library. The figure module provides the top-level Artist, the Figure, which contains all the plot elements. This module is used to control the default spacing of the subplots and top level container for all plot elements.
The align_labels() method figure module of matplotlib library is used to Align the xlabels and ylabels of subplots with the same subplots row or column if label alignment is being done automatically.
Syntax: align_labels(self, axs=None)
Parameters: This accept the following parameters that are described below:
axs : This parameter is the list of Axes to align the labels.
Returns: This method does not return any value.
Below examples illustrate the matplotlib.figure.Figure.align_labels() function in matplotlib.figure:
Example 1:
# Implementation of matplotlib functionimport matplotlib.pyplot as pltimport numpy as npimport matplotlib.gridspec as gridspec  fig = plt.figure()gs = gridspec.GridSpec(2, 2)  for i in range(2):    ax = fig.add_subplot(gs[1, i])    ax.set_ylabel('Y label')    ax.set_xlabel('X label')    if i == 0:        for tick in ax.get_xticklabels():            tick.set_rotation(45)  fig.align_labels()  fig.suptitle('matplotlib.figure.Figure.align_labels() \function Example\n\n', fontweight ="bold")  plt.show()
Output:
Example 2:
# Implementation of matplotlib functionimport matplotlib.pyplot as pltimport numpy as npimport matplotlib.gridspec as gridspec  fig = plt.figure(tight_layout = True)gs = gridspec.GridSpec(2, 2)  ax = fig.add_subplot(gs[0, :])ax.plot(np.arange(0, 1e6, 1000))  ax.set_ylabel('YLabel0')ax.set_xlabel('XLabel0')  for i in range(2):    ax = fig.add_subplot(gs[1, i])    ax.plot(np.arange(1., 0., -0.1) * 2000.,                          np.arange(1., 0., -0.1))          ax.set_ylabel('YLabel1 % d' % i)    ax.set_xlabel('XLabel1 % d' % i)          if i == 0:        for tick in ax.get_xticklabels():            tick.set_rotation(55)  fig.align_labels()    fig.suptitle('matplotlib.figure.Figure.align_labels() \function Example\n\n', fontweight ="bold")  plt.show()
Output:
Python-matplotlib
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Read a file line by line in Python
Enumerate() in Python
How to Install PIP on Windows ?
Iterate over a list in Python
Different ways to create Pandas Dataframe
Python String | replace()
Create a Pandas DataFrame from Lists
Python program to convert a list to string
Reading and Writing to text files in Python
ios fail() function in C++ with Examples - GeeksforGeeks

02 Sep, 2019
The fail() method of ios class in C++ is used to check if the stream is has raised any fail error. It means that this function will check if this stream has its failbit set.
Syntax:
bool fail() const;

Parameters: This method does not accept any parameter.
Return Value: This method returns true if the stream has failbit set, else false.
Example 1:
// C++ code to demonstrate// the working of fail() function  #include <bits/stdc++.h>using namespace std;  int main(){      // Stream    stringstream ss;      // Using fail() function    bool isFail = ss.fail();      // print result    cout << "is stream fail: "         << isFail << endl;      return 0;}
is stream fail: 0

Example 2:
// C++ code to demonstrate// the working of fail() function  #include <bits/stdc++.h>using namespace std;  int main(){      // Stream    stringstream ss;    ss.clear(ss.failbit);      // Using fail() function    bool isFail = ss.fail();      // print result    cout << "is stream fail: "         << isFail << endl;      return 0;}
is stream fail: 1

Reference: hhttp://www.cplusplus.com/reference/ios/ios/fail/
CPP-Functions
cpp-ios
C++
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++
Array of Strings in C++ (5 Different Ways to Create)
Pair in C++ Standard Template Library (STL)
Inline Functions in C++
Convert string to char array in C++
List in C++ Standard Template Library (STL)
How to Install SQLAlchemy in Python in Windows? - GeeksforGeeks

22 Sep, 2021
SQLAlchemy is the Python SQL toolkit and Object Relational Mapper that is used as flexible database access using SQL.  In this article, we will look into the process of installing SQLAlchemy on a windows machine.
The only thing that you need for installing Numpy on Windows are:
Python 
PIP or Conda (depending upon user preference)
If you want the installation to be done through conda,  open up the Anaconda Powershell Prompt and use the below command:
conda install -c anaconda sqlalchemy
Type y for yes when prompted.
You will get a similar message once the installation is complete:
Make sure you follow the best practices for installation using conda as:
Use an environment for installation rather than in the base environment using the below command:
conda create -n my-env
conda activate my-env
Note: If your preferred method of installation is conda-forge, use the below command:
conda config --env --add channels conda-forge
To verify if SQLAlchemy  has been successfully installed in your system run the below command in Anaconda Powershell Prompt:
conda list pyglet
You’ll get the below message if the installation is complete:
If you want the installation to be done through PIP,  open up the command Prompt and use the below command:
pip install pyglet
You will get a similar message once the installation is complete:
To verify if the SQLAlchemy  has been successfully installed in your system run the below command in Command Prompt:
python -m pip show sqlalchemy  
You’ll get the below message if the installation is complete:
Blogathon-2021
how-to-install
Picked
Blogathon
How To
Installation Guide
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Create a Table With Multiple Foreign Keys in SQL?
How to Import JSON Data into SQL Server?
Stratified Sampling in Pandas
How to pass data into table from a form using React Components
SQL Query to Convert Datetime to Date
How to Install PIP on Windows ?
How to Find the Wi-Fi Password Using CMD in Windows?
How to install Jupyter Notebook on Windows?
How to Align Text in HTML?
How to filter object array based on attributes?
GATE | GATE-CS-2015 (Set 1) | Question 65 - GeeksforGeeks

11 Oct, 2021
For any two languages L1 and L2 such that L1 is context free and L2 is recursively enumerable but not recursive, which of the following is/are necessarily true?
1. L1' (complement of L1) is recursive 
2. L2' (complement of L2) is recursive
3. L1' is context-free 
4. L1' ∪ L2 is recursively enumerable 
(A) 1 only(B) 3 only(C) 3 and 4 only(D) 1 and 4 onlyAnswer: (D)Explanation: 1. L1′ (complement of L1) is recursive is trueL1 is context free. Every context free language is also recursive and recursive languages are closed under complement.
4. L1′ ∪ L2 is recursively enumerable is trueSince L1′ is recursive, it is also recursively enumerable and recursively enumerable languages are closed under union.Recursively enumerable languages are known as type-0 languages in the Chomsky hierarchy of formal languages. All regular, context-free, context-sensitive and recursive languages are recursively enumerable. (Source: Wiki)
3. L1′ is context-free:Context-free languages are not closed under complement, intersection, or difference.
2. L2′ (complement of L2) is recursive is false:Recursively enumerable languages are not closed under set difference or complementation
YouTubeGeeksforGeeks GATE Computer Science16.1K subscribersGATE PYQ's on Theory of Computation with Praddyumn Shukla | GeeksforGeeks GATE | GATE CSEWatch laterShareCopy linkInfoShoppingTap to unmuteIf playback doesn't begin shortly, try restarting your device.You're signed outVideos you watch may be added to the TV's watch history and influence TV recommendations. To avoid this, cancel and sign in to YouTube on your computer.CancelConfirmMore videosMore videosSwitch cameraShareInclude playlistAn error occurred while retrieving sharing information. Please try again later.Watch on0:000:002:23 / 56:33•Live•<div class="player-unavailable"><h1 class="message">An error occurred.</h1><div class="submessage"><a href="https://www.youtube.com/watch?v=iNOmopKv0aY" target="_blank">Try watching this video on www.youtube.com</a>, or enable JavaScript if it is disabled in your browser.</div></div>Quiz of this Question
GATE-CS-2015 (Set 1)
GATE-GATE-CS-2015 (Set 1)
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
GATE | GATE-CS-2014-(Set-1) | Question 30
GATE | GATE-CS-2015 (Set 1) | Question 65
GATE | GATE CS 2010 | Question 45
GATE | GATE-CS-2015 (Set 3) | Question 65
GATE | GATE-CS-2004 | Question 3
GATE | GATE CS 2012 | Question 40
C++ Program to count Vowels in a string using Pointer
GATE | GATE-CS-2015 (Set 1) | Question 42
GATE | GATE-CS-2006 | Question 49
GATE | GATE-CS-2014-(Set-3) | Question 65
How to remove margin introduced in pre tag in bootstrap 4? - GeeksforGeeks

25 May, 2020
The problem is that whenever you apply margin space as per your margin value it will give you output. But in <pre> tag if you apply it by keeping any space then it will consider as margin. Because pre is acted vice versa, means as you have written inside the pre tag the output will be the same.
Note: The examples will act same with the bootstrap.
Example 1: The approach of the pre tag is basically used if you want to write the code and print it as a normal text.
Program:<!DOCTYPE html><html>  <head>    <title>Pre tag usage</title></head>  <body>          <!-- Notice the spces inside of the pre tag -->    <pre> GeeskforGeeks  </pre>    <pre> A Computer Science Portal          For Geeks    </pre></body>  </html>
<!DOCTYPE html><html>  <head>    <title>Pre tag usage</title></head>  <body>          <!-- Notice the spces inside of the pre tag -->    <pre> GeeskforGeeks  </pre>    <pre> A Computer Science Portal          For Geeks    </pre></body>  </html>
Output: GeeskforGeeks  
 A Computer Science Portal
          For Geeks
    
 GeeskforGeeks  
 A Computer Science Portal
          For Geeks
    
Example 2: Sometimes it happens that you have written some code and give some space or margin inside the pre tag then the output also gives the margin.Inside pre tag the way you write the code same it will give as an output.
Program:<!DOCTYPE html><html>  <head>    <title>Demo</title></head>  <body>    <div class="row">        <div class="col-md-3">            <pre><p><b>GeeksforGeeks</b>This paragraph is on remove marginintroduced in pre tag in bootstrap 4</p></pre>        </div>    </div></body>  </html>                    
<!DOCTYPE html><html>  <head>    <title>Demo</title></head>  <body>    <div class="row">        <div class="col-md-3">            <pre><p><b>GeeksforGeeks</b>This paragraph is on remove marginintroduced in pre tag in bootstrap 4</p></pre>        </div>    </div></body>  </html>                    
Output:GeeksforGeeks
This paragraph is on remove margin
introduced in pre tag in bootstrap 4
GeeksforGeeks
This paragraph is on remove margin
introduced in pre tag in bootstrap 4
Bootstrap-4
Picked
Bootstrap
Web Technologies
Web technologies Questions
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to pass data into a bootstrap modal?
How to Show Images on Click using HTML ?
How to set Bootstrap Timepicker using datetimepicker library ?
How to Use Bootstrap with React?
Difference between Bootstrap 4 and Bootstrap 5
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?
How to split a big data frame into smaller ones in R?

Dealing with big data frames is not an easy task therefore we might want to split that into some smaller data frames. These smaller data frames can be extracted from the big one based on some criteria such as for levels of a factor variable or with some other conditions. This can be done by using split function.
Consider the below data frame −
> set.seed(1)
> Grades<-rep(c("A","B","C","D","E"),times=10)
> Age<-sample(1:30,50,replace=TRUE)
> Category<-sample(1:10,50,replace=TRUE)
> df<-data.frame(Grades,Age,Category)
> head(df,20)
  Grades Age Category
1    A    25    6
2    B     4    9
3    C     7    8
4    D     1    9
5    E     2    7
6    A    29    8
7    B    23    6
8    C    11   10
9    D    14    7
10   E    18    3
11   A    27   10
12   B    19    6
13   C     1    8
14   D    21    2
15   E    21    2
16   A    10    6
17   B    22    6
18   C    14    1
19   D    10    3
20   E     7    3
Splitting the data frame on the basis of grades −
> Split_based_on_Grades<-split(df,f=df$Grades)
> Split_based_on_Grades
$A
    Grades Age Category
1     A    25    6
6     A    29    8
11    A    27   10
16    A    10    6
21    A     9    8
26    A    25    7
31    A    10    9
36    A     1    1
41    A    10    7
46    A    20   10
$B
    Grades Age Category
2     B     4    9
7     B     23   6
12    B     19   6
17    B     22   6
22    B     15   6
27    B     14   1
32    B     30   7
37    B     20   5
42    B      6   7
47    B     26  10
$C
    Grades Age Category
3     C      7   8
8     C     11  10
13    C      1   8
18    C     14   1
23    C     21   7
28    C      5   4
33    C     25   4
38    C      3   6
43    C     15   3
48    C     12   7
$D
    Grades Age Category
4     D      1   9
9     D     14   7
14    D     21   2
19    D     10   3
24    D      5   6
29    D      5   8
34    D     12   7
39    D      6   1
44    D     20   6
49    D     25   3
$E
    Grades Age Category
5     E      2   7
10    E     18   3
15    E     21   2
20    E      7   3
25    E      9   8
30    E      2   9
35    E     15   6
40    E     10   9
45    E     28   2
50    E     23   2 
Now we can access each grade as shown below −
> Split_based_on_Grades[[1]]
   Grades Age Category
1     A    25   6
6     A    29   8
11    A    27  10
16    A    10   6
21    A     9   8
26    A    25   7
31    A    10   9
36    A     1   1
41    A    10   7
46    A    20  10
> Split_based_on_Grades[[4]]
   Grades Age Category
4     D     1    9
9     D    14    7
14    D    21    2 
19    D    10    3
24    D     5    6
29    D     5    8
34    D    12    7
39    D     6    1
44    D    20    6
49    D    25    3
Distinct permutations of a string containing duplicates using HashSet in Java - GeeksforGeeks

19 Sep, 2019
Given a string str that may contain duplicate characters, the task is to print all the distinct permutations of the given string such that no permutation is repeated in the output.
Examples:
Input: str = “ABA”Output:ABAAABBAA
Input: str = “ABC”Output:ABCACBBACBCACBACAB
Approach: An approach to generate all the permutations of a given string has been discussed in this article. All the permutations generated by this approach can be stored in a HashSet in order to avoid duplicates.
Below is the implementation of the above approach:
// Java implementation of the approachimport java.util.HashSet;  public class GFG {      // To store all the generated permutations    public static HashSet<String> h = new HashSet<String>();      public static void permute(char s[], int i, int n)    {          // If the permutation is complete        if (i == n) {              // If set doesn't contain            // the permutation already            if (!(h.contains(String.copyValueOf(s)))) {                  h.add(String.copyValueOf(s));                  // Print the generated permutation                System.out.println(s);            }        }          else {              // One by one swap the jth            // character with the ith            for (int j = i; j <= n; j++) {                  // Swapping a[i] and a[j];                char temp = s[i];                s[i] = s[j];                s[j] = temp;                  // Revert the swapping                permute(s, i + 1, n);                  temp = s[i];                s[i] = s[j];                s[j] = temp;            }        }    }      // Driver code    public static void main(String args[])    {        char s[] = { 'A', 'B', 'A' };        permute(s, 0, s.length - 1);    }}
ABA
AAB
BAA

permutation
Strings
Strings
permutation
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Top 50 String Coding Problems for Interviews
Hill Cipher
Naive algorithm for Pattern Searching
Vigenère Cipher
How to Append a Character to a String in C
Convert character array to string in C++
Reverse words in a given String in Python
Print all the duplicates in the input string
Converting Roman Numerals to Decimal lying between 1 to 3999
Print all subsequences of a string
How to give a limit to the input field in HTML?

The HTML <input> tag is used to get user input in HTML. To give a limit to the input field, use the min and max attributes, which is to specify a maximum and minimum value for an input field respectively.
The max and min attributes are used with number, range, date, datetime, datetime-local, month, time and week input types.
You can try to run the following code to give a limit to the input field in HTML −
<!DOCTYPE html>
<html>
   <head>
      <title>HTML input number</title>
   </head>
   <body>
      <form action = "" method = "get">
         Mention any number between 1 to 10
         <input type="number" name="num" min="1" max="10"><br>
         <input type="submit" value="Submit">
      </form>
   </body>
</html>
How to run SQL script in MySQL?

To run SQL script in MySQL, use the MySQL workbench. First, you need to open MySQL workbench.
The snapshot is as follows −
Now, File -> Open SQL Script to open the SQL script.
Alternatively, use the following shortcut key −
Ctrl+Shift+O
After that an option would be visible for you to choose your .sql file from the disk. In my system, the file is located on the Desktop. I will select the same “tblstudent” SQL file as shown in the following screenshot −
After browsing .sql files, you need to select the option “Reconnect to database” as shown in the following screenshot −
Now, it will ask for password to connect with MySQL. Add the password and click “OK” as in the following screenshot −
Note − Press OK button twice to connect with MySQL.
After completing the above process, the following screen will be visible with our SQL file “tblstudent”, which we uploaded before −
After that you need to execute the script. To execute the script, click the symbol marked in the following screenshot −
After that you will get the following output −
How to return a value from a JavaScript function?

To return a value from a JavaScript function, use the return statement in JavaScript. You need to run the following code to learn how to return a value −
<html>
   <head>
      <script>
         function concatenate(name, age) {
            var val;
            val = name + age;
            return val;
         }
         function DisplayFunction() {
            var result;
            result = concatenate('John ', 20) ;
            document.write (result );
         }
      </script>
   </head>
   <body>
      <p>Click the following button to call the function</p>

      <form>
         <input type = "button" onclick = "DisplayFunction()" value = "Result">
      </form>
   </body>
</html>
DAX Filter - ALLEXCEPT function

Removes all context filters in the table except filters that have been applied to the specified columns.
ALLEXCEPT (<table>, <column>, [<column>] ...) 

table
The table over which all context filters are removed, except filters on those columns that are specified in subsequent arguments.
column
One or more columns that are specified for which context filters must be preserved.
For the ALLEXCEPT function, the first argument must be a reference to a base table. All the subsequent arguments must be references to base columns in that table.
You cannot use table expressions or column expressions with the ALLEXCEPT function.
A table with all filters removed except for the filters on the specified columns.
ALLEXCEPT function is not used by itself, but serves as an intermediate function that can be used to change the set of results over which some other calculation is performed.
You can use ALLEXCEPT function if you want to remove the filters on many, but not all, columns in a table.
= CALCULATE (COUNTA (Results[Medal]), ALLEXCEPT (Hosts, Hosts[City])) 
The values in Medal column in the Results table are counted with all the filters removed, except for the filters on the Column City in the Hosts table.

    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
Why and how are Python functions hashable?

31 Aug, 2020
So start with the question i.e. Why and how are Python functions hashable? First, one should know what actually hashable means in Python. So, hashable is a feature of Python objects that tells if the object has a hash value or not. If the object has a hash value then it can be used as a key for a dictionary or as an element in a set.
An object is hashable if it has a hash value that does not change during its entire lifetime. Python has a built-in hash method ( __hash__() ) that can be compared to other objects. For comparing it needs __eq__() or __cmp__() method and if the hashable objects are equal then they have the same hash value. All immutable built-in objects in Python are hashable like tuples while the mutable containers like lists and dictionaries are not hashable. 
Objects which are instances of the user-defined class are hashable by default, they all compare unequal, and their hash value is their id().
Example: Consider two tuples t1, t2 with the same values, and see the differences:
Python3
t1 = (1, 5, 6) t2 = (1, 5, 6) # show the id of objectprint(id(t1)) print(id(t2))
  
Output:
 
140040984150664
140040984150880


 
In the above example, two objects are different as for immutable types the hash value depends on the data stored not on their id.
 
Example: Let’s see lambda functions are hashable or not.
 
Python3
# create a one-line functionl = lambda x : 1 # show the hash valueprint(hash(l)) # show the id valueprint(id(l)) # show the hash valueprint (l.__hash__())
  
Output:
 
-9223363246992694337
140637793303544
-9223363246992694337


 
Hence, lambda functions are hashable.
 
Example: Let’s see user defined def based function are hashable or not.
 
Python3
# create an empty functiondef fun():  pass # print types of functionprint(type(fun)) # print hash valueprint(fun.__hash__()) # print hash valueprint(hash(fun))
  
Output:
 
<class 'function'>
-9223363242199589441
-9223363242199589441 


 
Therefore, any user defined function is hashable as its hash value remains same during its lifetime.
 
urvashisaxena1997
Python-Functions
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Lodash _.union() Method

01 Sep, 2020
The _.union() method is used to take n number of arrays and creates an array of unique values in order, from all given arrays using SameValueZero for equality comparisons.
Syntax: 
_.union(*arrays)
Parameters: This method accepts a single parameter as mentioned above and described below:
arrays: This parameter holds arrays to inspect.
Return Value: This method is used to return the new array of combined values.
Example 1: Here, const _ = require(‘lodash’) is used to import the lodash library in the file.
Javascript
// Requiring the lodash library  const _ = require("lodash");    // Use of _.union() method let gfg = _.union([20, 12], [8, 15, 6]);         // Printing the output  console.log(gfg)
Output:
[20, 12, 8, 15, 6]
Example 2: 
Javascript
// Requiring the lodash library  const _ = require("lodash");   // Use of _.union() method let gfg = _.union([1, 2, 3],                  [3, 4, 5],                   [6, 2, 7]);         // Printing the output  console.log(gfg)
Output:
[1, 2, 3, 4, 5, 6, 7]
JavaScript-Lodash
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Set of Vectors in C++ STL with Examples

17 Mar, 2020
Set in STL Sets are a type of associative containers in which each element has to be unique, because the value of the element identifies it. The value of the element cannot be modified once it is added to the set, though it is possible to remove and add the modified value of that element.
Vector in STL Vector is same as dynamic arrays with the ability to resize itself automatically when an element is inserted or deleted, with their storage being handled automatically by the container. Vector elements are placed in contiguous storage so that they can be accessed and traversed using iterators.
Set of Vectors in STL: Set of Vectors can be very efficient in designing complex data structures.
Syntax:
set<vector<datatype>> set_of_vector;

For example: Consider a simple problem where we have to print all the unique vectors.
// C++ program to demonstrate// use of set for vectors  #include <bits/stdc++.h>using namespace std;  set<vector<int> > set_of_vectors;  // Print elements of Vectorvoid Print_Vector(vector<int> Vec){    for (int i = 0; i < Vec.size(); i++) {        cout << Vec[i] << " ";    }    cout << endl;    return;}  // Driver codeint main(){    // Initializing some vectors    vector<int> data_1{ 10, 20, 30, 40 };    vector<int> data_2{ 5, 10, 15 };    vector<int> data_3{ 1, 3, 5, 7, 9, 11, 13 };    vector<int> data_4{ 5, 10, 15 };    vector<int> data_5{ 10, 20, 30, 40 };      // Inserting vectors into set    set_of_vectors.insert(data_1);    set_of_vectors.insert(data_2);    set_of_vectors.insert(data_3);    set_of_vectors.insert(data_4);    set_of_vectors.insert(data_5);      // printing all the unique vectors in set    cout << "Set of Vectors: \n";    for (auto it = set_of_vectors.begin();         it != set_of_vectors.end();         it++) {          Print_Vector(*it);    }      return 0;}
Set of Vectors: 
1 3 5 7 9 11 13 
5 10 15 
10 20 30 40

cpp-set
cpp-vector
C++ Programs
Data Structures
Data Structures
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Shallow Copy and Deep Copy in C++
C++ Program to check if a given String is Palindrome or not
delete keyword in C++
C Program to Swap two Numbers
C++ Program for QuickSort
DSA Sheet by Love Babbar
SDE SHEET - A Complete Guide for SDE Preparation
Top 50 Array Coding Problems for Interviews
What is Hashing | A Complete Tutorial
Introduction to Data Structures
\shoveleft - Tex Command

\shoveleft - Used for forces flush left typesetting in a \multline or \multline*  environment.
{ \shoveleft }
\shoveleft command is used for forces flush left typesetting in a \multline or \multline*  environment.

\begin{multline}
(a+b+c+d)^2 \\
+ (e+f)^2 + (g+h)^2 + (i+j)^2 + (k+l)^2 \\
+ (m+n)^2 + (o+p)^2 + (q+r)^2 + (s+t)^2 + (u+v)^2  \\
+ (w+x+y+z)^2
\end{multline}


(a+b+c+d)2+(e+f)2+(g+h)2+(i+j)2+(k+l)2+(m+n)2+(o+p)2+(q+r)2+(s+t)2+(u+v)2+(w+x+y+z)2


\begin{multline}
(a+b+c+d)^2 \\
\shoveleft{+ (e+f)^2 + (g+h)^2 + (i+j)^2 + (k+l)^2} \\
\shoveright{+ (m+n)^2 + (o+p)^2 + (q+r)^2 + (s+t)^2 + (u+v)^2}  \\
+ (w+x+y+z)^2
\end{multline}


(a+b+c+d)2+(e+f)2+(g+h)2+(i+j)2+(k+l)2+(m+n)2+(o+p)2+(q+r)2+(s+t)2+(u+v)2+(w+x+y+z)2



\begin{multline}
(a+b+c+d)^2 \\
+ (e+f)^2 + (g+h)^2 + (i+j)^2 + (k+l)^2 \\
+ (m+n)^2 + (o+p)^2 + (q+r)^2 + (s+t)^2 + (u+v)^2  \\
+ (w+x+y+z)^2
\end{multline}


(a+b+c+d)2+(e+f)2+(g+h)2+(i+j)2+(k+l)2+(m+n)2+(o+p)2+(q+r)2+(s+t)2+(u+v)2+(w+x+y+z)2


\begin{multline}
(a+b+c+d)^2 \\
+ (e+f)^2 + (g+h)^2 + (i+j)^2 + (k+l)^2 \\
+ (m+n)^2 + (o+p)^2 + (q+r)^2 + (s+t)^2 + (u+v)^2  \\
+ (w+x+y+z)^2
\end{multline}

\begin{multline}
(a+b+c+d)^2 \\
\shoveleft{+ (e+f)^2 + (g+h)^2 + (i+j)^2 + (k+l)^2} \\
\shoveright{+ (m+n)^2 + (o+p)^2 + (q+r)^2 + (s+t)^2 + (u+v)^2}  \\
+ (w+x+y+z)^2
\end{multline}


(a+b+c+d)2+(e+f)2+(g+h)2+(i+j)2+(k+l)2+(m+n)2+(o+p)2+(q+r)2+(s+t)2+(u+v)2+(w+x+y+z)2


\begin{multline}
(a+b+c+d)^2 \\
\shoveleft{+ (e+f)^2 + (g+h)^2 + (i+j)^2 + (k+l)^2} \\
\shoveright{+ (m+n)^2 + (o+p)^2 + (q+r)^2 + (s+t)^2 + (u+v)^2}  \\
Python – Itertools Combinations() function

22 Feb, 2020
Itertool is a module of Python which is used to creation of iterators which helps us in efficient looping in terms of space as well as time. This module helps us to solve complex problems easily with the help of different sub-functions of itertools. The different sub-functions are divided into 3 subgroups which are:-
Infinite Iterators
Iterators terminating on the shortest input sequence
Combinatoric Generators
Note: For more information, refer to Python Itertools
Itertools.combinations() falls under the third subcategory called “Combinatoric Generators”. Combinatoric Generators are those iterators that are used to simplify combinatorial constructs such as permutations, combinations, and Cartesian products
As understood by name combinations is refers to a sequence or set of numbers or letters used in the iterator. Similarly itertools.combinations() provides us with all the possible tuples a sequence or set of numbers or letters used in the iterator and the elements are assumed to be unique on the basis of there positions which are distinct for all elements. All these combinations are emitted in lexicographical order. This function takes ‘r’ as input here ‘r’ represents the size of different combinations that are possible. All the combinations emitted are of length ‘r’ and ‘r’ is a necessary argument here.
Syntax:
combinations(iterator, r)
Example 1:-
# Combinations Of string "GeEKS" OF SIZE 3.    from itertools import combinations  letters ="GeEKS"  # size of combination is set to 3a = combinations(letters, 3) y = [' '.join(i) for i in a]  print(y)
Output:-
['G e E', 'G e K', 'G e S', 'G E K', 'G E S', 'G K S', 'e E K', 'e E S', 'e K S', 'E K S']

Example 2:-
from itertools import combinations        print ("All the combination of list in sorted order(without replacement) is:")   print(list(combinations(['A', 2], 2)))  print()        print ("All the combination of string in sorted order(without replacement) is:")  print(list(combinations('AB', 2)))  print()        print ("All the combination of list in sorted order(without replacement) is:")  print(list(combinations(range(2), 1))) 
Output :-
All the combination of list in sorted order(without replacement) is:
[('A', 2)]

All the combination of string in sorted order(without replacement) is:
[('A', 'B')]

All the combination of list in sorted order(without replacement) is:
[(0,), (1,)]

Python-itertools
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Iterate over a list in Python
Python OOPs Concepts
MongoDB $concat Operator

01 Aug, 2020
MongoDB provides different types of string expression operators that are used in the aggregation pipeline stages $concat operator is one of them. This operator is used to concatenate two or more strings and returns a single string.
Syntax: 
{ $concat: [ <expression1>, <expression2>, ... ] }


Here, the arguments passed in this operator can be any valid expression until they resolve to strings.
If the entered argument resolves to null, then this operator will return null.
If the entered argument refers to a missing field, then this operator will return null.
Examples:
In the following examples, we are working with:
Database: GeeksforGeeks
Collection: employee
Document: three documents that contain the details of the employees in the form of field-value pairs.
Concatenating strings using $concat operator:
In this example, we are finding the department of the employees. Here, we concatenate “My department is:” string with the value of the department field.
db.employee.aggregate([
... {$project: {"name.first": 1, _id: 0, dept:
... {$concat: ["My department is: ", "$department"]}}}])

Concatenating strings in the embedded documents using $concat operator:
In this example, we are going to find the full name of the employees by concatenating the values of the name.first, name.middle, and name.last fields. 
db.employee.aggregate([
... {$project: {fullname:
... {$concat: ["$name.first", "$name.middle", "$name.last"]}}}])

MongoDB-operators
MongoDB
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to connect MongoDB with ReactJS ?
MongoDB - limit() Method
Create user and add role in MongoDB
MongoDB - sort() Method
MongoDB - FindOne() Method
Export data from MongoDB
MongoDB updateOne() Method - db.Collection.updateOne()
MongoDB - Compound Indexes
MongoDB - Regex
MongoDB updateMany() Method - db.Collection.updateMany()
Difference Between GIT and SVN

21 Jun, 2022
GIT: Git is an open-source distributed version control system developed by Linus Torvalds in 2005. Its emphasis on speed and data integrity in which there is no centralized connectivity is needed. It is powerful and cheap branching with easy merge in which each developer has his repository and have a local copy in which they can change history. It supports non-linear development branches and applications with a large number of codes files. 
Here are some .git directory structures used in GIT:
HEAD/: A pointer structure used in git.
Config/: Contains all configuration preferences.
description/: Description of your project.
index/: It is used as a staging area between working directory.
object/: All the data are stored here.
logs/: Keeps record to change that are made.
SVN: Apache Subversion is an open-source software version and revision control system under the Apache license. It managed files and folders that are present in the repository. It can operate across the network, which allows it and used by people on different computer .we can say that a repository is like an ordinary file server which allows it to be used by people on a different computer.
  
Below is a table of differences between GIT and SVN:
Features of GIT:
Distributed System.
Branching.
Compatibility.
Non-linear Development.
Lightweight.
Open source.
Features of SVN:
Directories are versioned
Copying, deleting, and renaming.
Free-form versioned metadata .
Atomic commits.
Branching and tagging.
Merge tracking.
File locking.
9okfx6axjopy1zpnpkhuhgar0w0wg5p1enclhc5x
mitalibhola94
Difference Between
Git
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
Difference Between Method Overloading and Method Overriding in Java
Differences between JDK, JRE and JVM
Difference between Process and Thread
Difference between Clustered and Non-clustered index
Working on Git for GUI
How to Set Git Username and Password in GitBash?
How to integrate Git Bash with Visual Studio Code?
Git - Difference Between Git Fetch and Git Pull
How to Set Upstream Branch on Git?
Impala - Group By Clause

The Impala GROUP BY clause is used in collaboration with the SELECT statement to arrange identical data into groups.
Following is the syntax of the GROUP BY clause.
select data from table_name Group BY col_name;

Assume we have a table named customers in the database my_db and its contents are as follows −
[quickstart.cloudera:21000] > select * from customers; 
Query: select * from customers 
+----+----------+-----+-----------+--------+ 
| id | name     | age | address   | salary | 
+----+----------+-----+-----------+--------+ 
| 1  | Ramesh   | 32  | Ahmedabad | 20000  | 
| 2  | Khilan   | 25  | Delhi     | 15000  | 
| 3  | kaushik  | 23  | Kota      | 30000  | 
| 4  | Chaitali | 25  | Mumbai    | 35000  | 
| 5  | Hardik   | 27  | Bhopal    | 40000  | 
| 6  | Komal    | 22  | MP        | 32000  | 
+----+----------+-----+-----------+--------+ 
Fetched 6 row(s) in 0.51s

You can get the total amount of salary of each customer using GROUP BY query as shown below.
[quickstart.cloudera:21000] > Select name, sum(salary) from customers Group BY name;

On executing, the above query gives the following output.
Query: select name, sum(salary) from customers Group BY name 
+----------+-------------+ 
| name     | sum(salary) | 
+----------+-------------+ 
| Ramesh   | 20000       | 
| Komal    | 32000       | 
| Hardik   | 40000       | 
| Khilan   | 15000       | 
| Chaitali | 35000       | 
| kaushik  | 30000       |
+----------+-------------+ 
Fetched 6 row(s) in 1.75s

Assume that this table has multiple records as shown below.
+----+----------+-----+-----------+--------+ 
| id | name     | age | address   | salary | 
+----+----------+-----+-----------+--------+ 
| 1  | Ramesh   | 32  | Ahmedabad | 20000  |
| 2  | Ramesh   | 32  | Ahmedabad | 1000|  | 
| 3  | Khilan   | 25  | Delhi     | 15000  | 
| 4  | kaushik  | 23  | Kota      | 30000  | 
| 5  | Chaitali | 25  | Mumbai    | 35000  |
| 6  | Chaitali | 25  | Mumbai    | 2000   |
| 7  | Hardik   | 27  | Bhopal    | 40000  | 
| 8  | Komal    | 22  | MP        | 32000  | 
+----+----------+-----+-----------+--------+

Now again, you can get the total amount of salaries of the employees, considering the repeated entries of records, using the Group By clause as shown below.
Select name, sum(salary) from customers Group BY name;

On executing, the above query gives the following output.
Query: select name, sum(salary) from customers Group BY name 
+----------+-------------+ 
| name     | sum(salary) | 
+----------+-------------+ 
| Ramesh   | 21000       | 
| Komal    | 32000       | 
| Hardik   | 40000       | 
| Khilan   | 15000       | 
| Chaitali | 37000       | 
| kaushik  | 30000       | 
+----------+-------------+
Fetched 6 row(s) in 1.75s

 Print
 Add Notes
 Bookmark this page
How to change background color of Tkinter OptionMenu widget? - GeeksforGeeks

16 Mar, 2021
Prerequisites: Tkinter
While creating GUI applications, there occur various instances in which you need to make selections among various options available. For making such choices, the Option Menu widget was introduced. In this article, we will be discussing the procedure of changing menu background color of Tkinter’s option Menu widget. 
To achieve our required functionality a regular OptionMenu is first set up and then color is added and changed using config() method.
w = OptionMenu(app, #Options Menu widget name, “#Opton1”, “#Option2”, “#Option3”)
w.config(bg = “#Background Color of Options Menu”, fg=”#Text Color”)
OptionMenu() is used to create a dropdown menu
Syntax:
OptionMenu(master,options)
Parameters:
master: This parameter is used to represents the parent window.
options: Contain the Menu values
config() is used to set up the color change
Import module
Now, create a GUI app using tkinter
Next, give a title to the app(optional).
Then, create an Options Menu widget.
Moreover, create the Displayed Options for Options Menu widget.
Further, set the menu background color.
Assign the text you want to appear when Options Menu is not open
Set the background color of Displayed Options.
Display the Options Menu widget in GUI
Finally, make the loop for displaying the GUI app on the screen
Program:
Python
# Python program to change menu background# color of Tkinter's Option Menu  # Import the library tkinterfrom tkinter import *  # Create a GUI appapp = Tk()  # Give title to your GUI appapp.title("Vinayak App")  # Construct the label in your appl1 = Label(app, text="Choose the the week day here")  # Display the label l1l1.grid()  # Construct the Options Menu widget in your apptext1 = StringVar()  # Set the value you wish to see by defaulttext1.set("Choose here")  # Create options from the Option Menuw = OptionMenu(app, text1, "Sunday", "Monday", "Tuesday",               "Wednesday", "Thursday", "Friday", "Saturday")  # Se the background color of Options Menu to greenw.config(bg="GREEN", fg="WHITE")  # Set the background color of Displayed Options to Redw["menu"].config(bg="RED")  # Display the Options Menuw.grid(pady=20)  # Make the loop for displaying appapp.mainloop()
Output:
Picked
Python Tkinter-exercises
Python-tkinter
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Python | os.path.join() method
Python | Pandas dataframe.groupby()
Create a directory in Python
Defaultdict in Python
Python | Get unique values from a list
How to extract extension from a filename using PHP ? - GeeksforGeeks

06 Dec, 2021
In this article, we will see how to extract the filename extension in PHP, along with understanding their implementation through the examples. There are a few different ways to extract the extension from a filename with PHP, which is given below:
Using pathinfo() function: This function returns information about a file. If the second optional parameter is omitted, an associative array containing dirname, basename, extension, and the filename will be returned. If the second parameter is true, it will return specific data.
Example: This example describes the use of the pathinfo() function that returns information about a path using an associative array or a string. 
PHP
<?php  $file_name = 'gfg.html';  $extension = pathinfo($file_name, PATHINFO_EXTENSION);  echo $extension;?>
html
Using end() function: It explodes the file variable and gets the last array element to be the file extension. The PHP end() function is used to get the last element of the array.
Example: This example describes the use of the end() function that is used to find the last element of the given array.
PHP
<?php  $file_name = 'gfg.html';  $temp= explode('.',$file_name);  $extension = end($temp);  echo $extension;?>
html
Using substr() and strrchr() functions:
substr(): A part of the string is returned.
strrchr(): The last occurrence of a string inside another string is determined.
Example: This example uses both substr()  function & strchr() function. 
PHP
<?php  $file_name = 'gfg.html';  $extension = substr(strrchr($file_name, '.'), 1);  echo $extension;?>
html
Using strrpos() function: This function is used to find the last occurrence position of a ‘.’ in a filename and enhances the file position by 1 to explode string (.)
Example: This example describes the use of the strrpos() function that finds the position of the last occurrence of a string in another string. 
PHP
<?php  $file_name = 'gfg.html';  $extension = substr($file_name, strrpos($file_name, '.') + 1);  echo $extension;?>
html
Using preg_replace() function: Using regular expressions like replace and search. The first parameter of this function is the search pattern, the second parameter $1 is a reference to whatever matches the first (.*), and the third parameter is the file name.
Example: This example uses the preg_replace() function to perform a regular expression for search and replace the content.
PHP
<?php  $file_name = 'gfg.html';  $extension = preg_replace('/^.*\.([^.]+)$/D', '$1', $file_name);  echo $extension;?>
html
bhaskargeeksforgeeks
PHP-file-handling
PHP-function
PHP-Questions
PHP
Web Technologies
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to execute PHP code using command line ?
How to Insert Form Data into Database using PHP ?
PHP in_array() Function
How to convert array to string in PHP ?
How to delete an array element based on key in PHP?
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
How to invoke the Chrome browser in Selenium with python?

We can invoke any browsers with the help of the webdriver package. From this package we get access to numerous classes. Next we have to import the selenium.webdriver package. Then we shall be exposed to all the browsers belonging to that package.
For invoking chrome browser, we have to select the Chrome class. Then create the driver object of that class. This is the most important and mandatory step for browser invocation.
Every chrome browser gives an executable file. Through Selenium we need to invoke this executable file which is responsible for invoking the actual chrome browser.
Next we need to download the chrome driver version as per our browser version. The path of the chromedriver.exe file needs to be added in the executable file. Then we need to use the get () method to launch our application in that particular browser.
Code Implementation
from selenium import webdriver
#browser exposes an executable file
#Through Selenium test we will invoke the executable file which will then #invoke actual browser
driver = webdriver.Chrome(executable_path="C:\\chromedriver.exe")
# to maximize the browser window
driver.maximize_window()
#get method to launch the URL
driver.get("https://www.tutorialspoint.com/index.htm")
#to refresh the browser
driver.refresh()
#to close the browser
driver.close()