code-rag-bench/online-tutorials huggingface dataset:
map upper_bound() function in C++ STL - GeeksforGeeks

03 Jun, 2020
The map::upper_bound() is a built-in function in C++ STL which returns an iterator pointing to the immediate next element just greater than k. If the key passed in the parameter exceeds the maximum key in the container, then the iterator returned points to the number of elements in the map container as key and element=0.
Syntax:
map_name.upper_bound(key)
Parameters: This function accepts a single mandatory parameter key which specifies the element whose upper_bound is returned.
Return Value: The function returns an iterator pointing to the immediate next element which is just greater than k. If the key passed in the parameter exceeds the maximum key in the container, then returned iterator points to map_name.end(). Note that end() is a special iterator that does not store address of a valid member of a map.
Below is the implementation of the above approach:
// C++ function for illustration// map::upper_bound() function#include <bits/stdc++.h>using namespace std;  int main(){    // initialize container    map<int, int> mp;      // insert elements in random order    mp.insert({ 12, 30 });    mp.insert({ 11, 10 });    mp.insert({ 15, 50 });    mp.insert({ 14, 40 });      // when 11 is present    auto it = mp.upper_bound(11);    cout << "The upper bound of key 11 is ";    cout << (*it).first << " " << (*it).second << endl;      // when 13 is not present    it = mp.upper_bound(13);    cout << "The upper bound of key 13 is ";    cout << (*it).first << " " << (*it).second << endl;      // when 17 is exceeds the maximum key, so size        // of mp is returned as key and value as 0.    it = mp.upper_bound(17);    cout << "The upper bound of key 17 is ";    cout << (*it).first << " " << (*it).second;    return 0;}
The upper bound of key 11 is 12 30
The upper bound of key 13 is 14 40
The upper bound of key 17 is 4 0

devsinghindra
CPP-Functions
cpp-map
STL
C++
STL
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Inheritance in C++
C++ Classes and Objects
Bitwise Operators in C/C++
Virtual Function in C++
Constructors in C++
Templates in C++ with Examples
Operator Overloading in C++
Socket Programming in C/C++
vector erase() and clear() in C++
Object Oriented Programming in C++
Full Adder using Verilog HDL - GeeksforGeeks

13 Sep, 2021
In this article, we will discuss the overview part of Full Adder using Verilog HDL. And the objective to understand the concept and will implement using Verilog HDL code for Full Adder. Let’s discuss it one by one.
Prerequisite – Full Adder in Digital Logic
Problem Statement : Write a Verilog HDL to design a Full Adder. Let’s discuss it step by step as follows.
Step-1 :Concept –  Full Adder is a digital combinational Circuit which is having three input a, b and cin and two output sum and cout. Below Truth Table is drawn to show the functionality of the Full Adder.
Figure shows the block diagram of design requirements : Full Adder
Step-2 :Truth Table –
Step-3 :Verilog HDL code for Full Adder (Design Part) –
// Code your design : Full Adder
module full_add(a,b,cin,sum,cout);
  input a,b,cin;
  output sum,cout;
  wire x,y,z;
 
// instantiate building blocks of full adder 
  half_add h1(.a(a),.b(b),.s(x),.c(y));
  half_add h2(.a(x),.b(cin),.s(sum),.c(z));
  or o1(cout,y,z);
endmodule : full_add

// code your half adder design             
module half_add(a,b,s,c); 
  input a,b;
  output s,c;
 
// gate level design of half adder  
  xor x1(s,a,b);
  and a1(c,a,b);
endmodule :half_add
Step-4 :Test bench –
// Code your testbench here
module full_add_tb;
  reg a,b,cin;
  wire sum,cout;
 
// instantiate the DUT block  
  full_add f1(.a(a),.b(b),.cin(cin),.sum(sum),.cout(cout));
 
// this particular line is added to dump the file on online simulator
  initial begin $dumpfile("full_tb.vcd");$dumpvars(); end

// insert all the inputs 
  initial begin a=1'b1;  #4; a=1'b0;#10 $stop();end
  initial begin b=1'b1; forever #2 b=~b;end
  initial begin cin=1'b1;forever #1 cin=~cin; #10 $stop();end

