code-rag-bench/online-tutorials huggingface dataset:
PHP Multidimensional Array.

A multidimensional array in PHP an be treated as an array of arrays so that each element within the array is an array itself. Inner elements of a multi dimensional array may be associative or indexed.
Although arrays can be nested upto any levels, two dimensional array with more than one dimensional arrays inside outermost is of realistic use
//two dimensional associative array
twodim = array(
   "row1"=>array(k1=>v1,k2=>v2,k3=>v3),
   "row2"=>array(k4=>v4,k5=>v5,k6=>v6)
)
//two dimensional indexed array
twodim=array(
   array(v1,v2,v3),
   array(v4,v5,v6)
)
In case of indexed two dimensional array, we can access an element from the array by its index with following syntax:
$arr[row][column];
Use of square brackets for assignment of array is available since PHP 5.4
Following example shows indexed 2D array in which each element is an indexed array
 Live Demo
<?php
$arrs=array(
   array(1,2,3,4,5),
   array(11,22,33,44,55),
);
foreach ($arrs as $arr){
   foreach ($arr as $i){
      echo $i . " ";
   }
   echo "\n";
}
$cols=count($arrs[0]);
$rows=count($arrs);
for ($i=0; $i<$rows; $i++){
   for ($j=0;$j<$cols;$j++){
      echo $arrs[$i][$j] . " ";
   }
   echo "\n";
}
?>
This will produce following result −
1 2 3 4 5
11 22 33 44 55
1 2 3 4 5
11 22 33 44 55
Following example has indexed 2D array whaving associative arrays as element
 Live Demo
<?php
$arrs=array(
   array(1=>100, 2=>200, 3=>300),
   array(1=>'aa', 2=>'bb', 3=>'cc'),
);
foreach ($arrs as $arr){
   foreach ($arr as $i=>$j){
      echo $i . "->" .$j . " ";
   }
   echo "\n";
}
for ($row=0; $row < count($arrs); $row++){
   foreach ($arrs[$row] as $i=>$j){
      echo $i . "->" .$j . " ";
   }
   echo "\n";
}
?>
This will produce following result −
1->100 2->200 3->300
1->aa 2->bb 3->cc

1->100 2->200 3->300
1->aa 2->bb 3->cc
}
In following example we have an associative two dimensional array:
 Live Demo
<?php
$arr1=array("rno"=>11,"marks"=>50);
$arr2=array("rno"=>22,"marks"=>60);
$arrs=array(
   "Manav"=>$arr1,
   "Ravi"=>$arr2
);
foreach ($arrs as $key=>$val){
   echo "name : " . $key . " ";
   foreach ($val as $i=>$j){
      echo $i . "->" .$j . " ";
   }
   echo "\n";
}
?>
This will produce following result −
name : Manav rno->11 marks->50
name : Ravi rno->22 marks->60
This Example has associative array with each value as indexed array
 Live Demo
<?php
$arr1=array("PHP","Java","Python");
$arr2=array("Oracle","MySQL","SQLite");
$arrs=array(
   "Langs"=>$arr1,
   "DB"=>$arr2
);
foreach ($arrs as $key=>$val){
   echo $key . ": ";
   for ($i=0; $i < count($val); $i++){
      echo $val[$i] . " ";
   }
   echo "\n";
}
?>
This will produce following result −
Langs: PHP Java Python
DB: Oracle MySQL SQLite
TypeScript | String toString() Method

18 Jun, 2020
The toString() is an inbuilt function in TypeScript which is used to return a string representing the specified object.
Syntax: 
string.toString( ) 
Parameter: This methods does not accept any parameter. Return Value: This method returns the string representing the specified object. Below examples illustrate the String toString() method in TypeScript
Example 1: 
JavaScript
<script>    // Original strings    var str = "Geeksforgeeks - Best Platform";       // use of String toString() Method    var newstr = str.toString()     console.log(newstr);</script>
Output: 
Geeksforgeeks - Best Platform

Example 2: 
JavaScript
<script>    // Original strings    var str = "TypeScript - String toString()";       // use of String toString() Method    var newstr = str.toString()     console.log(newstr);</script>
Output: 
TypeScript - String toString()

TypeScript
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Create the Mean and Standard Deviation of the Data of a Pandas Series

17 Aug, 2020
Standard Deviation is the square root of the Variance. The Standard Deviation denoted by sigma is a measure of the spread of numbers. In pandas, the std() function is used to find the standard Deviation of the series.The mean can be simply defined as the average of numbers. In pandas, the mean() function is used to find the mean of the series.
Example 1 : Finding the mean and Standard Deviation of a Pandas Series.
# importing the moduleimport pandas as pd  # creating a seriess = pd.Series(data = [5, 9, 8, 5, 7, 8, 1, 2, 3,                      4, 5, 6, 7, 8, 9, 5, 3])  # displaying the seriesprint(s)
Output :
Finding the mean of the series using the mean() function.
# finding the meanprint(s.mean())
Output :
Finding the standard deviation of the series using the std() function.
# finding the Standard deviationprint(s.std())
Output :
Example 2 : Finding the mean and Standard Deviation of a Pandas DataFrame.
# importing the moduleimport pandas as pd  # creating a dataframe df = pd.DataFrame({'ID':[114, 345, 157788, 5626],                   'Product':['shirt', 'trousers', 'tie', 'belt'],                   'Color':['White', 'Black', 'Red', 'Brown'],                   'Discount':[10, 10, 10, 10]})  # displaying the DataFrameprint(df)
Output :
Finding the mean of the DataFrame using the mean() function.
# finding the meanprint(df.mean())
Output :
Finding the standard deviation of the DataFrame using the std() function.
# finding the Standard deviationprint(df.std())
Output :
Python pandas-series
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comparing Maps in Golang

