code-rag-bench/online-tutorials huggingface dataset:
How to Deploy React project on Firebase?

06 Jan, 2021
When developing any project we must host it somewhere so that the whole world can see our hard-work. Hosting websites can be hectic sometimes, but you don’t need to worry as we can now host our React project on Firebase within a minute or two with a very simple setup. 
Steps to Deploy React project on Firebase:
Follow the below steps or specially needed to Setup a Firebase for your React Project.
Step 1: First we shall set up our Firebase project, go to its official website, and create a project as shown below.
Step 2: Then we will enable Firebase Hosting by going into the hosting section under Build dropdown.
Step 3: Then we will go through the hosting setup as described below.
Step 3: Then we will go through the hosting setup as described below.
Creating React Application:
Step 1: Create a React application using the following command:npx create-react-app react_hostingStep 2: Install Firebase Tools:
Step 1: Create a React application using the following command:
npx create-react-app react_hosting
Step 2: Install Firebase Tools:
npm install -g firebase-toolsProject Structure:Project Structure
npm install -g firebase-tools
Project Structure:
Project Structure
Hosting Website:
Step 1: First, we will initialize a firebase project in our React app by running the following command in the console in our root directory.firebase initNow type y as we are ready to proceed.
Step 1: First, we will initialize a firebase project in our React app by running the following command in the console in our root directory.
firebase init
Now type y as we are ready to proceed.
Step 2: Select Hosting from the options provided.
Step 3: Select the Use an existing project option.
Step 4: As the build folder of react apps is generated in the build folder by default, we will use the same as our public directory.
Step 5: Type y as we want to configure our app as a single-page app.The initialization is complete, now we just need to run a few commands and our application will be ready to go.
The initialization is complete, now we just need to run a few commands and our application will be ready to go.
Step 6: Now we will run the following command to build our react app.npm run build
npm run build
Step 7: Now we just need to run the last command and our application will be deployed.firebase deployThis will deploy our project and also provide us the hosting link which we can visit.
firebase deploy
This will deploy our project and also provide us the hosting link which we can visit.
Output:We can verify that our website was successfully deployed by visiting the hosting link provided by firebase in the console as shown below:
Firebase
react-js
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
C# | Uri.ToString() Method

30 Apr, 2019
Uri.HexEscape(Char) Method is used to get a canonical string representation for the specified Uri instance.
Syntax: public override string ToString ();
Return Value: This method returns a String instance that contains the unescaped canonical representation of the Uri instance. All characters are unescaped except #, ?, and %.
Below programs illustrate the use of Uri.ToString() Method:
Example 1:
// C# program to demonstrate the// Uri.ToString() Methodusing System;using System.Globalization;  class GFG {      // Main Method    public static void Main()    {        // Create a new Uri from a string address.        Uri uri = new Uri("HTTP://www.Contoso.com:80/thick%20and%20thin.htm");          // Converts a specified uri into        // its string equivalent.        // using ToString() method        string value = uri.ToString();          // Displaying the result        Console.WriteLine("Converted string is: {0}", value);    }}
Converted string is: http://www.contoso.com/thick and thin.htm

Example 2:
// C# program to demonstrate the// Uri.ToString() Methodusing System;using System.Globalization;  class GFG {      // Main Method    public static void Main()    {          // calling get() method        get(new Uri("http://www.contoso.com"));        get(new Uri("http://www.google.com"));    }      // defining get() method    public static void get(Uri uri)    {          // Converts a specified uri         // into its string equivalent.        // using ToString() method        string value = uri.ToString();          // Displaying the result        Console.WriteLine("Converted string is: {0}", value);    }}
Converted string is: http://www.contoso.com/
Converted string is: http://www.google.com/

Reference:
https://docs.microsoft.com/en-us/dotnet/api/system.uri.tostring?view=netstandard-2.1
CSharp-method
CSharp-Uri-Class
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
C# Dictionary with examples
C# | Delegates
Introduction to .NET Framework
C# | Multiple inheritance using interfaces
Differences Between .NET Core and .NET Framework
C# | Method Overriding
C# | Data Types
C# | String.IndexOf( ) Method | Set - 1
C# | Constructors
C# | Class and Object
Kotlin | Math.abs() method with Examples

11 Nov, 2019
The Math.abs() function returns the absolute value of a given argument. If the argument is non-negative, the argument itself is returned. whereas, if the argument is negative, it’s negation value is returned. Basically, it works as the modulus function in mathematics.
Syntax : fun abs(x : DataType) : DataType
Parameters: It can take values of Data type int, double, long, float.
Returns: It returns absolute value of the argument, without changing the data type.
Exceptions:
If the argument is NaN, the result is NaN.
If the argument is Int.MIN_VALUE, the result is that same value, Int.MIN_VALUE, which is negative.
If the argument is Long.MIN_VALUE, the result if that same value, Long.MIN_VALUE, which is negative.
Code #1: Taking float and double data types as argument.
// Kotlin program to illustrate// working of Math.abs() method import kotlin.math.abs  fun main(args : Array<String>){      val f = -45.23f;    val d = 999.32;        // abs() function taking float as input    println(abs(f));      // abs() function taking double as input    println(abs(d));}
Output:
45.23
999.32

Code #2: Taking int and long data types as argument.
// Kotlin program to illustrate// working of Math.abs() method import kotlin.math.abs  fun main(args : Array<String>){      val i = -0;    val l = -69973688;        // abs() function taking int as input    println(abs(i));    println(abs(Int.MIN_VALUE));      // abs() function taking long as input    println(abs(l));    println(abs(Long.MIN_VALUE));}
Output:
0
-2147483648