// monitor all the input and output ports at times 
// when any of the input changes its state

 initial begin $monitor(" time=%0d A=%b B=%b 
                          Cin=%b Sum=%b Cout=%b",$time,a,b,cin,sum,cout);end
 endmodule : full_add_tb
Step-5 :Expected Output –
time=0 A=1 B=1 Cin=1 Sum=1 Cout=1
time=1 A=1 B=1 Cin=0 Sum=0 Cout=1
time=2 A=1 B=0 Cin=1 Sum=0 Cout=1
time=3 A=1 B=0 Cin=0 Sum=1 Cout=0
time=4 A=0 B=1 Cin=1 Sum=0 Cout=1
time=5 A=0 B=1 Cin=0 Sum=1 Cout=0
time=6 A=0 B=0 Cin=1 Sum=1 Cout=0
time=7 A=0 B=0 Cin=0 Sum=0 Cout=0
time=8 A=0 B=1 Cin=1 Sum=0 Cout=1
time=9 A=0 B=1 Cin=0 Sum=1 Cout=0
time=10 A=0 B=0 Cin=1 Sum=1 Cout=0
time=11 A=0 B=0 Cin=0 Sum=0 Cout=0
time=12 A=0 B=1 Cin=1 Sum=0 Cout=1
time=13 A=0 B=1 Cin=0 Sum=1 Cout=0
Digital Electronics & Logic Design
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Introduction to memory and memory units
Analog to Digital Conversion
Latches in Digital Logic
Introduction of Sequential Circuits
Restoring Division Algorithm For Unsigned Integer
Ring Counter in Digital Logic
Transmission Impairment in Data Communication
Synchronous 3 bit Up/Down counter
Differences between Synchronous and Asynchronous Counter
Counter Design using verilog HDL
jQuery | event.relatedTarget Property with Example - GeeksforGeeks

12 Feb, 2019
The event.relatedTarget is an inbuilt property in jQuery that is used to find which element is being entered or gets exit on mouse movement.Syntax:
event.relatedTarget

Parameter: It does not accept any parameter because it is a property not a function.Return Value: It returns which element being entered or exited on mouse movement.
jQuery code to show the working of event.relatedTarget property:
<html>  <head>    <script     src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">    </script>    <script>        <!-- jQuery code to show working of this property -->        $(document).ready(function() {            $("div, p").mouseenter(function(event) {                $("#d2").html("Pointer at : " + event.relatedTarget.nodeName);            });        });    </script>    <style>        #d1 {            height: 100px;            width: 50%;            padding: 10px;            border: 2px solid green;        }                  #d2 {            height: 20px;            width: 50%;            padding: 10px;            margin-top: 10px;            border: 2px solid green;        }    </style></head>  <body>    <!-- this is outer div element -->    <div id="d1">        <!-- this is inner div element -->        <div>This is a div element </div>        <!-- this is paragraph element -->        <p style="background-color:lightgreen">This is a paragraph</p>    </div>    <div id="d2" /></body>  </html>
Output:Before mouse pointer is moved over the div element-
After mouse pointer is moved over the div element-
jQuery-Events
JavaScript
JQuery
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
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 append HTML code to a div using JavaScript ?
JQuery | Set the value of an input text field
Form validation using jQuery
How to change selected value of a drop-down list using jQuery?
How to change the background color after clicking the button in JavaScript ?
How to fetch data from JSON file and display in HTML table using jQuery ?
AngularJS | angular.lowercase() Function - GeeksforGeeks

22 Apr, 2019
The angular.lowercase() Function in AngularJS is used to convert the string into lowercase. It can be used when user wants to show the text in lowercase instead of uppercase or one wants to compare two strings.Syntax:
angular.lowercase(string)
Example: In this example the string is converted into lowercase.
<html ng-app="app">    <head>    <script src=    "https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js">    </script>    <title>angular.lowercase()</title>    </head>    <body style="text-align:center">        <h1 style="color:green">GeeksforGeeks</h1>        <h2>angular.lowercase()</h2>        <div ng-controller="geek">        <br>        <b>Before: </b>{{ string1 }}        <br><br>        <button id="myButton" ng-mousedown="lower()">Click it!</button>        <br><br>          <b>After: </b>{{ string2 }}        </div>        <script>            var app = angular.module('app', []);            app.controller('geek', function($scope) {            $scope.obj1 =             "GEEKSFORGEEKS IS THE COMPUTER SCIENCE PORTAL FOR GEEKS."            $scope.obj2;            $scope.string1 = $scope.obj1;            $scope.lower = function() {            $scope.string2 = angular.lowercase($scope.obj1);            }            });        </script>    </body></html>
Output:Before Click:After Click:
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
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?
Difference between var, let and const keywords in JavaScript
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to create footer to stay at the bottom of a Web page?
Differences between Functional Components and Class Components in React
Node.js fs.readFileSync() Method
GATE | GATE CS 2013 | Question 7 - GeeksforGeeks

28 Jun, 2021
Which one of the following is the tightest upper bound that represents the time complexity of inserting an object into a binary search tree of n nodes?(A) O(1)(B) O(Logn)(C) O(n)(D) O(nLogn)Answer: (C)Explanation: To insert an element, we need to search for its place first. The search operation may take O(n) for a skewed tree like following.
To insert 50, we will have to traverse all nodes.
        10
         \
          20
            \
             30
               \
                40

Quiz of this Question
GATE-CS-2013
GATE-GATE CS 2013
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | Gate IT 2007 | Question 25
GATE | GATE-CS-2001 | Question 39
GATE | GATE-CS-2000 | Question 41
GATE | GATE-CS-2005 | Question 6
GATE | GATE MOCK 2017 | Question 21
GATE | GATE-CS-2006 | Question 47
GATE | GATE MOCK 2017 | Question 24
GATE | Gate IT 2008 | Question 43
GATE | GATE-CS-2009 | Question 38
GATE | GATE-CS-2003 | Question 90
get_cookies driver method - Selenium Python - GeeksforGeeks

15 May, 2020
Selenium’s Python Module is built to perform automated testing with Python. Selenium Python bindings provides a simple API to write functional/acceptance tests using Selenium WebDriver. To open a webpage using Selenium Python, checkout – Navigating links using get method – Selenium Python. Just being able to go to places isn’t terribly useful. What we’d really like to do is to interact with the pages, or, more specifically, the HTML elements within a page. There are multiple strategies to find an element using Selenium, checkout – Locating Strategies. Selenium WebDriver offers various useful methods to control the session, or in other words, browser. For example, adding a cookie, pressing back button, navigating among tabs, etc.
This article revolves around get_cookies drrver method in Selenium. get_cookies method is used to get all cookies in current session. It returns a set of dictionaries, corresponding to cookies visible in the current session.
Syntax –
driver.get_cookies()
Example –Now one can use get_cookies method as a driver method as below –
diver.get("https://www.geeksforgeeks.org/")
driver.get_cookies()

To demonstrate, get_cookies method of WebDriver in Selenium Python. Let’ s visit https://www.geeksforgeeks.org/ and get all cookies.
Program –
# import webdriverfrom selenium import webdriver  # create webdriver objectdriver = webdriver.Firefox()  # get geeksforgeeks.orgdriver.get("https://www.geeksforgeeks.org/")  # get all cookies in scope of sessionprint(driver.get_cookies())
Output –Browser cookies are as verified below –Terminal Output –
Python-selenium
selenium
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 | Get unique values from a list
Python | os.path.join() method
Defaultdict in Python
Create a directory in Python
Python | Pandas dataframe.groupby()
modinfo command in Linux with Examples - GeeksforGeeks

23 May, 2019
modinfo command in Linux system is used to display the information about a Linux Kernel module. This command extracts the information from the Linux kernel modules given on the command line. If the module name is not a file name, then the /lib/modules/kernel-version directory is searched by default. modinfo can understand modules from any of the Linux Kernel architecture.
Syntax:
modinfo [-0] [-F field] [-k kernel] [modulename|filename...]

Example:
modinfo bluetooth
Options:
modinfo command with help option: It will print the general syntax of the modinfo along with the various options and gives a brief description about each option.
modinfo -V: This option gives the version information of modinfo command.modinfo -V
modinfo -V
modinfo -F: This option only print this field value, one per line. Field names are case-insensitive. Common fields that may include author, description, license, parm, depends, and alias. There are possibly multiple parm, alias and depends on fields. The special field filename lists are the filename of the module.modinfo -F modulename
modinfo -F modulename
modinfo -b : This option is the root directory for modules.modinfo -b modulename
modinfo -b modulename
modinfo -k : This option provides the information about a kernel other than the running one. This option is particularly being useful for the distributions that need to extract information from a newly installed set of kernel modules. For example, to find which firmware files are needed by various modules inside a new kernel for which you need to make an initrd/initramfs image prior to booting.modinfo -k modulename
modinfo -k modulename
modinfo -0: This option use the ASCII zero character to separate field values, instead of a new line. This option is proven useful for scripts since a new line can theoretically appear inside a field.Example:modinfo bluetooth -0
Example:
modinfo bluetooth -0
modinfo -a –author, -d –description, -l –license, -p –parameters, -n –filename: These are the shortcuts used for the –field flag’s author, description, license, parm and filename arguments to make the transition from the old modutils modinfo easy.Example:modinfo bluetooth -amodinfo bluetooth -nmodinfo bluetooth -dmodinfo bluetooth -lmodinfo bluetooth -p
Example:
modinfo bluetooth -a
modinfo bluetooth -n
modinfo bluetooth -d
modinfo bluetooth -l
modinfo bluetooth -p
linux-command
Linux-misc-commands
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
scp command in Linux with Examples
mv command in Linux with examples
Docker - COPY Instruction
SED command in Linux | Set 2
chown command in Linux with Examples
nohup Command in Linux with Examples
Named Pipe or FIFO with example C program
Thread functions in C/C++
uniq Command in LINUX with examples
Start/Stop/Restart Services Using Systemctl in Linux
Data Structures | Queue | Question 11 - GeeksforGeeks

28 Nov, 2021
Consider the following pseudo code. Assume that IntQueue is an integer queue. What does the function fun do?
void fun(int n){    IntQueue q = new IntQueue();    q.enqueue(0);    q.enqueue(1);    for (int i = 0; i < n; i++)    {        int a = q.dequeue();        int b = q.dequeue();        q.enqueue(b);        q.enqueue(a + b);        print(a);    }}
(A) Prints numbers from 0 to n-1(B) Prints numbers from n-1 to 0(C) Prints first n Fibonacci numbers(D) Prints first n Fibonacci numbers in reverse order.Answer: (C)Explanation: The function prints first n Fibonacci Numbers. Note that 0 and 1 are initially there in q. In every iteration of loop sum of the two queue items is enqueued and the front item is dequeued.Quiz of this Question
sumitgumber28
Data Structures
Data Structures-Queue
Data Structures
Data Structures
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Data Structures | Linked List | Question 5
Data Structures | Tree Traversals | Question 4
Data Structures | Linked List | Question 6
Difference between Singly linked list and Doubly linked list
Advantages and Disadvantages of Linked List
Data Structures | Graph | Question 9
FIFO vs LIFO approach in Programming
C program to implement Adjacency Matrix of a given Graph
Introduction to Data Structures
Data Structures | Stack | Question 1
Python | Find Dissimilar Elements in Tuples - GeeksforGeeks

11 Nov, 2019
Sometimes, while working with tuples, we can have a problem in which we need dissimilar features of two records. This type of application can come in Data Science domain. Let’s discuss certain ways in which this problem can be solved.
Method #1 : Using set() + "^" operator
This task can be performed using symmetric difference functionality offered by XOR operator over sets. The conversion to set is done by set().
# Python3 code to demonstrate working of# Dissimilar elements in tuples# Using set() + "^" operator  # initialize tuplestest_tup1 = (3, 4, 5, 6)test_tup2 = (5, 7, 4, 10)  # printing original tuplesprint("The original tuple 1 : " + str(test_tup1))print("The original tuple 2 : " + str(test_tup2))  # Dissimilar elements in tuples# Using set() + "^" operatorres = tuple(set(test_tup1) ^ set(test_tup2))  # printing resultprint("The Dissimilar elements from tuples are : " + str(res))
The original tuple 1 : (3, 4, 5, 6)
The original tuple 2 : (5, 7, 4, 10)
The Dissimilar elements from tuples are : (3, 6, 7, 10)

 
Method #2 : Using symmetric_difference() + set()
This is method similar to above method, the difference is that instead of XOR operator, we use inbuilt function to perform the task of filtering dissimilar elements.
# Python3 code to demonstrate working of# Dissimilar elements in tuples# Using symmetric_difference() + set()  # initialize tuplestest_tup1 = (3, 4, 5, 6)test_tup2 = (5, 7, 4, 10)  # printing original tuplesprint("The original tuple 1 : " + str(test_tup1))print("The original tuple 2 : " + str(test_tup2))  # Dissimilar elements in tuples# Using symmetric_difference() + set()res = tuple(set(test_tup1).symmetric_difference(set(test_tup2)))  # printing resultprint("The Dissimilar elements from tuples are : " + str(res))
The original tuple 1 : (3, 4, 5, 6)
The original tuple 2 : (5, 7, 4, 10)
The Dissimilar elements from tuples are : (3, 6, 7, 10)

Python tuple-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
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
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Split string into list of characters
Python | Convert a list to dictionary
How to print without newline in Python?
Python | Sort Flatten list of list - GeeksforGeeks

11 May, 2020
The flattening of list of lists has been discussed earlier, but sometimes, in addition to flattening, it is also required to get the string in a sorted manner. Let’s discuss certain ways in which this can be done.
Method #1 : Using sorted() + list comprehensionThis idea is similar to flattening a list of list but in addition to it, we add a sorted function to sort the returned flattened list done by list comprehension.
# Python3 code to demonstrate# sort flatten list of list # using sorted + list comprehension  # initializing list of list test_list = [[3, 5], [7, 3, 9], [1, 12]]  # printing original list of list print("The original list : " + str(test_list))  # using sorted + list comprehension# sort flatten list of listres = sorted([j for i in test_list for j in i])  # print resultprint("The sorted and flattened list : " + str(res))
The original list : [[3, 5], [7, 3, 9], [1, 12]]
The sorted and flattened list : [1, 3, 3, 5, 7, 9, 12]

 
Method #2 : Using itertools.chain() + sorted()The task that was done by list comprehension above can also be performed using the chain function that links elements of list and then sorted function does the task of sorting.
# Python3 code to demonstrate# sort flatten list of list # using itertools.chain() + sorted()from itertools import chain  # initializing list of list test_list = [[3, 5], [7, 3, 9], [1, 12]]  # printing original list of list print("The original list : " + str(test_list))  # using itertools.chain() + sorted()# sort flatten list of listres = sorted(chain(*test_list))  # print resultprint("The sorted and flattened list : " + str(res))
The original list : [[3, 5], [7, 3, 9], [1, 12]]
The sorted and flattened list : [1, 3, 3, 5, 7, 9, 12]

Python list-programs
Python-list-of-lists
Python-sort
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
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
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Split string into list of characters
Python | Convert a list to dictionary
How to print without newline in Python?
Difference between Function and Predicate in Java 8

Function and Predicate both functional interface was introduced in Java 8 to implement functional programming in Java.
Function interface is used to do the transformation.It can accepts one argument and produces a result. On the other side, Predicate can also accept only one argument but it can only return boolean value. It is used to test the condition.
public class Main {
   public static void main(String args[]) {
      List<Integer> numList = new ArrayList<>();
      numList.add(5);
      numList.add(10);
      Predicate<Integer> pred = i -> i > 5;
      numList.stream().filter(pred).forEach(i -> System.out.println(i));
   }
}
public class Main {
   public static void main(String args[]) {
      List<Integer> numList = new ArrayList<>();
      numList.add(78);
      numList.add(10);
      Function<Integer, Integer> fun = i -> i / 2;
      numList.stream().map(fun).forEach(System.out::println);    
   }
}
Tryit Editor v3.7

CSS 2D Transforms
Tryit: The rotate() method
IS vs AS Operators in C#

The "is" operator in C# checks whether the run-time type of an object is compatible with a given type or not.
The following is the syntax −
expr is type
Here, expr is the expression
type is the name of the type
The following is an example showing the usage of is operator in C# &minis;
 Live Demo
using System;

class One { }
class Two { }

public class Demo {
   public static void Test(object obj) {
      One x;
      Two y;

      if (obj is One) {
         Console.WriteLine("Class One");
         x = (One)obj;
      } else if (obj is Two) {
         Console.WriteLine("Class Two");
         y = (Two)obj;
      } else {
         Console.WriteLine("None of the classes!");
      }
   }

   public static void Main() {
      One o1 = new One();
      Two t1 = new Two();
      Test(o1);
      Test(t1);
      Test("str");
      Console.ReadKey();
   }
}
Class One
Class Two
None of the classes!
The "as" operator perform conversions between compatible types. It is like a cast operation and it performs only reference conversions, nullable conversions, and boxing conversions. The as operator can't perform other conversions, such as user-defined conversions, which should instead be performed by using cast expressions.
The following is an example showing the usage of as operation in C#. Here as is used for conversion −
string s = obj[i] as string;
Try to run the following code to work with ‘as’ operator in C# −
 Live Demo
using System;

public class Demo {
   public static void Main() {
      object[] obj = new object[2];
      obj[0] = "jack";
      obj[1] = 32;

      for (int i = 0; i < obj.Length; ++i) {
         string s = obj[i] as string;
         Console.Write("{0}: ", i);
         if (s != null)
         Console.WriteLine("'" + s + "'");
         else
         Console.WriteLine("This is not a string!");
      }
      Console.ReadKey();
   }
}
0: 'jack'
1: This is not a string!
How can I create a simple message box in Tkinter?

Tkinter is a popular Python library for creating and developing applications. It has
various methods and functions that can be used for adding multiple features in an
application. Using Tkinter, we can create dialogue boxes and other widgets.
In this article, we will see how we can create a simple message box that will pop
up and display some information to select an option.
#Import the required libraries
from tkinter import *
from tkinter import messagebox
#Create an instance of tkinter frame or window
win= Tk()

#Set the geometry
win.geometry("700x100")

#Define the function for button
def pop_up():
   messagebox.showerror("Error! Please check and correct.")
   messagebox.showwarning("Warning! You can not proceed.")

#Create a button
Button(win, text="Click",command= pop_up).pack(pady=20)

#Keep Running the window
win.mainloop()
Running the above code will produce the following window.
If you click the “Click” button, the following error message will pop up.
Again, if you click the “OK” button, it will pop up the following warning message.
How do I create a popup window using Tkinter?

Tkinter supports toplevel classes, and these classes contain toplevel window. Toplevel window is also known as child window. We can create a toplevel window by creating the object of Toplevel(parent).
The toplevel window inherits all the properties of Tkinter's parent object. It can contain widgets, frames, canvas and other objects as well.
In this example, we will create a button that will open a popup window.
#Import the required libraries
from tkinter import *

#Create an instance of Tkinter Frame
win = Tk()

#Set the geometry
win.geometry("700x250")

def open_win():
   #Create a Button to Open the Toplevel Window
   top= Toplevel(win)
   top.geometry("700x250")
   top.title("Child Window")
   #Create a label in Toplevel window
   Label(top, text= "Hello World!")

Label(win, text= "Click the button to Open Popup Window", font= ('Helvetica 18')).place(relx=.5, rely=.5, anchor= CENTER)
Button(win, text= "Click Me", background= "white", foreground= "blue", font= ('Helvetica 13 bold'), command= open_win).pack(pady= 50)
win.mainloop()
Running the above code will display a window with a Label and a button.
Now, clicking the button will open a New Popup window.
Group by element in array JavaScript

Suppose, we have an array of objects like this −
const arr = [
   {"name": "toto", "uuid": 1111},
   {"name": "tata", "uuid": 2222},
   {"name": "titi", "uuid": 1111}
];
We are required to write a JavaScript function that splits the objects into separate array of
arrays that have the similar values for the uuid property.
Therefore, the output should look like this −
const output = [
   [
      {"name": "toto", "uuid": 1111},
      {"name": "titi", "uuid": 1111}
   ],
   [
      {"name": "tata", "uuid": 2222}
   ]
];
The code for this will be −
const arr = [
   {"name": "toto", "uuid": 1111},
   {"name": "tata", "uuid": 2222},
   {"name": "titi", "uuid": 1111}
];
const groupByElement = arr => {
   const hash = Object.create(null),
   result = [];
   arr.forEach(el => {
      if (!hash[el.uuid]) {
         hash[el.uuid] = [];
         result.push(hash[el.uuid]);
      };
      hash[el.uuid].push(el);
   });
   return result;
};
console.log(groupByElement(arr));
The output in the console −
[
   [ { name: 'toto', uuid: 1111 }, { name: 'titi', uuid: 1111 } ],
   [ { name: 'tata', uuid: 2222 } ]
]
Creating a Docker Image with Git Installed - GeeksforGeeks

29 Oct, 2020
Version control is one of the most important aspects of any software development project and when we talk about version control, there is no better tool than Git. The majority of the developers depend upon Git to manage and share their project components among the team members. 
Even if you are running your project on Docker, you can still access your git account inside Docker Containers. All you need to do is just install Git inside your Docker Container. In this article, we will discuss exactly the same. We will create an Ubuntu Image, install Git inside it, create a Container associated with the Image, and verify whether Git has been installed or not.
To create a Docker image with git follow the below steps:
You can use the following template to create your Dockerfile. 
FROM ubuntu:latest
RUN apt-get -y update
RUN apt-get -y install git


In the above Dockerfile, we have specified instructions to pull the Ubuntu base image, update the OS, and install Git inside it.
After creating the Dockerfile, we can build the Docker Image using the Docker build command.
sudo docker build -t sample-image .


To verify whether the image has been built or not, you can list all the Images.
sudo docker images

After you have built the Image, you can run the Container associated with the Image, using the Docker Run command.
sudo docker run -it sample-image bash


The above command creates and runs a Container and fires up the bash of the Docker Container.
After you have the bash opened up, you can verify whether Git has been installed or not by checking the version of Git.
git --version


This command returns the version of the git installed.
Docker Container
linux
Advanced Computer Subject
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Copying Files to and from Docker Containers
Principal Component Analysis with Python
Python | Decision Tree Regression using sklearn
Fuzzy Logic | Introduction
Classifying data using Support Vector Machines(SVMs) in Python
How to create a REST API using Java Spring Boot
An introduction to Machine Learning
Mounting a Volume Inside Docker Container
Basics of API Testing Using Postman
ML | Stochastic Gradient Descent (SGD)
chsh command in Linux with examples - GeeksforGeeks

26 Aug, 2021
chsh command in Linux is used to change the user’s login shell(currently login shell). Shell is an interactive user interface with an operating system and can be considered an outer layer of the operating system. The bash shell is one of the most widely used login shells in Linux. This command allows the user to change the shell from the current shell. It can also give warning if the shell is not present in the /etc/shells file. The superuser can change the login shell for the existing accounts. 
Syntax:  
chsh [OPTIONS] [LOGIN]
Example 1: To show the list of all shells. You can use echo command along with ‘$SHELL’ to check the current shell 
Example 2: To change the current logging shell 
Options: 
-l: Used to specifies your login shell.
-u: Prints the list of shells.
-v: Shows information about version and exits.
-s: Used to set the shell as your login shell.
sooda367
linux-command
Linux-Shell-Commands
Picked
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Thread functions in C/C++
Basic Operators in Shell Scripting
nohup Command in Linux with Examples
Array Basics in Shell Scripting | Set 1
Named Pipe or FIFO with example C program
chown command in Linux with Examples
mv command in Linux with examples
Docker - COPY Instruction
Start/Stop/Restart Services Using Systemctl in Linux
SED command in Linux | Set 2
How to create a data frame with a column having repeated values in R?

To create a data frame with a column having repeated values, we simply need to use rep function and we can repeat the values in a sequence of the values passed or repeating each value a particular number of times. For example, if we have three values 1, 2, 3 then the data frame can be created by repeating these values as 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3 or by repeating the same as 1, 1, 1, 2, 2, 2, 3, 3, 3.
 Live Demo
x<-rep(c(1,2,3,4),times=5)
df1<-data.frame(x)
df1
   x
1  1
2  2
3  3
4  4
5  1
6  2
7  3
8  4
9  1
10 2
11 3
12 4
13 1
14 2
15 3
16 4
17 1
18 2
19 3
20 4
 Live Demo
y<-rep(c(1,2,3,4),each=5)
df2<-data.frame(y)
df2
   y
1  1
2  1
3  1
4  1
5  1
6  2
7  2
8  2
9  2
10 2
11 3
12 3
13 3
14 3
15 3
16 4
17 4
18 4
19 4
20 4
 Live Demo
z<-rep(c("A","B","C","D","E"),each=4)
df3<-data.frame(z)
df3
   z
1  A
2  A
3  A
4  A
5  B
6  B
7  B
8  B
9  C
10 C
11 C
12 C
13 D
14 D
15 D
16 D
17 E
18 E
19 E
20 E
 Live Demo
w<-rep(c("A","B","C","D","E"),times=4)
df4<-data.frame(w)
df4
   w
1  A
2  B
3  C
4  D
5  E
6  A
7  B
8  C
9  D
10 E
11 A
12 B
13 C
14 D
15 E
16 A
17 B
18 C
19 D
20 E
Powershell - Logical Operators Examples

The following scripts demonstrates the logical operators.
> $a = 10
 
> $b = 20
 
> $a -AND $b
 True
 
> $a -OR $b
 True

> -NOT ($a -AND $b)
Python program to Increment Suffix Number in String

02 Dec, 2020
Given a String, the task is to write a Python program to increment the number which is at end of the string.
Input : test_str = ‘geeks006’ Output : geeks7 Explanation : Suffix 006 incremented to 7.
Input : test_str = ‘geeks007’ Output : geeks8 Explanation : Suffix 007 incremented to 8.  
Method #1 : Using findall() + join() + replace()
In this, strategy we perform the task of finding number using findall(), then perform the task of separating numeric string and prefix string, then an increment of a numeric string is performed. At last, the string is joined to get a prefix followed by an incremented number.
Python3
# Python3 code to demonstrate working of # Increment Suffix Number# Using findall() + join() + replace()import re  # initializing stringtest_str = 'geeks006'  # printing original stringprint("The original string is : " + str(test_str))  # getting suffix number reg = re.compile(r'[ 0 - 9]')mtch = reg.findall(test_str)  # getting number num = ''.join(mtch[-3 : ])pre_str = test_str.replace(num, '')  # Increment number add_val = int(num) + 1  # joining prefix str and added value res = pre_str + str(add_val)      # printing result print("Incremented numeric String : " + str(res)) 
Output:
The original string is : geeks006
Incremented numeric String : geeks61
Method #2 : Using sub() + group() + zfill()
In this, we perform the task of grouping numbers using group() and incrementing, zfill() is used for task of filling the required leading values in numerical. The sub() is used to find the numerical part of strings.
Python3
# Python3 code to demonstrate working of # Increment Suffix Number# Using sub() + group() + zfill()import re  # initializing stringtest_str = 'geeks006'  # printing original stringprint("The original string is : " + str(test_str))  # fstring used to form string # zfill fills values post incrementres = re.sub(r'[0-9]+$',             lambda x: f"{str(int(x.group())+1).zfill(len(x.group()))}",              test_str)      # printing result print("Incremented numeric String : " + str(res)) 
Output:
The original string is : geeks006
Incremented numeric String : geeks007
Python string-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Zoho Off Campus Drive | Set 26 (Software Developer)

04 Dec, 2018
Round 1: Written test
The first round comprised of 40 one mark questions (without options) from C output questions and flow chart questions (Test Duration: 2 hour) :-
C output questions part covered questions from iterations, pointers, array and data structures.
Suggestion: I would suggest to do quizzes from geeksforgeeks to get in touch with all concepts of C and other subjects.
Tips :- Solve the questions with calm mind. Don’t stress yourself during test because you have to do 40 questions in 120 minutes. Don’t spend too much time on any question if you are not able to do it in the first attempt.
Round 2: Coding round
You will be provided laptop and turbo C compiler. Java and C++ not allowed for second round.
Some of the questions are.
1. Print second frequently occurring number in given series
Example :
Input: 1 1 2 3 1 2 4
Output: 2

Explanation: 1 occurs 3 times, 2 occurs 2 times, 3 occurs 1 time and 4 occurs 1 time. Hence second frequently occurring number in given series is 2
2. Print only numbers which is present in Fibonacci series (0 1 1 2 3 5 8 ........)
Example:
Input: 2 10 4 8
Output: 2 8 
Input: 1 10 6 8 13 21
Output: 1 8 13 21

3. Print pattern like this
Example:
Input: 1
Output: 0

Input: 2
Output: 
0 0
0 1
1 0
1 1

Input: 3
Output:
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1

4. NxN matrix will be provided. 0->block, 1->Not a blockAlways starting point is (0,0), Ending point is (N-1,N-1).You have to go from starting point to ending point. One valid solution is enough.Example:
 
   Input:
   N=4 
   1 1 0 0
   1 0 0 1
   1 1 1 1
   0 0 0 1
   Output:
   _ 1 0 0
   _ 0 0 1
   _ _ _ _
   0 0 0 _

5. Insert 0 after consecutive (K times) of 1 is found.Example:
Input:
Number of bits: 12
Bits: 1 0 1 1 0 1 1 0 1 1 1 1
Consecutive K: 2

Output:
1 0 1 1 0 0 1 1 0 0 1 1 0 1 1 0
Round 3: Advance programming round
You have to code for Railway reservation system.
(Test Duration : 3 hours)
Round 4 and 5: Interview (technical and HR)
In technical interview some puzzles and programming questions were asked.
In HR interview some basic HR questions were asked.
Finally 3 got selected for extend interview process.
In extend interview process they will assign a mentor for you. Your mentor will give some task from Java, Javascript etc..After one month they confirmed my offer.
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Off-Campus
Zoho
Interview Experiences
Zoho
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python calendar module | isleap() method - GeeksforGeeks

22 Oct, 2018
Calendar module allows to output calendars like program, and provides additional useful functions related to the calendar. Functions and classes defined in Calendar module use an idealized calendar, the current Gregorian calendar extended indefinitely in both directions.
In Python, calendar.isleap() is a function provided in calendar module for simple text calendars.
isleap() method is used to get value True if the year is a leap year, otherwise gives False.
Syntax: isleap()
Parameter: 
year: Year to be tested leap or not.

Returns: Returns True if the year is a leap year, otherwise False.
Code #1:
# Python program to explain working of isleap() method  # importing calendar moduleimport calendar  # checking whether given year is leap or notprint(calendar.isleap(2016))print(calendar.isleap(2001))
Output:
True
False
 
Code #2: Explaining working of isleap() method.
Below code prints 4th months calendar if given year is year, otherwise notifies year is not leap.
# Python code to demonstrate the working of isleap()   # importing calendar module for calendar operations import calendar   year = 2017  # calling isleap() method to verifyval = calendar.isleap(year)  # checking the condition is True or notif val == True:      # print 4th month of given leap year     calendar.prmonth(year, 4, 2, 1)   # Returned False, year is not a leapelse:    print("% s is not a leap year" % year)
Output:
2017 is not a leap year
Python Calander-module
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Install PIP on Windows ?
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | Pandas dataframe.groupby()
Defaultdict in Python
Python | Get unique values from a list
Python Classes and Objects
Python | os.path.join() method
Create a directory in Python
How to read the data from a file in Java?

The read(byte[] b) method of the FileInputStream class reads up to the b.length from this file input stream to the array of bytes. The method blocks until some input is available.
import java.io.File;
import java.io.FileInputStream;
public class Sample {
   public static void main(String args[]) throws Exception {
      int count =0;
      File file = new File("myData");
      FileInputStream fis = new FileInputStream(file);
      byte[] bytesArray = new byte[(int)file.length()];
      fis.read(bytesArray);
      String s = new String(bytesArray);
      System.out.println("Contents of the given file are :: " +new String(bytesArray));
   }
}
Contents of the given file are :: Hi how are you welcome to tutorialspoint
Bootstrap 4 .border-danger class

Use the border-danger class to set a red border to an element.
Set the border-danger class to an element as if we include any other class −
<div class="new border border-danger">
  Red Border
</div>
Above, we have also set another class “new”, to style the element −
<style>
.new {
  width: 120px;
  height: 120px;
  margin: 20px;
}
</style>
You can try to run the following code to implement the border-danger class −
Live Demo
<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Bootstrap Example</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
    <style>
    .new {
      width: 120px;
      height: 120px;
      margin: 20px;
     }
    </style>
  </head>
<body>

<div class="container">
  <p>Rectangle with red border:</p>
  <div class="new border border-danger">Red Border</div>
</div>

</body>
</html>
Connectivity in a directed graph

To check connectivity of a graph, we will try to traverse all nodes using any traversal algorithm. After completing the traversal, if there is any node, which is not visited, then the graph is not connected.
For the directed graph, we will start traversing from all nodes to check connectivity. Sometimes one edge can have the only outward edge but no inward edge, so that node will be unvisited from any other starting node.
In this case, the traversal algorithm is recursive DFS traversal.
Input:
Adjacency matrix of a graph
   0 1 0 0 0
   0 0 1 0 0
   0 0 0 1 1
   1 0 0 0 0
   0 1 0 0 0

Output:
The Graph is connected.     
traverse(u, visited)
Input: The start node u and the visited node to mark which node is visited.
Output − Traverse all connected vertices.
Begin
   mark u as visited
   for all vertex v, if it is adjacent with u, do
      if v is not visited, then
         traverse(v, visited)
   done
End
isConnected(graph)
Input: The graph.
Output: True if the graph is connected.
Begin
   define visited array
   for all vertices u in the graph, do
      make all nodes unvisited
      traverse(u, visited)
      if any unvisited node is still remaining, then
         return false
   done
   return true
End
#include<iostream>
#define NODE 5
using namespace std;

int graph[NODE][NODE] = {
   {0, 1, 0, 0, 0},
   {0, 0, 1, 0, 0},
   {0, 0, 0, 1, 1},
   {1, 0, 0, 0, 0},
   {0, 1, 0, 0, 0}
};
                                               
void traverse(int u, bool visited[]) {
   visited[u] = true;    //mark v as visited

   for(int v = 0; v<NODE; v++) {
      if(graph[u][v]) {
         if(!visited[v])
            traverse(v, visited);
      }
   }
}

bool isConnected() {
   bool *vis = new bool[NODE];
   //for all vertex u as start point, check whether all nodes are visible or not

   for(int u; u < NODE; u++) {
      for(int i = 0; i<NODE; i++)
         vis[i] = false;    //initialize as no node is visited
               
      traverse(u, vis);
      for(int i = 0; i<NODE; i++) {
         if(!vis[i])    //if there is a node, not visited by traversal, graph is not connected
            return false;
      }
   }
   return true;
}

int main() {
   if(isConnected())
      cout << "The Graph is connected.";
   else
      cout << "The Graph is not connected.";
}
The Graph is connected.
Find all collections in MongoDB with specific field?

Let us implement the above syntax in order to find all documents in MongoDB with field name “StudentFirstName”. The query is as follows −
> db.getCollectionNames().forEach(function(myCollectionName) {
...    var frequency = db[myCollectionName].find({"StudentFirstName": {$exists: true}}).count();
...    if (frequency > 0) {
...       print(myCollectionName);
...    }
... });
This will produce the following output −
multiDimensionalArrayProjection
removeKeyFieldsDemo
stringOrIntegerQueryDemo
Let us verify the removeKeyFieldsDemo collection has field with name “StudentFirstName” or not. Following is the query −
> db.removeKeyFieldsDemo.find({"StudentFirstName":{$exists:true}});
This will produce the following output displaying the StudentFirstName field exist −
{ "_id" : ObjectId("5cc6c8289cb58ca2b005e672"), "StudentFirstName" : "John", "StudentLastName" : "Doe" }
{ "_id" : ObjectId("5cc6c8359cb58ca2b005e673"), "StudentFirstName" : "John", "StudentLastName" : "Smith" }
Java program to count the number of consonants in a given sentence

To count the number of consonants in a given sentence:
 Read a sentence from the user.
 Create a variable (count) initialize it with 0;
 Compare each character in the sentence with the characters {'a', 'e', 'i', 'o', 'u' } If match doesn't occurs increment the count.
 Finally print count.
import java.util.Scanner;
public class CountingConsonants {
   public static void main(String args[]){
      int count = 0;
      System.out.println("Enter a sentence :");
      Scanner sc = new Scanner(System.in);
      String sentence = sc.nextLine();

      for (int i=0 ; i<sentence.length(); i++){
         char ch = sentence.charAt(i);
         if(ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u' ){
            System.out.print("");
         }else if(ch != ' '){
            count++;
         }
      }
      System.out.println("Number of consonants in the given sentence is "+count);
   }
}
Enter a sentence :
Hi hello how are you welcome to tutorialspoint
Number of consonants in the given sentence is 21
C++ Utility Library - swap Function

It exchanges the values of a and b.
Following is the declaration for std::swap function.
template <class T> void swap (T& a, T& b);
template <class T> void swap (T& a, T& b)
   noexcept (is_nothrow_move_constructible<T>::value && is_nothrow_move_assignable<T>::value);
a, b − These are two objects.
none
Basic guarantee − if the construction or assignment of type T throws.
Both a and b are modified.
In below example explains about std::swap function.
#include <iostream>
#include <utility>

int main () {

   int foo[4];
   int bar[] = {100,200,300,400};
   std::swap(foo,bar);

   std::cout << "foo contains:";
   for (int i: foo) std::cout << ' ' << i;
   std::cout << '\n';

   return 0;
}
Let us compile and run the above program, this will produce the following result −
foo contains: 100 200 300 400

 Print
 Add Notes
 Bookmark this page
How to convert a single char into an int in C++

The following is an example to convert a character into int.
 Live Demo
#include <iostream>
using namespace std;
int main() {
   char c = '8';
   int i = c - 48;
   cout << i;
   i = c - '0';
   cout <<"\t" << i;
   return 0;
}
8 8
In the above program, a character ‘c’ is initialized with a value. The character is converted into integer value as shown below −
char c = '8';
int i = c - 48;
cout << i;
i = c - '0';
cout <<"\t" << i;