code-rag-bench/online-tutorials huggingface dataset:
Barnsley Fern in Python - GeeksforGeeks

22 Oct, 2018
Barnsley fern is a fractal shape created by mathematician Michael Barnsley. The geometric features of this fractal resemble a natural fern and hence it gets its name. Barnsley fern is created by iterating over a large number of times on four mathematical equations, introduced by Barnsley, known as Iterated Function System (IFS).
The transformation Barnsley used had the formula :where, the letters had following value :
and “p” is the probability.
Thus the four equations are:With the help of above equations, the fern is created. Now lets see the Python3 implementation for the same.
# importing necessary modulesimport matplotlib.pyplot as pltfrom random import randint  # initializing the listx = []y = []  # setting first element to 0x.append(0)y.append(0)  current = 0  for i in range(1, 50000):      # generates a random integer between 1 and 100    z = randint(1, 100)      # the x and y coordinates of the equations    # are appended in the lists respectively.          # for the probability 0.01    if z == 1:        x.append(0)        y.append(0.16*(y[current]))          # for the probability 0.85        if z>= 2 and z<= 86:        x.append(0.85*(x[current]) + 0.04*(y[current]))        y.append(-0.04*(x[current]) + 0.85*(y[current])+1.6)          # for the probability 0.07        if z>= 87 and z<= 93:        x.append(0.2*(x[current]) - 0.26*(y[current]))        y.append(0.23*(x[current]) + 0.22*(y[current])+1.6)          # for the probability 0.07        if z>= 94 and z<= 100:        x.append(-0.15*(x[current]) + 0.28*(y[current]))        y.append(0.26*(x[current]) + 0.24*(y[current])+0.44)              current = current + 1   plt.scatter(x, y, s = 0.2, edgecolor ='green')  plt.show()        
Output :
Note: The whole output depends upon the coefficients of the equations. One experiment might be to change the coefficients and get a new pattern every time.
python-utility
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
PyQt5 QScrollBar – Getting Slider Position

04 Aug, 2021
In this article we will see how we can get position of slider in QScrollBar. QScrollBar is a control that enables the user to access parts of a document that is larger than the widget used to display it. Slider is the scroll-able object inside the bar. We can change its position with the help of mouse and keyboard. Also we can change its position programmatically with the help of setSliderPosition method. 
In order to do this we will use sliderPosition method with the scroll bar object.Syntax : scroll.sliderPosition()Argument : It takes no argumentReturn : It returns integer  
Example: Below is the implementation 
Python3
# importing librariesfrom PyQt5.QtWidgets import *from PyQt5 import QtCore, QtGuifrom PyQt5.QtGui import *from PyQt5.QtCore import *import sys  class Window(QMainWindow):     def __init__(self):        super().__init__()         # setting title        self.setWindowTitle("Python ")         # setting geometry        self.setGeometry(100, 100, 500, 400)         # calling method        self.UiComponents()         # showing all the widgets        self.show()       # method for components    def UiComponents(self):         scroll = QScrollBar(self)         # setting geometry of the scroll bar        scroll.setGeometry(100, 50, 30, 200)         # making its background color to green        scroll.setStyleSheet("background : lightgrey;")         # setting slider position        scroll.setSliderPosition(50)          # creating a label        label = QLabel("GeesforGeeks", self)         # setting geometry to the label        label.setGeometry(200, 100, 300, 80)         # making label multi line        label.setWordWrap(True)         # getting current position of the slider        value = scroll.sliderPosition()         # setting text to the label        label.setText("Slider Position : " + str(value))     # create pyqt5 appApp = QApplication(sys.argv) # create the instance of our Windowwindow = Window() # start the appsys.exit(App.exec())
Output :  
 
kalrap615
Python PyQt-QScrollBar
Python-gui
Python-PyQt
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
<mat-progress-bar> in Angular Material

17 Feb, 2021
Introduction:
Angular Material is a UI component library that is developed by the Angular team to build design components for desktop and mobile web applications. In order to install it, we need to have angular installed in our project, once you have it you can enter the below command and can download it. <mat-progress-bar> tag is used for displaying the progress bar. Progress bars are used to indicate the status of a particular task.
Installation syntax:
ng add @angular/material
Approach:
First, install the angular material using the above-mentioned command.
After completing the installation, Import ‘MatProgressBarModule’ from ‘@angular/material/progress-bar’ in the app.module.ts file.
To use progress bars we need to simply use <mat-progress-bar> tag.
They are many types of progress bars like determinate, indeterminate, buffer and etc.
In-order to show the progress we need to give a value property to the tag.
If we want to change the theme then we can change it by using the color property. In angular we have 3 themes, they are primary, accent, and warn.
Once done with the above steps then serve or start the project.
Code Implementation:
app.module.ts:
Javascript
import { CommonModule } from '@angular/common'; import { NgModule } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { MatProgressBarModule } from '@angular/material';     import { AppComponent } from './example.component';     @NgModule({   declarations: [AppComponent],   exports: [AppComponent],   imports: [     CommonModule,     FormsModule,     MatProgressBarModule    ], }) export class AppModule {}
app.component.html:
HTML
<h4> Progress Bars with primary theme </h4>  <mat-progress-bar mode="determinate"     value="40"></mat-progress-bar><br><br><br>  <mat-progress-bar mode="buffer"     value="40"></mat-progress-bar><br><br><br>  <mat-progress-bar mode="indeterminate"     value="40"></mat-progress-bar>  <h4> Progress Bars with warn theme </h4><mat-progress-bar mode="determinate"     value="40" color="warn"></mat-progress-bar><br><br><br>  <mat-progress-bar mode="buffer" value="40"     color="warn"></mat-progress-bar><br><br><br>  <mat-progress-bar mode="indeterminate"     value="40" color="warn"></mat-progress-bar><br><br><br>  <h4> Progress Bars with accent theme </h4>  <mat-progress-bar mode="determinate" value="40"        color="accent"></mat-progress-bar><br><br><br>  <mat-progress-bar mode="buffer" value="40"     color="accent"></mat-progress-bar><br><br><br>  <mat-progress-bar mode="indeterminate"     value="40" color="accent"></mat-progress-bar>
Output:
 