69973688
-9223372036854775808

Kotlin Mics
Kotlin
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Calculate Deciles in Excel?

30 Nov, 2021
Decile is a statistical method to split data into 10 equal parts.  Each represents 1/10 of the Population or Sample data. It is denoted D1, D2, ... D9.  Fifth deciles D5 are equal to the median.  It determines 10%,20%, ... 90%.
Here,
n: Number of data points in the population or sample (In the below eg. n = 25)
Find the position of Deciles
D1 = 1*((25+1)/10) = 1*(26/10) = 1*(2.6) = 2.6th value [data between 2 and 3 ]
D2 = 2*((25+1)/10) = 2*(26/10) = 2*(2.6) = 5.2nd value [data between 5 and 6 ]
Follow the below steps to calculate the Deciles in Excel:
Step 1: Sort the data in ascending order.
Step 2: Compute n (Number of data points); in the above example n is 25, which is placed in cell “F1”
Step 3: Write Headers for decile table as below in cells E3, F3 and G3.
Step 4: Type text D1 to D9 in cells “E4 to E12” respectively
Step 5: In cells “F4 to F12” fill decile formula for the respective deciles to find the positions
D1 =1*($F$1+1)/10
D2 =2*($F$1+1)/10
D3 =3*($F$1+1)/10
D4 =4*($F$1+1)/10
D5 =5*($F$1+1)/10
D6 =6*($F$1+1)/10
D7 =7*($F$1+1)/10
D8 =8*($F$1+1)/10
D9 =9*($F$1+1)/10
Step 6: Decile value calculation for the respective positions
For D1 2.6th Position 
    find 2nd observation – 12
    find 3rd observation – 13
    2nd observation + (3rd observation-2nd observation) * 0.6
    12 + (13-12) *0.6 = 12.6
Write below formula in cells G4 to G12 for D1 to D9
=B3+(B4-B3)*0.6
=B6+(B7-B6)*0.2
=B7+(B8-B7)*0.8
=B11+(B12-B11)*0.4
=B14+(B14-B14)*0
=B16+(B17-B16)*0.6
=B19+(B20-B19)*0.2
=B21+(B22-B21)*0.8
=B24+(B25-B24)*0.4
Output:
Excel-functions
Picked
Excel
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Delete Blank Columns in Excel?
How to Normalize Data in Excel?
How to Get Length of Array in Excel VBA?
How to Find the Last Used Row and Column in Excel VBA?
How to Use Solver in Excel?
How to make a 3 Axis Graph using Excel?
Macros in Excel
Introduction to Excel Spreadsheet
How to Show Percentages in Stacked Column Chart in Excel?
How to Create a Macro in Excel?
How to plot a multi-colored line, like a rainbow using Matplotlib?

To plot multi-colored lines, like a rainbow, we can create a list of seven rainbow colors (VIBGYOR).
Create x for data points using numpy.
Create x for data points using numpy.
Create a list of colors (rainbow VIBGYOR).
Create a list of colors (rainbow VIBGYOR).
Iterate in the range of colors list length.
Iterate in the range of colors list length.
Plot lines with x and y(x+i/20) using plot() method, with marker=o, linewidth=7 and colors[i] where i is the index.
Plot lines with x and y(x+i/20) using plot() method, with marker=o, linewidth=7 and colors[i] where i is the index.
To display the figure, use show() method.
To display the figure, use show() method.
import numpy as np
from matplotlib import pyplot as plt
plt.rcParams["figure.figsize"] = [7.00, 3.50]
plt.rcParams["figure.autolayout"] = True
x = np.linspace(-1, 1, 10)
colors = ["red", "orange", "yellow", "green", "blue", "indigo", "violet"]
for i in range(len(colors)):
   plt.plot(x, x+i/20, c=colors[i], lw=7, marker='o')
plt.show()
List push_back() function in C++ STL

In this article we will be discussing the working, syntax and examples of list:: push_back() function in C++.
List is a data structure that allows constant time insertion and deletion anywhere in sequence. Lists are implemented as doubly linked lists. Lists allow non-contiguous memory allocation. List perform better insertion extraction and moving of element in any position in container than array, vector and deque. In List the direct access to the element is slow and list is similar to forward_list, but forward list objects are single linked lists and they can only be iterated forwards.
list::push_back() is an inbuilt function in C++ STL which is declared in header file. push_back() is used to push/insert the element at the end of the list container. push_back also increases the size of the container by 1.
list_name. push_back (int ele);
This function accept one parameter only, i.e. the element we want to push/insert at the back/last of the list_name container.
This function returns nothing. It will only insert the element in the list container.
 Live Demo
#include<bits/stdc++.h>
using namespace std;
int main(){
   //create a list
   list<int> myList;
   //Displaying the initial size of a list
   cout<<"size of the list: "<<myList.size()<< endl;
   //inserting elements to the list
   myList.push_back(1);
   myList.push_back(2);
   myList.push_back(3);
   //Size of the list after inserting elements
   cout<<"Size of the list after inserting elements: "<<myList.size();
   return 0;
}

If we run the above code then it will generate the following output
Size of the list : 0
Size of the list after inserting elements: 3
How to add percentages on top of bars in Seaborn using Matplotlib?

