code-rag-bench/online-tutorials huggingface dataset:
Python – List of tuples to multiple lists

23 Aug, 2021
In this article, we will discuss how to convert a List of tuples to multiple lists. We can convert lit of tuples to multiple lists by using the map() function
Syntax: map(list, zip(*list_of_tuples)
Example:
Input: [('a', 'b', 'c'), (1,2,3), ('1','3','4')]
Output: ['a', 'b', 'c'], [1, 2, 3], ('1', '3', '4')
Example 1: Python code to display a list of tuples and display them.
Python3
# list of tuple for student data# with both integer and stringsa = [(1, 2,3,4,5),     ("sravan","bobby","ojaswi","rohith","Gnanesh"),      (96,89,78,90,78)]  # displayprint("Original list of tuple")print(a)  # list of tuple for student data # with both integer and stringsa = [(1, 2,3,4,5),     ("sravan","bobby","ojaswi","rohith","Gnanesh"),     (96,89,78,90,78)]  # convert list of tuple to multiple listsdata = map(list, zip(*a))  print("")  # display print("List")for i in data:  print(i)
Output:
Original list of tuple
[(1, 2, 3, 4, 5), (‘sravan’, ‘bobby’, ‘ojaswi’, ‘rohith’, ‘Gnanesh’), (96, 89, 78, 90, 78)]
List
[1, ‘sravan’, 96]
[2, ‘bobby’, 89]
[3, ‘ojaswi’, 78]
[4, ‘rohith’, 90]
[5, ‘Gnanesh’, 78]
Example 2: Python code to convert a list of tuples to multiple lists
Python3
# list of tuple for student# data with both integer and stringsa = [(1, 2,3,4,5),      ("sravan","bobby","ojaswi","rohith","Gnanesh"),     (96,89,78,90,78),     ("kakumanu","kakumanu","hyd","hyd","hyd")]  # convert list of tuple to multiple listsdata = map(list, zip(*a))  # display for i in data:  print(i)
Output:
[1, 'sravan', 96, 'kakumanu']
[2, 'bobby', 89, 'kakumanu']
[3, 'ojaswi', 78, 'hyd']
[4, 'rohith', 90, 'hyd']
[5, 'Gnanesh', 78, 'hyd']
Picked
Python List-of-Tuples
python-list
Python
Python Programs
python-list
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
Introduction To PYTHON
Python | os.path.join() method
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python | Convert string dictionary to dictionary
Python Program for Fibonacci numbers
HTML | accesskey Attribute

10 Aug, 2021
The accesskey attribute in HTML is the keyboard shortcuts to activate/focus specific elements. The access key attribute is browser dependent. It may vary from browser to browser.Supported Tags: It supports all HTML elements. 
Syntax:  
<element accessKey = "single_character">
Shortcut to use access key: The table describes the shortcut to use access key.  
Note:  
In HTML4.1, the accesskey attributes can be used with only few elements which include <a>, <area>, <button>, <input>, <label>, <legend>, and <textarea>.
In HTML5, the accesskey attribute can be used with any element.
 
The behavior of the browser differs when dealing with more than one element having the same accesskey:
 
Google Chrome and Safari: The last element with the accesskey will be activated
Opera: The first element with the accesskey will be activated
Internet Explorer and Mozilla Firefox: The next element with the accesskey will be activated
Example:  
html
<!DOCTYPE html><html>    <head>        <title>            accesskey attribute        </title>    </head>         <body style = "text-align:center">        <h1>GeeksforGeeks</h1>                 <h2>HTML accesskey attribute</h2>                 <!-- The accesskey attribute used here -->        <a href="https://ide.geeksforgeeks.org/tryit.php"            accesskey = "g">GeeksforGeeks        </a>    </body></html>                   
Output: Before using the access key:  
After using the access key:  
Supported Browsers: The browser supported by accesskey attribute are listed below:  
Google Chrome
Internet Explorer
Firefox
Opera
Safari
 
ManasChhabra2
HTML-Attributes
Picked
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 ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
REST API (Introduction)
Hide or show elements in HTML using display property
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
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 ?
How to Push a Container Image to a Docker Repository?

30 Sep, 2021
In this article we will look into how you can push a container image to a Docker Repo. We’re going to use Docker Hub as a container registry, that we’re going to push our Docker image to. 
Follow the below steps to push container Image to Docker repository:
Step 1: The first thing you need to do is make sure that you’ve signed up for Docker account. You can easily come to hub.docker.com, enter a Docker ID, your email address and a password. That’s all you need to do. This Docker account is completely free and you don’t have to pay a single dime for it. You want to make sure that you sign in. This will take you to your dashboard. As you can see here, we haven’t pushed any containers to my register yet:
Step 2: Now, let’s go ahead and take care of that right now. First, we’ll start off with typing the below command. Now, here our credentials are already authenticated, but if yours aren’t, this will ask you to enter your Docker ID and password that you would’ve created when you signed up for Docker Hub account. 
docker login
Step 3: The next thing we are going to need to do is, select an image that we want to push. So, we are going to type the below command:
docker images
We would use a awesomeapp image that we created earlier for this article. 
Step 4: So we will use the below command with the tag of the current image
docker push awesomeapp/firstimage
Now, what it’s doing is, taking that image that’s on our local machine and pushing it out into the Docker Hub. If we head back over to our Docker Hub, when we refresh the page, we can now see that image that we just pushed available here in our registry. 
At this point we have successfully pushed our docker image to docker repo.
simranarora5sos
Cloud-Computing
docker
Docker Container
Advanced Computer Subject
Microsoft Azure
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Write a program that produces different results in C and C++

29 May, 2017
Write a program that compiles and runs both in C and C++, but produces different results when compiled by C and C++ compilers.
There can be many such programs, following are some of them.
1) Character literals are treated differently in C and C++. In C character literals like ‘a’, ‘b’, ..etc are treated as integers, while as characters in C++. (See this for details)
For example, the following program produces sizeof(int) as output in C, but sizeof(char) in C++.
#include<stdio.h>int main(){  printf("%d", sizeof('a'));  return 0;}
2) In C, we need to use struct tag whenever we declare a struct variable. In C++, the struct tag is not necessary. For example, let there be a structure for Student. In C, we must use ‘struct Student‘ for Student variables. In C++, we can omit struct and use ‘Student‘ only.Following is a program that is based on the fact and produces different outputs in C and C++. It prints sizeof(int) in C and sizeof(struct T) in C++.
#include <stdio.h>int T;   int main(){    struct T { double x; };  // In C++, this T hides the global variable T,                             // but not in C    printf("%d", sizeof(T));    return 0;}
3) Types of boolean results are different in C and C++. Thanks to Gaurav Jain for suggesting this point.
   // output = 4 in C (which is size of int)printf("%d", sizeof(1==1));   // output = 1 in c++ (which is the size of boolean datatype)cout << sizeof(1==1); 