Angular-material
Picked
AngularJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Mathematics | Sum of squares of even and odd natural numbers

04 Apr, 2019
We know sum squares of first n natural numbers is .
How to compute sum of squares of first n even natural numbers?We need to compute 22 + 42 + 62 + .... + (2n)2
EvenSum = 22 + 42 + 62 + .... + (2n)2 
        = 4 x (12 + 22 + 32 + .... + (n)2)
        = 4n(n+1)(2n+1)/6
        = 2n(n+1)(2n+1)/3

Example:
Sum of squares of first 3 even numbers =
                 2n(n+1)(2n+1)/3
               = 2*3(3+1)(2*3+1)/3
               = 56
22 + 42 + 62 = 4 + 16 + 36 = 56
How to compute sum of squares of first n odd natural numbers?We need to compute 12 + 32 + 52 + .... + (2n-1)2
OddSum  = (Sum of Squares of all 2n numbers) - 
          (Sum of squares of first n even numbers)
        = 2n*(2n+1)*(2*2n + 1)/6 - 2n(n+1)(2n+1)/3
        = 2n(2n+1)/6 [4n+1 - 2(n+1)] 
        = n(2n+1)/3 * (2n-1)
        = n(2n+1)(2n-1)/3

Example:
Sum of squares of first 3 odd numbers = n(2n+1)(2n-1)/3
                                      = 3(2*3+1)(2*3-1)/3
                                      = 35
12 + 32 + 52 = 1 + 9 + 25 = 35
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above
VaibhavRai3
Engineering Mathematics
GATE CS
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Generating Random Integers in Pandas Dataframe

10 Jul, 2020
Pandas is the most popular Python library that is used for data analysis. It provides highly optimized performance with back-end source code that is purely written in C or Python.
Here we will see how to generate random integers in the Pandas datagram. We will be using the numpy.random.randint() method to generate random integers.
Example 1 : Generating random integers in Pandas Single Data frame column.
# importing pandas and numpy librariesimport numpy as npimport pandas as pd  # generating 11 random integers from 5 to 35 data = np.random.randint(5, 35, size = 11)df = pd.DataFrame(data, columns = ['random_numbers'])  # displaying random integers in data frameprint(df)
Output :
Example 2 : Sorting a column in Pandas Single Data frame column.
# importing pandas and numpy librariesimport numpy as npimport pandas as pd  # generating 7 random integers from 5 to 35 data = np.random.randint(5, 35, size = 7)df = pd.DataFrame(data, columns = ['integers'])  # displaying random integers in data frameprint("Before Sorting :")print(df)  # sorting the random integer values # using dataframe.sort_values()# and displaying them df.sort_values("integers", axis = 0, ascending = True,                 inplace = True, na_position ='last')  print("After Sorting :")print(df)
Output :
Example 3 : Generating random integers in Pandas Multiple Data frame column.
# importing pandas and numpy librariesimport numpy as npimport pandas as pd  # generating 12X3 i.e 36 random integers from 5 to 40 data = np.random.randint(5, 40, size = (12, 3))df = pd.DataFrame(data, columns = ['random_no_1',                                   'random_no_2',                                   'random_no_3'])  # displaying random integers in the dataframe print(df)
Output :
Example 4 : Sorting random integers columns in Pandas Multiple Data frame column.
# importing pandas and numpy librariesimport numpy as npimport pandas as pd  # generating 6x2 i.e 12 random integers# from 5 to 40 data = np.random.randint(5, 40, size = (6, 2))df = pd.DataFrame(data, columns = ['random_col_1', 'random_col_2'])  # displaying random integers in data frame print("Before Sorting :")print(df)  # Sorting both Random integer column # First column 1 is sorted # then for every column 1, column 2 is sorted # in ascending order# using dataframe.sort_values()df.sort_values(['random_col_1', 'random_col_2'], axis = 0,                ascending = [True, True], inplace = True)  print("After Sorting :")print(df)
Output :
Python pandas-dataFrame
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between DAS and NAS

22 Jun, 2020
1. Directly Attached Storage (DAS) :The storage device which is permanently attached to a desktop computer. DAS is for a single user (Hard drive attached to a computer). DAS is well suited for a small-to-medium sized business where sufficient amounts of storage can be configured at a low startup cost. The DAS enclosure will be a separate adjacent cabinet that contains the additional disk drives.
Component of Directly Attached Storage (DAS) –
1. Storage devices
2. Cables
3. Disk Array
4. Protocol
5. Storage protocols: ATA, SCSI, SAS, SASA, FC 
2. Network Attached Storage (NAS) :This Storage Device is attached on the Local Area Network and used for sharing of data among different users attached to the Local Area Network. Instead of accessing data at the sector level, users can access information on file level over the network. This NAS system is having its own file system, which is once set with proper configuration of NAS and is not dependent upon the operating system of computers from which it is connected. This type of network requires a medium for attaching with several computers. File sharing protocols like NFS, AFP, or CIFS provide access to files in a network.
Components of Network Attached Storage (NAS) –
1. Head unit: CPU, Memory
2. Network Interface Card (NIC)
3. Optimized operating system
4. Protocols
5. Storage protocols: ATA, SCSI, FC  
Difference between DAS and NAS :
Computer Networks
Difference Between
Computer Networks
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between String and Character array in Java.

