code-rag-bench/online-tutorials huggingface dataset:
GATE | GATE CS 2021 | Set 2 | Question 10

23 May, 2021
Six students P, Q, R, S, T and U, with distinct heights, compare their heights and make the following observations.
Observation I: S is taller than R.
Observation II: Q is the shortest of all.
Observation III: U is taller than only one student.
Observation IV: T is taller than S but is not the tallest.
The number of students that are taller than R is the same as the number of students shorter than ____________.(A) T(B) R(C) S(D) PAnswer: (C)Explanation: From observations II and III, we can say that Q is the shortest. U is the second shortest.
 __ __ __ __ U Q 
From observations I and IV, we can say that T is the second tallest. S is the third tallest. R is the fourthtallest. Thus, P is the tallest. Therefore, the final arrangement is as follows,
P T S R U Q 
Three students are taller than R, hence three students are shorter than S.Quiz of this Question
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | GATE-CS-2014-(Set-2) | Question 65
GATE | Sudo GATE 2020 Mock I (27 December 2019) | Question 33
GATE | GATE CS 2008 | Question 46
GATE | GATE-CS-2015 (Set 3) | Question 65
GATE | GATE-CS-2014-(Set-3) | Question 65
GATE | GATE-CS-2014-(Set-1) | Question 51
GATE | GATE CS 1996 | Question 63
GATE | GATE-CS-2015 (Set 2) | Question 55
GATE | GATE-CS-2001 | Question 50
GATE | GATE-CS-2004 | Question 31
How to use NULL in MySQL SELECT statement?

In MySQL, the length of NULL is 0. Here, we will see how NULL can be used with SELECT
statement. Let us create a table with the help of CREATE command −
Creating a table −
mysql> CREATE table NullWIthSelect
-> (
-> Name varchar(100)
-> );
Query OK, 0 rows affected (0.62 sec)
Above, I have created a table successfully. Now I will insert some records with the help of
INSERT command −
Inserting records −
mysql> INSERT into NullWIthSelect values('John');
Query OK, 1 row affected (0.16 sec)

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

mysql> INSERT into NullWIthSelect values();
Query OK, 1 row affected (0.18 sec)

mysql> INSERT into NullWIthSelect values('Carol');
Query OK, 1 row affected (0.15 sec)

mysql> INSERT into NullWIthSelect values('');
Query OK, 1 row affected (0.16 sec)

mysql> INSERT into NullWIthSelect values('David');
Query OK, 1 row affected (0.19 sec)

mysql> INSERT into NullWIthSelect values();
Query OK, 1 row affected (0.08 sec)
Above, I have inserted 7 records in which one record has empty value and two have null values.
Rest of them has some values.
To display all the records, we can use the SELECT command −
mysql> SELECT * from NullWIthSelect;

The following is the output
+-------+
| Name  |
+-------+
| John  |
| Bob   |
| NULL  |
| Carol |
|       |
| David |
| NULL  |
+-------+
7 rows in set (0.00 sec)
Now, we can use NULL with SELECT statement as shown below.
Firstly, let us see the syntax −
SELECT * from yourTableNamet where column_name is NULL;

Applying the above query to know which column value is null. The query is as follows −
mysql> SELECT * from NullWIthSelect where Name is NULL;
The following is the output −
+------+
| Name |
+------+
| NULL |
| NULL |
+------+
2 rows in set (0.00 sec)
Now, we can get the length of NULL value that is 0. The query is as follows −
mysql> SELECT count(Name) from NullWIthSelect where Name is NULL;

The following is the output −
+-------------+
| count(Name) |
+-------------+
| 0           |
+-------------+
1 row in set (0.04 sec)
Treap (A Randomized Binary Search Tree)

22 Mar, 2017
Like Red-Black and AVL Trees, Treap is a Balanced Binary Search Tree, but not guaranteed to have height as O(Log n). The idea is to use Randomization and Binary Heap property to maintain balance with high probability. The expected time complexity of search, insert and delete is O(Log n).
Every node of Treap maintains two values.1) Key Follows standard BST ordering (left is smaller and right is greater)2) Priority Randomly assigned value that follows Max-Heap property.
Basic Operation on Treap:Like other self-balancing Binary Search Trees, Treap uses rotations to maintain Max-Heap property during insertion and deletion.
T1, T2 and T3 are subtrees of the tree rooted with y (on left side) 
or x (on right side)           
                y                               x
               / \     Right Rotation          /  \
              x   T3   – – – – – – – >        T1   y 
             / \       < - - - - - - -            / \
            T1  T2     Left Rotation            T2  T3
Keys in both of the above trees follow the following order 
      keys(T1) < key(x) < keys(T2) < key(y) < keys(T3)
So BST property is not violated anywhere. 
search(x)Perform standard BST Search to find x.
Insert(x):1) Create new node with key equals to x and value equals to a random value.2) Perform standard BST insert.3) Use rotations to make sure that inserted node's priority follows max heap property.
Delete(x):1) If node to be deleted is a leaf, delete it.2) Else replace node's priority with minus infinite ( -INF ), and do appropriate rotations to bring the node down to a leaf.
Refer Implementation of Treap Search, Insert and Delete for more details.
References:https://en.wikipedia.org/wiki/Treaphttps://courses.cs.washington.edu/courses/cse326/00wi/handouts/lecture19/sld017.htm
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Self-Balancing-BST
Advanced Data Structure
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
AVL Tree | Set 1 (Insertion)
Trie | (Insert and Search)
Agents in Artificial Intelligence
LRU Cache Implementation
Introduction of B-Tree
Red-Black Tree | Set 1 (Introduction)
Difference between B tree and B+ tree
Decision Tree Introduction with example
AVL Tree | Set 2 (Deletion)
Binary Indexed Tree or Fenwick Tree
Scala List init() method with example

