code-rag-bench/online-tutorials huggingface dataset:
numpy.vsplit() function | Python - GeeksforGeeks

22 Apr, 2020
numpy.vsplit() function split an array into multiple sub-arrays vertically (row-wise). vsplit is equivalent to split with axis=0 (default), the array is always split along the first axis regardless of the array dimension.
Syntax : numpy.vsplit(arr, indices_or_sections)Parameters :arr : [ndarray] Array to be divided into sub-arrays.indices_or_sections : [int or 1-D array] If indices_or_sections is an integer, N, the array will be divided into N equal arrays along axis.If indices_or_sections is a 1-D array of sorted integers, the entries indicate where along axis the array is splitReturn : [ndarray] A list of sub-arrays.
Code #1 :
# Python program explaining# numpy.vsplit() function  # importing numpy as geek import numpy as geek  arr = geek.arange(9.0).reshape(3, 3)  gfg = geek.vsplit(arr, 1)  print (gfg)
Output :
[array([[ 0.,  1.,  2.],
       [ 3.,  4.,  5.],
       [ 6.,  7.,  8.]])]

 Code #2 :
# Python program explaining# numpy.vsplit() function  # importing numpy as geek import numpy as geek  arr = geek.arange(36.0).reshape(6, 6)  gfg = geek.vsplit(arr, 2)  print (gfg)
Output :
[array([[  0.,   1.,   2.,   3.,   4.,   5.],
       [  6.,   7.,   8.,   9.,  10.,  11.],
       [ 12.,  13.,  14.,  15.,  16.,  17.]]), array([[ 18.,  19.,  20.,  21.,  22.,  23.],
       [ 24.,  25.,  26.,  27.,  28.,  29.],
       [ 30.,  31.,  32.,  33.,  34.,  35.]])]

Python numpy-arrayManipulation
Python-numpy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Read a file line by line in Python
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Iterate over a list in Python
*args and **kwargs in Python
Reading and Writing to text files in Python
Create a Pandas DataFrame from Lists
Convert integer to string in Python
Difference between File System and DBMS - GeeksforGeeks

26 Apr, 2022
Prerequisite – DBMS over the File system 
File System : The file system is basically a way of arranging the files in a storage medium like a hard disk. The file system organizes the files and helps in the retrieval of files when they are required. File systems consist of different files which are grouped into directories. The directories further contain other folders and files. The file system performs basic operations like management, file naming, giving access rules, etc. 
Example: NTFS(New Technology File System), EXT(Extended File System).
File System
DBMS(Database Management System) : Database Management System is basically software that manages the collection of related data. It is used for storing data and retrieving the data effectively when it is needed. It also provides proper security measures for protecting the data from unauthorized access. In Database Management System the data can be fetched by SQL queries and relational algebra. It also provides mechanisms for data recovery and data backup. 
Example: 
Oracle, MySQL, MS SQL server.
DBMS
brillianttyagi
itskawal2000
manassinghal77
guptavivek0503
DBMS Basics
DBMS
Difference Between
GATE CS
DBMS
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
SQL Interview Questions
Introduction of B-Tree
CTE in SQL
Difference between Clustered and Non-clustered index
Data Preprocessing in Data Mining
Difference between BFS and DFS
Class method vs Static method in Python
Differences between TCP and UDP
Difference between var, let and const keywords in JavaScript
Differences between IPv4 and IPv6
HTML | <select> autofocus Attribute - GeeksforGeeks

29 Apr, 2019
The HTML <select> autofocus Attribute is used to specify that the dropdown should automatically get focus when the page loads. It is a type of boolean attribute.
Syntax:
<select autofocus>
Example: This Example that illustrates the use of autofocus attribute in select Element.
<!DOCTYPE html><html>  <head>    <title>      HTML select autofocus Attribute  </title></head>  <body style="text-align:center">    <h1 style="color: green;">      GeeksforGeeks  </h1>    <h2>      HTML <select> autofocus Attribute  </h2>        <select autofocus>            <option value="binary">              Binary Search          </option>            <option value="linear">              Linear Search          </option>            <option value="interpolation">              Interpolation Search          </option>        </select></body>  </html>
Output:
Supported Browsers: The browser supported by HTML | <select>autofocus Attribute are listed below:
Google Chrome
Internet Explorer
Firefox
Opera
Safari
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
HTML-Attributes
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to update Node.js and NPM to next version ?
How to Insert Form Data into Database using PHP ?
REST API (Introduction)
Types of CSS (Cascading Style Sheet)
HTML | <img> align Attribute
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 ?
Difference between var, let and const keywords in JavaScript
How to remove duplicate values from array using PHP ? - GeeksforGeeks