On technical groud, we can say that both a character array and string contain the sequence of characters and used as a collection of characters. But there are significant differences between both which we would discuss below.
The following are the important differences between String and Character array.
 Live Demo
JavaTester.java
public class JavaTester{
   public static void main(String[] args) {
      String s = "HELLO";
      char [] ch = s.toCharArray();
      char[] a = {'H', 'E', 'L', 'L', 'O'};
      String A = new String(a);
      System.out.println(s);
      System.out.println(A);
   }
}
HELLO
HELLO
Java Program to count letters in a String

Let’s say we have the following string, that has some letters and numbers.
String str = "9as78";
Now loop through the length of this string and use the Character.isLetter() method. Within that, use the charAt() method to check for each character/ number in the string.
for (int i = 0; i < str.length(); i++) {
   if (Character.isLetter(str.charAt(i)))
   count++;
}
We have set a count variable above to get the length of the letters in the string.
Here’s the complete example.
 Live Demo
public class Demo {
   public static void main(String []args) {
      String str = "9as78";
      int count = 0;
      System.out.println("String: "+str);
      for (int i = 0; i < str.length(); i++) {
         if (Character.isLetter(str.charAt(i)))
         count++;
      }
      System.out.println("Letters: "+count);
   }
}
String: 9as78
Letters: 2
Let us see another example.
 Live Demo
public class Demo {
   public static void main(String []args) {
      String str = "amit";
      int count = 0;
      System.out.println("String: "+str);
      for (int i = 0; i < str.length(); i++) {
         if (Character.isLetter(str.charAt(i)))
         count++;
      }
      System.out.println("Letters: "+count);
   }
}
String: amit
Letters: 4
GATE | GATE-CS-2003 | Question 59 - GeeksforGeeks

28 Jun, 2021
Consider the syntax directed definition shown below.
S → id : = E  {gen (id.place = E.place;);}
E → E1 + E2   {t = newtemp ( ); gen (t = El.place + E2.place;); E.place = t}
E → id     {E.place = id.place;} 
Here, gen is a function that generates the output code, and newtemp is a function that returns the name of a new temporary variable on every call. Assume that ti’s are the temporary variable names generated by newtemp.For the statement ‘X: = Y + Z’, the 3-address code sequence generated by this definition is(A) X = Y + Z(B) t1 = Y + Z; X = t1(C) t1 =Y; t2 = t1 + Z; X = t2(D) t1 = Y; t2 = Z; t3 = t1 + t2; X = t3Answer: (B)Explanation: It must be B. The production E –> E + E is used only one time and hence only one temporary variable is generated.Quiz of this Question
GATE-CS-2003
GATE-GATE-CS-2003
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | Gate IT 2007 | Question 25
GATE | GATE-CS-2000 | Question 41
GATE | GATE-CS-2001 | Question 39
GATE | GATE-CS-2005 | Question 6
GATE | GATE MOCK 2017 | Question 21
GATE | GATE-CS-2006 | Question 47
GATE | GATE MOCK 2017 | Question 24
GATE | Gate IT 2008 | Question 43
GATE | GATE-CS-2009 | Question 38
GATE | GATE-CS-2003 | Question 90
p5.js | createSelect() Function - GeeksforGeeks

03 Dec, 2021
The createSelect() function in p5.js is used to create a dropdown menu element in the DOM (Document Object Model) for taking input. The .value() method is used to get the selected option. This function includes the p5.dom library. Add the following syntax in the head section.
Note: This function requires the p5.dom library. So add the following line in the head section of the index.html file.
<script src=”https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.9.0/addons/p5.dom.min.js”> </script>
Syntax:  
createSelect(multiple)
or  
createSelect(existing)
Parameters:  
multiple: It holds the state of input. Multiple if True, single if False.
existing: It holds the object DOM select element.
Return Value: This function returns the value of an attribute in p5.Element format.
Example: This example uses a dropdown menu to change the background color from the given options. 
Javascript
// Create a variable for dropdown menu objectvar dropdown; function setup() {    // Create a canvas    createCanvas(400,400);    // Create a dropdown menu object    dropdown = createSelect();    // Position the dropdown menu    dropdown.position(150,200);    // Set options    dropdown.option("orange");    dropdown.option("green");    dropdown.option("skyblue");} function draw() {    // Set the background-color as chosen    // from the dropdown menu    background(dropdown.value());}
Output: 
Before changing the color:
During changing the color:
After changing the color:
Online editor: https://editor.p5js.org/ Environment Setup: https://www.geeksforgeeks.org/p5-js-soundfile-object-installation-and-methods/
Reference: https://p5js.org/reference/#/p5/createSelect 
surinderdawra388
adnanirshad158
JavaScript-p5.js
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Convert a string to an integer in JavaScript
How to calculate the number of days between two dates in javascript?
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
File uploading in React.js
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
What is a base class in C#?