29 Jul, 2019
The init() method is utilized to find all the elements of the list except the last one.
Method Definition: def init: List[A]
Return Type: It returns all the elements of the list except the last one.
Example #1:
// Scala program of init()// method  // Creating objectobject GfG{       // Main method    def main(args:Array[String])    {        // Creating a list        val m1 = List(3, 6, 2, 9, 21)                  // Applying init method        val result = m1.init                  // Displays output        println(result)          }} 
List(3, 6, 2, 9)

Example #2:
// Scala program of init()// method  // Creating objectobject GfG{       // Main method    def main(args:Array[String])    {        // Creating a list        val m1 = List(3)                  // Applying init method        val result = m1.init                  // Displays output        println(result)          }} 
List()

Scala
Scala-list
Scala-Method
Scala
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Class and Object in Scala
Scala Lists
Operators in Scala
Scala Constructors
Scala | Arrays
How to Install Scala with VSCode?
Enumeration in Scala
Lambda Expression in Scala
Scala String replace() method with example
How to get the first element of List in Scala
Python Program to print digit pattern

16 Jun, 2022
The program must accept an integer N as the input. The program must print the desired pattern as shown in the example input/ output. Examples:
Input : 41325 Output : |**** |* |*** |** |***** Explanation: for a given integer print the number of *’s that are equivalent to each digit in the integer. Here the first digit is 4 so print four *sin the first line. The second digit is 1 so print one *. So on and the last i.e., the fifth digit is 5 hence print five *s in the fifth line. Input : 60710 Output : |****** | |******* |* |
Approach Read the input For each digit in the integer print the corresponding number of *s If the digit is 0 then print no *s and skip to the next line 
Python3
# function to print the patterndef pattern(n):     # traverse through the elements    # in n assuming it as a string    for i in n:         # print | for every line        print("|", end = "")         # print i number of * s in        # each line        print("*" * int(i)) # get the input as string        n = "41325"pattern(n)
|****
|*
|***
|**
|*****
Time complexity: O(n)Auxiliary Space: O(1)
Alternate solution that takes integer as input : 
Python3
n = 41325x = []while n>0:    x.append(n%10)    n //= 10for i in range(len(x)-1,-1,-1):    print('|'+x[i]*'*') # code contributed by Baivab Dash
|****
|*
|***
|**
|*****
Time complexity: O(n)Auxiliary Space: O(n)
dbaivab
hasani
pattern-printing
Python Pattern-printing
Python
Python Programs
School Programming
Technical Scripter
pattern-printing
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()
Python program to convert a list to string
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python | Convert string dictionary to dictionary
Angular Google Charts - Tree Map

TreeMap is a visual representation of a data tree, where each node may have zero or more children, and one parent (except for the root). Each node is displayed as a rectangle, can be sized and colored according to values that we assign. Sizes and colors are valued relative to all other nodes in the graph. Following is an example of a treemap chart.
We have already seen the configurations used to draw a chart in Google Charts Configuration Syntax chapter. Now, let us see an example of a TreeMap Chart.
We've used TreeMap class to show a TreeMap chart.
type = 'TreeMap';

app.component.ts
import { Component } from '@angular/core';
@Component({
   selector: 'app-root',
   templateUrl: './app.component.html',
   styleUrls: ['./app.component.css']
})
export class AppComponent {
   title = '';
   type='TreeMap';
   data = [
      ["Global",null,0,0],
      ["America","Global",0,0],
      ["Europe","Global",0,0],
      ["Asia","Global",0,0],
      ["Australia","Global",0,0],
      ["Africa","Global",0,0],

      ["USA","America",52,31],
      ["Mexico","America",24,12],
      ["Canada","America",16,-23],

      ["France","Europe",42,-11],
      ["Germany","Europe",31,-2],
      ["Sweden","Europe",22,-13],

      ["China","Asia",36,4],
      ["Japan","Asia",20,-12],
      ["India","Asia",40,63],

      ["Egypt","Africa",21,0],
      ["Congo","Africa",10,12],
      ["Zaire","Africa",8,10],
          
   ];
   columnNames = ["Location", "Parent","Market trade volume (size)","Market increase/decrease (color)"];
   options = { 
      minColor:"#ff7777",
      midColor:'#ffff77',
      maxColor:'#77ff77',
      headerHeight:15,
      showScale:true
   };
   width = 550;
   height = 400;
}
Verify the result.

    16 Lectures 
     1.5 hours 

 Anadi Sharma

    28 Lectures 
     2.5 hours 

 Anadi Sharma

    11 Lectures 
     7.5 hours 

 SHIVPRASAD KOIRALA

    16 Lectures 
     2.5 hours 

 Frahaan Hussain

    69 Lectures 
     5 hours 

 Senol Atac

    53 Lectures 
     3.5 hours 

 Senol Atac
 Print
 Add Notes
 Bookmark this page