To add percentages on top of bars in Seaborn, we can take the following steps −
Create the lists, x, y and percentages to plot using Seaborn.
Create the lists, x, y and percentages to plot using Seaborn.
Using barplot, show point estimates and confidence intervals with bars. Store the returned axis.
Using barplot, show point estimates and confidence intervals with bars. Store the returned axis.
Find patches from the returned axis (In step 2).
Find patches from the returned axis (In step 2).
Iterate the patches (returned in step 3).
Iterate the patches (returned in step 3).
Find x and y from the patches to place the percentage value at the top of the bars.
Find x and y from the patches to place the percentage value at the top of the bars.
To display the figure, use show() method.
To display the figure, use show() method.
import matplotlib.pyplot as plt
import seaborn as sns
plt.rcParams["figure.figsize"] = [7.00, 3.50]
plt.rcParams["figure.autolayout"] = True
x = ['A', 'B', 'C', 'D', 'E']
y = [1, 3, 2, 0, 4]
percentage = [10, 30, 20, 0, 40]
ax = sns.barplot(x=x, y=y, palette='PuBuGn_r')
patches = ax.patches
for i in range(len(patches)):
   x = patches[i].get_x() + patches[i].get_width()/2
   y = patches[i].get_height()+.05
   ax.annotate('{:.1f}%'.format(percentage[i]), (x, y), ha='center')
plt.show()
How to set the width of an element's border with JavaScript?

To set the width of an element’s border in JavaScript, use the borderWidth property. Set the width using this property.
You can try to run the following code to learn how to set the width of an element’s border −
<!DOCTYPE html>
<html>
   <head>
      <style>
         #box {
            border: thick solid gray;
            width: 300px;
            height: 200px
         }
      </style>
   </head>
   
   <body>
      <div id = "box">Demo Text</div>
      <br>
      <br>
      
      <button type = "button" onclick = "display()">Change border width</button>
      <script>
         function display() {
            document.getElementById("box").style.borderWidth = "thin";
         }
      </script>
      
   </body>
</html>
How to limit an HTML input box so that it only accepts numeric input?

To limit an HTML input box to accept numeric input, use the <input type="number">. With this, you will get a numeric input field.
After limiting the input box to number, if a user enters text and press submit button, then the following can be seen “Please enter a number.”
You can try to run the following code to limit an HTML input box so that it only accepts numeric input −
<!DOCTYPE html>
<html>
   <head>
      <title>HTML input number</title>
   </head>

   <body>
      <form action = "" method = "get">
         Enter any number between 1 to 20:
         <input type="number" name="num" min="1" max="20"><br>
         <input type="submit" value="Submit">
      </form>
   </body>
</html>
Apache POI Word - Document

Here the term 'document' refers to a MS-Word file. After completion of this chapter, you will be able to create new documents and open existing documents using your Java program.
The following simple program is used to create a blank MS-Word document −
import java.io.File;
import java.io.FileOutputStream;
import org.apache.poi.xwpf.usermodel.XWPFDocument;

public class CreateDocument {
   public static void main(String[] args)throws Exception  {
      //Blank Document
      XWPFDocument document = new XWPFDocument(); 
		
      //Write the Document in file system
      FileOutputStream out = new FileOutputStream( new File("createdocument.docx"));
      document.write(out);
      out.close();
      System.out.println("createdocument.docx written successully");
   }
}
Save the above Java code as CreateDocument.java, and then compile and execute it from the command prompt as follows −
$javac  CreateDocument.java
$java CreateDocument

If your system environment is configured with the POI library, it will compile and execute to generate a blank Word document file named createdocument.docx in your current directory and display the following output in the command prompt −
createdocument.docx written successfully


    46 Lectures 
     3.5 hours 

 Arnab Chakraborty

    23 Lectures 
     1.5 hours 

 Mukund Kumar Mishra

    16 Lectures 
     1 hours 

 Nilay Mehta

    52 Lectures 
     1.5 hours 

 Bigdata Engineer

    14 Lectures 
     1 hours 

 Bigdata Engineer

    23 Lectures 
     1 hours 

 Bigdata Engineer
 Print
 Add Notes
 Bookmark this page
GATE | GATE-CS-2016 (Set 1) | Question 51 - GeeksforGeeks

28 Jun, 2021
Let Q denote a queue containing sixteen numbers and S be an empty stack. Head(Q) returns the element at the head of the queue Q without removing it from Q. Similarly Top(S) returns the element at the top of S without removing it from S. Consider the algorithm given below.
The maximum possible number of iterations of the while loop in the algorithm is______
[This Question was originally a Fill-in-the-Blanks question](A) 16(B) 32(C) 256(D) 64Answer: (C)Explanation: The worst case happens when the queue is sorted in decreasing order. In worst case, loop runs n*n times.
Queue: 4 3 2 1
Stack: Empty

3 2 1
4

3 2 1 4
Empty

2 1 4
3

2 1 4 3
Empty

1 4 3
2

1 4 3 2
Empty

4 3 2
1

3 2
1 4

3 2 4
1

2 4
1 3

2 4 3
1

4 3
1 2

3 
1 2 4

3 4 
1 2

4
1 2 3

Empty
1 2 3 4
Quiz of this QuestionPlease comment below if you find anything wrong in the above post
GATE-CS-2016 (Set 1)
GATE-GATE-CS-2016 (Set 1)
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-2001 | Question 39
GATE | GATE-CS-2000 | Question 41
GATE | GATE-CS-2005 | Question 6
GATE | GATE MOCK 2017 | Question 21
GATE | GATE MOCK 2017 | Question 24
GATE | GATE-CS-2006 | Question 47
GATE | Gate IT 2008 | Question 43
GATE | GATE-CS-2009 | Question 38
GATE | GATE-CS-2003 | Question 90
GATE | GATE-CS-2003 | Question 64 - GeeksforGeeks