07 Oct, 2021
In this article, we will discuss how to remove duplicate elements from an array in PHP. We can get the unique elements by using array_unique() function. This function will remove the duplicate values from the array.
Syntax:
array array_unique($array, $sort_flags)
Note: The keys of the array are preserved i.e. the keys of the not removed elements of the input array will be the same in the output array.
Parameters: This function accepts two parameters that are discussed below:
$array: This parameter is mandatory to be supplied and it specifies the input array from which we want to remove duplicates.
$sort_flags: It is optional parameter. This parameter may be used to modify the sorting behavior using these values:SORT_REGULAR: This is the default value of the parameter $sort_flags. This value tells the function to compare items normally (don’t change types).SORT_NUMERIC: This value tells the function to compare items numerically.SORT_STRING: This value tells the function to compare items as strings.SORT_LOCALE_STRING: This value tells the function to compare items as strings, based on the current locale.
SORT_REGULAR: This is the default value of the parameter $sort_flags. This value tells the function to compare items normally (don’t change types).
SORT_NUMERIC: This value tells the function to compare items numerically.
SORT_STRING: This value tells the function to compare items as strings.
SORT_LOCALE_STRING: This value tells the function to compare items as strings, based on the current locale.
Return Value: The array_unique() function returns the filtered array after removing all duplicates from the array.
Example: PHP program to remove duplicate values from the array.
PHP
<?php  // Input Array$a = array("red", "green", "red", "blue");  // Array after removing duplicatesprint_r(array_unique($a));  ?>
Array
(
    [0] => red
    [1] => green
    [3] => blue
)
Example 2: PHP program to remove duplicate elements from an associative array.
PHP
<?php  // Input array$arr = array(      "a" => "MH",       "b" => "JK",       "c" => "JK",       "d" => "OR");  // Array after removing duplicatesprint_r(array_unique($arr));  ?>
Array
(
    [a] => MH
    [b] => JK
    [d] => OR
)
PHP-array
PHP-function
PHP-Questions
Picked
PHP
Web Technologies
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to fetch data from localserver database and display on HTML table using PHP ?
How to pass form variables from one page to other page in PHP ?
Create a drop-down list that options fetched from a MySQL database in PHP
How to create admin login page using PHP?
Different ways for passing data to view in Laravel
Top 10 Front End Developer Skills That You Need in 2022
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
How to push an element into array in MongoDB?

To push an element into array, use $push. Let us first create a collection with documents −
> db.demo6.insertOne({"ListOfNames":["Bob","David","Mike","Sam"]});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e0b6b3f25ddae1f53b62228")
}
Following is the query to display all documents from a collection with the help of find() method −
> db.demo6.find().pretty();
This will produce the following output −
{
"_id" : ObjectId("5e0b6b3f25ddae1f53b62228"),
   "ListOfNames" : [
      "Bob",
      "David",
      "Mike",
      "Sam"
   ]
}
Here is the query to push an element into array in MongoDB −
> db.demo6.update({ _id: ObjectId("5e0b6b3f25ddae1f53b62228") },{ $push: { ListOfNames: "Robert" } });
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
Following is the query to display all documents from a collection with the help of find() method −
> db.demo6.find().pretty();
This will produce the following output −
{
   "_id" : ObjectId("5e0b6b3f25ddae1f53b62228"),
   "ListOfNames" : [
      "Bob",
      "David",
      "Mike",
      "Sam",
      "Robert"
   ]
}
jQuery UI Datepicker dateFormat Option - GeeksforGeeks

23 Feb, 2021
jQuery UI consists of GUI widgets, visual effects, and themes implemented using jQuery, CSS, and HTML. jQuery UI is great for building UI interfaces for the webpages. jQuery UI Datepickers widget allow users to enter dates easily and visually. In this article, we will see how to use the dateFormat option in jQuery UI Datepicker. The dateFormat option is used to set the format of date in the jQuery UI Datepicker.
Syntax:
$(".selector").datepicker(
   {dateFormat : 'yy/dd/mm'}
);
CDN Link: First, add jQuery UI scripts needed for your project.
<link href = “https://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css” rel = “stylesheet”><script src = “https://code.jquery.com/jquery-1.10.2.js”></script><script src = “https://code.jquery.com/ui/1.10.4/jquery-ui.js”></script>
Example:
HTML
<!DOCTYPE html><html lang="en">  <head>    <meta charset="utf-8" />    <link href="https://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css"          rel="stylesheet"/>    <script src="https://code.jquery.com/jquery-1.10.2.js">    </script>    <script src="https://code.jquery.com/ui/1.10.4/jquery-ui.js">    </script>      <!-- JavaScript -->    <script>      $(function () {        $("#gfg").datepicker({ dateFormat: "yy/dd/mm" });      });    </script>  </head>  <h1>GeeksforGeeks</h1>  <h3>jQuery UI | datepicker dateFormat option</h3>    <body>    <!-- HTML -->      <p>Enter Date: <input type="text" id="gfg" /></p>  </body></html>
Output:
Reference: https://api.jqueryui.com/datepicker/#option-dateFormat
jQuery-UI
JQuery
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
jQuery | ajax() Method
How to prevent Body from scrolling when a modal is opened using jQuery ?
How to get a DOM Element from a jQuery Selector ?
How to get the value in an input text box using jQuery ?
How to generate a simple popup using jQuery ?
QR Code Generator using HTML, CSS and jQuery
How to submit a form using ajax in jQuery ?
Not class selector in jQuery
Difference Between JavaScript and jQuery
jQuery | find() with Examples
$("input:radio[name=bar]:checked").val()

This gets the first value from a set of radio buttons.
Here is the simple syntax to use this method −
selector.val();

None
Following example gets the first value from a set of radio buttons.
<html>
   <head>
      <title>The jQuery Example</title>
      <script type = "text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js">
      </script>		
      <script type = "text/javascript" language = "javascript">	 
         function show(){
            alert($("input:radio[name=bar]:checked").val());
         }
      </script>
   </head>	

   <body>
      <div>
         <form name = "sampleForm">
            <input type = "radio" name = "bar" title="The jQuery Example" value = "red" >red</input><br/><br/>
            <input type = "radio" name = "bar" title="The jQuery Example" value = "green" >green</input> <br/><br/>
            <input type = "button" id = "submitButton" onclick="show();" value = "submit"/>
         </form>
      </div>
   </body>	
</html>
This will produce following result −
 Print
 Add Notes
 Bookmark this page
How to get the title and URL of a webpage with Javascript executor in Selenium with python?