How do I unload (reload) a Python module?

The function reload(moduleName) reloads a previously loaded module (assuming you loaded it with the syntax "importmoduleName" without exiting the script. It is intended for conversational use, where you have edited the source file for a module and want to test it without leaving Python and starting it again. For example,
>>> import mymodule
>>> # Edited mymoduleand want to reload it in this script
>>> reload(mymodule)
Note that the moduleName is the actual name of the module, not a string containing its name. The python docs state following about reload function:
 Python modules’ code is recompiled and the module-level code re-executed, defining a new set of objects which are bound to names in the module’s dictionary. The init function of extension modules is not called a second time. The names in the module namespace are updated to point to any new or changed objects. Other references to the old objects (such as names external to the module) are not rebound to refer to the new objects and must be updated in each namespace where they occur if that is desired.
Declare an empty List in Python - GeeksforGeeks

12 Dec, 2019
Lists are just like the arrays, declared in other languages. Lists need not be homogeneous always which makes it the most powerful tool in Python. A single list may contain DataTypes like Integers, Strings, as well as Objects. Lists are mutable, and hence, they can be altered even after their creation.
However, Have you ever wondered about how to declare an empty list in Python? This can be achieved by two ways i.e. either by using square brackets[] or using the list() constructor.
Using square brackets []Lists in Python can be created by just placing the sequence inside the square brackets[]. To declare an empty list just assign a variable with square brackets.
Example:
# Python program to declare# empty list  # list is declareda = []           print("Values of a:", a)print("Type of a:", type(a))print("Size of a:", len(a))     
Output:
Values of a: []
Type of a: <class 'list'>
Size of a: 0

Using list() constructorThe list() constructor is used to create list in Python.
Syntax: list([iterable])
Parameters:iterable: This is an optional argument that can be a sequence(string, tuple) or collection(dictionary, set) or an iterator object.
Return Type:
Returns an empty list if no parameters are passed.
If a parameter is passed then it returns a list of elements in the iterable.
Example:
# Python program to create# empty list    # list is declareda = list()    print("Values of a:", a)print("Type of a:", type(a))print("Size of a:", len(a))     
Output:
Values of a: []
Type of a: <class 'list'>
Size of a: 0

python-list
Python
Technical Scripter
python-list
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Python Dictionary
Read a file line by line in Python
How to Install PIP on Windows ?
Different ways to create Pandas Dataframe
Python String | replace()
Python program to convert a list to string
Create a Pandas DataFrame from Lists
Reading and Writing to text files in Python
*args and **kwargs in Python
How to drop one or multiple columns in Pandas Dataframe
Create a large button group with Bootstrap

To create a large button group in Bootstrap, use the .btn-group-lg class.
You can try to run the following code to form a large button group −
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <title>Bootstrap Example</title>
      <link rel = "stylesheet" href = "https://maxcdn.bootstrapcdn.com/bootstrap/4.1.1/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.1/js/bootstrap.min.js"></script>
   </head>
   <body>
      <p>The following are the car brands:</p>
      <div class = "btn-group-justified">
         <button type = "button" class = "btn btn-default">BMW</button>
         <button type = "button" class = "btn btn-default">Audi</button>
         <button type = "button" class = "btn btn-default">Jeep</button>
         <button type = "button" class = "btn btn-default">Datsun</button>
         <button type = "button" class = "btn btn-default">Toyota</button>
      </div>
      <p>The following are FMCG:</p>
      <div class = "btn-group-justified btn-group-lg">
         <button type = "button" class = "btn btn-default">ITC Limited</button>
         <button type = "button" class = "btn btn-default">Colgate-Palmolive</button>
         <button type = "button" class = "btn btn-default">Nestle</button>
         <button type="button" class = "btn btn-default">Britannia Industries Limited</button>
      </div>
   </body>
</html>
Java Program to display Time in 12-hour format

Use the SimpleDateFormat class to display time in 12-hour format.
Set the format
Date dt = new Date();
SimpleDateFormat dateFormat;
dateFormat = new SimpleDateFormat("hh:mm:ss a");
Now, the following will display time in 12-hour format
dateFormat.format(dt)
The following is an example
 Live Demo
import java.text.SimpleDateFormat;
import java.util.Date;
public class Demo {
   public static void main(String[] argv) throws Exception {
      Date dt = new Date();
      SimpleDateFormat dateFormat;
      dateFormat = new SimpleDateFormat("hh:mm:ss a");
      System.out.println("Time in 12 hr format = "+dateFormat.format(dt));
   }
}
Time in 12 hr format = 11:33:53 AM
Integer toString() in Java

The toString() method of the java.lang.Integer returns a string object. The Integer class has three toString() methods. Let us see them one by one −
The java.lang.Integer.toString() method returns a String object representing this Integer's value. Let us now see an example −
 Live Demo
import java.lang.*;
public class Demo {
   public static void main(String[] args) {
      Integer i = new Integer(20);
      // returns a string representation of the integer value in base 10
      String retval = i.toString();
      System.out.println("Value = " + retval);
   }
}
Value = 20
The java.lang.Integer.toString(int i) method returns a String object representing the specified integer. Here, i is the integer to be converted.
Let us now see an example −
 Live Demo
import java.lang.*;
public class Demo {
   public static void main(String[] args) {
      Integer i = new Integer(10);
      // returns a string representation of the specified integer in base 10
      String retval = i.toString(30);
      System.out.println("Value = " + retval);
   }
}
Value = 30
The java.lang.Integer.toString(int i, int radix) method returns a string representation of the first argument i in the radix specified by the second argument radix.If the radix is smaller than Character.MIN_RADIX or larger than Character.MAX_RADIX, then the radix 10 is used instead.
Here, i is the integer to be converted, whereas radix is the radix to be used in the string representation.
Let us now see an example −
 Live Demo
import java.lang.*;
public class Demo {
   public static void main(String[] args) {
      Integer i = new Integer(10);
      // returns a string representation of the specified integer with radix 10
      String retval = i.toString(30, 10);
      System.out.println("Value = " + retval);
      // returns a string representation of the specified integer with radix 16
      retval = i.toString(30, 16);
      System.out.println("Value = " + retval);
      // returns a string representation of the specified integer with radix 8
      retval = i.toString(30, 8);
      System.out.println("Value = " + retval);
   }
}
Value = 30
Value = 1e
Value = 36
How to delete the specific node from the XML file using PowerShell?

To delete the specific XML node from the PowerShell, we can use the RemoveChild() method of the XML.
For example, We have a sample XML file from Microsoft.
https://docs.microsoft.com/en-us/previous-versions/windows/desktop/ms762271(v=vs.85)
We have saved the above file into C:\Temp\SampleXml.XML and we need to delete the book node with attribute ‘bk102’ and for that, we will use the XPath method of the XML.
Below commands will first search the XML book node with the book attribute ‘bk102’ and then we will delete it.
$xml = [xml](Get-Content C:\Temp\SampleXML.xml)
$node = $xml.SelectSingleNode("//book[@id='bk102']")
$node.ParentNode.RemoveChild($node) | Out-Null
$xml.Save('C:\Temp\SampleXML.xml')
If you want to delete all the nodes which have the name “Book”, we can use the below commands.
$xml = [xml](Get-Content C:\Temp\SampleXML.xml)
$xml.SelectNodes("//book")
$nodes = $xml.SelectNodes("//book")
foreach($node in $nodes){$node.ParentNode.RemoveChild($node)}
In the above example, SelectNodes(‘//book’) method will select all nodes having the name Book and then deletes them.
Lodash _.mapValues() Method - GeeksforGeeks

22 Mar, 2021
Lodash is a JavaScript library that works on the top of underscore.js. Lodash helps in working with arrays, strings, objects, numbers, etc.
The _.mapValues() method is used to create a new mapped object with the same keys of the given object and the values are generated using the given iteratee function.
Syntax:
_.mapValues( object, iteratee )
Parameters: This method accepts two parameters as mentioned above and described below:
object: This parameter holds the object to iterate over.
iteratee: This parameter holds the function that is invoked per iteration on the object. It is an optional value.
Return Value: This method returns the new mapped object.
Example 1:
Javascript
// Requiring the lodash library const _ = require("lodash");  var users = {'Geeksforgeeks': {    'username': 'gfg_id',    'password': 'gfg@123'  },  'W3school': {    'username': 'w3school_id',    'password': 'w@123'  }}; // Using the _.mapValues() methodconsole.log(  _.mapValues(users, function(o) {    return o.password;  }));
 
 
Output:
 
{Geeksforgeeks: "gfg@123", W3school: "w@123"}
 
Example 2:  
 
Javascript
// Requiring the lodash library const _ = require("lodash");  var users = {  'Geeksforgeeks': {    'username': 'gfg_id',    'password': 'gfg@123'  },  'W3school': {    'username': 'w3school_id',    'password': 'w@123'  }}; // Using the _.mapValues() methodconsole.log(_.mapValues(users, 'password'));
Output:
{Geeksforgeeks: "gfg@123", W3school: "w@123"}
arorakashish0911
JavaScript-Lodash
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
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 Open URL in New Tab using JavaScript ?
Set the value of an input field in JavaScript
Roadmap to Become a Web Developer 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?
PHP | DOMNode removeChild() Function - GeeksforGeeks

02 Mar, 2020
The DOMNode::removeChild() function is an inbuilt function in PHP which is used remove child from list of children.
Syntax:
DOMNode DOMNode::removeChild( DOMNode $oldnode )
Parameters: This function accepts a single parameter $oldnode which holds the child to remove.
Return Value: This function returns the removed child on success.
Exceptions: This function throws DOM_NO_MODIFICATION_ALLOWED_ERR, if the node is readonly and DOM_NOT_FOUND, if $oldnode is not a child of this node.
Below examples illustrate the DOMNode::removeChild() function in PHP:
Example 1:
<?php  // Create a new DOMDocument instance$document = new DOMDocument();  // Create a div element$element = $document->         appendChild(new DOMElement('div'));  // Create a text Node$text1 = $document->          createTextNode('GeeksforGeeks');  // Append the nodes$element->appendChild($text1);  // Remove the child$element->removeChild($text1);  // Render the XMLecho $document->saveXML();?>
Output: Press Ctrl+U to see the XML
Example 2:
<?php  // Create a new DOMDocument instance$document = new DOMDocument();  // Create a h1 element$element = $document->             appendChild(new DOMElement('h1'));  // Create the text Node$text1 = $document->               createTextNode('GeeksforGeeks');$text2 = $document->          createTextNode('Text to be removed');  // Append the nodes$element->appendChild($text1);$element->appendChild($text2);  // Remove the child$element->removeChild($text2);  // Render the outputecho $document->saveXML();?>
Output:
Reference: https://www.php.net/manual/en/domnode.removechild.php
PHP-DOM
PHP-function
PHP
Web Technologies
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Insert Form Data into Database using PHP ?
How to convert array to string in PHP ?
How to Upload Image into Database and Display it using PHP ?
How to check whether an array is empty using PHP?
How to receive JSON POST with PHP ?
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?
Java Examples - Use of label in a method

How to use  method overloading for printing different types of array ?
This example shows how to jump to a particular label when break or continue statements occour in a loop.
public class NewClass {
   public static void main(String[] args) {
      String strSearch = "This is the string in which you have to search for a substring.";
      String substring = "substring";
      boolean found = false;
      int max = strSearch.length() - substring.length();
      testlbl: for (int i = 0; i <= max; i++) {
         int length = substring.length();
         int j = i;
         int k = 0;
         while (length-- != 0) {
            if(strSearch.charAt(j++) != substring.charAt(k++)){
               continue testlbl;
            }
         }
         found = true;
         break testlbl;
      }
      if (found) {
         System.out.println("Found the substring .");
      } else {
         System.out.println("did not find the substing in the string.");
      }
   }
}
The above code sample will produce the following result.
Found the substring .

 Print
 Add Notes
 Bookmark this page
Python | Create a Pandas Dataframe from a dict of equal length lists - GeeksforGeeks

23 Nov, 2018
Given a dictionary of equal length lists, task is to create a Pandas DataFrame from it.
There are various ways of creating a DataFrame in Pandas. One way is to convert a dictionary containing lists of equal lengths as values. Let’s discuss how to create a Pandas Dataframe from a dict of equal length lists with help of examples.
Example #1: Given a dictionary which contains format of cricket as keys and list of top five teams as values.
# Import pandas package import pandas as pd  # Define a dictionary containing ICC rankingsrankings = {'test': ['India', 'South Africa', 'England',                            'New Zealand', 'Australia'],              'odi': ['England', 'India', 'New Zealand',                            'South Africa', 'Pakistan'],               't20': ['Pakistan', 'India', 'Australia',                               'England', 'New Zealand']}  # Convert the dictionary into DataFramerankings_pd = pd.DataFrame(rankings)  # Increment the index so that index # starts at 1 (starts at 0 by default) rankings_pd.index += 1  rankings_pd
Output:
 Example #2: Given three lists test_batsmen, odi_batsmen, t20_batsmen. So we first need to convert this data into a dictionary and then convert the dictionary into DataFrame.
# Import pandas package import pandas as pd  # Lists of top 5 batsmen for each formattest_batsmen = ['Virat Kohli', 'Steve Smith', 'Kane Williamson',                                     'Joe Root', 'David Warner']odi_batsmen = ['Virat Kohli', 'Rohit Sharma', 'Joe Root',                            'David Warner', 'Babar Azam']t20_batsmen = ['Babar Azam', 'Aaron Finch', 'Colin Munro',                           'Lokesh Rahul', 'Fakhar Zaman']  # Define a dictionary containing ICC rankings for batsmenrankings_batsmen = {'test': test_batsmen,                      'odi': odi_batsmen,                      't20': t20_batsmen}  # Convert the dictionary into DataFramerankings_batsmen_pd = pd.DataFrame(rankings_batsmen)  # Increment the index so that index# starts at 1 (starts at 0 by default) rankings_batsmen_pd.index += 1  rankings_batsmen_pd
Output:
pandas-dataframe-program
Picked
Python pandas-dataFrame
Python-pandas
Technical Scripter 2018
Python
Technical Scripter
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
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
Selecting rows in pandas DataFrame based on conditions
Defaultdict in Python
Python | Get unique values from a list
Python | os.path.join() method
Create a directory in Python
Python | Split string into list of characters
Inheritance in Dart Programming

Inheritance in dart is defined as the process in which one class derive the properties and characteristics of another class. It is helpful as it provides an ability with which we can create a new class from an existing class.
Inheritance is a major component of a programming paradigm known as OOPS (Object-Oriented Programming).
With the help of Inheritance, one class can make use of all the properties and characteristics of another class.
In general, two classes are required for inheritance and these mainly are −
Parent class - A class that is inherited by the other class is known as the parent class. Sometimes, we also refer it to as the base class.
Parent class - A class that is inherited by the other class is known as the parent class. Sometimes, we also refer it to as the base class.
Child class - A class that inherits the properties and characteristics of the parent class is known as child class.
Child class - A class that inherits the properties and characteristics of the parent class is known as child class.
The syntax for a class to inherit the properties and characteristics of another class looks something like this −
class Childclass extends ParentClass {
...
}
Whenever a child class wants to inherit the properties and characteristics of a parent class, we make use of the extends keyword.
There are different types of inheritance that are possible in Dart. Mainly these are −
Single level inheritance
Single level inheritance
Multi-level inheritance
Multi-level inheritance
Hierarchal inheritance
Hierarchal inheritance
In this article, we will learn only about single level inheritance to keep things simple.
Single level inheritance is that case of inheritance where a single class inherits from the parent class.
Consider the example shown below −
 Live Demo
class Human{
   void walk(){
      print("Humans walk!");
   }
}

// inherting the parent class i.e Human
class Person extends Human{
   void speak(){
      print("That person can speak");
   }
}

void main(){
   Person p = new Person();
   p.speak();
   p.walk(); // invoking the parent class method
}
In the above example, we have two classes, named Human and Person respectively, the class named Human is the superclass and the class named Person is the child class, which is inheriting the method named walk() from the class named Human.
That person can speak
Humans walk!
GATE | Gate IT 2007 | Question 30

28 Jun, 2021
Suppose you are given an implementation of a queue of integers. The operations that can be performed on the queue are:i. isEmpty (Q) — returns true if the queue is empty, false otherwise.ii. delete (Q) — deletes the element at the front of the queue and returns its value.iii. insert (Q, i) — inserts the integer i at the rear of the queue.Consider the following function:
void f (queue Q) {int i ;if (!isEmpty(Q)) {   i = delete(Q);   f(Q);   insert(Q, i);  }}
What operation is performed by the above function f ?(A) Leaves the queue Q unchanged(B) Reverses the order of the elements in the queue Q(C) Deletes the element at the front of the queue Q and inserts it at the rear keeping the other elements in the same order(D) Empties the queue Q
Answer: (B)Explanation: As it is recursive call, and removing from front while inserting from end, that means last element will be deleted at last and will be inserted 1st in the new queue. And like that it will continue till first call executes insert(Q,i) function.So, the queue will be in reverse.Quiz of this Question
Gate IT 2007
GATE-Gate IT 2007
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to swap columns of a given NumPy array?

22 Jun, 2021
In this article, let’s discuss how to swap columns of a given NumPy array.
Approach :
Import NumPy module
Create a NumPy array
Swap the column with Index
Print the Final array
Example 1: Swapping the column of an array. 
Python3
# importing Moduleimport numpy as np  # creating array with shape(4,3)my_array = np.arange(12).reshape(4, 3)print("Original array:")print(my_array) # swapping the column with index of# original arraymy_array[:, [2, 0]] = my_array[:, [0, 2]]print("After swapping arrays the last column and first column:")print(my_array)
 
 
Output :
 
Original array:
[[ 0  1  2]
 [ 3  4  5]
 [ 6  7  8]
 [ 9 10 11]]
After swapping arrays the last column and first column:
[[ 2  1  0]
 [ 5  4  3]
 [ 8  7  6]
 [11 10  9]]
 
Example 2: Swapping the column of an array with the user chooses.
 
Python3
# Importing Moduleimport numpy as np  # Creating arraymy_array = np.arange(12).reshape(4, 3)print("Original Array : ")print(my_array)# creating function for swap def Swap(arr, start_index, last_index):    arr[:, [start_index, last_index]] = arr[:, [last_index, start_index]] # passing parameter into the functionSwap(my_array, 0, 1)print(" After Swapping :")print(my_array)
Output :
Original Array : 
[[ 0  1  2]
 [ 3  4  5]
 [ 6  7  8]
 [ 9 10 11]]
 After Swapping :
[[ 1  0  2]
 [ 4  3  5]
 [ 7  6  8]
 [10  9 11]]
simranarora5sos
Python numpy-arrayManipulation
Python-numpy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Enumerate() in Python
Different ways to create Pandas Dataframe
Read a file line by line in Python
How to Install PIP on Windows ?
Python String | replace()
Python OOPs Concepts
Python Classes and Objects
*args and **kwargs in Python
Introduction To PYTHON
HTML | <Iframe> frameborder Attribute

19 Sep, 2019
The HTML Iframe frameborder Attribute is used to specify whether or not to display the border around the content of an <Iframe> Element.
Syntax:
<iframe frameborder="1 | 0">
Attribute Values:
0: It has a Default value. It sets the border on one state.
1: It sets the border on-off state.
Note: This attribute does not support in HTML5 as a replacement you can use CSS.
Below program will illustrate HTML Iframe frameborder Attribute:Example:
<!DOCTYPE html><html>  <head>    <title>        HTML <Iframe> frameborder Attribute    </title></head>  <body>  <center>    <h1 style="color:green;">        GeeksforGeeks    </h1>    <h2>        HTML Iframe frameborder Attribute    </h2>      <p>Content goes here</p>      <iframe src="https://ide.geeksforgeeks.org/tryit.php"            height="300"             width="400"             marginheight="40"             frameborder="0">    </iframe>  </center>  </body>  </html>
Output:
Supported Browsers: The browsers supported by HTML <Iframe> frameborder Attribute are listed below:
Google Chrome
Internet Explorer
Firefox
Opera
Safari
nidhi_biet
HTML-Attributes
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Fix: module ‘pandas’ has no attribute ‘dataframe’

19 Dec, 2021
In this article, we are going to see how to fix errors while creating dataframe ” module ‘pandas’ has no attribute ‘dataframe’”.
To create dataframe we need to use DataFrame(). If we use dataframe it will throw an error because there is no dataframe attribute in pandas. The method is DataFrame(). We need to pass any dictionary as an argument. Since the dictionary has a key, value pairs we can pass it as an argument. Dataframe considers keys as attributes and pairs as tuples. Let us see why we get errors while creating a dataframe.
Python3
import pandas as pd  data = {"id": [1, 2, 3],        "name": ["karthik", "nikhil", "bhagi"]}  df = pd.dataframe(data)print(df)
Output:
To fix the above error we need to use DataFrame instead of dataframe.
Python3
import pandas as pd  data = {"id": [1, 2, 3],        "name": ["karthik", "nikhil", "bhagi"]}  df = pd.DataFrame(data)df
Output:
id        name
0    1        karthik
1    2        nikhil
2    3        bhagi
In this way, we can fix the module ‘pandas’ has no attribute ‘dataframe’  error .
Picked
Python How-to-fix
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
What is Event Capturing in JavaScript?

Event capturing is the event starts from top element to the target element. It is the opposite of Event bubbling, which starts from target element to the top element.
In the following code, in body section three div elements are taken and a style got applied so as to make them nested.
Add a event handler to each of the div tags using addEventListener().
Make sure that here the event is "click" event.
The addEventListener() method accepts 3 parameters.
             a) The event it is going to access, here it is click event.  
             b) An event handler function so as to display alert messages.
             c) The third parameter is called phase. In this parameter if we keep true then the event capturing will be                           enabled.If we keep false then event bubbling will be enabled.  