28 Jun, 2021
Let S be a stack of size n ≥ 1. Starting with the empty stack, suppose we push the first n natural numbers in sequence, and then perform n pop operations. Assume that Push and pop operation take X seconds each, and Y seconds elapse between the end of one such stack operation and the start of the next operation. For m ≥ 1, define the stack-life of m as the time elapsed from the end of Push(m) to the start of the pop operation that removes m from S. The average stack-life of an element of this stack is(A) n (X + Y)(B) 3Y + 2X(C) n (X + Y) – X(D) Y + 2XAnswer: (C)Explanation: Background required – Stack and Basic Maths
Let Tn be time span of nth element of stack. Let us first find out the sum of Tn for n = 1 to n
Stack Lifetime of last element, Tn = Y (Since it is popped as soon 
                                        as it is pushed on the stack)

Stack Lifetime of last element, Tn-1 = Tn  + 2X + 2Y 
                                       (The time needed to push and then
                                        pop nth element plus two pauses Y each).
                        = 2X + 3Y 

Stack Lifetime of last element, Tn-2 = Tn-1  + 2X + 2Y (Using the Same reasoning above)
                        = 4X + 5Y
.
.
.
Stack Lifetime of 1st element = 2(n-1)X + (2n-1)Y    (Generalizing the pattern)

Sum of all the time spans of all the elements = (Σ 2(n-1)X) + (Σ (2n-1)Y) 
                                                                   for n = 1 to n

= 2X(1 + 2 + . . . + n-1) + Y(1 + 3 + 5 + . . . + (2n-1))


Using 2 identities
Sum of n natural numbers = (n*(n+1))/2 for the first summation
Sn = (n/2)(a+l) Sum of AP series with a as first term and l being last for second summation
Above sum is,
= (2X(n-1)n)/2 + Y(n/2)*(1 + 2n-1)
= n(n(X+Y)-X)
Therefore Average = Sum/n = n(X+Y)-X . Hence Option (c)
This explanation has been contributed by Pranjul Ahuja.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-2001 | Question 39
GATE | GATE-CS-2000 | Question 41
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
Convert date string to timestamp in Python - GeeksforGeeks

29 Dec, 2020
The Most Common way we use to store dates and times into a Database is in the form of a timestamp. When we receive a date and time in form of a string before storing it into a database, we convert that date and time string into a timestamp. Python provides various ways of converting the date to timestamp. Few of them discussed in this article are:
Using timetuple()
Using timestamp()
Approach:
import datetime is use to import the date and time modules
After importing date time module next step is to accept date string as an input and then store it into a variable
Then we use strptime method. This method takes two arguments:First argument is the string format of the date and timeSecond argument is the format of the input string
First argument is the string format of the date and time
Second argument is the format of the input string
We convert date and time string into a date object
Then we use timetuple() to convert date object into tuple
At the end we use mktime(tuple) to convert the Date tuple into a timestamp.
Example 1:
# Python program to convert # date to timestamp    import timeimport datetime    string = "20/01/2020"print(time.mktime(datetime.datetime.strptime(string,                                             "%d/%m/%Y").timetuple()))
Output:
1579458600.0

Example 2:
# Python program to convert # date to timestamp      import timeimport datetime    string = "20/01/2020"  element = datetime.datetime.strptime(string,"%d/%m/%Y")  tuple = element.timetuple()timestamp = time.mktime(tuple)  print(timestamp)
Output:
1579458600.0

Approach:
import datetime is use to import the date and time modules
After importing date time module next step is to accept date string as an input and then store it into a variable
Then we use strptime method. This method takes two argumentsFirst arguments s the string format of the date and timeSecond argument is the format of the input string
First arguments s the string format of the date and time
Second argument is the format of the input string
Then it returns date and time value in timestamp format and we stored this in timestamp variable.
Example 1:
# Python program to convert # date to timestamp    import timeimport datetime    string = "20/01/2020"    element = datetime.datetime.strptime(string,"%d/%m/%Y")  timestamp = datetime.datetime.timestamp(element)print(timestamp)
Output:
1579458600.0

Python datetime-program
Python-datetime
Technical Scripter 2019
Python
Technical Scripter
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
*args and **kwargs in Python
Create a Pandas DataFrame from Lists
Convert integer to string in Python
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
sum() function in Python
Python-Quizzes | Python List Quiz | Question 2 - GeeksforGeeks

17 Sep, 2020
Question 2: Find the output of the following program:
nameList = ['Harsh', 'Pratik', 'Bob', 'Dhruv']   print nameList[1][-1] 
(A) r(B) b(C) D(D) kAnswer: (D)Explanation: The index position -1 represents either the last element in a list or the last character in a String. In the above given list of names “nameList”, the index 1 represents the second element i.e, the second string “Pratik” and the index -1 represents the last character in the string “Pratik”. So, the output is “k”.Quiz of this Question
Python-Quizzes
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python-Quizzes | Python List Quiz | Question 4
Python-Quizzes | Python Dictionary Quiz | Question 25
Python-Quizzes | Python List Quiz | Question 5
Python-Quizzes | Python Dictionary Quiz | Question 23
Python | Miscellaneous | Question 1
Python-Quizzes | Miscellaneous | Question 7
Python | Animated Banner showing 'GeeksForGeeks'
Python-Quizzes | Miscellaneous | Question 9
Why do people prefer Selenium with Python?
Output of Python Program - Dictionary (set 25)
PyQt5 QCalendarWidget - Selection Changed signal - GeeksforGeeks