This article is contributed by Abhay Rathi. Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above
cpp-puzzle
C Language
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Substring in C++
Multidimensional Arrays in C / C++
Function Pointer in C
Left Shift and Right Shift Operators in C/C++
Different Methods to Reverse a String in C++
Vector in C++ STL
Initialize a vector in C++ (7 different ways)
Templates in C++ with Examples
Operator Overloading in C++
Set in C++ Standard Template Library (STL)
Python – Get particular Nested level Items from Dictionary

24 Oct, 2020
Given a dictionary, extract items from particular level.
Examples:
Input : {“Gfg” : {  “n1”: 3, “nd2”: { “n2” : 6 }}, “is” : { “ne1”: 5, “ndi2”: { “ne2” : 8, “ne22” : 10 } }}, K = 2 Output : {‘n2’: 6, ‘ne2’: 8, ‘ne22’: 10} Explanation : 2nd nesting items are extracted.
Input : {“Gfg” : { “n1”: 3, “nd2”: { “n2” : 6 }}, “is” : { “ne1”: 5, “ndi2”: { “ne2” : 8, “ne22” : 10 } }}, K = 1 Output : {“n1”: 3, “ne1”: 5} Explanation : Elements of 1st nesting extracted. 
Method : Using isinstance() + recursion
This is one of the ways in which this task can be performed. In this, we perform required recursion for inner nestings, and isinstance is used to differentiate between dict instance and other data types to test for nesting.
Python3
# Python3 code to demonstrate working of# Get particular Nested level Items from Dictionary# Using isinstance() + recursion  # helper function    def get_items(test_dict, lvl):      # querying for lowest level    if lvl == 0:        yield from ((key, val) for key, val in test_dict.items()                    if not isinstance(val, dict))    else:          # recur for inner dictionaries        yield from ((key1, val1) for val in test_dict.values()                    if isinstance(val, dict) for key1, val1 in get_items(val, lvl - 1))    # initializing dictionarytest_dict = {"Gfg": { "n1": 3, "nd2": { "n2": 6 }},              "is": { "ne1": 5, "ndi2": { "ne2": 8, "ne22": 10 } }}  # printing original dictionaryprint("The original dictionary is : " + str(test_dict))  # initializing KK = 2  # calling functionres = get_items(test_dict, K)  # printing resultprint("Required items : " + str(dict(res)))
The original dictionary is : {‘Gfg’: {‘n1’: 3, ‘nd2’: {‘n2’: 6}}, ‘is’: {‘ne1’: 5, ‘ndi2’: {‘ne2’: 8, ‘ne22’: 10}}}Required items : {‘n2’: 6, ‘ne2’: 8, ‘ne22’: 10}
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 ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
How to drop one or multiple columns in Pandas Dataframe
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python Program for Fibonacci numbers
Python | Convert string dictionary to dictionary
C# | Convert Stack to array

01 Feb, 2019
Stack represents a last-in, first out collection of object. It is used when you need a last-in, first-out access of items. When you add an item in the list, it is called pushing the item and when you remove it, it is called popping the item. Stack<T>.ToArray Method is used to copy a Stack<T> to a new array.
Properties:
The capacity of a Stack is the number of elements the Stack can hold. As elements are added to a Stack, the capacity is automatically increased as required through reallocation.
If Count is less than the capacity of the stack, Push is an O(1) operation. If the capacity needs to be increased to accommodate the new element, Push becomes an O(n) operation, where n is Count. Pop is an O(1) operation.
Stack accepts null as a valid value and allows duplicate elements.
Syntax:
public T[] ToArray ();