The event handler function, which is used to display alert boxes, will use getAttribute() to get the id value of the div element which got clicked.
When we click on the inner most nested tag div3, since event capturing got enabled here, the alert messages starts from top div1 tag to the target tag div3.
When we click on the div2 tag, then alert boxes will display from top div1 tag to target tag div2.
Example
Live Demo
<html>
<head>
<style>
   .divstyle{
      display:table-cell;
      border: 2px solid black;
      padding: 20px;
      text-align: center;
   }
</style>
</head>
<body>
   <div id = "div1" class="divstyle">
   div1
   <div id = "div2" class="divstyle">
   div2
   <div id = "div3" class="divstyle">
   div3
<script>
   var divs = document.getElementsByTagName("div");
   for(var i = 0; i<divs.length; i++){
      divs[i].addEventListener("click",clickhandler,true );
   }
   function clickhandler() {
      alert(this.getAttribute("id") + "event got handled");
   }
</script>
</body>
</html>
On executing the above program we get the following image on the screen
On clicking the above div3(target element) we get the following as output

On clicking ok of the above div1 alert box we get the following div2 alert box opened


On clicking ok of the above div2 alert box we get the following div3 alert box opened.
Python | Ways to find all permutation of a string

23 Jul, 2021
Given a string, write a Python program to find out all possible permutations of a string. Let’s discuss a few methods to solve the problem.Method #1: Using Naive Method  
Python3
# Python code to demonstrate# to find all permutation of# a given string # Initialising stringini_str = "abc" # Printing initial stringprint("Initial string", ini_str) # Finding all permutationresult = [] def permute(data, i, length):    if i == length:        result.append(''.join(data) )    else:        for j in range(i, length):            # swap            data[i], data[j] = data[j], data[i]            permute(data, i + 1, length)            data[i], data[j] = data[j], data[i] permute(list(ini_str), 0, len(ini_str)) # Printing resultprint("Resultant permutations", str(result))
Initial string abc
Resultant permutations ['abc', 'acb', 'bac', 'bca', 'cba', 'cab']
 
  Method #2: Using itertools  