08 Jul, 2021
In this article, we will see how we can get the selection changed signal from the QCalendarWidget. Selection changed signal is emitted when the currently selected date is changed. The currently selected date can be changed by the user using the mouse or keyboard. 
In order to do this we will use selectionChanged method with the QCalendarWidget object.Syntax : calendar.selectionChanged.connect(lambda: print(“Selection Changed”))Argument : It takes method as argumentAction Performed : It will print the message whenever activated signal get emitted  
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, 600, 400)         # calling method        self.UiComponents()         # showing all the widgets        self.show()     # method for components    def UiComponents(self):         # creating a QCalendarWidget object        calendar = QCalendarWidget(self)         # setting geometry to the calendar        calendar.setGeometry(10, 10, 400, 250)         # creating a label        label = QLabel(self)         # setting geometry to the label        label.setGeometry(100, 280, 250, 60)         # making label multi line        label.setWordWrap(True)         # text        text = "Selection Changed signal (No.) : "         # current count        self.count = 0         # getting the selection change signal and        # when receives the signal printing the message        calendar.selectionChanged.connect(lambda: label.setText(text + str(get_count())))         # method to increase the count value        def get_count():            self.count += 1            return self.count  # create pyqt5 appApp = QApplication(sys.argv) # create the instance of our Windowwindow = Window() # start the appsys.exit(App.exec())
Output :  
 
clintra
Python PyQt-QCalendarWidget
Python-gui
Python-PyQt
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python Classes and Objects
How to drop one or multiple columns in Pandas Dataframe
Defaultdict in Python
Python | Get unique values from a list
Python | os.path.join() method
Create a directory in Python
Python | Pandas dataframe.groupby()
How to read excel file in R ? - GeeksforGeeks

26 Mar, 2021
In this article, we will be discussing two different techniques to read or import an excel file in R.
Approach
Import module
Pass path of the file to required function
Read file
Display content
read_excel() function is basically used to import/read an excel file and it can only be accessed after importing of the readxl library in R language..
Syntax:
read_excel(path)
Example:
R
library(readxl)  Data_gfg <- read_excel("Data_gfg.xlsx")  Data_gfg
Output:
read.xlsx() function is imported from the xlsx library of R language and used to read/import an excel file in R language.
Syntax:
read.xlsx(path)
Example:
R
install.packages("xlsx")  Data_gfg <-read.xlsx('Data_gfg.xlsx')  Data_gfg
Output:
Picked
R-Excel
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Change Color of Bars in Barchart using ggplot2 in R
Group by function in R using Dplyr
How to Change Axis Scales in R Plots?
How to Split Column Into Multiple Columns in R DataFrame?
Replace Specific Characters in String in R
How to filter R DataFrame by values in a column?
How to import an Excel File into R ?
Time Series Analysis in R
R - if statement
How to filter R dataframe by multiple conditions?
GATE | GATE-CS-2000 | Question 38 - GeeksforGeeks

10 Jul, 2018
Suppose you are given an array s[1..n] and a procedure reverse (s, i, j) which reverses the order of elements in a between positions i and j (both inclusive). What does the following sequence do, where 1 <= k <= n:
reverse(s, 1, k) ;
reverse(s, k + 1, n);
reverse(s, l, n); 
(A) Rotates s left by k positions(B) Leaves s unchanged
(C) Reverses all elements of s(D) None of the aboveAnswer: (A)Explanation: Effect of the above 3 reversals for any k is equivalent to left rotation of the array of size n by k. Please see this post for details.If we rotate an array n times for k = 1 to n, we get the same array back.Quiz of this Question
GATE-CS-2000
GATE-GATE-CS-2000
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-2001 | Question 39
GATE | GATE-CS-2000 | Question 41
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
PLSQL | CHR Function - GeeksforGeeks

19 Sep, 2019
The string in PL/SQL is actually a sequence of characters with an optional size specification.The characters could be numeric, letters, blank, special characters or a combination of all.The CHR Function in PLSQL is the opposite of the ASCII function and is used to return the character based on the NUMBER code.
Syntax:
CHR( number_code )
Parameters Used:
number_code – It is used to retrieve the character for the specified number code.
Supported Versions of Oracle/PLSQL:
Oracle 12cOracle 11gOracle 10gOracle 9iOracle 8i
Oracle 12c
Oracle 11g
Oracle 10g
Oracle 9i
Oracle 8i
Example:
DECLARE 
   Test_Char varchar2(4) := '69';
   Test_Char1 varchar2(4) := '72';
   
   BEGIN 
   dbms_output.put_line(CHR(Test_Char)); 
   dbms_output.put_line(CHR(Test_Char1)); 
    
END; 
Output:
E
H
SQL-PL/SQL
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
SQL Interview Questions
CTE in SQL
SQL Trigger | Student Database
How to Update Multiple Columns in Single Update Statement in SQL?
SQL | Views
Difference between DDL and DML in DBMS
Difference between DELETE, DROP and TRUNCATE
MySQL | Group_CONCAT() Function
Difference between DELETE and TRUNCATE
SQL | Subquery
JQuery | parseJSON() method - GeeksforGeeks

27 Apr, 2020
This parseJSON() Method in jQuery takes a well-formed JSON string and returns the resulting JavaScript value.
Syntax:
jQuery.parseJSON( json )