We can get the title and URL of a webpage with Javascript executor in
Selenium. Javascript is a language used for scripting and runs on the client side (on the browser). Selenium gives default methods to work with Javascript.
print(driver.execute_script('return document.title'))
print(driver.execute_script('return document.URL'))
There are couple of methods of working with Javascript −
Javascript execution at document root level.
Javascript execution at document root level.
In this process, we shall identify the element with locators (class or id) and then perform the required action on it. Then execute_script() method is called and the Javascript is passed as a string to it.
javas = "document.getElementsByName('user-search')[0].click();"
driver.execute_script(javas)
Please note, we have used getElementsByName('user-search')[0]. The functions like getElementsByName and getElementsById return an array of
matching elements. So for locating the first element, the index[0] is used. However if we are using getElementById function, we need not use the index since only one matching element is referred there.
Finally, for execution the web driver will put the Javascript statement in the browser and then perform the necessary action like clicking the required button. This Javascript does not mingle with the Javascript present in the
webpage.
Javascript execution at element level.
Javascript execution at element level.
In this process, we shall identify the element with the help of web driver
methods like find_element_by_xpath or find_element_by_id and so on.
Then execute the necessary action on it like clicking the element. Finally, the
method execute_script() is called. This method has the Javascript statement
and the identified webelement as arguments.
userN= driver.find_element_by_id("user-search']")
driver.execute_script("arguments[0].click();", userN)
The Javascript executor is also capable of returning values. Thus execute_script() can return values for example we can fetch the title of the page using this concept.
print driver.execute_script('return document.title')
Code Implementation with Javascript for getting title and URL of webpage.
from selenium import webdriver
#browser exposes an executable file
#Through Selenium test we will invoke the executable file which will then
#invoke #actual browser
driver = webdriver.Chrome(executable_path="C:\\chromedriver.exe")
# to maximize the browser window
driver.maximize_window()
#get method to launch the URL
driver.get("https://www.tutorialspoint.com/index.htm")
#to refresh the browser
driver.refresh()
# get the title of page in console
print(driver.execute_script('return document.title'))
# get the URL of page in console
print(driver.execute_script('return document.URL'))
#to close the browser
driver.close()
Placement | Reasoning | Blood Relationship - GeeksforGeeks

09 Aug, 2018
While solving the questions on blood relationship, one should be familiar with basic concepts like various relations.
Mother's or Father's Brother - Uncle
Mother's or Father's Sister - Aunt
Mother's or Father's Father - Grand Father 
Mother's or Father's Mother - Grand Mother
Grand Father's or Grand Mother's Brother - Grand Uncle
Grand Father's or Grand Mother's Sister - Grand Aunt
Children's Children(Grand Son, Grand Daughter) - Grand Children
Uncle or Aunt's Son/Daughter - Cousin
Son's Wife - Daughter-in-law
Daughter Husband - Son-in-law
Sister's or Brother's Son - Nephew
Sister's or Brother's Daughter - Niece
Husband's or Wife's Brother or Sister's Husband - Brother-in-law
Husband's or Wife's Sister or Brother Wife - Sister-in-law
Important Terms:
Children of the same parent - Siblings
Paternal relatives - Father side relations
Maternal relatives - Mother side relations
One's husband/wife - Spouse
The easiest and non-confusing way to solve blood relationship problems would be to draw a family tree diagram and increase the levels in the generation wise as shown below-Generation 1 : Grand Parents-Grand father, Grandmother, Granduncle, Grand aunt.Generation 2 : Parents & in laws-Father, Mother, Uncle, Aunt, Father-in-law, Mother-in-lawGeneration 3 : Siblings, spouse & in laws-Brother, Sister, Cousin, Wife, Husband, Brother-in-law, Sister-in-law.Generation 4 : Children & in laws-Son, Daughter, Niece, Nephew, Son-in-law, Daughter-in-lawGeneration 5 : Grand children-Grand son, Grand daughter.
Below Examples illustrate the process for solving this kind of problems:
Example 1:Pointing to a man in the photograph a woman said, “He is the brother of the daughter of the wife of my husband” How is the man related to the woman?
Solution:
My husband means woman’s husband, wife of my husband means again women itself, daughter of the wife of my husband means woman’s daughter and brother of the daughter means woman’s son. So, the woman is the mother of the man in the photograph. Example 2:Introducing Sanghoti to guests, Dinabandhu said, “Her father is the only son of my father”.How is Sanghoti related to Dinabandhu?(a) Daughter(b) Mother(c) Sister(d) Niece
Solution:
Hence, Sanghoti is Dinabandhu’s daughter.Answer: (a) Daughter. Example 3:A woman introduces a man as the son of the brother of her mother. How is a man related to the woman?(a) Nephew(b) Son(c) Cousin(d) Uncle
Solution:
Hence, man is woman’s Cousin.Answer: (c) Cousin.
AkshitMittal2
Placements
Reasoning - Placements
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Top 20 Puzzles Commonly Asked During SDE Interviews
Codenation Recruitment Process
Problem on HCF and LCM
C program to reverse the content of the file and print it
Interview Preparation
Series
Data Sufficiency
Syllogism
Assumptions and Conclusions, Courses of Action
Count the number of comma’s in every record from a comma-separated value column in MySQL

Let us first create a −
mysql> create table DemoTable1510
   -> (
   -> Value varchar(50)
   -> );
Query OK, 0 rows affected (6.75 sec)
Insert some records in the table using insert −
mysql> insert into DemoTable1510 values('20,35');
Query OK, 1 row affected (0.57 sec)
mysql> insert into DemoTable1510 values('45,67,89');
Query OK, 1 row affected (0.99 sec)
mysql> insert into DemoTable1510 values('90,97,101,190');
Query OK, 1 row affected (1.15 sec)
Display all records from the table using select −
mysql> select * from DemoTable1510;
This will produce the following output −
+---------------+
| Value         |
+---------------+
| 20,35         |
| 45,67,89      |
| 90,97,101,190 |
+---------------+
3 rows in set (0.00 sec)
Here is the query to count comma’s −
mysql> select length(Value) - length(replace(Value, ',', '')) as NumberOfComma from DemoTable1510;
This will produce the following output −
+---------------+
| NumberOfComma |
+---------------+
|             1 |
|             2 |
|             3 |
+---------------+
3 rows in set (0.00 sec)
How to get specific key value from array in PHP ?