Python3
# Python code to demonstrate# to find all permutation of# a given string from itertools import permutations # Initialising stringini_str = "abc" # Printing initial stringprint("Initial string", ini_str) # Finding all permutationpermutation = [''.join(p) for p in permutations(ini_str)]# Printing resultprint("Resultant List", str(permutation))
Initial string abc
Resultant List ['abc', 'acb', 'bac', 'bca', 'cab', 'cba']
 
anikaseth98
akshaysingh98088
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 | Convert string dictionary to dictionary
Python Program for Fibonacci numbers
ReactJS | Using Babel

30 Mar, 2021
Now we know that what Babel is, we will focus on how to install it on your machine using node. Babel can be installed easily after following these simple steps. Requirements :  
A code editor like atom, sublime text or Visual studio code.
Node should be installed on the machine with npm too.
We will install Babel using Node. Open your text editor, then create your directories structure like the one below:  
  |--node_modules
  |--src
    --app.js
  |--.babelrc
  |--package.json
  |--package.lock.json
If you know how node works then you know about node_modules, package.json, and package.lock.json. These are automatically formed once we run some commands. Now, open the command line and set the path to the directory of the folder then write these lines in the cmd:  
npm install --save-dev @babel/core @babel/cli @babel/preset-env @babel/node
npm install nodemon --save-dev
The first npm commands will install babel dependencies and the second will is used to install nodemon which allows us to update the browser content without refreshing it. After entering the command we will get:  
As we can see in the above image, the command that we used to install babel dependencies are now visible in our ‘package.json’ file. It is also important to add the below line inside the .babelrc file which we have in our project directory.  
// .babelrc
{
  "presets": ["@babel/preset-env"]
}
Now we finally need to add scripts into our ‘package.json’ file.  
"start": "nodemon --exec babel-node src/app.js" // inside your scripts tag
The final ‘package.json’ will look like this:  
Now we are all set we just need to write normal ES6, 7, 8 code in our app.js file and run it with ‘npx babel filename’ command where ‘filename’ is replaced by app.js here, and we will get the ES5 output in the console. Example:  
javascript
// next generation javascript codelet alice = () => {}; let bob = (b) => b; const usingMap = [1, 2, 3].map((number) => number * 2);console.log(usingMap); // [2, 4, 6] var immukul = {     _name: "Mukul",     _friends: ["Mukul", "Mayank"],     printFriends(){         this._friends.forEach(             f =>console.log(this._name + " knows " + f));             }        }; console.log(immukul.printFriends());
Output:  
 