Parameters: The parseXML() method accepts only one parameter that is mentioned above and described below:
json: This parameter is the well-formed JSON string to be parsed.
String
Number
Object
Array
Boolean
Example 1:
<!DOCTYPE html><html><head><meta charset="utf-8"><title>JQuery | parseJSON() method</title> <script src="https://code.jquery.com/jquery-3.4.1.js"></script><style>    #a {        color: blue;    }    #b {        color: red;    }</style></head><body style="text-align:center;">           <h1 style="color: green">         GeeksForGeeks     </h1>           <h3>JQuery | parseJSON() method</h3>    <b id="a"></b>          <script>    var txt = '{"name":"John", "age":30, "city":"New York"}'    var obj = jQuery.parseJSON(txt);    document.getElementById("a").innerHTML = "Object Name : "+obj.name + "<br> Object Age : " + obj.age;    </script></body></html>                                                                
Output:
Example 2: .
<!DOCTYPE html><html><head><meta charset="utf-8"><title>JQuery | parseJSON() method</title> <script src="https://code.jquery.com/jquery-3.4.1.js"></script>  </head><body style="text-align:center;">           <h1 style="color: green">         GeeksForGeeks     </h1>           <h3>JQuery | parseJSON() method</h3>    <button onclick="gfg()">Click</button>          <script>        function gfg(){            var txt = '{"name":"Shubham Singh", "age":21, "Cars":"ABC" }'            var obj = jQuery.parseJSON(txt);            alert( obj.name === "ABC" );        }        </script></body></html>                    
Output:Before Click:After Click:
jQuery-Methods
JQuery
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
JQuery | Set the value of an input text field
Form validation using jQuery
How to change selected value of a drop-down list using jQuery?
How to change the background color after clicking the button in JavaScript ?
How to fetch data from JSON file and display in HTML table using jQuery ?
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
plotly.express.scatter_ternary() function in Python

17 Jul, 2020
Plotly library of Python can be very useful for data visualization and understanding the data simply and easily. Plotly graph objects are a high-level interface to plotly which are easy to use.
This method is used to create a ternary plot. A ternary plot is used to depics the ratio of three variables on an equilateral triangle.
Syntax: plotly.express.scatter_ternary(data_frame=None, a=None, b=None, c=None, color=None, symbol=None, size=None, text=None, hover_name=None, hover_data=None, size_max=None, title=None, template=None, width=None, height=None)
Parameters:
data_frame: DataFrame or array-like or dict needs to be passed for column names.
a, b, c:  These parameters are either a name of a column in data_frame, or a pandas Series or array_like object. These are used to position marks along the a, b, and c axis in ternary coordinates respectively.
color: This parameters assign color to marks.
symbol: This parameter is used to assign symbols to marks. It is either a name of a column in data_frame, or a pandas Series or array_like object.
size: This parameter is used to assign mark sizes. It is either a name of a column in data_frame, or a pandas Series or array_like object.
hover_name:  Values from this column or array_like appear in bold in the hover tooltip.
hover_data: This parameter is used to appear in the hover tooltip or tuples with a bool or formatting string as first element, and list-like data to appear in hover as second element Values from these columns appear as extra data in the hover tooltip.
title: The title of the figure.
width: Set the width of the figure.
height: Set the height of the figure.
Example 1:
Python3
import plotly.express as px  df = px.data.iris()  plot = px.scatter_ternary(df, a = 'sepal_width',                          b = 'sepal_length',                           c = 'petal_width')plot.show()
Output:
Example 2: Using the size and color arguments
Python3
import plotly.express as px  df = px.data.iris()  plot = px.scatter_ternary(df, a = 'sepal_width',                           b = 'sepal_length',                          c='petal_width',                          color = 'species',                          size = 'petal_length')plot.show()
Output:
Example 3: Using the symbol parameter
Python3
import plotly.express as px  df = px.data.iris()  plot = px.scatter_ternary(df, a = 'sepal_width',                          b = 'sepal_length',                           c = 'petal_width',                           color = 'species',                          size = 'petal_length',                          symbol = 'species_id')plot.show()
Output:
Python Plotly express-class
Python-Plotly
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Secant method to solve non-linear equation


Secant method is also used to solve non-linear equations. This method is similar to the Newton-Raphson method, but here we do not need to find the differentiation of the function f(x). Only using f(x), we can find f’(x) numerically by using Newton’s Divide difference formula. From the Newton-Raphson formula,
we know that,
Now, using divide difference formula, we get,
By replacing the f’(x) of Newton-Raphson formula by the new f’(x), we can find the secant formula to solve non-linear equations.
Note: For this method, we need any two initial guess to start finding the root of non-linear equations.
Input:
The function f(x) = (x*x) - (4*x) - 10
Output:
The root is: -1.74166
secant(x1, x2)
Input: Two initial guess for root.
Output: The approximate root of a non-linear equation f(x).
Begin
   f1 := f(x1)
   f2 := f(x2)
   x3 := ((f2*x1) – (f1*x2)) / (f2 – f1)
   while relative error of x3 and x2 are > precision, do
      x1 := x2
      f1 := f2
      x2 := x3
      f2 := f(x2)
      x3 := ((f2*x1) – (f1*x2)) / (f2 – f1)
   done
   root := x3
   return root
End
#include<iostream>
#include<cmath>
using namespace std;

double absolute(double value) {             //to find magnitude of value
   if(value < 0)
      return (-value);
   return value;
}

double f(double x) {              //the given function x^2-4x-10
   return ((x*x)-(4*x)-10);
}