When creating a class, instead of writing completely new data members and member functions, the programmer can designate that the new class should inherit the members of an existing class. This existing class is called the base class, and the new class is referred to as the derived class.
A class can be derived from more than one class or interface, which means that it can inherit data and functions from multiple base classes or interfaces.
The following is the syntax of base class in C# −
<access-specifier> class <base_class> {
   ...
}

class <derived_class> : <base_class> {
   ...
}
Let us see an example −
using System;

namespace InheritanceApplication {
   class Shape {
      public void setWidth(int w) {
      width = w;
   }

   public void setHeight(int h) {
      height = h;
   }

   protected int width;
      protected int height;
   }

   // Derived class
   class Rectangle: Shape {
      public int getArea() {
         return (width * height);
      }
   }

   class RectangleTester {
      static void Main(string[] args) {
         Rectangle Rect = new Rectangle();

         Rect.setWidth(5);
         Rect.setHeight(7);

         // Print the area of the object.
         Console.WriteLine("Total area: {0}", Rect.getArea());
         Console.ReadKey();
      }
   }
}
Ruby | Hash each() function - GeeksforGeeks

07 Jan, 2020
Hash#each() is a Hash class method which finds the nested value which calls block once for each key in hash by passing the key-value pair as parameters.
Syntax: Hash.each()
Parameter: Hash values
Return: calls block once for each key in hash otherwise Enumerator if no argument is passed.
Example #1 :
# Ruby code for Hash.each() method  # declaring Hash valuea = {a:100, b:200}  # declaring Hash valueb = {a:100, c:300, b:200}  # declaring Hash valuec = {a:100}  # each Valueputs "Hash a each form : #{a.each()}\n\n"  puts "Hash b each form : #{b.each {|key| puts "#{key}"}}\n\n"  puts "Hash c each form : #{c.each {|value| puts "#{value}"}}\n\n"
Output :
Hash a each form : #

[:a, 100]
[:c, 300]
[:b, 200]
Hash b each form : {:a=>100, :c=>300, :b=>200}

[:a, 100]
Hash c each form : {:a=>100}


Example #2 :
# Ruby code for Hash.each() method  # declaring Hash valuea = { "a" => 100, "b" => 200 }  # declaring Hash valueb = {"a" => 100}  # declaring Hash valuec = {"a" => 100, "c" => 300, "b" => 200}    # each Valueputs "Hash a each form : #{a.each()}\n\n"  puts "Hash b each form : #{b.each {|key| puts "#{key}"}}\n\n"  puts "Hash c each form : #{c.each {|value| puts "#{value}"}}\n\n"
Output :
Hash a each form : #

["a", 100]
Hash b each form : {"a"=>100}

["a", 100]
["c", 300]
["b", 200]
Hash c each form : {"a"=>100, "c"=>300, "b"=>200}


Ruby Hash-class
Ruby-Methods
Ruby
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Ruby | Array count() operation
Include v/s Extend in Ruby
Global Variable in Ruby
Ruby | Hash delete() function
Ruby | Enumerator each_with_index function
Ruby | Array select() function
Ruby | Data Types
Ruby | Numeric round() function
Ruby For Beginners
Ruby | String capitalize() Method
How to create a custom object in JavaScript?

To create a custom object in JavaScript, try the following code
Live Demo
<!DOCTYPE html>
<html>
   <body>
      <p id="test"></p>
      <script>
         var dept = new Object();
         dept.employee = "Amit";
         dept.department = "Technical";
         dept.technology ="Java";

         document.getElementById("test").innerHTML =
         dept.employee + " is working on " + dept.technology + " technology.";
      </script>
   </body>
</html>
CSS Selector to Select Elements Not Having Certain Class / Attribute / Type

Using the CSS :not() pseudo-class, we can refine our styling by selecting those elements which do not have a specific value or does not match a selector.
The following examples illustrate CSS :not pseudo-class.
 Live Demo
<!DOCTYPE html>
<html>
<head>
<style>
p {
   background-color: cornflowerblue;
   color: white;
}
p:not(div>p) {
   background-color: khaki;
   font-size: 1.4em;
   font-style: italic;
   color: blue;
}
</style>
</head>
<body>
<div>
<p>Curabitur sapien diam, imperdiet ut est sed, blandit blandit velit. Nunc viverra nunc id ligula ultricies, a fringilla lacus interdum. <span>Sed vel diam at magna pellentesque porttitor.</span>
</p>
<h3>Demo</h3>
</div>
<p> Ut rutrum sapien sit amet sapien lacinia, at ullamcorper felis lobortis. Praesent dignissim vel turpis nec ultricies.</p>
</body>
</html>
This will produce the following result −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<style>
div {
   margin: 2%;
   background-color: cadetblue;
   padding: 10%;
   height: 80px;
}
div:not(.parent) {
   box-shadow: inset 0 0 24px tomato;
   padding: 2%;
}
.parent{
   border: 4px ridge orange;
}
.one {
   background-color: lightgreen;
   border: 4px groove gray;
}
.two{
   height: 20px;
}
</style>
</head>
<body>
<div class="parent">
<div class="one">
<div class="two"></div>
<div class="two"></div>
</div>
<div class="one"></div>
</div>
</body>
</html>
This will produce the following result −
Python – Split strings ignoring the space formatting characters