suryap
kananivinitrocking
react-js
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
Difference between var, let and const keywords in JavaScript
Node.js fs.readFileSync() Method
How to set input type date in dd-mm-yyyy format using HTML ?
File uploading in React.js
REST API (Introduction)
How to set the default value for an HTML <select> element ?
How to calculate the number of days between two dates in javascript?
Python | Ways to count number of substring in string

30 Jun, 2019
Given a string and a substring, write a Python program to find how many numbers of substring are there in the string (including overlapping cases). Let’s discuss a few methods below.
Method #1: Using re.findall()
# Python code to demonstrate # to count total number# of substring in string  import re# Initialising stringini_str = "ababababa"sub_str = 'aba'  # Count count of substrings using re.findallres = len(re.findall('(?= aba)', ini_str))  # Printing resultprint("Number of substrings", res)
Number of substrings 0

Method #2: Using re.finditer()
# Python code to demonstrate # to count total number# of substring in string  import re# Initialising stringini_str = "ababababa"sub_str = 'aba'  # Count count of substrings using re.finditerres = sum(1 for _ in re.finditer('(?= aba)', ini_str))  # Printing resultprint("Number of substrings", res)
Number of substrings 0

 Method #3: Using startswith()
# Python code to demonstrate # to count total number# of substring in string  # Initialising stringini_str = "ababababa"sub_str = 'aba'  # Count count of substrings using startswithres = sum(1 for i in range(len(ini_str))          if ini_str.startswith("aba", i))  # Printing resultprint("Number of substrings", res)
Number of substrings 4