06 Nov, 2020
In Go language, a map is a powerful, ingenious, and versatile data structure. Golang Maps is a collection of unordered pairs of key-value. It is widely used because it provides fast lookups and values that can retrieve, update, or delete with the help of keys. In Go language, you are allowed to compare two maps with each other using DeepEqual() function provided by the reflect package. This function returns true if both the maps satisfy the following conditions:
Both maps are nil or non-nil.
Both maps have the same length.
Both maps are the same map object or their corresponding keys map to deeply equal values.
Otherwise, this function returns false.
Syntax: 
reflect.DeepEqual(a, b)


Here, a and b are maps, and this function checks whether a and b are deeply equal or not, then return boolean type result. 
Example: 
Go
// Go program to illustrate// how to compare two mapspackage main import (    "fmt"    "reflect") func main() {     map_1 := map[int]string{         200: "Anita",        201: "Neha",        203: "Suman",        204: "Robin",        205: "Rohit",    }    map_2 := map[int]string{         200: "Anita",        201: "Neha",        203: "Suman",        204: "Robin",        205: "Rohit",        206: "Sumit",    }     map_3 := map[int]string{         200: "Anita",        201: "Neha",        203: "Suman",        204: "Robin",        205: "Rohit",    }    map_4 := map[string]int{         "Anita": 200,        "Neha":  201,        "Suman": 203,        "Robin": 204,        "Rohit": 205,    }     // Comparing maps    // Using DeepEqual() function    res1 := reflect.DeepEqual(map_1, map_2)    res2 := reflect.DeepEqual(map_1, map_3)    res3 := reflect.DeepEqual(map_1, map_4)    res4 := reflect.DeepEqual(map_2, map_3)    res5 := reflect.DeepEqual(map_3, map_4)    res6 := reflect.DeepEqual(map_4, map_4)    res7 := reflect.DeepEqual(map_2, map_4)     // Displaying result    fmt.Println("Is Map 1 is equal to Map 2: ", res1)    fmt.Println("Is Map 1 is equal to Map 3: ", res2)    fmt.Println("Is Map 1 is equal to Map 4: ", res3)    fmt.Println("Is Map 2 is equal to Map 3: ", res4)    fmt.Println("Is Map 3 is equal to Map 4: ", res5)    fmt.Println("Is Map 4 is equal to Map 4: ", res6)    fmt.Println("Is Map 2 is equal to Map 4: ", res7) }
Output:
Is Map 1 is equal to Map 2:  false
Is Map 1 is equal to Map 3:  true
Is Map 1 is equal to Map 4:  false
Is Map 2 is equal to Map 3:  false
Is Map 3 is equal to Map 4:  false
Is Map 4 is equal to Map 4:  true
Is Map 2 is equal to Map 4:  false




warrenbrodskyfacebook
Golang
Go Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
strings.Replace() Function in Golang With Examples
fmt.Sprintf() Function in Golang With Examples
How to Split a String in Golang?
Interfaces in Golang
Different Ways to Find the Type of Variable in Golang
How to Parse JSON in Golang?
How to Trim a String in Golang?
How to convert a string in lower case in Golang?
How to compare times in Golang?
Inheritance in GoLang
GATE | GATE-CS-2005 | Question 45

28 Jun, 2021
Consider three decision problems P1, P2 and P3. It is known that P1 is decidable and P2 is undecidable. Which one of the following is TRUE?(A) P3 is decidable if P1 is reducible to P3(B) P3 is undecidable if P3 is reducible to P2(C) P3 is undecidable if P2 is reducible to P3(D) P3 is decidable if P3 is reducible to P2’s complementAnswer: (C)Explanation:  Background: In computational complexity theory, a decision problem has only two possible outputs yes or no.A decision problem is said to be decidable if there exists an effective method or algorithm that returns a correct yes/no answer to that problem.A decision problem is said to be undecidable if there does not exist a single algorithm that always lead to a correct yes/no solution.
In terms of reducibility: A ≤p B denotes A is a decision problem that is reducible to B in polynomial time p. This simply means that A’s instance can be transformed into B’s instance and following the solution of B we can get a solution for the problem A.So here we can draw some conclusions:
1. If A ≤p B and B is decidable then A is also decidable.
This is because if there exists a specific algorithm for solving B and we can 
also reduce A to B then we can have a solution of A as well. Hence A is decidable.

However the reverse is not true i.e. if A ≤p B and A is decidable 
then B is also decidable because A can have an algorithm existing for its correct 
solution but might be the case that B does not.

2. If A ≤p B and A is undecidable then B is also undecidable.
This is because if A is undecidable even when it can be reduced to B that simply 
reflects even B cannot provide an algorithm by which we can solve B and hence A. 
So decision problem B is also undecidable.


However the reverse is not true here as well i.e. if A ≤p B and B is undecidable then A is also undecidable because there might exist an algorithm for A that can provide a solution to A.
Using the above stated conclusions we can say that option 1, 2 and 4 are false and option 3 is true.
Option 1: P1 ≤p P3 and given P1 is decidable gives no conclusion for P3.
Option 2: P3 ≤p P2 and given P2 is undecidable gives no conclusion for P3.
Option 3: P2 ≤p P3 and given P2 is undecidable gives conclusion for P3 to be 
          undecidable.
Option 4: P3 ≤p P2’s complement and given P2 is undecidable therefore P2’s 
           complement is also undecidable gives no conclusion for P3.