22 Nov, 2021
In this article, we will see how to get specific key values from the given array. PHP array is a collection of items that are stored under keys. There are two possible types of keys: strings and integers. For any type of key, there is a common syntax to get a specific value by key — square brackets.
Example 1:
PHP
<?php  $mixedArr = [    10,    20,    'hello' => 'world',    30,];  // Get a specific value by index$firstItem = $mixedArr[0];echo "An item by index 0: {$firstItem}\n";  // Get a specific value by string key$stringItem = $mixedArr['hello'];echo "An item by key 'hello': {$stringItem}\n";  ?>
An item by index 0: 10
An item by key 'hello': world
Example 2: Sometimes we can accidentally try to get a non-existent item from the array. In this case, PHP throws a NOTICE. To avoid the issue, we have to check the key existence before accessing it. 
PHP
<?php  $arr = [1, 2, 3];  // Check the key existence with // the built-in 'isset' functionif (isset($arr[10])) {    echo "index 10 value is: {$arr[10]}\n";} else {    echo "There are no value under the index 10\n";}  $value = $arr[10] ?? 'unknown';  echo "A value under the index 10: {$value}\n";  ?>
There are no value under the index 10
A value under the index 10: unknown
PHP-function
PHP-Questions
Picked
PHP
Web Technologies
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to fetch data from localserver database and display on HTML table using PHP ?
Difference between HTTP GET and POST Methods
Different ways for passing data to view in Laravel
PHP | file_exists( ) Function
How to create admin login page using PHP?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Installation of Node.js on Linux
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
Difference between Django and PHP

10 Dec, 2020
In the present world, many new frameworks have emerged in web technology. One such framework is Django which is based on Python. PHP has been in use for several years and has been serving as a powerful scripting language especially for backend connectivity. This article compares and contrasts Django and PHP.
Django is a high-level python based web framework which allows you to quickly create web applications. It is a collection of libraries written in python MVT-style. It gives you ready-made components to use. It has a built-in admin section, decorators and view classes. The offline documents for Django make it easier to learn it. 
PHP is a server-side scripting language used mainly for web development. This can be easily embedded in HTML files and HTML codes can also be written in a PHP file. The difference between PHP and client-side language like HTML is, PHP codes are executed on the server whereas HTML codes are directly rendered on the browser.
Table of Difference between Django and PHP :
bunnyram19
Python Django
Difference Between
Python
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
CakePHP - Installation

In this chapter, we will show the installation of CakePHP 4.0.3. The minimum PHP version that we need to install is PHP 7.3.
You need to have PHP 7.3 and Composer to be installed before starting the installation of cakePHP.
For Windows users, install or update WAMP server with PHP version > 7.3.
Go to www.wampserver.com/en/download-wampserver-64bits/ and install it.
For Linux users, kindly refer Tutorials Point website which is available at www.tutorialspoint.com/php7/php7_installation_linux.htm for installation of PHP .
Go to composer at https://getcomposer.org/download/ and click on download as per the operating system (OS) of your computer and install composer on your system. Add the location to PATH variable for windows users, so that you can use composer from any directory.
Once you are done installing composer, let us now start to install CakePHP.
Go to the folder where wamp is located for windows users and in www/ folder, create a folder cakephp4/.
For Linux users, create the folder var/www/html/ and then create folder cakephp4/.
cakephp4/ is the folder where we are going to install CakePHP.
cakephp4/ is the folder where we are going to install CakePHP.
Use composer to execute the following command −
composer create-project --prefer-dist cakephp/app:4.0.3 cakephp4

This is what you should see, when the command executes −
Once the installation is complete, use localhost to open your project in browser.
The Path for the same is http://localhost/cakephp.
 Print
 Add Notes
 Bookmark this page
MATLAB - Matrix Multiplication

Consider two matrices A and B. If A is an m x n matrix and B is an n x p matrix, they could be multiplied together to produce an m x p matrix C. Matrix multiplication is possible only if the number of columns n in A is equal to the number of rows n in B.
In matrix multiplication, the elements of the rows in the first matrix are multiplied with corresponding columns in the second matrix.
Each element in the (i, j)th position, in the resulting matrix C, is the summation of the products of elements in ith row of first matrix with the corresponding element in the jth column of the second matrix.
Matrix multiplication in MATLAB is performed by using the * operator.
Create a script file with the following code −
a = [ 1 2 3; 2 3 4; 1 2 5]
b = [ 2 1 3 ; 5 0 -2; 2 3 -1]
prod = a * b
When you run the file, it displays the following result −
a =
      1     2     3
      2     3     4
      1     2     5
b =
      2     1     3
      5     0    -2
      2     3    -1
prod =
      18    10    -4
      27    14    -4
      22    16    -6


    30 Lectures 
     4 hours 

 Nouman Azam

    127 Lectures 
     12 hours 

 Nouman Azam

    17 Lectures 
     3 hours 

 Sanjeev

    37 Lectures 
     5 hours 

 TELCOMA Global

    22 Lectures 
     4 hours 

 TELCOMA Global

    18 Lectures 
     3 hours 

 Phinite Academy
 Print
 Add Notes
 Bookmark this page
How to check if two numbers (m,n) are amicable or not using Python?