double secant(double x1, double x2) {
   double x3, root;
   double f1, f2;
   f1 = f(x1);
   f2 = f(x2);
   x3 = (f2*x1-f1*x2)/(f2-f1);

   while(absolute((x3-x2)/x3) > 0.00001) {         //test accuracy of x3
      x1 = x2;           //shift x values
      f1 = f2;
      x2 = x3;
      f2 = f(x2);                 //find new x2
      x3 = (f2*x1-f1*x2)/(f2-f1);          //calculate x3
   }

   root = x3;
   return root;              //root of the equation
}

main() {
   double a, b, res;
   a = 0.5;
   b = 0.75;
   res = secant(a, b);
   cout << "The root is: " << res;
}
The root is: -1.74166
Python program to display Astrological sign or Zodiac sign for a given data of birth.

Given date of birth, our task is to display astrological sign or Zodiac sign.
Input : Day = 13, Month = November
Output : Scorpio.
Step 1 : input date of birth.
Step 2 : checks month and date within the valid range of a specified zodiac.
Step 3 : display zodiac sign.
def zodiac_sign(day, month):
   # checks month and date within the valid range
   # of a specified zodiac
   if month == 'december':
      astro_sign = 'Sagittarius' if (day < 22) else 'capricorn'
   elif month == 'january':
      astro_sign = 'Capricorn' if (day < 20) else 'aquarius'
   elif month == 'february':
      astro_sign = 'Aquarius' if (day < 19) else 'pisces'
   elif month == 'march':
      astro_sign = 'Pisces' if (day < 21) else 'aries'
   elif month == 'april':
      astro_sign = 'Aries' if (day < 20) else 'taurus'
   elif month == 'may':
      astro_sign = 'Taurus' if (day < 21) else 'gemini'
   elif month == 'june':
      astro_sign = 'Gemini' if (day < 21) else 'cancer'
   elif month == 'july':
      astro_sign = 'Cancer' if (day < 23) else 'leo'
   elif month == 'august':
      astro_sign = 'Leo' if (day < 23) else 'virgo'
   elif month == 'september':
      astro_sign = 'Virgo' if (day < 23) else 'libra'
   elif month == 'october':
      astro_sign = 'Libra' if (day < 23) else 'scorpio'
   elif month == 'november':
      astro_sign = 'scorpio' if (day < 22) else 'sagittarius'
   print(astro_sign)

# Driver code
if __name__ == '__main__':
d = int(input("Enter Day ::>"))
m = input("Enter the Month ::>")
zodiac_sign(d, m)
Enter Day ::>13
Enter the Month ::>november
scorpio
All Pair Testing