Return Type: This method returns a new array t[] which contains the copy of the elements of the Stack<T>.
Below given are some examples to understand the implementation in a better way :
Example 1:
// C# code to Convert Stack to arrayusing System;using System.Collections.Generic;  class GFG {      // Driver code    public static void Main()    {          // Creating a Stack of strings        Stack<string> myStack = new Stack<string>();          // Inserting the elements into the Stack        myStack.Push("Geeks");        myStack.Push("Geeks Classes");        myStack.Push("Noida");        myStack.Push("Data Structures");        myStack.Push("GeeksforGeeks");          // Converting the Stack into array        String[] arr = myStack.ToArray();          // Displaying the elements in array        foreach(string str in arr)        {            Console.WriteLine(str);        }    }}
GeeksforGeeks
Data Structures
Noida
Geeks Classes
Geeks

Example 2:
// C# code to Convert Stack to arrayusing System;using System.Collections.Generic;  class GFG {      // Driver code    public static void Main()    {          // Creating a Stack of Integers        Stack<int> myStack = new Stack<int>();          // Inserting the elements into the Stack        myStack.Push(2);        myStack.Push(3);        myStack.Push(4);        myStack.Push(5);        myStack.Push(6);          // Converting the Stack into array        int[] arr = myStack.ToArray();          // Displaying the elements in array        foreach(int i in arr)        {            Console.WriteLine(i);        }    }}
6
5
4
3
2

Reference:
https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.stack-1.toarray?view=netframework-4.7.2
CSharp-Generic-Namespace
CSharp-Generic-Stack
CSharp-method
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Bokeh – Plotting Line Segments on a Graph

10 Jul, 2020
Bokeh is a Python interactive data visualization. It renders its plots using HTML and JavaScript. It targets modern web browsers for presentation providing elegant, concise construction of novel graphics with high-performance interactivity.
Bokeh can be used to plot line segments on a graph. Plotting line segments on a graph can be done using the segment() method of the plotting module.
Syntax : segment(parameters)
Parameters :
x0 : x-coordinates of the starting points of the line segment
y0 : y-coordinates of the starting points of the line segment
x1 : x-coordinates of the ending points of the line segment
y1 : y-coordinates of the ending points of the line segment
Returns : an object of class GlyphRenderer
Example 1 : In this example we will be using the default values for plotting the graph.
# importing the modulesfrom bokeh.plotting import figure, output_file, show        # file to save the modeloutput_file("gfg.html")        # instantiating the figure objectgraph = figure(title = "Bokeh Segment Graph")      # the points to be plottedx0 = 0y0 = 0x1 = 10y1 = 10  # plotting the graphgraph.segment(x0, y0,              x1, y1)      # displaying the modelshow(graph)
Output :
Example 2 : In this example we will be plotting the multiple line segments with various other parameters
# importing the modules from bokeh.plotting import figure, output_file, show   # file to save the model output_file("gfg.html")        # instantiating the figure object graph = figure(title = "Bokeh Segment Graph")   # name of the x-axis graph.xaxis.axis_label = "x-axis"       # name of the y-axis graph.yaxis.axis_label = "y-axis"  # points to be plottedx0 = [0, 0, 5]y0 = [0, 5, 0]x1 = [10, 10, 5]y1 = [10, 5, 10]  # color of the linesline_color = ["yellow", "red", "purple"]  # value of line dashline_dash = "dotted"  # thickness of the linesline_width = [15, 10, 20]  # plotting the graph graph.segment(x0, y0,              x1, y1,              line_color = line_color,              line_dash = line_dash,              line_width = line_width)        # displaying the model show(graph)
Output :
Data Visualization
Python Bokeh-plotting-figure-class
Python-Bokeh
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
B+ tree Deletion in Data Structure

Here we will see, how to perform the deletion of a node from B+ Tree. Suppose we have a B+ Tree like below 7minus;
Example of B+ Tree −
Deletion has two parts. At first we have to find the element. That strategy is like the querying. Now for deletion, we have to care about some rules. One node must have at-least m/2 elements. So if we delete, one element, and it has less than m-1 elements remaining, then it will adjust itself. If the entire node is deleted, then its children will be merged, and if their size is same as m, then split them into two parts, and again the median value will go up.
Suppose we want to delete 78. Now there are two children. [75, 77], and [78, 85], then It will delete 78 from the leaf node first, after that take 85, and make a copy of key 85, and make it as root of the subtree.
BPlusTreeDelete(x, key) −
Input − The root of the tree, and key to delete
We will assume, that the key is present into the list
Start from root node, perform exact match for key as ‘key’ till a leaf node. Let the search path
be x1, x2, ... , xh. The x1 is first node so root, then xh is leaf node. Each node xi is parent of xi+1
delete the object where key is ‘key’ from xh.
if h = 1, then return, as there is only one node which is root.
i := h
while xi underflows, do
   if immediate sibling node s of xi, has at least m/2 + 1 elements, then
      redistribute entries evenly between s and xi.
      corresponding to redistribution, a key k in the parent node xi-1, will be changed.
      if xi is non-leaf node, then
         k is dragged down to xi. and a key from s is pushed up to fill the place of k
      else
         k is simply replaced by a key in s
      return
   else
      merge xi with the sibling node s. Delete the corresponding child pointer in xi-1.
      if xi is an internal node, then
         drag the key in xi-1. which is previously divides xi and s. into the new node
         xi and s, into the new node xi.
      else
         delete that key in xi-1.
      i := i – 1
   end if