12 Oct, 2021
Given a String, Split into words ignoring space formatting characters like \n, \t etc.
Input : test_str = ‘geeksforgeeks\n\r\\nt\t\n\t\tbest\r\tfor\f\vgeeks’ Output : [‘geeksforgeeks’, ‘best’, ‘for’, ‘geeks’] Explanation : All space characters are used as parameter to join.
Input : test_str = ‘geeksforgeeks\n\r\\nt\t\n\t\tbest’ Output : [‘geeksforgeeks’, ‘best’] Explanation : All space characters are used as parameter to join.  
Method 1: Using re.split()
In this, we employ appropriate regex composed of space characters and use split() to perform split on set of regex characters.
Python3
# Python3 code to demonstrate working of# Split Strings ignoring Space characters# Using re.split()import re # initializing stringtest_str = 'geeksforgeeks\n\r\t\t\nis\t\tbest\r\tfor geeks' # printing original stringprint("The original string is : " + str(test_str)) # space regex with split returns the resultres = re.split(r'[\n\t\f\v\r ]+', test_str)     # printing resultprint("The split string : " + str(res))
Output:
The original string is : geeksforgeeks

        
is        best
    for geeks
The split string : ['geeksforgeeks', 'is', 'best', 'for', 'geeks']
Method 2: Using split()
The split() function by-default splits the string on white-spaces.
Python3
# Python3 code to demonstrate working of# Split Strings ignoring Space characters# Using split() # initializing stringtest_str = 'geeksforgeeks\n\r\t\t\nis\t\tbest\r\tfor geeks' # printing original stringprint("The original string is : " + str(test_str))     # printing resultprint("The split string : " + str(test_str.split()))
Output:
The original string is : geeksforgeeks

        
is        best
    for geeks
The split string : ['geeksforgeeks', 'is', 'best', 'for', 'geeks']
akshaysingh98088
varshagumber28
Python string-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 | Convert string dictionary to dictionary
Python Program for Fibonacci numbers
Working of Bottom up parser

12 Oct, 2021
In this article, we are going to cover working of the bottom-up parser and will see how we can take input and parse it and also cover some basics of bottom-up parser. 
Pre-requisite – Parsing  
Bottom-up parser :  
It will start from string and proceed to start.
In Bottom-up parser, Identifying the correct handle (substring) is always difficult.
It will follow rightmost derivation in reverse order.
Note : In bottom-up parser, no variable that’s why not have any derivation from the bottom but in reverse order it is looking like top-down, when you have rightmost derivation. 
Working of Bottom-up parser : Let’s consider an example where grammar is given and you need to construct a parse tree by using bottom-up parser technique. 
Example –  
S -> aABe
A -> Abc | b
B -> d
Now, let’s consider the input to read and to construct a parse tree with bottom-up approach. 
Input –  
abbcde$
Now, you will see that how bottom-up approach works. Here, you will see how you can generate a input string from the grammar for bottom-up approach.  
First, you can start with A -> b.
Now, expand A -> Abc.
After that Expand B-> d.
In the last, just expand the S -> aABe
Final string, you will get abbcde.
Given below is the Diagram explanation for constructing bottom-up parse tree. You can see clearly in the diagram how you can generate the input string using grammar with bottom-up approach. 
 
From the above explanation and diagram, you can clearly see and can say it follows reverse of the rightmost derivation. 
sumitgumber28
Compiler Design
GATE CS
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Directed Acyclic graph in Compiler Design (with examples)
Type Checking in Compiler Design
Data flow analysis in Compiler
S - attributed and L - attributed SDTs in Syntax directed translation
Runtime Environments in Compiler Design
Layers of OSI Model
ACID Properties in DBMS
TCP/IP Model
Types of Operating Systems
Normal Forms in DBMS
Regex in Python to put spaces between words starting with capital letters

20 Jun, 2022
Given an array of characters, which is basically a sentence. However, there is no space between different words and the first letter of every word is in uppercase. You need to print this sentence after the following amendments: 
Put a single space between these words. Convert the uppercase letters to lowercase. 
Put a single space between these words. 
Convert the uppercase letters to lowercase. 
Examples: 
Input : BruceWayneIsBatman
Output : bruce wayne is batman

Input :  GeeksForGeeks
Output :  geeks for geeks
We have an existing solution for this problem, please refer Put spaces between words starting with capital letters link.  
We can solve this problem quickly in python using findall() method of re (regex) library. 
Approach : 
Split each word starting with a capital letter using re.findall(expression, str) method.Now change the capital letter of each word to lowercase and concatenate each word with space.
Split each word starting with a capital letter using re.findall(expression, str) method.
Now change the capital letter of each word to lowercase and concatenate each word with space.
Python3
import re   def putSpace(input):       # regex [A-Z][a-z]* means any string starting     # with capital character followed by many     # lowercase letters     words = re.findall('[A-Z][a-z]*', input)       # Change first letter of each word into lower    # case    for i in range(0,len(words)):    words[i]=words[i][0].lower()+words[i][1:]    print(' '.join(words))        # Driver programif __name__ == "__main__":    input = 'BruceWayneIsBatman'    putSpace(input)
Output:  
bruce wayne is batman
Time Complexity: O(n)
Auxiliary Space: O(n) 
sanyaaapandey
riya55
Python Regex-programs
python-regex
python-string
Python
Strings
Strings
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
Write a program to reverse an array or string
Reverse a string in Java
Write a program to print all permutations of a given string
C++ Data Types
Check for Balanced Brackets in an expression (well-formedness) using Stack
SQL Query to Find the Highest Purchase Amount Ordered by the Each Customer