This explanation is contributed by Yashika Arora.
Visit the following articles to learn more:undecidability-and-reducibilityWikipedia: Reduction_(Complexity)Quiz of this Question
GATE-CS-2005
GATE-GATE-CS-2005
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 2011 | Question 49
GATE | GATE CS 1996 | Question 38
GATE | GATE-CS-2004 | Question 31
GATE | GATE-CS-2016 (Set 1) | Question 45
GATE | GATE CS 1996 | Question 63
turtle.left() method in Python

16 Jul, 2020
The turtle module provides turtle graphics primitives, in both object-oriented and procedure-oriented ways. Because it uses Tkinter for the underlying graphics, it needs a version of Python installed with Tk support.
The turtle.left() method is used to change the direction of the turtle by the value of the argument that it takes. It gives the moving of the head of the turtle in a direction. 
turtle.left(angle)

The argument it takes is angle { a number (integer or float) }. So, it turns turtle left by angle units. (Units are by default degrees but can be set via the degrees() and radians() functions.) Angle orientation depends on the mode.
Below is the implementation of the above method with some examples :
Example 1:
Python3
# importing packageimport turtle    # move the turtle forward by # 100 unit distance in the# direction of head of turtleturtle.forward(100)  # change the direction of turtle# by 90 degrees to the left.turtle.left(90)  # move the turtle forward by # 100 unit distance in the # direction of head of turtleturtle.forward(100)
Output:
Example 2:
Python3
# importing packageimport turtle  # Loop for patternfor i in range(10):      # move the turtle forward by   # 100+variable unit distance  # in the direction of head of  # turtle  turtle.forward(100+10*i)      # change the direction of turtle  # by 90 degrees to the left.  turtle.left(90)
Output :
Python-turtle
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Python | os.path.join() method
How to drop one or multiple columns in Pandas Dataframe
Introduction To PYTHON
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | datetime.timedelta() function
Python | Get unique values from a list
How to set the background color of a ttk.Combobox in tkinter?

Tkinter supports ttk widget which is used to change the style and properties of any widget in a tkinter application. We can set the background color, foreground color, and other attributes of the Combobox widget by visiting the configure function in ttk and passing 'TCombobox' as the first parameter.
In this example, we will set the background color of the Combobox widget by defining its values in the ttk widget.
# Import the required libraries
from tkinter import *
from tkinter import ttk

# Create an instance of tkinter frame
win = Tk()

# Set the size of the tkinter window
win.geometry("700x350")

# Define the style for combobox widget
style= ttk.Style()
style.theme_use('clam')
style.configure("TCombobox", fieldbackground= "orange", background= "white")

# Add a label widget
label=ttk.Label(win, text= "Select a Car Model",
font= ('Aerial 11'))
label.pack(pady=30)
# Add a Combobox widget
cb= ttk.Combobox(win, width= 25, values=["Honda", "Hyundai", "Wolkswagon", "Tata", "Renault", "Ford", "Chrevolet", "Suzuki","BMW", "Mercedes"])

cb.pack()

win.mainloop()
Running the above code will open a window that will have a combobox widget to select an option from the list.
How to Add Labels in a Plot using Python? - GeeksforGeeks

20 Oct, 2021
Prerequisites: Python Matplotlib 
In this article, we will discuss adding labels to the plot using Matplotlib in Python. But first, understand what are labels in a plot. The heading or sub-heading written at the vertical axis (say Y-axis) and the horizontal axis(say X-axis) improves the quality of understanding of plotted stats.
Example: Let’s create a simple plot
Python
# python program to plot graph without labelsimport matplotlibimport matplotlib.pyplot as pltimport numpy as np  # it will take x coordinates by default# starting from 0,1,2,3,4...y = np.array([3, 8, 1, 10]) plt.plot(y)plt.show()
Output:
Plot without Labels or Title
By using pyplot() function of library we can add xlabel() and ylabel() to set x and y labels. 
Example: Let’s add Label in the above Plot
Python
# python program for plots with labelimport matplotlibimport matplotlib.pyplot as pltimport numpy as np  # Number of children it was default in earlier casex = np.array([0, 1, 2, 3]) # Number of familiesy = np.array([3, 8, 1, 10]) plt.plot(x, y) # Label for x-axisplt.xlabel("Number of Childerns") # Label for y-axisplt.ylabel("Number of Families") plt.show()  # for display
Output:
Plot with Labels
If you would like to make it more understandable, add a Title to the plot, by just adding a single line of code.
plt.title("Survey Of Colony")
Example:
Python3
# python program for plots with labelimport matplotlibimport matplotlib.pyplot as pltimport numpy as np  # Number of children it was default in earlier casex = np.array([0, 1, 2, 3]) # Number of familiesy = np.array([3, 8, 1, 10]) plt.plot(x, y) # Label for x-axisplt.xlabel("Number of Childerns") # Label for y-axisplt.ylabel("Number of Families") # title of the plotplt.title("Survey Of Colony") plt.show()  # for display
 
 
Output:
 
Plot with Title
 
In order to make the Plot more attractive use the fontdict parameter in xlabel(), ylabel(), and title() to apply the font properties.
 