Python string-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Perl | eq operator

07 May, 2019
‘eq‘ operator in Perl is one of the string comparison operators used to check for the equality of the two strings. It is used to check if the string to its left is stringwise equal to the string to its right.
Syntax: String1 eq String2
Returns: 1 if left argument is equal to the right argument
Example 1:
#!/usr/local/bin/perl  # Initializing Strings$a = "Welcome";$b = "Geeks";  # Comparing the strings using eq operator$c = $a eq $b;  if($c == 1){    print"String1 is equal to String2";}else{    print"String1 is not equal to String2";}
String1 is not equal to String2

Example 2:
#!/usr/local/bin/perl  # Initializing Strings$a = "Geeks";$b = "Geeks";  # Comparing the strings using eq operator$c = $a eq $b;  if($c == 1){    print"String1 is equal to String2";}else{    print"String1 is not equal to String2";}
String1 is equal to String2

perl-operators
Perl-String-Operators
Perl
Perl
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Perl | Arrays (push, pop, shift, unshift)
Perl | Arrays
Perl Tutorial - Learn Perl With Examples
Perl | Polymorphism in OOPs
Perl | Boolean Values
Perl | length() Function
Perl | Subroutines or Functions
Hello World Program in Perl
Use of print() and say() in Perl
Perl | Basic Syntax of a Perl Program
HTTP headers | If-Match