done
Change the Return-Path in PHP mail function

The reply and return path can be placed in the headers as shown below −
$headers = 'From: sample@example.com' . "\r\n" .
'Reply-To: sample@example.com' . "\r\n" .
'Return-Path: sample@example.com'
Otherwise, it can be passed as the fifth parameter to change the return path −
mail($to, $subject, $message, $headers, "-f email@wherever.com");
Here, 'email@wherever.com' has to be replaced with the user's respective email id.
How do you fill in or pad a column with zeros using a MySQL query?

You can use ZEROFILL for column to fill in or pad with zeros. Let us first create a table−
mysql> create table DemoTable
   (
   Number int
   );
Query OK, 0 rows affected (0.58 sec)
Following is the query to add zerofill attribute for Number column−
mysql> alter table DemoTable change Number Number int(10) zerofill not null;
Query OK, 0 rows affected (1.13 sec)
Records: 0 Duplicates: 0 Warnings: 0
Insert records in the table using insert command −
mysql> insert into DemoTable values(1);
Query OK, 1 row affected (0.23 sec)
mysql> insert into DemoTable values(12);
Query OK, 1 row affected (0.53 sec)
mysql> insert into DemoTable values(123);
Query OK, 1 row affected (0.13 sec)
mysql> insert into DemoTable values(1234);
Query OK, 1 row affected (0.14 sec)
mysql> insert into DemoTable values(12345);
Query OK, 1 row affected (0.15 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output−
+------------+
| Number     |
+------------+
| 0000000001 |
| 0000000012 |
| 0000000123 |
| 0000001234 |
| 0000012345 |
+------------+
5 rows in set (0.00 sec)
HTML | Marquee scrolldelay attribute

11 Jan, 2022
The Marquee scrolldelay attribute in HTML is used to set the interval between each scroll movement in milliseconds. The default value of Scrolldelay is 85. Note: Value less then 60 is not acceptable, unless truespeed is specified.Syntax:  
<marquee scrolldelay=number>
Attribute value:  
number: Define the speed of marquee.
Example:  
html
<!DOCTYPE html><html> <head>    <title>HTML | Marquee scrolldelay 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="">            scrolldealy: default(85)        </marquee>        <marquee class="marq"                 Scrolldelay=100                 bgcolor="Green"                 direction="left"                 loop="">            scrolldelay: 100        </marquee>    </div></body> </html>
Output:  
Supported Browsers: The browsers supported by HTML Marquee scrolldelay attribute are listed below:  
Google Chrome
Internet Explorer
Firefox
Apple Safari
Opera
 
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 ?
REST API (Introduction)
CSS to put icon inside an input element in a form
Types of CSS (Cascading Style Sheet)
Design a Tribute Page using HTML & CSS
Installation of Node.js on Linux
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
HTML | Marquee bgcolor attribute

14 Jan, 2022
The Marquee bgcolor attribute in HTML is used to set the backgroundcolor of marquee.
Note: This attribute is no longer supported in HTML5.
Syntax:
<marquee bgcolor="colorname" >
Attribute value:
color name: Define the background color of the marquee.
Example:
html
<!DOCTYPE html><html>  <head>    <title>HTML Marquee bgcolor 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>      <marquee class="marq"             bgcolor="Green"              direction="left"              loop="">        Background color is green    </marquee>  </body>  </html>
Google Chrome
Internet Explorer
Firefox
Apple Safari
Opera
ManasChhabra2
HTML-Attributes
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
REST API (Introduction)
HTTP headers | Content-Type
Design a Tribute Page using HTML & CSS
How to Insert Form Data into Database using PHP ?
How to position a div at the bottom of its container using CSS?
Installation of Node.js on Linux
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
Difference between System Testing and Acceptance Testing

21 May, 2020
System Testing:System Testing is done to check whether the software or product meets the specified requirements or not. It is done by both testers and developers. It contains the Testings: System testing, Integration Testing. It is done through more positive and negative test cases.
Acceptance Testing:Acceptance Testing is done after the system testing. It is used to check whether the software meets the customer requirements or not. Acceptance testing is used by testers, stakeholders as well as clients. It includes only Functional Testing and it contain two testing Alpha Testing and Beta Testing.
Difference between System Testing and Acceptance Testing:
ashushrma378
Software Testing
Software Engineering
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Functional vs Non Functional Requirements
Differences between Verification and Validation
Unit Testing | Software Testing
Software Engineering | Classical Waterfall Model
Software Requirement Specification (SRS) Format
Difference between Spring and Spring Boot
Software Engineering | Requirements Engineering Process
Software Testing Life Cycle (STLC)
Difference between IAAS, PAAS and SAAS
Equivalence Partitioning Method
Heap Sort

Heap sort is performed on the heap data structure. We know that heap is a complete binary tree. Heap tree can be of two types. Min-heap or max heap. For min heap the root element is minimum and for max heap the root is maximum. After forming a heap, we can delete an element from the root and send the last element to the root. After these swapping procedure, we need to re-heap the whole array. By deleting elements from root we can sort the whole array.
Time Complexity: O(n log n)
Space Complexity: O(1)
Input:
A list of unsorted data: 30 8 99 11 24 39
Output:
Array before Sorting: 30 8 99 11 24 39
Array after Sorting: 8 11 24 30 39 99
heapify(array, size)
Input − An array of data, and the total number in the array
Output − The max heap using an array element
Begin
   for i := 1 to size do
      node := i
      par := floor (node / 2)
      while par >= 1 do
         if array[par] < array[node] then
            swap array[par] with array[node]
         node := par
         par := floor (node / 2)
      done
   done
End
heapSort(array, size)
Output −nbsp;sorted array
Begin
   for i := n to 1 decrease by 1 do
      heapify(array, i)
      swap array[1] with array[i]
   done
End
#include<iostream>
using namespace std;

void display(int *array, int size) {
   for(int i = 1; i<=size; i++)
      cout << array[i] << " ";
   cout << endl;
}

void heapify(int *array, int n) {
   int i, par, l, r, node;
   // create max heap

   for(i = 1; i<= n; i++) {
      node = i; par = (int)node/2;
      while(par >= 1) {
         //if new node bigger than parent, then swap
         if(array[par] < array[node])
            swap(array[par], array[node]);
         node = par;
         par = (int)node/2;//update parent to check
      }
   }
}

void heapSort(int *array, int n) {
   int i;

   for(i = n; i>= 1; i--) {
      heapify(array, i);//heapify each time
      swap(array[1], array[i]);//swap last element with first
   }
}

int main() {
   int n;
   cout << "Enter the number of elements: ";
   cin >> n;
   int arr[n+1]; //effective index starts from i = 1.
   cout << "Enter elements:" << endl;

   for(int i = 1; i<=n; i++) {
      cin >> arr[i];
   }

   cout << "Array before Sorting: ";
   display(arr, n);
   heapSort(arr, n);
   cout << "Array after Sorting: ";
   display(arr, n);
}
Enter the number of elements: 6
Enter elements:
30 8 99 11 24 39
Array before Sorting: 30 8 99 11 24 39
Array after Sorting: 8 11 24 30 39 99
numpy.cos() in Python

09 Feb, 2021
numpy.cos(x[, out]) = ufunc ‘cos’) : This mathematical function helps user to calculate trigonometric cosine for all x(being the array elements). Parameters :  
array  : [array_like]elements are in radians. 
 