Python
# Adding font properties to labels and titlesimport matplotlibimport matplotlib.pyplot as pltimport numpy as np  # Number of Childrenx = np.array([0, 1, 2, 3]) # Number of Familiesy = np.array([3, 8, 1, 10]) # label including this form1 will have these propertiesform1 = {'family': 'serif', 'color': 'blue', 'size': 20} # label including this form2 will have these propertiesform2 = {'family': 'serif', 'color': 'darkred', 'size': 15} plt.plot(x, y)plt.xlabel("Number of Childerns", fontdict=form1)plt.ylabel("Number of Families", fontdict=form1)plt.title("Survey Of Colony", fontdict=form2)plt.show()
Output:
Plot with Font Properties
surindertarika1234
Python-matplotlib
Technical Scripter 2020
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 ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python Classes and Objects
How to drop one or multiple columns in Pandas Dataframe
Defaultdict in Python
Python | Get unique values from a list
Python | os.path.join() method
Create a directory in Python
Python | Pandas dataframe.groupby()
Insert statement in MS SQL Server - GeeksforGeeks

05 Aug, 2020
A database contains of many tables which has data stored in an order.  To add up the rows, the user needs to use insert statement. 
Syntax :  
insert into table_name(column_list)
values(values_list) 

For better understanding, an example is given below. 
Example – A table named student must have values inserted into it. It has to be done as follows: 
 
insert into student (varchar2 name(20), int rollnumber, varchar2 course(50));
values('Riya', 111, 'Computer Science'); 

Output –  
1 row(s) inserted 

To check whether the value is actually inserted, the query must be given as follows:  
select *
from student; 

Output – 
 
insert multiple rows : A table can store upto 1000 rows in one insert statement.  If a user want to insert multiple rows at a time, the following syntax has to written. 
Syntax :  
insert into table_name(column_list)
values(value_list1)
values(values_list2)
.
.
.
.
values(values_listn) 

If a user wants to insert more than 1000 rows, multiple insert statements, bulk insert or derived table must be used. 
Example – Consider a table student. If a user has to enter the data of 6 students at a time, the query must be given as follows-  
insert into student(int rollnumber, varchar2(30) name, varchar2(20) course);
values(111, 'Riya', 'CSE');
values(112, 'Apoorva', 'ECE');
values(113, 'Mina', 'Mech');
values(114, 'Rita', 'Biotechnology);
values(115, 'Veena', 'Chemical');
values(116, 'Deepa', 'EEE'); 

Output –  
6 row(s) inserted 

To check whether the values are present in the table, the query must be given as follows:  
select *
from student; 

Output – 
 
The insert multiple rows statement was only available in the year 2008 and later on.  
khushboogoyal499
SQL-Server
DBMS
SQL
DBMS
SQL
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
SQL Trigger | Student Database
Difference between Clustered and Non-clustered index
SQL | DDL, DQL, DML, DCL and TCL Commands
How to find Nth highest salary from a table
SQL | ALTER (RENAME)
SQL Interview Questions
CTE in SQL
HTML | Marquee direction attribute - GeeksforGeeks

17 Mar, 2022
The Marquee direction attribute in HTML is used to set the direction of scrolling. The default direction of scrolling is left. Possible values are up, down, left, right.Syntax:  
<marquee direction= up | down | left | right> 
Attribute Value 
up: It sets the direction to upward.
down: It sets the direction downward.
left: It sets the direction to the left. It has a default value.
right:  It sets the direction to the right.
Example:  
html
<!DOCTYPE html><html> <head>    <title>HTML | Marquee direction attribute</title>    <style>        .main {            text-align: center;        }                 .marq {            padding-top: 30px;            padding-bottom: 30px;        }    </style></head> <body>    <h1 style="color:green; text-align:center;">      GeeksforGeeks  </h1>    <div class="main">        <marquee class="marq"                 bgcolor="Green"                 direction="left"                 loop="">            Left        </marquee>        <marquee class="marq"                 bgcolor="Green"                 direction="right"                 loop="">            Right        </marquee>    </div></body> </html>
Output:  
Supported Browsers: The browsers supported by HTML Marquee direction attribute are listed below:  
Google Chrome
Internet Explorer
Firefox
Apple Safari
Opera
 
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
hritikbhatnagar2182
ManasChhabra2
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)
CSS to put icon inside an input element in a form
Types of CSS (Cascading Style Sheet)
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
C# | Char.GetHashCode() Method with Examples - GeeksforGeeks

19 Dec, 2019
This method is used to return the hash code for this instance.
Syntax:
public override int GetHashCode ();
Return Value: This method returns a 32-bit signed integer hash code.
Below programs illustrate the use of Char.GetHashCode() Method:
Example 1:
// C# program to demonstrate// Char.GetHashCode() Methodusing System;  class GFG {      // Main Method    public static void Main()    {          // declaring and initializing char        char ch1 = 'B';          // checking condition        // using Equals() Method        int val = ch1.GetHashCode();          // Display Hashcode        Console.WriteLine("Hashcode :- {0}", val);    }}
Hashcode :- 4325442

Example 2:
// C# program to demonstrate// Char.GetHashCode() Methodusing System;  class GFG {      // Main Method    public static void Main()    {          // calling hash() Method        hash('a');        hash('b');        hash('c');        hash('x');        hash('y');        hash('z');    }      // Defining hash() Method    public static void hash(char ch)    {        // checking condition        // using Equals() Method        int val = ch.GetHashCode();          // Display Hashcode        Console.WriteLine("Hashcode of " + ch +                                " :- {0}", val);    }}
Hashcode of a :- 6357089
Hashcode of b :- 6422626
Hashcode of c :- 6488163
Hashcode of x :- 7864440
Hashcode of y :- 7929977
Hashcode of z :- 7995514