08 Oct, 2021
In order to find the highest purchase amount of each customer, we can use the GROUP BY clause which is very useful with aggregate functions. We use MAX() function with GROUP BY  to find the highest purchase of each customer.
In this article let us see SQL Query to Find the Highest Purchase Amount Ordered by Each Customer using MSSQL as a server.
Step 1: We are creating a Database. For this use the below command to create a database named GeeksforGeeks.
Query:
CREATE DATABASE GeeksforGeeks;
Step 2: To use the GeeksforGeeks database use the below command.
Query:
USE GeeksforGeeks
Output:
Step 3: Now we creating a table. Create a table customer_order_details with  4 columns using the following SQL query.
Query:
CREATE TABLE customer_order_details(
customer_id VARCHAR(20),
customer_name VARCHAR(20),
order_id VARCHAR(20),
order_price INT)
Output:
Step 4: The query for Inserting rows into the Table. Inserting rows into customer_order_details  table using the following SQL query.
Query:
INSERT INTO customer_order_details
VALUES( 'C1098','PRADEEP','O3006', 20000),
( 'C1098','PRADEEP','O3010', 5000),
( 'C1098','PRADEEP','O3016', 600),
( 'C1100','KIRAN','O3068', 1000),
( 'C1100','KIRAN','O3075', 200),
( 'C1195','PRANAV','O3072', 6000),
( 'C1195','PRANAV','O3045', 80000),
( 'C2026','BUTCHI RAJU','O3056', 100000),
( 'C2026','BUTCHI RAJU','O3058', 20000)
Output:
Step 5: Viewing the description of the table.
Query:
EXEC sp_columns customer_order_details
Output:
 Step 6: Viewing the inserted data
Query:
SELECT * FROM customer_order_details
Output:
Query to Find the Highest Purchase Amount Ordered by the Each Customer
Query:
SELECT customer_id , MAX(order_price) AS HighestPurchase
FROM customer_order_details
GROUP BY customer_id 
ORDER BY MAX(order_price) DESC
Output:
Query to find the number of orders ordered by each customer.
Query:
SELECT customer_id , COUNT(order_id) AS NoofOrders
FROM customer_order_details
GROUP BY customer_id
Output:
Picked
SQL-Query
SQL-Server
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Update Multiple Columns in Single Update Statement in SQL?
Window functions in SQL
SQL | Sub queries in From Clause
What is Temporary Table in SQL?
SQL using Python
SQL Query to Find the Name of a Person Whose Name Starts with Specific Letter
RANK() Function in SQL Server
SQL Query to Convert VARCHAR to INT
SQL Query to Compare Two Dates
SQL Query to Insert Multiple Rows
Requests - Handling GET Requests

This chapter will concentrate more on the GET requests, which is the most common and used very often. The working of GET in the requests module is very easy. Here is a simple example about working with the URL using the GET method.
import requests
getdata = requests.get('https://jsonplaceholder.typicode.com/users')
print(getdata.content)
getdata.content, will print all the data available in the response.   
E:\prequests>python makeRequest.py
b'[\n {\n "id": 1,\n "name": "Leanne Graham",\n "username": "Bret",\n
"email": "Sincere@april.biz",\n "address": {\n "street": "Kulas Light
",\n "suite": "Apt. 556",\n "city": "Gwenborough",\n "zipcode": "
92998-3874",\n "geo": {\n "lat": "-37.3159",\n "lng": "81.149
6"\n }\n },\n "phone": "1-770-736-8031 x56442",\n "website": 
"hildegard.org",\n "company": {\n "name": "Romaguera-Crona",\n "catchPhrase": 
"Multi-layered client-server neural-net",\n "bs":
"harness real-time e-markets"\n }\n }

You can also pass parameters to the get method using the param attribute as shown below −
import requests
payload = {'id': 9, 'username': 'Delphine'}
getdata = requests.get('https://jsonplaceholder.typicode.com/users',
params=payload)
print(getdata.content)
The details are stored in the object payload in the key/value pair and passed to params, inside get() method.
E:\prequests>python makeRequest.py
b'[\n {\n "id": 9,\n "name": "Glenna Reichert",\n "username": "Delphine",
\n "email": "Chaim_McDermott@dana.io",\n "address": {\n "street":
"Dayna Park",\n "suite": "Suite 449",\n "city": "Bartholomebury",\n
"zipcode": "76495-3109",\n "geo": {\n "lat": "24.6463",\n
"lng": "-168.8889"\n }\n },\n "phone": "(775)976-6794 x41206",\n "
website": "conrad.com",\n "company": {\n "name": "Yost and Sons",\n
"catchPhrase": "Switchable contextually-based project",\n "bs": "aggregate
real-time technologies"\n }\n }\n]'
HTML <col> Tag