2pi Radians = 360 degrees
Return :  
An array with trigonometric cosine 
of x for all x i.e. array elements 
  Code #1 : Working  
Python
# Python program explaining# cos() function import numpy as npimport math in_array = [0, math.pi / 2, np.pi / 3, np.pi]print ("Input array : \n", in_array) cos_Values = np.cos(in_array)print ("\nCosine values : \n", cos_Values)
Output :  
Input array : 
 [0, 1.5707963267948966, 1.0471975511965976, 3.141592653589793]

Cosine values : 
 [  1.00000000e+00   6.12323400e-17   5.00000000e-01  -1.00000000e+00]
  Code #2 : Graphical representation  
Python
# Python program showing# Graphical representation of# cos() function import numpy as npimport matplotlib.pyplot as plt in_array = np.linspace(-(2*np.pi), 2*np.pi, 20)out_array = np.cos(in_array) print("in_array : ", in_array)print("\nout_array : ", out_array) # red for numpy.cos()plt.plot(in_array, out_array, color = 'red', marker = "o")plt.title("numpy.cos()")plt.xlabel("X")plt.ylabel("Y")plt.show()
Output :  
in_array :  [-6.28318531 -5.62179738 -4.96040945 -4.29902153 -3.6376336  -2.97624567
 -2.31485774 -1.65346982 -0.99208189 -0.33069396  0.33069396  0.99208189
  1.65346982  2.31485774  2.97624567  3.6376336   4.29902153  4.96040945
  5.62179738  6.28318531]

out_array :  [ 1.          0.78914051  0.24548549 -0.40169542 -0.87947375 -0.9863613
 -0.67728157 -0.08257935  0.54694816  0.94581724  0.94581724  0.54694816
 -0.08257935 -0.67728157 -0.9863613  -0.87947375 -0.40169542  0.24548549
  0.78914051  1.        ]
 
References : https://docs.scipy.org/doc/numpy-dev/reference/generated/numpy.cos.html#numpy.cos . 
AshokJaiswal
Python numpy-Mathematical Function
Python-numpy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Iterate over a list in Python
Python Classes and Objects
Convert integer to string in Python
Arduino - Variables & Constants

Before we start explaining the variable types, a very important subject we need to make sure, you fully understand is called the variable scope.
Variables in C programming language, which Arduino uses, have a property called scope. A scope is a region of the program and there are three places where variables can be declared. They are −
Inside a function or a block, which is called local variables.
In the definition of function parameters, which is called formal parameters.
Outside of all functions, which is called global variables.
Variables that are declared inside a function or block are local variables. They can be used only by the statements that are inside that function or block of code. Local variables are not known to function outside their own. Following is the example using local variables −
Void setup () {

}