Reference:
https://docs.microsoft.com/en-us/dotnet/api/system.char.gethashcode?view=netframework-4.7.2
shubham_singh
CSharp-Char-Struct
CSharp-method
C#
C# Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between Abstract Class and Interface in C#
String.Split() Method in C# with Examples
C# | How to check whether a List contains a specified element
C# | IsNullOrEmpty() Method
C# Dictionary with examples
Convert String to Character Array in C#
Program to Print a New Line in C#
Getting a Month Name Using Month Number in C#
Socket Programming in C#
C# Program for Dijkstra's shortest path algorithm | Greedy Algo-7
How to detect operating system on the client machine using JavaScript ? - GeeksforGeeks

16 Aug, 2019
To detect the operating system on the client machine, one can simply use navigator.appVersion or navigator.userAgent property.The Navigator appVersion property is a read-only property and it returns a string which represents the version information of the browser.
Syntax
navigator.appVersion
Example 1: This example uses navigator.appVersion property to display the operating system name.
<!DOCTYPE html> <html>   <head>     <title>        How to detect operating system on the        client machine using JavaScript ?    </title></head>   <body style="text-align:center;">       <h1 style="color:green;">GeeksforGeeks</h1>       <button ondblclick="operatingSytem()">         Return Operating System Name     </button>       <p id="OS"></p>           <!-- Script to display the OS name -->    <script>         function operatingSytem() {             var OSName="Unknown OS";            if (navigator.appVersion.indexOf("Win")!=-1) OSName="Windows";            if (navigator.appVersion.indexOf("Mac")!=-1) OSName="MacOS";            if (navigator.appVersion.indexOf("X11")!=-1) OSName="UNIX";            if (navigator.appVersion.indexOf("Linux")!=-1) OSName="Linux";                          // Display the OS name            document.getElementById("OS").innerHTML = OSName;        }     </script>   </body>   </html>
Output:
Before Click on the Button:
After Click on the Button:
Example 2: This example uses navigator.appVersion property to display all the properties of the client machine.
<!DOCTYPE html> <html>   <head>     <title>        How to detect operating system on the        client machine using JavaScript ?    </title></head>   <body style="text-align:center;">       <h1 style="color:green;">GeeksforGeeks</h1>      <button ondblclick="version()">         Return OS Version     </button>       <p id="OS"></p>           <!-- Script to return OS details -->    <script>         function version() {             var os = navigator.appVersion;                           // Display the OS details            document.getElementById("OS").innerHTML = os;         }     </script> </body>   </html>                 
Output:
Before Click on the Button:
After Click on the Button:
JavaScript-Misc
Picked
JavaScript
Web Technologies
Web technologies Questions
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Remove elements from a JavaScript Array
Convert a string to an integer in JavaScript
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
How to append HTML code to a div using JavaScript ?
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
Python - Convert Key-Value list Dictionary to List of Lists - GeeksforGeeks

22 Apr, 2020
Sometimes, while working with Python dictionary, we can have a problem in which we need to perform the flattening a key value pair of dictionary to a list and convert to lists of list. This can have applications in domains in which we have data. Lets discuss certain ways in which this task can be performed.
Method #1 : Using loop + items()This brute force way in which we can perform this task. In this, we loop through all the pairs and extract list value elements using items() and render in a new list.
# Python3 code to demonstrate working of # Convert Key-Value list Dictionary to Lists of List# Using loop + items()  # initializing Dictionarytest_dict = {'gfg' : [1, 3, 4], 'is' : [7, 6], 'best' : [4, 5]}  # printing original dictionaryprint("The original dictionary is : " + str(test_dict))  # Convert Key-Value list Dictionary to Lists of List# Using loop + items()res = []for key, val in test_dict.items():    res.append([key] + val)  # printing result print("The converted list is : " + str(res)) 
The original dictionary is : {‘gfg’: [1, 3, 4], ‘is’: [7, 6], ‘best’: [4, 5]}The converted list is : [[‘gfg’, 1, 3, 4], [‘is’, 7, 6], [‘best’, 4, 5]]
 
Method #2 : Using list comprehensionThis task can also be performed using list comprehension. In this, we perform the task similar to above method just in one-liner shorter way.
# Python3 code to demonstrate working of # Convert Key-Value list Dictionary to Lists of List# Using list comprehension  # initializing Dictionarytest_dict = {'gfg' : [1, 3, 4], 'is' : [7, 6], 'best' : [4, 5]}  # printing original dictionaryprint("The original dictionary is : " + str(test_dict))  # Convert Key-Value list Dictionary to Lists of List# Using list comprehensionres = [[key] + val for key, val in test_dict.items()]  # printing result print("The converted list is : " + str(res)) 
The original dictionary is : {‘gfg’: [1, 3, 4], ‘is’: [7, 6], ‘best’: [4, 5]}The converted list is : [[‘gfg’, 1, 3, 4], [‘is’, 7, 6], [‘best’, 4, 5]]
Python dictionary-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Python String | replace()
*args and **kwargs in Python
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Split string into list of characters
Python | Convert a list to dictionary
How to print without newline in Python?
How do we create an image map in HTML?

To add an image map, use the <map> tag in HTML. The HTML <map> tag is used for defining an image map along with <img> tag.
The following is the attribute −
You can try to run the following code to learn how to create an image map in HTML −
<!DOCTYPE html>
<html>
   <head>
      <title>HTML map Tag</title>
   </head>
   <body>
      <img src = "/images/html.gif" alt = "HTML Map" border = "0" usemap = "#html"/>
      <!-- Create Mappings -->
      <map name = "html">
         <area shape = "circle" coords = "154,150,59" href = "about/about_team.htm"
         alt = "Team" target = "_self" />
      </map>
   </body>
</html>
Python | Numpy numpy.matrix.H() - GeeksforGeeks

08 Apr, 2019
With the help of Numpy numpy.matrix.H() method, we can make a conjugate Transpose of any complex matrix either having dimension one or more than more.
Syntax : numpy.matrix.H()
Return : Return conjugate transpose of every complex matrix
Example #1 :In this example we can see that with the help of matrix.H() method, we are able to transform any type of complex matrix.
# import the important module in pythonimport numpy as np          # make a matrix with numpygfg = np.matrix([1-2j, 3-4j])          # applying matrix.H() methodgeeks = gfg.getH()    print(geeks)
[[ 1.+2.j]
 [ 3.+4.j]]

Example #2 :
# import the important module in pythonimport numpy as np          # make a matrix with numpygfg = np.matrix([[1-5j, 2 + 5j, 3-3j], [4 + 6j, 5-8j, 6-2j], [7 + 6j, 8-6j, 9 + 1.j]])          # applying matrix.H() methodgeeks = gfg.getH()    print(geeks)
[[ 1.+5.j  4.-6.j  7.-6.j]
 [ 2.-5.j  5.+8.j  8.+6.j]
 [ 3.+3.j  6.+2.j  9.-1.j]]

Python numpy-Matrix Function
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
Enumerate() in Python
How to Install PIP on Windows ?
Iterate over a list in Python
Different ways to create Pandas Dataframe
Python String | replace()
Create a Pandas DataFrame from Lists
Python program to convert a list to string
Reading and Writing to text files in Python
How to set "step" on axis X in my figure in Matplotlib Python 2.6.6?

To set Step on X-axis in a figure in Matplotlib Python, we can take the following Steps −
Create a list of data points, x.
Add a subplot to the current figure using subplot() method.
Set xticks and ticklabels with rotation=45.
To display the figure, use show() method.
import matplotlib.pyplot as plt
plt.rcParams["figure.figsize"] = [7.00, 3.50]
plt.rcParams["figure.autolayout"] = True
x = [1, 2, 3, 4]
y = [1.2, 1.9, 3.1, 4.2]
plt.plot(x,y)
ax1 = plt.subplot()
ax1.set_xticks(x)
ax1.set_xticklabels(["one", "two", "three", "four"], rotation=45)
plt.show()
Color Spaces in OpenCV | Python - GeeksforGeeks

20 Apr, 2022
Color spaces are a way to represent the color channels present in the image that gives the image that particular hue. There are several different color spaces and each has its own significance. Some of the popular color spaces are RGB (Red, Green, Blue), CMYK (Cyan, Magenta, Yellow, Black), HSV (Hue, Saturation, Value), etc. BGR color space: OpenCV’s default color space is RGB. However, it actually stores color in the BGR format. It is an additive color model where the different intensities of Blue, Green and Red give different shades of color.  HSV color space: It stores color information in a cylindrical representation of RGB color points. It attempts to depict the colors as perceived by the human eye. Hue value varies from 0-179, Saturation value varies from 0-255 and Value value varies from 0-255. It is mostly used for color segmentation purpose.  CMYK color space: Unlike, RGB it is a subtractive color space. The CMYK model works by partially or entirely masking colors on a lighter, usually white, background. The ink reduces the light that would otherwise be reflected. Such a model is called subtractive because inks “subtract” the colors red, green and blue from white light. White light minus red leaves cyan, white light minus green leaves magenta, and white light minus blue leaves yellow.  Visualizing the different color channels of an RGB image. 
Python3
import cv2 image = cv2.imread('C://Users//Gfg//rgb.png')B, G, R = cv2.split(image)# Corresponding channels are separated cv2.imshow("original", image)cv2.waitKey(0) cv2.imshow("blue", B)cv2.waitKey(0) cv2.imshow("Green", G)cv2.waitKey(0) cv2.imshow("red", R)cv2.waitKey(0) cv2.destroyAllWindows()
Output: 
sweetyty
Image-Processing
OpenCV
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
Python String | replace()
*args and **kwargs in Python
Reading and Writing to text files in Python
Create a Pandas DataFrame from Lists
Matplotlib.patches.Circle class in Python - GeeksforGeeks

27 Apr, 2020
Matplotlib is an amazing visualization library in Python for 2D plots of arrays. Matplotlib is a multi-platform data visualization library built on NumPy arrays and designed to work with the broader SciPy stack.
The matplotlib.patches.Circle class is used to create a circular patch at a given center xy = (x, y) with a given radius. It uses Bezier splines and is much closer to a scale-free circle.
Syntax: class matplotlib.patches.Circle(xy, radius=5, **kwargs)
parameters:
xy: It is the center of the circle.
radius: It sets the radius of the circle to be drawn. Its default value is 5 units and is optional.
Below table provides with the optional valid kwargs ;
Example 1:
import numpy as npfrom matplotlib.patches import Circlefrom matplotlib.collections import PatchCollectionimport matplotlib.pyplot as pltfrom matplotlib import cmfrom matplotlib import animation    fig, ax = plt.subplots()  patches = []# create circles with random sizes # and locationsN = 12 # number of circlesx = np.random.rand(N)y = np.random.rand(N)radii = 0.1 * np.random.rand(N)for x1, y1, r in zip(x, y, radii):    circle = Circle((x1, y1), r)    patches.append(circle)  # add these circles to a collectionp = PatchCollection(patches, cmap = cm.prism, alpha = 0.4)ax.add_collection(p)  def animate(i):          # random index to color map    colors = 100 * np.random.rand(len(patches))          # set new color colors    p.set_array(np.array(colors))    return p,  ani = animation.FuncAnimation(fig, animate,                              frames = 50, interval = 50)  plt.show()
Output:
Example 2:
import numpy as npimport matplotlibfrom matplotlib.patches import Circle, Wedge, Polygon, Ellipsefrom matplotlib.collections import PatchCollectionimport matplotlib.pyplot as pltimport matplotlib.patches as matpatches    fig, ax = plt.subplots(figsize =(8, 8))patches = []    circle = Circle((2, 2), 2)patches.append(circle)  polygon = matpatches.PathPatch(patches[0].get_path())patches.append(polygon)    colors = 2 * np.random.rand(len(patches))p = PatchCollection(patches,                    cmap = matplotlib.cm.jet,                    alpha = 0.4)  p.set_array(np.array(colors))ax.add_collection(p)  plt.axis([-10, 10, -10, 10])  plt.show()    contain2 = patches[0].get_path().contains_points([[0.5, 0.5],                                                   [1.0, 1.0]])contain3 = patches[0].contains_point([0.5, 0.5])contain4 = patches[0].contains_point([1.0, 1.0])
Output:
Matplotlib patches-class
Python-matplotlib
Python
Write From Home
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Python Dictionary
Enumerate() in Python
Read a file line by line in Python
How to Install PIP on Windows ?
Iterate over a list in Python
Convert integer to string in Python
Convert string to integer in Python
Python infinity
How to set input type date in dd-mm-yyyy format using HTML ?
Matplotlib.pyplot.title() in Python
HTML | data value attribute

15 Jul, 2021
The HTML data value attribute is used to Specify the machine-readable translation of the content of the element.Syntax: 
<data attribute> Contents... </data> 
Example:
html
<!DOCTYPE html><html> <head>    <title>data tag</title></head> <body>    <h1 style="color:green;">GeeksforGeeks</h1>    <h2> HTML data value attribute </h2>     <p><b><i>GeeksforGeeks Subject List:</i></b></p>     <ul>        <li>            <data value="009">              Data Structure          </data>        </li>        <li>            <data value="010">              Algorithm          </data>        </li>        <li>            <data value="011">              HTML          </data>        </li>        <li>            <data value="019">              Operating System          </data>        </li>        <li>            <data value="110">              Computer Network          </data>        </li>        <li>            <data value="111">              DBMS          </data>        </li>    </ul></body> </html>
Output:
Supported Browsers: The browsers supported by data value attribute are listed below:
Google Chrome
Internet Explorer
Firefox
Opera
 
arorakashish0911
hritikbhatnagar2182
HTML-Attributes
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
HTTP header | X-Forwarded-Host

22 Nov, 2019
The HTTP X-Forwarded-Host header is a request-type header de-facto standard header. This header is used to identify the original request made by the client. Because the hostnames and the ports differ in the reverse proxies that time this header took the leade and identify the original request. This header can also be used for debugging, creating location-based content. So this header kept the privacy of the client. The root version of this header is HTTP Forwarded.
Syntax:
X-Forwarded-Host: <host>
Directives: This header accepts a single directive as mentioned above and described below:
<host>: This directive holds the domain name of the forwrded server.
Below examples illustrate the HTTP X-Forwarded-Host header:Examples:
In this example visited site was forwarded from the mentioned host website.X-Forwarded-Host: www.example-cdn.com
X-Forwarded-Host: www.example-cdn.com
In this example forwarded host is geeksforgeeks cdn page.X-Forwarded-Host: www.cdn.geeksforgeeks.org
X-Forwarded-Host: www.cdn.geeksforgeeks.org
To check the X-Forwarded-Host in action go to Inspect Element -> Network check the request header for X-Forwarded-Host like below.
Supported Browsers: The browsers are compatible with the HTTP X-Forwarded-Host header is unknown till now.
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)
How to create footer to stay at the bottom of a Web page?
Difference Between PUT and PATCH Request
How to Open URL in New Tab using JavaScript ?
Roadmap to Learn JavaScript For Beginners
How to float three div side by side using CSS?
PostgreSQL – WHERE clause

28 Aug, 2020
The PostgreSQL WHERE clause is used to filter results returned by the SELECT statement.
Syntax: SELECT select_list FROM table_name WHERE condition;
Let’s analyze the above syntax:
The WHERE clause appears right after the FROM clause of the SELECT statement
The condition evaluates to true, false, or unknown. It can either be a Boolean expression or a combination of Boolean expressions where AND and OR operators are used.
The WHERE clause can also be used with the UPDATE and DELETE statement to specify rows to be updated or deleted.
Below table provides us with the list of comparison operators valid in PostgreSQL:
For the sake of this article we will be using the sample DVD rental database, which is explained here and can be downloaded by clicking on this link.Now, let’s look into some examples.
Example 1:Using WHERE clause with the equal (=) operator. Here we will be using the equal operator in the “customer” table of our sample database.
SELECT
    last_name,
    first_name
FROM
    customer
WHERE
    first_name = 'Kelly';
Output:
Example 2:Using the WHERE clause with the AND operator. Here we will be using the AND operator in the “customer” table of our sample database.
SELECT
    last_name,
    first_name
FROM
    customer
WHERE
    first_name = 'Kelly'
AND last_name = 'Knott';
Output:
Example 3:Using the WHERE clause with the OR operator. Here we will be using the OR operator in the “customer” table of our sample database.
SELECT
    first_name,
    last_name
FROM
    customer
WHERE
    last_name = 'Cooper' OR 
    first_name = 'Jo';
Output:
Example 4:Using the WHERE clause with the IN operator. The IN operator is used for string matching. Here we will be using the IN operator in the “customer” table of our sample database.
SELECT
    first_name,
    last_name
FROM
    customer
WHERE 
    first_name IN ('Kelly', 'Jo', ' Alexander');
Output:
Example 5:Using the WHERE clause with the LIKE operator. The LIKE operator is used to find string matching a particular pattern. Here we will be using the LIKE operator in the “customer” table of our sample database.
SELECT
    first_name,
    last_name
FROM
    customer
WHERE 
    first_name LIKE 'Kath%';
Output:
Example 6:Using the WHERE clause with the BETWEEN operator. The BETWEEN operator return if a value is in the mentioned range. Here we will be using the BETWEEN operator in the “customer” table of our sample database.
SELECT
    first_name,
    LENGTH(first_name) name_length
FROM
    customer
WHERE 
    first_name LIKE 'K%' AND
    LENGTH(first_name) BETWEEN 3 AND 7
ORDER BY
    name_length;
Output:
Example 7:Using the WHERE clause with the not equal operator (<>). Here we will be using the <> operator in the “customer” table of our sample database.
SELECT 
    first_name, 
    last_name
FROM 
    customer 
WHERE 
    first_name LIKE 'Bra%' AND 
    last_name <> 'Motley';
Output:
postgreSQL-clauses
PostgreSQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | sympy.evalf() method

18 Jun, 2019
With the help of sympy.evalf() method, we are able to evaluate the mathematical expressions.
Syntax : sympy.evalf()Return : Return the evaluated mathematical expression.
Example #1 :In this example we can see that by using sympy.evalf() method, we are able to evaluate the mathematical expressions.
# Import sympyfrom sympy import *  # Use sympy.evalf() methodexpn = sqrt(9)gfg = expn.evalf()  print(gfg)
Output :
3.00000000000000
Example #2 :
# Import sympyfrom sympy import *  # Use sympy.evalf() methodexpn = sqrt(9)*cos(45)gfg = expn.evalf()  print(gfg)
Output :
1.57596596645319
SymPy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to join two Arrays using STL in C++? - GeeksforGeeks

19 Mar, 2019
Given two arrays, join these two arrays using STL in C++.
Example:
Input:arr1[] = {1, 45, 54, 71, 76, 12},arr2[] = {1, 7, 5, 4, 6, 12}Output: {1, 4, 5, 6, 7, 12, 45, 54, 71, 76}
Input:arr1[] = {1, 7, 5, 4, 6, 12},arr2[] = {10, 12, 11}Output: {1, 4, 5, 6, 7, 10, 11, 12}
Approach: Joining can be done with the help of set_union() function provided in STL.
Syntax:
set_union (InputIterator1 first1, InputIterator1 last1,
           InputIterator2 first2, InputIterator2 last2,
           OutputIterator result);

Below is the implementation of the above approach:
// C++ program to join two Arrays// using set_union() in STL  #include <bits/stdc++.h>using namespace std;  int main(){      // Get the array    int arr1[] = { 1, 45, 54, 71, 76, 12 };    int arr2[] = { 1, 7, 5, 4, 6, 12 };      // Compute the sizes    int n1 = sizeof(arr1) / sizeof(arr1[0]);    int n2 = sizeof(arr2) / sizeof(arr2[0]);      // Sort the arrays    sort(arr1, arr1 + n1);    sort(arr2, arr2 + n2);      // Print the array    cout << "First Array: ";    for (int i = 0; i < n1; i++)        cout << arr1[i] << " ";    cout << endl;      cout << "Second Array: ";    for (int i = 0; i < n2; i++)        cout << arr2[i] << " ";    cout << endl;      // Initialise a vector    // to store the merged values    // and an iterator    // to traverse this vector    vector<int> v(n1 + n2);    vector<int>::iterator it, st;      it = set_union(arr1, arr1 + n1,                   arr2, arr2 + n2,                   v.begin());      // Print the merged array    cout << "\nAfter joining:\n";    for (st = v.begin(); st != it; ++st)        cout << *st << ", ";    cout << '\n';      return 0;}
First Array: 1 12 45 54 71 76 
Second Array: 1 4 5 6 7 12 

After joining:
1, 4, 5, 6, 7, 12, 45, 54, 71, 76,

cpp-array
STL
C++
C++ Programs
STL
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Iterators in C++ STL
Operator Overloading in C++
Polymorphism in C++
Friend class and function in C++
Inline Functions in C++
Header files in C/C++ and its uses
How to return multiple values from a function in C or C++?
C++ Program for QuickSort
C++ program for hashing with chaining
delete keyword in C++
How to use subSet() method of Java NavigableSet Class

Use the subset() method to get elements from a limit. At first, create NavigableSet and add elements −
NavigableSet<Integer> set = new TreeSet<>();
set.add(10);
set.add(25);
set.add(40);
set.add(55);
set.add(70);
set.add(85);
Now, use the subset() method −
set.subSet(40, 85)
The following is an example to implement subset() method of Java NaviagbleSet class −
 Live Demo
import java.util.NavigableSet;
import java.util.TreeSet;
public class Demo {
   public static void main(String[] args) {
      NavigableSet<Integer> set = new TreeSet<>();
      set.add(10);
      set.add(25);
      set.add(40);
      set.add(55);
      set.add(70);
      set.add(85);
      set.add(100);
      System.out.println("Returned Value = " + set.subSet(40, 85));
   }
}
Returned Value = [40, 55, 70]