17 Mar, 2022
The <col> tag in HTML is used to set the column properties for each column within a <colgroup> tag. This tag is used to set the style property to each column. This tag does not contain closing tags.
Syntax: 
<col attribute = "value">
Attributes: The various attributes that can be used with the col tag are listed below. Most of the attributes are not supported by HTML5.
span: It is used to define the number of columns on which property will be applied.
style: This attribute is used to define the CSS to change the properties of the column.
align: This attribute is used to set the alignment of the content of <col> element.
width: It is used to specify the width of a <col> element.
charoff: It is used to specify the number of characters the content will be aligned from the character specified by the char attribute.
Example: The below example explains the HTML col Tag.
html
<!DOCTYPE html><html>  <body>    <h1>GeeksforGeeks</h1>    <h2>HTML col Tag</h2>    <table>      <colgroup>        <!-- col tag starts from here -->        <col span="1" style="background-color: green" />        <col span="1" style="background-color: red" />        <col span="1" style="background-color: none" />        <!-- col tag ends here. col tag does not                 contains ending tag -->      </colgroup>        <tr>        <th>NAME</th>        <th>AGE</th>        <th>BRANCH</th>      </tr>      <tr>        <td>BITTU</td>        <td>22</td>        <td>CSE</td>      </tr>      <tr>        <td>RAM</td>        <td>21</td>        <td>ECE</td>      </tr>    </table>  </body></html>
Output: 
Supported Browsers: 
Google Chrome
Internet Explorer
Firefox
Opera
Safari
shubhamyadav4
HTML-Tags
HTML
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
How to set the default value for an HTML <select> element ?
How to set input type date in dd-mm-yyyy format using HTML ?
CSS to put icon inside an input element in a form
Design a Tribute Page using HTML & CSS
Types of CSS (Cascading Style Sheet)
Number of possible Functions

25 Nov, 2019
In the below articles, we are going to calculate the number of functions possible from given two sets of the element.
Statement:Suppose there are two sets ‘A’ and ‘B’ containing ‘n’ and ‘m’ number of elements respectively, i.e., Sets,
'A' = {1, 2, 3, 4, ............, n},
'B' = {1, 2, 3, 4, ............, m} 
Then the number of function possible will be  when functions are counted from set ‘A’ to ‘B’ and  when function are counted from set ‘B’ to ‘A’.
Explanation:In the below diagram, as we can see that Set ‘A’ contain ‘n’ elements and set ‘B’ contain ‘m’ element. Each element of set ‘A’ makes ‘m’ number of functions with each element of the set ‘B’ and hence total number of functions possible is .
Examples:
If set ‘A’ contain ‘3’ element and set ‘B’ contain ‘2’ elements then total number of function possible will be .If set ‘A’ contain ‘5’ element and set ‘B’ contain ‘2’ elements then total number of function possible will be .
If set ‘A’ contain ‘3’ element and set ‘B’ contain ‘2’ elements then total number of function possible will be .
If set ‘A’ contain ‘5’ element and set ‘B’ contain ‘2’ elements then total number of function possible will be .
But when functions are counted from set ‘B’ to ‘A’ then the formula will be  where n, m are the number of elements present in set ‘A’ and ‘B’ respectively then examples will be like below:
If set ‘A’ contain ‘3’ element and set ‘B’ contain ‘2’ elements then the total number of functions possible will be .If set ‘A’ contain ‘5’ element and set ‘B’ contain ‘2’ elements then the total number of function possible will be .
If set ‘A’ contain ‘3’ element and set ‘B’ contain ‘2’ elements then the total number of functions possible will be .
If set ‘A’ contain ‘5’ element and set ‘B’ contain ‘2’ elements then the total number of function possible will be .
Similarly when the two sets increases to 3 sets,
'A' = {1, 2, 3, 4, ............, n},   
'B' = {1, 2, 3, 4, ............, m} 
'C' = {1, 2, 3, 4, ............, p}  
Then the number of possible function will be  when the function is counted from Set ‘A’ to ‘B’ then to ‘C’ and thus so on for any number of sets.
Digital Electronics & Logic Design
Engineering Mathematics
GATE CS
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Change command Method for Tkinter Button in Python

The significance of Button widget is that it is used for handling events to perform certain operations in the application. In order to handle such events, we generally define a method which contains certain operations.
Let us suppose we want to change the event method after initializing the button. We can configure the Button and its handler using configure(options) method. Thus, by defining a new method and configuring the button we can trigger a new event with the same button.
#Import tkinter library
from tkinter import *

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

#Set the geometry
win.geometry("750x250")
#Define a function to show the text label
def text_label():
   Label(win, text= "Woohoo! An Event has occurred!", font= ('Helvetica 10 bold')).pack(pady=20)

   #Configure the Button to trigger a new event
   button.configure(command= close_win)
#Define a function to close the event
def close_win():
   win.destroy()
#Create a Button widget
button= Button(win, text= "Click", font= ('Helvetica 10 bold'), command= text_label)
button.pack(side= TOP)
win.mainloop()
Running the above code will display a window that contains a button.
When the Button is pressed for the first time, it will display a text label.
Now click the button for a second time and it will terminate the TCL interpreter.
Java Regex - Matcher Class

The java.util.regex.Matcher class acts as an engine that performs match operations on a character sequence by interpreting a Pattern.
Following is the declaration for java.util.regex.Matcher class −
public final class Matcher
   extends Object
      implements MatchResult