Void loop () {
   int x , y ;
   int z ; Local variable declaration
   x = 0;
   y = 0; actual initialization
   z = 10;
}
Global variables are defined outside of all the functions, usually at the top of the program. The global variables will hold their value throughout the life-time of your program.
A global variable can be accessed by any function. That is, a global variable is available for use throughout your entire program after its declaration.
The following example uses global and local variables −
Int T , S ;
float c = 0 ; Global variable declaration

Void setup () {

}

Void loop () {
   int x , y ;
   int z ; Local variable declaration
   x = 0;
   y = 0; actual initialization
   z = 10;
Remove common elements from two list in Python

19 Dec, 2021
Given two lists, the task is to write a Python program to remove all the common elements of two lists. 
Examples:
Input : list1 = [1, 2, 3, 4, 5]  
          list2 = [4, 5, 6, 7, 8,]
Output : list1 = [1, 2, 3]  
              list2 = [6, 7, 8]
Explanation: Lists after removing common elements of  both the lists i.e, 4 and 5.
Input : list1 = [1, 2, 3]  
           list2 = [1, 2, 3]
Output :  list1 = []  
               list2 = []
Explanation: They have all the elements in common in 
between them.
The remove() method removes the first matching element (which is passed as an argument) from the list.
Python3
# Python program to remove common elements# in the two lists using remove methoddef remove_common(a, b):      for i in a[:]:        if i in b:            a.remove(i)            b.remove(i)      print("list1 : ", a)    print("list2 : ", b)  if __name__ == "__main__":      a = [1, 2, 3, 4, 5]    b = [4, 5, 6, 7, 8]      remove_common(a, b)
Output:
list1 :  [1, 2, 3]
list2 :  [6, 7, 8]
List comprehension gives a shorter syntax when you want to create a new list based on the elements of the existing list.
Python3
# Python program to remove common elements# in the two lists using list comprehensiondef remove_common(a, b):      a, b = [i for i in a if i not in b],     [j for j in b if j not in a]      print("list1 : ", a)    print("list2 : ", b)  if __name__ == "__main__":      a = [1, 2, 3, 4, 5]    b = [4, 5, 6, 7, 8]      remove_common(a, b)
Output:
list1 :  [1, 2, 3]
list2 :  [6, 7, 8]
The difference operator – gets items in the first set but not in the second.
Python3
# Python program to remove common elements# in the two lists using Set’s difference# operatordef remove_common(a, b):      a, b = list(set(a) - set(b)),     list(set(b) - set(a))      print("list1 : ", a)    print("list2 : ", b)    if __name__ == "__main__":      a = [1, 2, 3, 4, 5]    b = [4, 5, 6, 7, 8]      remove_common(a, b)
Output:
list1 :  [1, 2, 3]
list2 :  [6, 7, 8]
The difference() method in python returns a set that contains the difference between two sets i.e, the returned set contains items that exist only in the first set and excludes elements present in both sets.
Python3
# Python program to remove common elements# in the two lists using Set difference()# methoddef remove_common(a, b):      a, b = list(set(a).difference(b)), list(set(b).difference(a))      print("list1 : ", a)    print("list2 : ", b)  if __name__ == "__main__":      a = [1, 2, 3, 4, 5]    b = [4, 5, 6, 7, 8]      remove_common(a, b)
Output:
list1 :  [1, 2, 3]
list2 :  [6, 7, 8]
Python list-programs
python-list
Python
Python Programs
python-list
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | Pandas Series.to_dense()

05 Feb, 2019
Pandas series is a One-dimensional ndarray with axis labels. The labels need not be unique but must be a hashable type. The object supports both integer- and label-based indexing and provides a host of methods for performing operations involving the index.
Pandas Series.to_dense() function return dense representation of NDFrame (as opposed to sparse). This basically mean that memory will be allocated to store even the missing values in the dataframe.
Syntax: Series.to_dense()
Parameter : None
Returns : Dense series
Example #1: Use Series.to_dense() function to convert the given series object to dense series object.
# importing pandas as pdimport pandas as pd  # Creating the Seriessr = pd.Series(['New York', 'Chicago', 'Toronto', 'Lisbon', 'Rio', 'Moscow'])  # Create the Datetime Indexdidx = pd.DatetimeIndex(start ='2014-08-01 10:00', freq ='W',                      periods = 6, tz = 'Europe/Berlin')   # set the indexsr.index = didx  # Print the seriesprint(sr)
Output :
Now we will use Series.to_dense() function to achieve the conversion of the given Series object to dense series object.
# convert to dense objectsr.to_dense()
Output :
<
As we can see in the output, the Series.to_dense() function has returned the dense representation of the given series object. If we notice our series object does not have any missing values for this reason both the outputs looks the same. Let’s see another example which contains some missing values. Example #2: Use Series.to_dense() function to convert the given series object to dense series object.
# importing pandas as pdimport pandas as pd  # Creating the Seriessr = pd.Series([19.5, 16.8, None, 22.78, None, 20.124, None, 18.1002, None])  # Print the seriesprint(sr)
Output :
But, before we go ahead let’s convert the given series object to SparseSeries object to see the difference between the sparse and dense versions.
Now we will use Series.to_sparse() function to achieve the conversion of the given Series object to SparseSeries object.
# convert to Sparse objectsr.to_sparse()
Output :
As we can see in the output, the Series.to_sparse() function has successfully converted the given series object to sparseseries object. If we look at the bottom two lines, it has returned the info about memory Block location and the number of values contained in those blocks.
Now we will use Series.to_dense() function to achieve the conversion of the given Series object to dense series object.
# convert to dense objectsr.to_dense()
Output :
As we can see in the output, the Series.to_dense() function has returned the dense representation of the given series object. It has allocated memory to store even the missing values in the Series. Dense representation is not memory efficient when lots of data is missing.
Python pandas-series
Python pandas-series-methods
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to apply radial gradient (color) to a node in JavaFX?

You can apply colors to shapes in JavaFX using the setFill() method it adds color to the interior of the geometrical shapes or background.
This method accepts an object of the javafx.scene.paint.Paint class as a parameter. It is the base class for the color and gradients that are used to fill the shapes and backgrounds with color.
The javafx.scene.paint.RadialGradient class in JavaFX is a subclass of the Paint and using this you can fill a shape with a circular color gradient pattern.
To apply a radial gradient pattern to a geometrical shape −
Instantiate the RadialGradient class by passing the required parameters.
Instantiate the RadialGradient class by passing the required parameters.
Set the created gradient to the shape using the setFill() method.
Set the created gradient to the shape using the setFill() method.
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.paint.CycleMethod;
import javafx.scene.paint.RadialGradient;
import javafx.scene.paint.Stop;
import javafx.stage.Stage;
import javafx.scene.shape.Circle;
import javafx.scene.shape.Ellipse;
import javafx.scene.shape.Polygon;
import javafx.scene.shape.Rectangle;
public class RadialGradientExample extends Application {
   public void start(Stage stage) {
      //Drawing a circle
      Circle circle = new Circle(75.0f, 65.0f, 40.0f );
      //Drawing a Rectangle
      Rectangle rect = new Rectangle(150, 30, 100, 65);
      //Drawing an ellipse
      Ellipse ellipse = new Ellipse(330, 60, 60, 35);
      //Drawing Polygon
      Polygon poly = new Polygon(410, 60, 430, 30, 470, 30, 490, 60, 470, 100, 430, 100 );
      //Setting the radial gradient
      Stop[] stops = new Stop[] {
         new Stop(0.0, Color.WHITE),
         new Stop(0.3, Color.RED),
         new Stop(1.0, Color.DARKRED)
      };
      RadialGradient gradient = new RadialGradient(0, 0, 300, 178, 60, false, CycleMethod.NO_CYCLE, stops);
      //Setting the pattern
      circle.setFill(gradient);
      circle.setStrokeWidth(3);
      circle.setStroke(Color.CADETBLUE);
      rect.setFill(gradient);
      rect.setStrokeWidth(3);
      rect.setStroke(Color.CADETBLUE);
      ellipse.setFill(gradient);
      ellipse.setStrokeWidth(3);
      ellipse.setStroke(Color.CADETBLUE);
      poly.setFill(gradient);
      poly.setStrokeWidth(3);
      poly.setStroke(Color.CADETBLUE);
      //Setting the stage
      Group root = new Group(circle, ellipse, rect, poly);
      Scene scene = new Scene(root, 600, 150);
      stage.setTitle("Radial Gradient");
      stage.setScene(scene);
      stage.show();
   }
   public static void main(String args[]){
      launch(args);
   }
}
Division Operators in Java

The division operator in Java includes the Division, Modulus, and the Divide And Assignment operator. Let us work with them one by one −
The division operator divides left-hand operand by right-hand operand.
The modulus operator divides left-hand operand by right-hand operand and returns remainder.
This operator divides left operand with the right operand and assign the result to left operand.
Let us now see an example −
public class Demo {
   public static void main( String args[] ) {
      int a = 10;
      int b = 20;
      int c = 25;
      System.out.println("b / a = " + (b / a) );
      System.out.println("b % a = " + (b % a) );
      c /= a ;
      System.out.println("c /= a = " + c );
   }
}
b / a = 2
b % a = 0
c /= a = 2
How to use Breadcrumbs Component in ReactJS?

16 Feb, 2021
Breadcrumbs allow users to make selections from a range of values. Material UI for React has this component available for us, and it is very easy to integrate. We can use Breadcrumbs Component in ReactJS using the following approach.
Creating React Application And Installing Module:
Step 1: Create a React application using the following command.
npx create-react-app foldername
Step 2: After creating your project folder i.e. foldername, move to it using the following command.
cd foldername
Step 3: After creating the ReactJS application, Install the material-ui modules using the following command.
npm install @material-ui/core
Project Structure: It will look like the following.
Project Structure
Filename- App.js: Now write down the following code in the App.js file. Here, App is our default component where we have written our code.
Javascript
import React from "react";import Link from "@material-ui/core/Link";import Typography from "@material-ui/core/Typography";import Breadcrumbs from "@material-ui/core/Breadcrumbs";  const App = () => {  return (    <div      style={{        margin: "auto",        display: "table",      }}    >      <h4>How to use Breadcrumbs in ReactJS?</h4>      <Breadcrumbs aria-label="breadcrumb">        <Link          color="inherit"          href="/"          onClick={(event) => {            event.preventDefault();            alert("Home Page Clicked");          }}        >          Home Page        </Link>        <Link          color="inherit"          href="/getting-started/installation/"          onClick={(event) => {            event.preventDefault();            alert("Dashboard Clicked");          }}        >          Dashboard        </Link>        <Typography color="textPrimary">            Breadcrumb        </Typography>      </Breadcrumbs>    </div>  );};  export default App;
Step to Run Application: Run the application using the following command from the root directory of the project:
npm start
Output: Now open your browser and go to http://localhost:3000/, you will see the following output.
React-Questions
ReactJS
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Axios in React: A Guide for Beginners
ReactJS useNavigate() Hook
How to install bootstrap in React.js ?
How to create a multi-page website using React.js ?
How to do crud operations in ReactJS ?
How to Use Bootstrap with React?
React-Router Hooks
How to navigate on path by button click in react router ?
How to check the version of ReactJS ?
How to Create a Countdown Timer Using ReactJS ?
How to Install Pyproj on Windows?

22 Sep, 2021
Pyproj is an Interface for the cartographic projections and coordinate transformations library (PROJ). In this article, we will look into the process of installing the Pyproj interface on a windows machine.
The only thing that you need for installing Numpy on Windows are:
Python 
PIP or Conda (depending upon user preference))
If you want the installation to be done through conda,  open up the Anaconda Powershell Prompt and use the below command:
conda install -c anaconda pyproj
Type y for yes when prompted.
You will get a similar message once the installation is complete:
Make sure you follow the best practices for installation using conda as:
Use an environment for installation rather than in the base environment using the below command:
conda create -n my-env
conda activate my-env
Note: If your preferred method of installation is conda-forge, use the below command:
conda config --env --add channels conda-forge
To verify if the Pyproj interface has been successfully installed in your system run the below command in Anaconda Powershell Prompt:
conda list pyproj
You’ll get the below message if the installation is complete:
If you want the installation to be done through PIP,  open up the Command Prompt and use the below command:
pip install pyproj
You will get a similar message once the installation is complete:
To verify if the Pyproj interface has been successfully installed in your system run the below command in Command Prompt:
python -m pip show pyproj
You’ll get the below message if the installation is complete:
Blogathon-2021
how-to-install
Picked
Blogathon
How To
Installation Guide
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | GATE-CS-2017 (Set 2) | Question 58