21 May, 2020
The HTTP headers If-Match is request-type header. It is used to make the request conditional. If it matches one of the listed conditional ETags then the server will send back the requested resource for PUT and other non-safe methods, it will only upload the resource in this case.
This ETag header uses a string comparison algorithm. Using this header are two common use cases:
it can ensure that the modern ranges requested comes from the same resource than the past one. For GET and HEAD methods, utilized in combination with a Run header.if at a point a 416 (Range Not Satisfiable) reaction is returned, then it doesn’t coordinate.
If-Match can be utilized to anticipate the misplaced upgrade issue, For other methods, and in specific for PUT. It can check in case the alteration of a resource that the client needs to transfer will not override another alter that has been done since the first resource was gotten. the 412 (Precondition Fizzled) response is returned if the response is not requested.
Syntax
If-Match:<*;
If-Match:<etag_value>, <etag_value>, ...
Directives: This header accept two directives as mentioned above and described below:
<etag_value> This directive holds the value of the Etag list, values are in form of string of ASCII characters placed between double quotes. Used prefixed by W/ to indicate that they are “weak”.
*:
The asterisk directive could be a special value representing a resource.
Examples:
If-Match: *
If-Match: "afyr456nfk560hfef5bhoy007dfhgfd9h"
To check the HTTP headers If-Match in action go to Inspect Element -> Network check the request header
Supported Browsers: The browsers are compatible with HTTP header If-Match are listed below:
Google Chrome
Internet Explorer
Firefox
Opera
Safari
Microsoft Edge
HTTP-headers
Picked
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
How to fetch data from an API in ReactJS ?
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
REST API (Introduction)
Difference Between PUT and PATCH Request
Roadmap to Learn JavaScript For Beginners
How to float three div side by side using CSS?
ReactJS | Router
How to get character array from string in JavaScript?