Amicable numbers are two different numbers so related that the sum of the proper divisors of each is equal to the other number. (A proper divisor of a number is a positive factor of that number other than the number itself. For example, the proper divisors of 6 are 1, 2, and 3.)
In python, you can find these numbers by taking the sum of each of these and comparing them with the other. For example, 
def are_amicable(x, y)
   if x==y:
      return False
   # Find sum of their proper divisors
   sum_x = sum(e for e in range(1, x//2+1) if x % e == 0)
   sum_y = sum(e for e in range(1, y//2+1) if y % e == 0)
   
   #Return true of they satisfy the last condition
   return sum_x==y and sum_y==x
print(are_amicable(15, 20))
print(are_amicable(220, 284))
This will give the output
False
True
How to use NameValueCollection class in C#?

The NameValueCollection sets more than one value for a single key. Now let us see how to use them in our C# program.
Set the collection −
static NameValueCollection GetCollection() {
   NameValueCollection myCollection = new NameValueCollection();
   myCollection.Add("Tim", "One");
   myCollection.Add("John", "Two");
   myCollection.Add("Jamie", "Three");
   return myCollection;
}
Now with the GetCollection() method use the “AllKeys” method property to display all the keys −
NameValueCollection myCollection = GetCollection();
foreach (string key in myCollection.AllKeys) {
   Console.WriteLine(key);
}
How to Download and Extract Tar Files with One Command in Linux

We can download any required file form the web using the linux terminal. But many times it is found that the downloaded file is a zipped file which is in tar format. In this article we will see how to download and extract the file in a single command.
The wget command downloads the data form the given URL while the tar command does the extraction of the tar.gz files.
$ wget -c https://www.metoffice.gov.uk/hadobs/hadisd/v300_2018f/data/WMO_200000-249999.tar.gz -O - | sudo tar -xz
Running the above code gives us the following result:
--2020-01-01 07:25:18-- https://www.metoffice.gov.uk/hadobs/hadisd/v300_2018f/data/WMO_200000-249999.tar.gz
Resolving www.metoffice.gov.uk (www.metoffice.gov.uk)... 104.80.55.230
Connecting to www.metoffice.gov.uk (www.metoffice.gov.uk)|104.80.55.230|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 454079101 (433M) [application/x-gzip]
Saving to: ‘STDOUT’
- 100%[================================================================================>] 433.04M 4.23MB/s in 1m 46s
2020-01-01 07:27:04 (4.10 MB/s) - written to stdout [454079101/454079101]
Next we list the extracted files to verify the result.
$ ls -lrt
Running the above code gives us the following result −
total 500040
-rw-r--r-- 1 10013 users 948807 Jan 26 2019 hadisd.3.0.0.2018f_19310101-20190101_200660-99999.nc.gz
-rw-r--r-- 1 10013 users 1296563 Jan 26 2019 hadisd.3.0.0.2018f_19310101-20190101_200490-99999.nc.gz
-rw-r--r-- 1 10013 users 2298004 Jan 26 2019 hadisd.3.0.0.2018f_19310101-20190101_200460-99999.nc.gz
.......
........
We can also use curl in place of wget in the above example. Again it is a single command.
$ sudo curl https://www.metoffice.gov.uk/hadobs/hadisd/v300_2018f/data/WMO_200000-249999.tar.gz | sudo tar -xz
Running the above code gives us the following result:
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 433M 100 433M 0 0 5217k 0 0:01:24 0:01:24 --:--:-- 5370k
Next we list the extracted files to verify the result.
$ ls -lrt
Running the above code gives us the following result −
total 500040
-rw-r--r-- 1 10013 users 948807 Jan 26 2019 hadisd.3.0.0.2018f_19310101-20190101_200660-99999.nc.gz
-rw-r--r-- 1 10013 users 1296563 Jan 26 2019 hadisd.3.0.0.2018f_19310101-20190101_200490-99999.nc.gz
-rw-r--r-- 1 10013 users 2298004 Jan 26 2019 hadisd.3.0.0.2018f_19310101-20190101_200460-99999.nc.gz
.......
........
How to update the plot title with Matplotlib using animation?

To update the plot title with Matplotlib using animation, we can take the following steps −
Set the figure size and adjust the padding between and around the subplots.
Create a new figure or activate an existing figure using figure() method.
Create x and y data points using numpy.
Get the current axis.
Add text to the axes using text() method.
Add an animate method that can be used to make an animation by repeatedly calling a function.
To display the figure, use show() method.
import numpy as np
from matplotlib import pyplot as plt, animation

plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True

fig = plt.figure()

x = np.linspace(-10, 10, 1000)
y = np.sin(x)

plt.plot(x, y)

ax = plt.gca()
ax.text(0.5, 1.100, "y=sin(x)", bbox={'facecolor': 'red',
                                       'alpha': 0.5, 'pad': 5},
         transform=ax.transAxes, ha="center")

def animate(frame):
   ax.text(0.5, 1.100, "y=sin(x), frame: %d" % frame,
            bbox={'facecolor': 'red', 'alpha': 0.5, 'pad': 5},
            transform=ax.transAxes, ha="center")

ani = animation.FuncAnimation(fig, animate, interval=100,
                              frames=10, repeat=True)

plt.show()
Python Pandas - Plot a Grouped Horizontal Bar Chart will all the columns

For a grouped Horizontal Bar Chart with all the columns, create a Bar Chart using the barh() and do not set the a and y values.
At first, import the required libraries −
import pandas as pd
import matplotlib.pyplot as plt
Create a DataFrame with 3 columns −
dataFrame = pd.DataFrame({"Car": ['Bentley', 'Lexus', 'BMW', 'Mustang', 'Mercedes', 'Jaguar'],"Cubic_Capacity": [2000, 1800, 1500, 2500, 2200, 3000],"Reg_Price": [7000, 1500, 5000, 8000, 9000, 6000],
})
Plotting grouped Horizontal Bar Chart with all the columns −
dataFrame.plot.barh(title='Car Specifications', color=("blue", "orange"))

Following is the complete code −
import pandas as pd
import matplotlib.pyplot as plt

# creating dataframe
dataFrame = pd.DataFrame({"Car": ['Bentley', 'Lexus', 'BMW', 'Mustang', 'Mercedes', 'Jaguar'],"Cubic_Capacity": [2000, 1800, 1500, 2500, 2200, 3000],"Reg_Price": [7000, 1500, 5000, 8000, 9000, 6000],
})

# plotting grouped Horizontal Bar Chart with all the columns
dataFrame.plot.barh(title='Car Specifications', color=("blue", "orange"))

# display the plotted Horizontal Bar Chart
plt.show()


This will produce the following output −
How to create facets in vertical order using ggplot2 in R?

To create facets in vertical order using ggplot2 in R, we can follow the below steps −
First of all, create a data frame.
Then, create facetted plot with facet_grid function.
After that, create the facetted plot with facet_wrap function.
Let's create a data frame as shown below −
 Live Demo
x<-rnorm(20)
y<-rnorm(20)
Grp<-sample(LETTERS[1:3],20,replace=TRUE)
df<-data.frame(x,y,Grp)
df
On executing, the above script generates the below output(this output will vary on your system due to randomization) −
        x           y   Grp
1 0.94991539 -1.0542462  A
2 -0.57885618 -2.0540170 A
3 -1.23460243 0.8274220  A
4 -0.21877000 -1.9415441 C
5 0.04090913 1.6289717   B
6 -0.64176648 -0.3619278 B
7 -0.96150947 -0.6270708 B
8 0.67482657 -0.9131730  A
9 -0.91607782 -1.6654625 C
10 0.28532388 0.4168112  B
11 0.35770097 -1.7113561 C
12 1.11407808 0.3201749  C
13 -0.01130312 -1.0384266 A
14 -2.02079485 0.5223646 B
15 0.61790518 0.7451400  C
16 -0.11281998 0.2334734 B
17 1.59511515 -2.0538179 C
18 0.54389377 -1.4884317 C
19 -1.65685694 2.1253106 B
20 0.10209988 1.6262022  B
Using facet_grid function to create the facetted scatterplots between x and y based on Grp column −
x<-rnorm(20)
y<-rnorm(20)
Grp<-sample(LETTERS[1:3],20,replace=TRUE)
df<-data.frame(x,y,Grp)
library(ggplot2)
ggplot(df,aes(x,y,col=Grp))+geom_point()+facet_grid(~Grp)
Using facet_wrap function to create the facetted scatterplots between x and y based on Grp column −
x<-rnorm(20)
y<-rnorm(20)
Grp<-sample(LETTERS[1:3],20,replace=TRUE)
df<-data.frame(x,y,Grp)
library(ggplot2)
ggplot(df,aes(x,y,col=Grp))+geom_point()+facet_wrap(~Grp,ncol=1)
Creating a Dropdown Menu using Tkinter

Navigation is the most important part of any application, as it improves the user
experience in an aesthetic way. Using Tkinter, we can create menus and
submenus very efficiently.
Tkinter has an inbuilt function to create menus and these can be invoked with another tkinter widget or window. Tkinter.Menu module provides some properties in Menu-items. Some of these properties are used to label the buttons, toggling the button, adding submenus using cascade properties, etc.
In this article, we will see how to create a dropdown menu using tkinter.Menu and its Menu-item properties. We will use OptionMenu widget to create a list of options and related commands.
from tkinter import *
win =Tk()
win.geometry("700x300")
label= Label(win, text= "Select any One Language!", font= ("", 10))
label.pack(pady=30)

#Access the Menu Widget using StringVar function
clicked= StringVar()
#Create an instance of Menu in the frame
main_menu = OptionMenu(win, clicked, "C++", "Java", "Python", "Rust","Go","Ruby")
main_menu.pack()

win.mainloop()
Running the above code will create a dropdown Menu.
SQL - NULL Values

The SQL NULL is the term used to represent a missing value. A NULL value in a table is a value in a field that appears to be blank.
A field with a NULL value is a field with no value. It is very important to understand that a NULL value is different than a zero value or a field that contains spaces.
The basic syntax of NULL while creating a table.
SQL> CREATE TABLE CUSTOMERS(
   ID   INT              NOT NULL,
   NAME VARCHAR (20)     NOT NULL,
   AGE  INT              NOT NULL,
   ADDRESS  CHAR (25) ,
   SALARY   DECIMAL (18, 2),       
   PRIMARY KEY (ID)
);

Here, NOT NULL signifies that column should always accept an explicit value of the given data type. There are two columns where we did not use NOT NULL, which means these columns could be NULL.
A field with a NULL value is the one that has been left blank during the record creation.
The NULL value can cause problems when selecting data. However, because when comparing an unknown value to any other value, the result is always unknown and not included in the results. You must use the IS NULL or IS NOT NULL operators to check for a NULL value.
Consider the following CUSTOMERS table having the records as shown below.
+----+----------+-----+-----------+----------+
| ID | NAME     | AGE | ADDRESS   | SALARY   |
+----+----------+-----+-----------+----------+
|  1 | Ramesh   |  32 | Ahmedabad |  2000.00 |
|  2 | Khilan   |  25 | Delhi     |  1500.00 |
|  3 | kaushik  |  23 | Kota      |  2000.00 |
|  4 | Chaitali |  25 | Mumbai    |  6500.00 |
|  5 | Hardik   |  27 | Bhopal    |  8500.00 |
|  6 | Komal    |  22 | MP        |          |
|  7 | Muffy    |  24 | Indore    |          |
+----+----------+-----+-----------+----------+
Now, following is the usage of the IS NOT NULLoperator.
SQL> SELECT  ID, NAME, AGE, ADDRESS, SALARY
   FROM CUSTOMERS
   WHERE SALARY IS NOT NULL;
This would produce the following result −
+----+----------+-----+-----------+----------+
| ID | NAME     | AGE | ADDRESS   | SALARY   |
+----+----------+-----+-----------+----------+
|  1 | Ramesh   |  32 | Ahmedabad |  2000.00 |
|  2 | Khilan   |  25 | Delhi     |  1500.00 |
|  3 | kaushik  |  23 | Kota      |  2000.00 |
|  4 | Chaitali |  25 | Mumbai    |  6500.00 |
|  5 | Hardik   |  27 | Bhopal    |  8500.00 |
+----+----------+-----+-----------+----------+

Now, following is the usage of the IS NULL operator.
SQL> SELECT  ID, NAME, AGE, ADDRESS, SALARY
   FROM CUSTOMERS
   WHERE SALARY IS NULL;
This would produce the following result −
+----+----------+-----+-----------+----------+
| ID | NAME     | AGE | ADDRESS   | SALARY   |
+----+----------+-----+-----------+----------+
|  6 | Komal    |  22 | MP        |          |
|  7 | Muffy    |  24 | Indore    |          |
+----+----------+-----+-----------+----------+


    42 Lectures 
     5 hours 

 Anadi Sharma

    14 Lectures 
     2 hours 

 Anadi Sharma

    44 Lectures 
     4.5 hours 

 Anadi Sharma

    94 Lectures 
     7 hours 

 Abhishek And Pukhraj

    80 Lectures 
     6.5 hours 

 Oracle Master Training | 150,000+ Students Worldwide

    31 Lectures 
     6 hours 

 Eduonix Learning Solutions
 Print
 Add Notes
 Bookmark this page
What is Bitwise AND Operator (&) in JavaScript?

It performs a Boolean AND operation on each bit of its integer arguments.
You can try to run the following code to learn how to work with Bitwise AND Operator −
<html>
   <body>
      <script>
         var a = 2; // Bit presentation 10
         var b = 3; // Bit presentation 11

         document.write("(a & b) => ");
         result = (a & b);
         document.write(result);
      </script>
   </body>
</html>
Maximum and minimum of an array using minimum number of comparisons in C

We are given with an array of integers. The task is to find the minimum and maximum element of the array in the minimum number of comparisons.
Input 
Arr[] = { 1,2,4,5,-3,91 }
Output 
Maximum element : 91 Minimum Element : -3
Explanation − Here to minimize the number of comparisons, we will initialize the maximum and minimum element with Arr[0]. And starting from the 2nd element compare each value with min and max and update accordingly.
Input 
Arr[] = { 10,20,21,31,18,11 }
Output 
Maximum element : 31 Minimum Element : 10
Explanation − Here also, to minimize the number of comparisons, we will initialize the maximum and minimum element with Arr[0]. And starting from the 2nd element compare each value with min and max and update accordingly.
We take an integer array having numbers as Arr[]
We take an integer array having numbers as Arr[]
The function getresult( int arr[],int n) is to find the maximum and minimum element present in the array in minimum no. of comparisons.
The function getresult( int arr[],int n) is to find the maximum and minimum element present in the array in minimum no. of comparisons.
If there is only one element then we will initialize the variables max and min with arr[0] .
If there is only one element then we will initialize the variables max and min with arr[0] .
For more than one element, we will initialize max with arr[1] and min with arr[0].
For more than one element, we will initialize max with arr[1] and min with arr[0].
Inside for loop start traversing from third element ( i=2 ) till last.
Inside for loop start traversing from third element ( i=2 ) till last.
Now we will compare each value ( arr[i] ) with min and max. If it is less than min, update min with arr[i]. If it is more than max, then update max with arr[i].
Now we will compare each value ( arr[i] ) with min and max. If it is less than min, update min with arr[i]. If it is more than max, then update max with arr[i].
In the end print the results stored in max and min variables.
In the end print the results stored in max and min variables.
 Live Demo
#include <stdio.h>
#include <math.h>
int getresult(int arr[], int n){
   int min=0,max=0;
   /*If there is only one element then return it as min and max both*/
   if (n == 1)
      { min=max=arr[0]; }
   /* If there are more than one elements, then initialize min and max*/
   if (arr[0] > arr[1]){
      max = arr[0];
      min = arr[1];
   }
   else{
      max = arr[1];
      min = arr[0];
   }
   for (int i = 2; i<n; i++){
      if (arr[i] > max)
         max = arr[i];
      else if (arr[i] < min)
         min = arr[i];
   }
   printf(" Minimum element: %d", min);
   printf(" Maximum element: %d", max);
}
/* Driver program to test above function */
int main(){
   int arr[] = {200, 191, 112, -11, 330, 60};
   int n = 6;
   getresult (arr, n);
}
If we run the above code it will generate the following output −
Minimum element: -11 Maximum element: 330
How to get information of all collections present in MongoDB database using Node.js ? - GeeksforGeeks

12 Feb, 2021
MongoDB, the most popular NoSQL database, we can count the number of documents in MongoDB Collection using the MongoDB collection.countDocuments() function. The mongodb module is used for connecting the MongoDB database as well as used for manipulating the collections and databases in MongoDB. 
Installing module: You can install mongodb module using the following command. 
npm install mongodb
Project Structure:
Project Structure
Running the server on Local IP: Data is the directory where MongoDB server is present.
mongod --dbpath=data --bind_ip 127.0.0.1
MongoDB Collections:
Filename: index.js
Javascript
// Requiring moduleconst MongoClient = require("mongodb");const url = 'mongodb://localhost:27017/'; // Database nameconst databasename = "GFG";  MongoClient.connect(url).then((client) => {   const connect = client.db(databasename)   connect.listCollections().toArray(function(err, names) {          if(!err) {           console.log(names)       }   });}).catch((err) => {    // Printing the error message   console.log(err.Message);})
Run index.js file using the following command:
node index.js
Output: 
mridulmanochagfg
Node.js-Misc
Technical Scripter 2020
MongoDB
Node.js
Technical Scripter
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to connect MongoDB with ReactJS ?
MongoDB - limit() Method
MongoDB - FindOne() Method
Create user and add role in MongoDB
MongoDB updateOne() Method - db.Collection.updateOne()
Installation of Node.js on Linux
Node.js fs.readFileSync() Method
How to update Node.js and NPM to next version ?
Node.js fs.readFile() Method
Node.js fs.writeFile() Method
Check if given four points form a Square

In a 2d plane, four points are given. This algorithm will check whether four points are forming a square or not.
Checking for a square we have to match these conditions −
All four sides formed by given points are same.
All two connecting sides are right-angled.
Input:
Four points {(20, 10), (10, 20), (20, 20), (10, 10)}
Output:
Points are forming a square.
isFormingSquare(p1, p2, p3, p4)
In this procedure, we will use a method squareDist(p1, p2), it will return squared distance of two given points.
Input: Four points.
Output: True when given points are forming a square.
Begin
   dist12 := squareDist(p1, p2)
   dist13 := squareDist(p1, p3)
   dist14 := squareDist(p1, p4)

   if dist12 = dist13 and 2*dist12 = dist14, then
      dist := squareDist(p2, p4)
      return true when dist = squareDist(p3, p4) and dist = dist12
   if dist13 = dist14 and 2*dist13 = dist12, then
      dist := squareDist(p2, p3)
      return true when dist = squareDist(p2, p4) and dist = dist13
   if dist12 = dist14 and 2*dist12 = dist13, then
      dist := squareDist(p2, p3)
      return true when dist = squareDist(p3, p4) and dist = dist12
   return false
End
#include<iostream>
using namespace std;

struct Point {
   int x, y;
};

int squareDist(Point p, Point q) {
   return (p.x - q.x)*(p.x - q.x) + (p.y - q.y)*(p.y - q.y);
}

bool isSquare(Point p1, Point p2, Point p3, Point p4) {    //check four points are forming square or not
   int dist12 = squareDist(p1, p2);     // distance from p1 to p2
   int dist13 = squareDist(p1, p3);     // distance from p1 to p3
   int dist14 = squareDist(p1, p4);     // distance from p1 to p4

   //when length of p1-p2 and p1-p3 are same, and square of (p1-p4) = 2*(p1-p2)
   if (dist12 == dist13 && 2*dist12 == dist14) {
      int dist = squareDist(p2, p4);
      return (dist == squareDist(p3, p4) && dist == dist12);
   }

   //same condition for all other combinations
   if (dist13 == dist14 && 2*dist13 == dist12) {
      int dist = squareDist(p2, p3);
      return (dist == squareDist(p2, p4) && dist == dist13);
   }

   if (dist12 == dist14 && 2*dist12 == dist13) {
      int dist = squareDist(p2, p3);
      return (dist == squareDist(p3, p4) && dist == dist12);
  }
  return false;
}

int main() {
   Point p1 = {20, 10}, p2 = {10, 20}, p3 = {20, 20}, p4 = {10, 10};
   if(isSquare(p1, p2, p3, p4))
      cout << "Points are forming a square.";
   else
      cout << "Points are not forming a square";
}
Points are forming a square.
Database Management Systems | Set 10 - GeeksforGeeks

27 Mar, 2017
Following questions have been asked in GATE CS 2005 exam.
1) Let r be a relation instance with schema R = (A, B, C, D). We define r1 = ‘select A,B,C from r’ and r2 = ‘select A, D from r’. Let s = r1 * r2 where * denotes natural join. Given that the decomposition of r into r1 and r2 is lossy, which one of the following is TRUE?(a) s is subset of r(b) r U s = r(c) r is a subset of s(d) r * s = s
Answer (c)Consider the following example with lossy decomposition of r into r1 and r2. We can see that r is a subset of s.
Table r
 A      B      C      D
---------------------------
 1     10     100    1000    
 1     20     200    1000    
 1     20     200    1001 

Table r1
 A      B      C
------------------
 1     10     100 
 1     20     200 

Table r2
 A     D  
-----------
 1    1000  
 1    1001

Table s (natural join of r1 and r2)
 A      B      C      D
---------------------------
 1     10     100    1000    
 1     20     200    1000    
 1     10     100    1001 
 1     20     200    1001 


2) Let E1 and E2 be two entities in an E/R diagram with simple single-valued attributes. R1 and R2 are two relationships between E1 and E2, where R1 is one-to-many and R2 is many-to-many. R1 and R2 do not have any attributes of their own. What is the minimum number of tables required to represent this situation in the relational model?(a) 2(b) 3(c) 4(d) 5
Answer (b)See http://geeksquiz.com/gate-gate-cs-2005-question-75/ for explanation.
3) Consider a relation scheme R = (A, B, C, D, E, H) on which the following functional dependencies hold: {A–>u0001B, BC–>u0001 D, E–>C, D–>A}. What are the candidate keys of R?(a) AE, BE(b) AE, BE, DE(c) AEH, BEH, BCH(d) AEH, BEH, DEH
Answer (d)A set of attributes S is candidate key of relation R if the closure of S is all attributes of R and there is no subset of S whose closure is all attributes of R.Closure of AEH, i.e. AEH+ = {ABCDEH}Closure of BEH, i.e. BEH+ = {ABCDEH}Closure of DEH, i.e. DEH+ = {ABCDEH}
Please see GATE Corner for all previous year paper/solutions/explanations, syllabus, important dates, notes, etc.
Please write comments if you find any of the answers/explanations incorrect, or you want to share more information about the topics discussed above.
GATE-CS-2005
DBMS
GATE CS
MCQ
DBMS
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
SQL | Join (Inner, Left, Right and Full Joins)
SQL | WITH clause
SQL query to find second highest salary?
SQL Trigger | Student Database
Difference between Clustered and Non-clustered index
Layers of OSI Model
TCP/IP Model
Page Replacement Algorithms in Operating Systems
Types of Operating Systems
Differences between TCP and UDP