28 Jun, 2021
A message is made up entirely of characters from the set X = {P,Q,R,S,T} . The table of probabilities of each character is shown below :
A message of 100 characters over X is encoded using Huffman coding. Then the excepted length of the encoded message in bits is _____(A) 225(B) 226(C) 227(D) 228Answer: (A)Explanation:
In Huffman coding, we pick the least
two frequent (or probable) character, combine them and create
a new node.

    .08 (T)      0.17(R)    0.19(S)     0.22(P)
      \        /                 \       /
         0.25    0.34(Q)         0.47
           \      /               /
             0.59                /
               \                /
                         1
Looking at above tree structure, Number of bits required by each:P – 2Q – 2R – 3S – 2T – 3
Therefore, excepted length of the encoded message
= 3*0.8 + 3*0.17 +  2*0.19  + 2 *0.22 + 2*0.34
= 2.25
For 100 characters, 2.25*100 = 225
Therefore, option A is correct.
 Quiz of this Question
GATE-CS-2017 (Set 2)
GATE-GATE-CS-2017 (Set 2)
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
Runtime and Compile-time constants in C++

19 Oct, 2020
Run-time Constant:
These are the constants whose respective values can only be known or computed at the time of running of source code. Run time Constants are a bit slower than compile-time constants but are more flexible than compile-time constants. However, once it is initialized, the value of these constants can’t be changed.
Below is the program for illustration of Runtime constants:
C++
// C++ program to illustrate// Run-time Constants#include <iostream>using namespace std;  // Driver Codeint main(){    // Input a variable    double electonmass;    cin >> electonmass;      // Define a constant    // and initialize it at    // run-time    const double electon_mass{ electonmass };      // Known to the compiler    // at the run-time    cout << electon_mass << endl;      return 0;}
2.07335e-317

Compile-time Constant:
These are the constants whose respective value is known or computed at the time of compilation of source code. Compile-time constants are faster than run-time constants but are less flexible than run-time constants.
Below is the program for illustration of Compile-time Constant:
C++
// C++ program to illustrate// compile-time constants#include <iostream>using namespace std;  // Driver Codeint main(){    // Declare and initialize    // compile time constant    const double electron_q{ 1.6e-19 };      // Value known to compiler    // at compile-time    cout << electron_q << endl;      return 0;}
1.6e-19

A runtime constant can have a different value each time the source code is run.
It is generally used while declaring an array size.
It is not preferred for declaring an array size.
Same compilation error, if runtime constant is used for initializing an enumerator.
const keyword
CPP-Basics
cpp-data-types
Programming Basics
C++
C++ Programs
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.