Implements a non-terminal append-and-replace step.
Implements a terminal append-and-replace step.
Returns the offset after the last character matched.
Returns the offset after the last character of the subsequence captured by the given group during the previous match operation.
Attempts to find the next subsequence of the input sequence that matches the pattern.
Resets this matcher and then attempts to find the next subsequence of the input sequence that matches the pattern, starting at the specified index.
Returns the input subsequence captured by the given group during the previous match operation.
Returns the input subsequence captured by the given named-capturing group during the previous match operation.
Returns the number of capturing groups in this matcher's pattern.
Queries the anchoring of region bounds for this matcher.
Queries the transparency of region bounds for this matcher.
Returns true if the end of input was hit by the search engine in the last match operation performed by this matcher.
Attempts to match the input sequence, starting at the beginning of the region, against the pattern.
Attempts to match the entire region against the pattern.
Returns the pattern that is interpreted by this matcher.
Returns a literal replacement String for the specified String.
Sets the limits of this matcher's region.
Reports the end index (exclusive) of this matcher's region.
Reports the start index of this matcher's region.
Replaces every subsequence of the input sequence that matches the pattern with the given replacement string.
Replaces the first subsequence of the input sequence that matches the pattern with the given replacement string.
Returns true if more input could change a positive match into a negative one.
Resets this matcher.
Resets this matcher with a new input sequence.
Returns the start index of the previous match.
Returns the start index of the subsequence captured by the given group during the previous match operation.
Returns the match state of this matcher as a MatchResult.
Returns the string representation of this matcher.
Sets the anchoring of region bounds for this matcher.
Changes the Pattern that this Matcher uses to find matches with.
Sets the transparency of region bounds for this matcher.
This class inherits methods from the following classes −
Java.lang.Object
 Print
 Add Notes
 Bookmark this page
C library function - localtime()

The C library function struct tm *localtime(const time_t *timer) uses the time pointed by timer to fill a tm structure with the values that represent the corresponding local time. The value of timer is broken up into the structure tm and expressed in the local time zone.
Following is the declaration for localtime() function.
struct tm *localtime(const time_t *timer)
timer − This is the pointer to a time_t value representing a calendar time.
timer − This is the pointer to a time_t value representing a calendar time.
This function returns a pointer to a tm structure with the time information filled in. Following is the tm structure information −
struct tm {
   int tm_sec;         /* seconds,  range 0 to 59          */
   int tm_min;         /* minutes, range 0 to 59           */
   int tm_hour;        /* hours, range 0 to 23             */
   int tm_mday;        /* day of the month, range 1 to 31  */
   int tm_mon;         /* month, range 0 to 11             */
   int tm_year;        /* The number of years since 1900   */
   int tm_wday;        /* day of the week, range 0 to 6    */
   int tm_yday;        /* day in the year, range 0 to 365  */
   int tm_isdst;       /* daylight saving time             */	
};
The following example shows the usage of localtime() function.
#include <stdio.h>
#include <time.h>
int main () {
   time_t rawtime;
   struct tm *info;
   time( &rawtime );
   info = localtime( &rawtime );
   printf("Current local time and date: %s", asctime(info));
   return(0);
}
Let us compile and run the above program that will produce the following result −
Current local time and date: Thu Aug 23 09:12:05 2012


    12 Lectures 
     2 hours 

 Nishant Malik

    12 Lectures 
     2.5 hours 

 Nishant Malik

    48 Lectures 
     6.5 hours 

 Asif Hussain

    12 Lectures 
     2 hours 

 Richa Maheshwari

    20 Lectures 
     3.5 hours 

 Vandana Annavaram

    44 Lectures 
     1 hours 

 Amit Diwan
 Print
 Add Notes
 Bookmark this page
Go - Interfaces

Go programming provides another data type called interfaces which represents a set of method signatures. The struct data type implements these interfaces to have method definitions for the method signature of the interfaces.
/* define an interface */
type interface_name interface {
   method_name1 [return_type]
   method_name2 [return_type]
   method_name3 [return_type]
   ...
   method_namen [return_type]
}

/* define a struct */
type struct_name struct {
   /* variables */
}

/* implement interface methods*/
func (struct_name_variable struct_name) method_name1() [return_type] {
   /* method implementation */
}
...
func (struct_name_variable struct_name) method_namen() [return_type] {
   /* method implementation */
}

package main

import ("fmt" "math")

/* define an interface */
type Shape interface {
   area() float64
}

/* define a circle */
type Circle struct {
   x,y,radius float64
}

/* define a rectangle */
type Rectangle struct {
   width, height float64
}

/* define a method for circle (implementation of Shape.area())*/
func(circle Circle) area() float64 {
   return math.Pi * circle.radius * circle.radius
}

/* define a method for rectangle (implementation of Shape.area())*/
func(rect Rectangle) area() float64 {
   return rect.width * rect.height
}

/* define a method for shape */
func getArea(shape Shape) float64 {
   return shape.area()
}

func main() {
   circle := Circle{x:0,y:0,radius:5}
   rectangle := Rectangle {width:10, height:5}
   
   fmt.Printf("Circle area: %f\n",getArea(circle))
   fmt.Printf("Rectangle area: %f\n",getArea(rectangle))
}
When the above code is compiled and executed, it produces the following result −
Circle area: 78.539816
Rectangle area: 50.000000


    64 Lectures 
     6.5 hours 

 Ridhi Arora

    20 Lectures 
     2.5 hours 

 Asif Hussain

    22 Lectures 
     4 hours 

 Dilip Padmanabhan

    48 Lectures 
     6 hours 

 Arnab Chakraborty

    7 Lectures 
     1 hours 

 Aditya Kulkarni

    44 Lectures 
     3 hours 

 Arnab Chakraborty
 Print
 Add Notes
 Bookmark this page
How can I use goto statement in JavaScript?

JavaScript goto statement is a reserved keyword. Generally, according to web standards it isn’t considered a good practice to use goto statement.
Using goto with JavaScript preprocessing is still considered good as shown below.
var a = 0;
[lbl] beginning:
console.log("Demo Text!");
a++;
if(i < 424) goto beginning;
The above code gets translated like the following −
var a = 0;
beginning: while(true) {
   console.log("Demo Text!");
   a++;
   if(i < 424) continue beginning;
      break;
}