All-pairs also known as pairwise testing is a testing approach taken for testing the software using combinatorial method. It's a method to test all the possible discrete combinations of the parameters involved.
Assume we have a piece of software to be tested which has got 10 input fields and 10 possible settings for each input field. Then, there are 10^10 possible inputs to be tested. In this case, exhaustive testing is impossible even if we wish to test all combinations.
Let us also understand the concept of All-pairs testing by taking an example.
An application with simple list box with 10 elements (Let's say 0,1,2,3,4,5,6,7,8,9) along with a checkbox, radio button, Text Box and OK Button. The Constraint for the Text box is it can accept values only between 1 and 100. Below are the values that each one of the GUI objects can take:
List Box  - 0,1,2,3,4,5,6,7,8,9
Check Box - Checked or Unchecked
Radio Button - ON or OFF
Text Box - Any Value between 1 and 100
Exhaustive combination of the application is calculated.
List Box = 10
Check Box = 2
Radio Button = 2
Text Box = 100

Total Number of Test Cases using Cartesian Method : 10*2*2*100 = 4000
Total Number of Test Cases including Negative Cases will be > 4000
Now, the idea is to bring down the number of test cases. We will first try to find out the number of cases using the conventional software testing technique. We can consider the list box values as 0 and others as 0 is neither positive nor negative. Radio button and check box values cannot be reduced. So each one of them will have 2 combinations (ON or OFF). The Text box values can be reduced into three inputs (Valid Integer, Invalid Integer, Alpha-Special Character).
Now, we will calculate the number of cases using software testing technique is 2*2*2*3 = 24 (including negative cases).
Now, we can still reduce the combination further into All-pairs technique.
Step 1 : Order the values such that one with most number of values is the first and the least is placed as the last variable.

Step 2 : Now, start filling the table column by column. List box can take 2 values.
Step 3 : The next column under discussion would be check box. Again, Check box can take 2 values.
Step 4 : Now, we need to ensure that we cover all combinations between list box and Check box.
Step 5 : Now, we will use the same strategy for checking the Radio Button. It can take 2 values.
Step 6 : Verify if all the pair values are covered as shown in the table below.
Exhaustive Combination results in > 4000 Test Cases.
Conventional Software Testing technique results in 24 Test Cases.
Pair Wise Software Testing technique results in just 6 Test Cases.
How to Convert all LinkedHashMap Values to a List in Java?

17 Dec, 2020
The task is to convert all LinkedHashMap values to a list in java. LinkedHashMap is an implementation of a Map. The Map and List are two different data structures. The Map stores key-value pairs while the List is an ordered collection of elements.
To convert all values of the LinkedHashMap to a List using the values() method. The values() method of the LinkedHashMap class returns a Collection view of all the values contained in the map object. You can then use this collection to convert it to a List object.
Syntax:
LinkedHashMap.values()
Return Value: The method is used to return a collection view containing all the values of the map.
Example 1:
Java
// Java program to Convert all LinkedHashMap values to a// List  import java.util.ArrayList;import java.util.LinkedHashMap;import java.util.List;  public class LinkedHashMapToListExample {      public static void main(String[] args)    {          // instance of linkedhashmap        LinkedHashMap<Integer, Integer> lhmap            = new LinkedHashMap<Integer, Integer>();          // add mappings        lhmap.put(1, 11);        lhmap.put(2, 22);        lhmap.put(3, 33);          // convert values to a list        List<Integer> listValues            = new ArrayList<Integer>(lhmap.values());          // print values        System.out.println("List contains:");        for (Integer value : listValues) {            System.out.println(value);        }    }}
List contains:
11
22
33
Example 2:
Java
// Java program to Convert all LinkedHashMap values to a// List  import java.util.ArrayList;import java.util.LinkedHashMap;import java.util.List;  public class LinkedHashMapToListExample {      public static void main(String[] args)    {          // instance of linkedhashmap        LinkedHashMap<Integer, String> lhmap            = new LinkedHashMap<Integer, String>();          // add mappings        lhmap.put(10, "Geeks");        lhmap.put(15, "4");        lhmap.put(20, "Geeks");        lhmap.put(25, "Welcomes");        lhmap.put(30, "You");          // convert values to a list        List<String> listValues            = new ArrayList<String>(lhmap.values());          // print values        System.out.println("List contains:");        for (String value : listValues) {            System.out.println(value);        }    }}
List contains:
Geeks
4
Geeks
Welcomes
You
Java-LinkedHashMap
java-list
Picked
Technical Scripter 2020
Java
Java Programs
Technical Scripter
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Object Oriented Programming (OOPs) Concept in Java
Interfaces in Java
Stream In Java
ArrayList in Java
Collections in Java
Initializing a List in Java
Java Programming Examples
Convert a String to Character Array in Java
Convert Double to Integer in Java
Implementing a Linked List in Java using Class
The String in Switch Case in Java

The introduction of Java 7 enhanced the switch case i.e. it support string as well.
At first, set a string −
String department = "AKD05";
Now, use the same string in switch as shown below −
switch(department)
Now, check for every string using case as we normally do while using SWITCH CASE. Following is an example to implement String in Switch Case −
public class Demo {
   public static void main(String[] args) {
      String department = "AKD05";
      switch(department) {
         case "AKD01":
            System.out.println("Finance");
            break;
         case "AKD02":
            System.out.println("Sales");
            break;
         case "AKD03":
            System.out.println("Production");
            break;
         case "AKD04":
            System.out.println("Marketing");
            break;
         case "AKD05":
            System.out.println("Operations");
            break;
         default:
            System.out.println("None!");
      }
   }
}
Operations
Ruby | Time rfc2822 function

07 Jan, 2020
Time#rfc2822() : rfc2822() is a Time class method which returns the string which represents the time as date-time defined by RFC 2822Format:
day-of-week, DD month-name CCYY hh:mm:ss zone
Syntax: Time.rfc2822()
Parameter: Time values
Return: the string which represents the time as date-time defined by RFC 2822
Example #1 :
# Ruby code for Time.rfc2822() method  # loading libraryrequire 'time'  # declaring time a = Time.new(2019)  # declaring timeb = Time.new(2019, 10)  # declaring timec = Time.new(2019, 12, 31)  # Time puts "Time a : #{a}\n\n"puts "Time b : #{b}\n\n"puts "Time c : #{c}\n\n\n\n"    # rfc2822 form puts "Time a rfc2822 form : #{a.rfc2822}\n\n"puts "Time b rfc2822 form : #{b.rfc2822}\n\n"puts "Time c rfc2822 form : #{c.rfc2822}\n\n"
Output :
Time a : 2019-01-01 00:00:00 +0100

Time b : 2019-10-01 00:00:00 +0200

Time c : 2019-12-31 00:00:00 +0100



Time a rfc2822 form : 3600

Time b rfc2822 form : 7200

Time c rfc2822 form : 3600


Example #2 :
# Ruby code for Time.rfc2822() method  # loading libraryrequire 'time'  # declaring time a = Time.now  # declaring timeb = Time.new(1000, 10, 10)  # declaring timec = Time.new(2020, 12)  # Time puts "Time a : #{a}\n\n"puts "Time b : #{b}\n\n"puts "Time c : #{c}\n\n\n\n"    # rfc2822 form puts "Time a rfc2822 form : #{a.rfc2822}\n\n"puts "Time b rfc2822 form : #{b.rfc2822}\n\n"puts "Time c rfc2822 form : #{c.rfc2822}\n\n"
Output :
Time a : 2019-08-27 04:05:51 +0200

Time b : 1000-10-10 00:00:00 +0053

Time c : 2020-12-01 00:00:00 +0100



Time a rfc2822 form : Tue, 27 Aug 2019 04:05:51 +0200

Time b rfc2822 form : Fri, 10 Oct 1000 00:00:00 +0053

Time c rfc2822 form : Tue, 01 Dec 2020 00:00:00 +0100


Ruby Time-class
Ruby-Methods
Ruby
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Make a Custom Array of Hashes in Ruby?
Ruby | Enumerator each_with_index function
Ruby | unless Statement and unless Modifier
Ruby on Rails Introduction
Ruby | String concat Method
Ruby | Array class find_index() operation
Ruby For Beginners
Ruby | Array shift() function
Ruby | Types of Variables