code-rag-bench/online-tutorials huggingface dataset:
Insert JSON into a MySQL table?

Let us create a table and set a column value with type JSON
mysql> create table DemoTable1832
     (
     ListOfNames JSON
     );
Query OK, 0 rows affected (0.00 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1832(ListOfNames) values('["Sam", "Mike", "Carol"]');
Query OK, 1 row affected (0.00 sec)
mysql> insert into DemoTable1832(ListOfNames) values('["David", "Bob"]');
Query OK, 1 row affected (0.00 sec)
mysql> insert into DemoTable1832(ListOfNames) values('["Adam", "John","Sam"]');
Query OK, 1 row affected (0.00 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1832;
This will produce the following output −
+--------------------------+
| ListOfNames              |
+--------------------------+
| ["Sam", "Mike", "Carol"] |
| ["David", "Bob"]         |
| ["Adam", "John", "Sam"]  |
+--------------------------+
3 rows in set (0.00 sec)
delete_cookie driver method - Selenium Python - GeeksforGeeks

23 Sep, 2021
Selenium’s Python Module is built to perform automated testing with Python. Selenium Python bindings provides a simple API to write functional/acceptance tests using Selenium WebDriver. To open a webpage using Selenium Python, checkout – Navigating links using get method – Selenium Python. Just being able to go to places isn’t terribly useful. What we’d really like to do is to interact with the pages, or, more specifically, the HTML elements within a page. There are multiple strategies to find an element using Selenium, checkout – Locating Strategies. Selenium WebDriver offers various useful methods to control the session, or in other words, browser. For example, adding a cookie, pressing back button, navigating among tabs, etc. This article revolves around delete_cookie driver method in Selenium. delete_cookie method is used to delete a cookie with a specified value. Syntax –  
driver.delete_cookie(name)
Example – Now one can use delete_cookie method as a driver method as below –  
diver.get("https://www.geeksforgeeks.org/")
driver.delete_cookie("foo")
 
To demonstrate, delete_cookie method of WebDriver in Selenium Python. Let’ s visit https://www.geeksforgeeks.org/ and operate on driver object. Let’s first add a cookie and then delete itProgram –  
Python3
# import webdriverfrom selenium import webdriver # create webdriver objectdriver = webdriver.Firefox() # get geeksforgeeks.orgdriver.get("https://www.geeksforgeeks.org/") # add_cookie method driverdriver.add_cookie({"name" : "foo", "value" : "bar"}) # delete browser cookiedriver.delete_cookie("foo")
Output – Screenshot after cookie added –  
Screenshot after cookie deleted –  
 
anikakapoor
Python-selenium
selenium
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Check if element exists in list in Python
Python | os.path.join() method
Selecting rows in pandas DataFrame based on conditions
Defaultdict in Python
Python | Get unique values from a list
Create a directory in Python
Python | Pandas dataframe.groupby()
C++ Queue Library - pop() Function

The C++ function std::queue::pop() removes front element of the queue and reduces size of the queue by one.
This member function effectively calls the pop_front member function of the underlying container.
Following is the declaration for std::queue::pop() function form std::queue header.
void pop();

None
None
Constant i.e. O(1)
The following example shows the usage of std::queue::pop() function.
#include <iostream>
#include <queue>

using namespace std;

int main(void) {
   queue<int> q;

   for (int i = 0; i < 5; ++i)
      q.emplace(i + 1);

   cout << "Contents of queue" << endl;
   while (!q.empty()) {
      cout << q.front() << endl;
      q.pop();
   }

   return 0;
}
Let us compile and run the above program, this will produce the following result −
Contents of queue
1
2
3
4
5

 Print
 Add Notes
 Bookmark this page
reflect.Copy() Function in Golang with Examples - GeeksforGeeks

28 Apr, 2020
Go language provides inbuilt support implementation of run-time reflection and allowing a program to manipulate objects with arbitrary types with the help of reflect package. The reflect.Copy() Function in Golang is used to copies the contents of the source into destination until either destination has been filled or source has been exhausted. To access this function, one needs to imports the reflect package in the program.
Syntax:
func Copy(dst, src Value) int

Parameters: This function takes two parameters of Slice or Array type. And dst and src must have the same element type.
Return Value: This function returns the number of elements copied.
Below examples illustrate the use of above method in Golang:
Example 1:
// Golang program to illustrate// reflect.Copy() Function   package main  import (    "fmt"    "reflect")  // Main function func main() {      // Source     src := reflect.ValueOf([]int{10, 20, 32})          /* make sure the dest space is larger than src */    // destination     dest := reflect.ValueOf([]int{1, 2, 3})          // To copy Copy() function is used    // and it returns the number of     // elements copied    cnt := reflect.Copy(dest, src)    data := dest.Interface().([]int)    data[0] = 100          // printing the values    fmt.Println("Number of element Copied :", cnt)    fmt.Println("Source :", src)    fmt.Println("destination :", dest)}
Output:
Number of element Copied : 3
Source : [10 20 32]
destination : [100 20 32]

Example 2:
// Golang program to illustrate// reflect.Copy() Function   package main  import (    "fmt"    "reflect")  // Struct with two int valuetype temp struct {    A0 []int    A1 []int}  // Main function func main() {          var val temp          // Source     val.A0 = append(val.A0, []int{1, 2, 3,                    4, 5, 6, 7, 8, 9}...)          // destination     val.A1 = append(val.A1, 9, 8, 7, 6)          // To copy Copy() function is used    // and it returns the number of     // elements copied    var n = reflect.Copy(reflect.ValueOf(val.A0),                         reflect.ValueOf(val.A1))          // printing the values    fmt.Println("Number of element Copied :", n)    fmt.Println("{Source, destination} :", val)      }
Output:
Number of element Copied : 4
{Source, destination} : {[9 8 7 6 5 6 7 8 9] [9 8 7 6]}

Golang-reflect
Go Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
fmt.Sprintf() Function in Golang With Examples
How to compare times in Golang?
strings.Replace() Function in Golang With Examples
Inheritance in GoLang
Time Formatting in Golang
Slices in Golang
strings.Join() Function in Golang With Examples
Rune in Golang
Interfaces in Golang
fmt.print() Function in Golang With Examples
Why are parenthesis used to wrap a JavaScript function call?

In JavaScript, the functions wrapped with parenthesis are called “Immediately Invoked Function Expressions" or "Self Executing Functions.
The purpose of wrapping is to namespace and control the visibility of member functions. It wraps code inside a function scope and decrease clashing with other libraries. This is what we call Immediately Invoked Function Expression (IIFE) or Self Executing Anonymous Function.
Here’s the syntax −
(function() {
   // code
})();
As you can see above, the following pair of parentheses converts the code inside the parentheses into an expression −
function(){...}
In addition, the next pair, i.e. the second pair of parentheses continues the operation. It calls the function, which resulted from the expression above.
sp_help for MySQL to display field types and foreign key constraints?

In MySQL, you can achieve sp_help with the help of SHOW CREATE command.
CASE 1 −
For table, the syntax is as follows −
SHOW CREATE TABLE yourTableName;
CASE 2 −
For stored procedure, the syntax is as follows −
SHOW CREATE PROCEDURE yourProcedureName;
Let us first create a table −
mysql> create table DemoTable
(
   EmployeeId int NOT NULL AUTO_INCREMENT,
   EmployeeFirstName varchar(40) NOT NULL,
   EmployeeLastName varchar(40) NOT NULL,
   EmployeeAge int,
   EmployeeCountryName varchar(40),
   EmployeeCityName varchar(40),
   PRIMARY KEY(EmployeeId),
   UNIQUE KEY(EmployeeFirstName,EmployeeCityName)
);
Query OK, 0 rows affected (0.97 sec)
Let us implement the above syntax for our table −
mysql> SHOW CREATE TABLE DemoTable;
This will produce the following output displaying the field names and constraints −
+---------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table         | Create Table 
+---------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| DemoTable     | CREATE TABLE `demotable` (`EmployeeId` int(11) NOT NULL AUTO_INCREMENT, `EmployeeFirstName` varchar(40) COLLATE utf8_unicode_ci NOT NULL, `EmployeeLastName` varchar(40) COLLATE utf8_unicode_ci NOT NULL, `EmployeeAge` int(11) DEFAULT NULL, `EmployeeCountryName` varchar(40) COLLATE utf8_unicode_ci DEFAULT NULL, `EmployeeCityName` varchar(40) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`EmployeeId`), UNIQUE KEY `EmployeeFirstName` (`EmployeeFirstName`,`EmployeeCityName`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci |
+---------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.03 sec)
All permutations of an array using STL in C++ - GeeksforGeeks

27 Mar, 2019
Given an array, the task is to print or display all the permutations of this array using STL in C++.
Examples:
Input: a[] = {1, 2, 3}
Output:
1  2  3  
1  3  2  
2  1  3  
2  3  1  
3  1  2  
3  2  1  

Input: a[] = {10, 20, 30, 40}
Output:
10  20  30  40  
10  20  40  30  
10  30  20  40  
10  30  40  20  
10  40  20  30  
10  40  30  20  
20  10  30  40  
20  10  40  30  
20  30  10  40  
20  30  40  10  
20  40  10  30  
20  40  30  10  
30  10  20  40  
30  10  40  20  
30  20  10  40  
30  20  40  10  
30  40  10  20  
30  40  20  10  
40  10  20  30  
40  10  30  20  
40  20  10  30  
40  20  30  10  
40  30  10  20  
40  30  20  10

Approach: The next possible permutation of the array can be found using next_permutation() function provided in STL.
Syntax:
bool next_permutation (BidirectionalIterator first,
                       BidirectionalIterator last);

Below is the implementation of the above Approach:
// C++ program to display all permutations// of an array using STL in C++  #include <bits/stdc++.h>using namespace std;  // Function to display the arrayvoid display(int a[], int n){    for (int i = 0; i < n; i++) {        cout << a[i] << "  ";    }    cout << endl;}  // Function to find the permutationsvoid findPermutations(int a[], int n){      // Sort the given array    sort(a, a + n);      // Find all possible permutations    cout << "Possible permutations are:\n";    do {        display(a, n);    } while (next_permutation(a, a + n));}  // Driver codeint main(){      int a[] = { 10, 20, 30, 40 };      int n = sizeof(a) / sizeof(a[0]);      findPermutations(a, n);      return 0;}
Possible permutations are:
10  20  30  40  
10  20  40  30  
10  30  20  40  
10  30  40  20  
10  40  20  30  
10  40  30  20  
20  10  30  40  
20  10  40  30  
20  30  10  40  
20  30  40  10  
20  40  10  30  
20  40  30  10  
30  10  20  40  
30  10  40  20  
30  20  10  40  
30  20  40  10  
30  40  10  20  
30  40  20  10  
40  10  20  30  
40  10  30  20  
40  20  10  30  
40  20  30  10  
40  30  10  20  
40  30  20  10

cpp-array
Permutation and Combination
STL
C++
STL
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Operator Overloading in C++
Constructors in C++
Socket Programming in C/C++
Virtual Function in C++
Multidimensional Arrays in C / C++
Templates in C++ with Examples
Copy Constructor in C++
Polymorphism in C++
C++ Data Types
unordered_map in C++ STL
How to get entered text from a textbox in selenium?

We can get the entered text from a textbox in Selenium webdriver. To obtain the value attribute of an element in the html document, we have to use the getAttribute() method. Then the value is passed as a parameter to the method.
Let us consider a textbox where we entered some text and then want to get the entered text.
If we spy on the element, we will find that there is no value attribute for this element in the html code.
After entering text inside that field, we can get the entered text by using the getAttribute() method.
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import java.util.concurrent.TimeUnit;

public class GetValAttribute{
   public static void main(String[] args) {
   System.setProperty("webdriver.chrome.driver","C:\\Users\\ghs6kor\\Desktop\\Java\\chromedriver.exe");
      WebDriver driver = new ChromeDriver();
      String url = "https://www.tutorialspoint.com/index.htm";
      driver.get(url);
      driver.manage().timeouts().implicitlyWait(4, TimeUnit.SECONDS);
      // identify element
      WebElement l = driver.findElement(By.id("gsc-i-id1"));
      // enter texts
      l.sendKeys("Selenium");
      // get value attribute with getAttribute()
      String val = l.getAttribute("value");
      System.out.println("Entered text is: " + val);
      driver.quit()
   }
}
Does Python support multiple inheritance?

Yes,Python supports multiple inheritance
Like C++, a class can be derived from more than one base classes in Python. This is called multiple inheritance.
In multiple inheritance, the features of all the base classes are inherited into the derived class.
class Animal:
   def eat(self):
      print("It eats insects.")
   def sleep(self):
      print("It sleeps in the night.")

class Bird(Animal):
   def fly(self):
      print("It flies in the sky.")

   def sing(self):
      print("It sings a song.")
      print(issubclass(Bird, Animal))

Koyal= Bird()
print(isinstance(Koyal, Bird))

Koyal.eat()
Koyal.sleep()
Koyal.fly()
Koyal.sing()

In the following example Bird class inherits the Animal class
Animal is the parent class also known as super class or base class.
Bird is the child class also known as sub class or derived class.
The issubclass method ensures that Bird is a subclass of Animal class.
True
True
It eats insects.
It sleeps in the night.
It flies in the sky.
It sings a song.
D3.js | d3.extent() function - GeeksforGeeks

26 Jun, 2019
The d3.extent() function in D3.js is used to returns the minimum and maximum value in an array from the given array using natural order. If an array is empty then it returns undefined, undefined as output.
Syntax:
d3.extent(Array)
Parameters: This function accepts a parameters Array which is an array of elements whose minimum and maximum value in an array are to be calculated. Here elements might be integers or any strings.
Return Value: It returns the minimum and maximum value in an array from the given array.
Below programs illustrate the d3.extent() function in D3.js.
Example 1:
<html>  <head>    <title>      Getting minimum and       maximum value in an array  </title></head>  <body>    <script src='https://d3js.org/d3.v4.min.js'>  </script>      <script>        // initialising the array of elements        var Array1 = [10, 20, 30, 40, 50, 60];        var Array2 = [1, 2];        var Array3 = [0, 1.5, 6.8];        var Array4 = [.8, .08, .008];          // Calling to d3.extent() function        A = d3.extent(Array1);        B = d3.extent(Array2);        C = d3.extent(Array3);        D = d3.extent(Array4);          // Getting minimum and maximum value        document.write(A + "<br>");        document.write(B + "<br>");        document.write(C + "<br>");        document.write(D + "<br>");    </script></body>  </html>
Output:
10, 60
1, 2
0, 6.8
0.008, 0.8
Example 2:
<html>  <head>    <title>      Getting minimum       and maximum value  </title></head>  <body>    <script src='https://d3js.org/d3.v4.min.js'>  </script>      <script>        // initialising the array of elements        var Array1 = [];        var Array2 = ["a", "b", "c"];        var Array3 = ["A", "B", "C"];        var Array4 = ["Geek", "Geeks", "GeeksforGeeks"];          // Calling to d3.extent() function        A = d3.extent(Array1);        B = d3.extent(Array2);        C = d3.extent(Array3);        D = d3.extent(Array4);          // Getting minimum and maximum value        document.write(A + "<br>");        document.write(B + "<br>");        document.write(C + "<br>");        document.write(D + "<br>");    </script></body>  </html>
Output:
undefined, undefined
a, c
A, C
Geek, GeeksforGeeks
Note: In the above output, first element is minimum value and second element is maximum value.
Ref: https://devdocs.io/d3~4/d3-array#extent
D3.js
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Difference between var, let and const keywords in JavaScript
Convert a string to an integer in JavaScript
Differences between Functional Components and Class Components in React
How to Open URL in New Tab using JavaScript ?
How to Use the JavaScript Fetch API to Get Data?
Top 10 Front End Developer Skills That You Need in 2022
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
How to Customize JupyterLab Keyboard Shortcuts | by Jeff Hale | Towards Data Science

I often find myself wanting to restart and run all cells, so I wanted to make a keyboard shortcut. I made this tutorial to help other folks out, because it’s not a one-click-selection kind of thing
JupyterLab is like Jupyter notebook on anabolic steroids — without the increased cancer risk and other negative side effects. JupyterLab is billed as the next generation UI for Project Jupyter. It was released in beta in early 2018.
Fun fact, the Jupyter folks write JupyterLab as one word but Jupyter notebook as two 😃.
It feels much like using your familiar Jupyter notebook with enhanced functionality such as navigation tabs. It’s the future — and it’s here now.
If you’re like me you might have seen JupyterLab in Anaconda but kept to your trusty Jupyter notebook. Try it. It can help you enhance your productivity. Speaking of productivity, let’s make a keyboard shortcut. 🚀
Install with conda install -c conda-forge jupyterlab or pip install jupyterlab. Then run JupyterLab in the terminal with jupyterlab or by selecting the app icon in Anaconda Navigator.
Once JupterLab is open click the Settings dropdown menu. Select Advanced Settings Editor.
Select Keyboard Shortcuts.
You’ll see a dictionary for each option in the System Defaults panel. There are a bunch of options, so you might want to Command + F (Ctrl + F on Windows) to find the one you want. Copy the code of the one you want to override.
Here’s the section for restart-and-run-all.
{  "command": "runmenu:restart-and-run-all",  "keys": [        ""   ],   "selector": "[data-jp-code-runner]"},
Paste this code in the User Preferences panel. Type the names of whichever keys you want to make your shortcut in the keys list. I added Ctrl and Shift and R below.
Update June 24, 2020, Shahida pointed out in the comments that JupyterLab had changed its API for changing keyboard shortcuts. The code below is updated. Thank you Shahida!
{"shortcuts":     [        {            "command": "runmenu:restart-and-run-all",            "keys": [                "Ctrl Shift R"            ],            "selector": "[data-jp-code-runner]"        }    ]}
I suggest making sure you aren’t overriding another JupyterLab keyboard shortcut by searching the System Defaults Panel for your new key combination.
And there you have it. Press Command + S (Ctrl + S on Windows) to save, open a notebook file, and try out your new keyboard shortcut!
Heck yeah!
You just learned how to save yourself time by making keyboard shortcuts in JupyterLab. Note that this will run in Edit mode or Command mode in Jupyter Lab.
Some commands don’t show up in the System Defaults panel. Here’a a list of the commands that can be bound.
Experiment and enjoy!
I hope you found this guide to customizing JupyterLab shortcuts to be helpful. If you did, please share it on your favorite social media so other folks can find it, too. 😀
I write about Python, SQL, and other tech topics. If any of that’s of interest to you, sign up for my mailing list of awesome data science resources and read more to help you grow your skills here. 👍
String indexOf(String str, int fromIndex)

This method returns the index within this string of the first occurrence of the specified substring, starting at the specified index. If it does not occur, -1 is returned.
Here is the syntax of this method −
int indexOf(String str, int fromIndex)

Here is the detail of parameters −
fromIndex − the index to start the search from.
fromIndex − the index to start the search from.
str − a string.
str − a string.
See the description.
import java.io.*;
public class Test {

   public static void main(String args[]) {
      String Str = new String("Welcome to Tutorialspoint.com");
      String SubStr1 = new String("Tutorials" );
      System.out.print("Found Index :" );
      System.out.println( Str.indexOf( SubStr1, 15 ));
   }
}
This will produce the following result −
Found Index :-1


    16 Lectures 
     2 hours 

 Malhar Lathkar

    19 Lectures 
     5 hours 

 Malhar Lathkar

    25 Lectures 
     2.5 hours 

 Anadi Sharma

    126 Lectures 
     7 hours 

  Tushar Kale

    119 Lectures 
     17.5 hours 

 Monica Mittal

    76 Lectures 
     7 hours 

 Arnab Chakraborty
 Print
 Add Notes
 Bookmark this page
How to extract date from string in MySQL?

To extract date from the string in MySQL, use SUBSTRING_INDEX(). Let us first create a table −
mysql> create table DemoTable
   -> (
   -> Title text
   -> );
Query OK, 0 rows affected (0.58 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('John has got joining date.12/31/2018');
Query OK, 1 row affected (0.13 sec)
mysql> insert into DemoTable values('Carol has got joining date.01/11/2019');
Query OK, 1 row affected (0.22 sec)
mysql> insert into DemoTable values('Sam will arrive at.12/03/2050');
Query OK, 1 row affected (0.87 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+---------------------------------------+
| Title                                 |
+---------------------------------------+
| John has got joining date.12/31/2018  |
| Carol has got joining date.01/11/2019 |
| Sam will arrive at.12/03/2050         |
+---------------------------------------+
3 rows in set (0.00 sec)
Here is the query to extract date from the string in MySQL −
mysql> select substring_index(substring_index(Title,".", -1), ".", 1) from DemoTable;
This will produce the following output −
+----------------------------------------------------------+
| substring_index(substring_index(Title,".", -1), ".", 1)  |
+----------------------------------------------------------+
| 12/31/2018                                               |
| 01/11/2019                                               |
| 12/03/2050                                               |
+----------------------------------------------------------+
3 rows in set (0.00 sec)
Altering a table to add a collection data type in Cassandra - GeeksforGeeks

13 Dec, 2019
In this article, we will discuss how we can alter a table to add MAP collection data type and how we insert data after altering the table with the help of the UPDATE command. Let’s discuss one by one.First, we are going to create a table let’s consider E_book is a table name and Bookk_name, Author_name, Selling_price are the fields in the E_book table. Let’s have a look.
Create table E_book
(
Book_name text,
Author_name text,
ISBN int,
Primary key(Book_name)
); 
Now, here we will insert some data by using the following CQL query given below.
Insert into E_book(Book_name, Author_name, ISBN) 
Values ('Attitude is Everything', 'Jeff keller', 123 );

Insert into E_book(Book_name, Author_name, ISBN) 
Values ('Life without Limits', 'Nick Vujicic', 124 );

Insert into E_book(Book_name, Author_name, ISBN) 
Values ('Wings of fire', 'Dr. APJ abdul kalam', 125 ); 
Let’s see the results,
select * 
from E_book; 
Output:
Now, here we will add a new collection data type column by using ALTER TABLE command. Let’s have a look.
ALTER TABLE E_book 
ADD price map<text, int>; 
Now, to verify used the following cqlsh query.
describe table E_book; 
Output:
In the above Cassandra Query Language (CQL) query, we are using MAP collection in which we insert key pair values. Now, after successfully alter the table we will use the UPDATE command to insert data.
Let’s have a look.
UPDATE E_book 
SET price = price + {'selling price' : 280, 'Actual price ' : 200} 
WHERE Book_name = 'Attitude is Everything'; 
Now, here to verify the result we will use the following CQL query given below.
SELECT price FROM E_book 
WHERE Book_name = 'Attitude is Everything';
Output:
Apache
DBMS
DBMS
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Types of Functional dependencies in DBMS
Introduction of Relational Algebra in DBMS
What is Temporary Table in SQL?
Two Phase Locking Protocol
KDD Process in Data Mining
Conflict Serializability in DBMS
MySQL | Regular expressions (Regexp)
Difference between Star Schema and Snowflake Schema
Difference between OLAP and OLTP in DBMS
Nested Queries in SQL
Display MySQL Results as comma separated list?

We can show the result as a comma separated list with the help of the ‘concat()’ function with the parameter ‘,’.
Let us see an example now. Firstly, we will create a table. The CREATE command is used to create a table.
mysql> create table CommaSeperateDemo
   - > (
   - > Id int,
   - > FirstName varchar(100),
   - > LastName varchar(100)
   - > );
Query OK, 0 rows affected (0.93 sec)
mysql> insert into CommaSeperateDemo values(1,'John','Taylor');
Query OK, 1 row affected (0.17 sec)

mysql> insert into CommaSeperateDemo values(2,'Carol','Taylor');
Query OK, 1 row affected (0.12 sec)

mysql> insert into CommaSeperateDemo values(3,'Johnson','T.');
Query OK, 1 row affected (0.16 sec)

Let us now display all the records.
mysql> select *from CommaSeperateDemo;
The following is the output.
+------+-----------+----------+
| Id   | FirstName | LastName |
+------+-----------+----------+
|    1 | John      | Taylor   |
|    2 | Carol     | Taylor   |
|    3 | Johnson   | T.       |
+------+-----------+----------+
3 rows in set (0.00 sec)

Here is the syntax to get the result as comma separated list with the help of concat()
Select concat(ColumnName1, ',', ColumnName2, ',', ColumnName3,.............) as AliasName from yourTableName;

Let us now implement the above syntax in the following query.
mysql> SELECT concat(Id, ',', FirstName,',', LastName) as CONCATEIDFIRSTANDLASTNAME from CommaSeperateDemo;
The following is the syntax.
+---------------------------+
| CONCATEIDFIRSTANDLASTNAME |
+---------------------------+
| 1,John,Taylor             |
| 2,Carol,Taylor            |
| 3,Johnson,T.              |
+---------------------------+
3 rows in set (0.00 sec)
How to find the Eigenvalues and Eigenvectors of a square matrix using SciPy?

We can find the Eigenvalues and Eigenvectors for a square matrix, say A, with the help of following relation −
SciPy library has scipy.linalg.eig() function for computing the eigenvalues and eigenvectors of a square matrix.
Let’s understand how we can use this function to calculate the inverse of a matrix −
Eigenvalues and Eigenvectors of a 2 by 2 matrix
#Importing the scipy package
import scipy

#Importing the numpy package
import numpy as np

#Declaring the numpy array(Square Matrix)
A = np.array([[3,3.5],[3.2,3.6]])

#Passing the values to scipy.linalg.eig() function
eigvalues, eigvectors = scipy.linalg.eig(A)
#Printing the result for eigenvalues
print(eigvalues)
#Printing the result for eigenvectors
print(eigvectors)
[-0.06005952+0.j 6.66005952+0.j]
[[-0.75283678 -0.6911271 ]
[ 0.65820725 -0.72273324]]
Eigenvalues and Eigenvectors of a 3 by 3 matrix
import scipy
import numpy as np
A = np.array([[2,1,-2],[1,0,0],[0,1,0]])
eigvalues, eigvectors = scipy.linalg.eig(A)
print(eigvalues)
print(eigvectors)
[-1.+0.j 2.+0.j 1.+0.j]
[[-0.57735027 -0.87287156 0.57735027]
[ 0.57735027 -0.43643578 0.57735027]
[-0.57735027 -0.21821789 0.57735027]]
C Program for compound interest - GeeksforGeeks

07 Feb, 2018
Compound Interest formula:
Formula to calculate compound interest annually is given by:Compound Interest = P(1 + R/100)rWhere,P is principle amountR is the rate andT is the time span
Example:
Input : Principle (amount): 1200
        Time: 2
        Rate: 5.4
Output : Compound Interest = 1333.099243

// CPP program to find compound interest for// given values.#include <bits/stdc++.h>using namespace std;  int main(){    double principle = 10000, rate = 10.25, time = 5;      /* Calculate compound interest */    double CI = principle * (pow((1 + rate / 100), time));      cout << "Compound interest is " << CI;      return 0;}
Please refer complete article on Program to find compound interest for more details!
C Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
C Program to read contents of Whole File
Producer Consumer Problem in C
C program to find the length of a string
Exit codes in C/C++ with Examples
Regular expressions in C
Conditional wait and signal in multi-threading
Handling multiple clients on server with multithreading using Socket Programming in C/C++
C / C++ Program for Dijkstra's shortest path algorithm | Greedy Algo-7
C Hello World Program
Difference between break and continue statement in C
Python | Pandas Dataframe.at[ ] - GeeksforGeeks

16 Jul, 2021
Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric Python packages. Pandas is one of those packages and makes importing and analyzing data much easier.
Pandas at[] is used to return data in a dataframe at the passed location. The passed location is in the format [position, Column Name]. This method works in a similar way to Pandas loc[ ] but at[ ] is used to return an only single value and hence works faster than it.
Syntax: Dataframe.at[position, label]Parameters: position: Position of element in column label: Column name to be usedReturn type: Single element at passed position  
To download the data set used in following example, click here.
In the following examples, the data frame used contains data of some NBA players. The image of data frame before any operations is attached below. 
Example #1: In this example, A dataframe is created by passing URL of csv to Pandas .read_csv() method. After that 2nd value in Name column is returned using .at[ ] method. 
Python3
# importing pandas module import pandas as pd # reading csv file from url data = pd.read_csv("https://media.geeksforgeeks.org/wp-content/uploads/nba.csv") # creating position and label variablesposition = 2label = 'Name'     # calling .at[] methodoutput = data.at[position, label] # displayprint(output)
Output: As shown in the output image, the output can be compared and it can be seen that the Value at 2nd position in the Name column is similar to output. 
Note:  
Unlike, .loc[ ], This method only returns single value. Hence dataframe.at[3:6, label] will return an error.
Since this method only works for single values, it is faster than .loc[] method.
 
surindertarika1234
Python pandas-dataFrame
Python pandas-dataFrame-methods
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Python Dictionary
Enumerate() in Python
How to Install PIP on Windows ?
Different ways to create Pandas Dataframe
Reading and Writing to text files in Python
sum() function in Python
Create a Pandas DataFrame from Lists
How to drop one or multiple columns in Pandas Dataframe
*args and **kwargs in Python
Graph Plotting in Python | Set 1
GET method - Python requests - GeeksforGeeks

26 Feb, 2020
Requests library is one of the important aspects of Python for making HTTP requests to a specified URL. This article revolves around how one can make GET request to a specified URL using requests.GET() method. Before checking out GET method, let’s figure out what a GET request is –
The GET method is used to retrieve information from the given server using a given URI. The GET method sends the encoded user information appended to the page request. The page and the encoded information are separated by the ‘?’ character.For example:
https://www.google.com/search?q=hello
Python’s requests module provides in-built method called get() for making a GET request to a specified URI.
Syntax –
requests.get(url, params={key: value}, args)

Example –
Let’s try making a request to github’s APIs for example purposes.
import requests   # Making a GET requestr = requests.get('https://api.github.com / users / naveenkrnl')  # check status code for response received# success code - 200print(r)  # print content of requestprint(r.content)
save this file as request.py and through terminal run,
python request.py
Output –
Since the data sent by the GET method are displayed in the URL, it is possible to bookmark the page with specific query string values.
GET requests can be cached and GET requests remain in the browser history.
GET requests can be bookmarked.
The GET method is not suitable for passing sensitive information such as the username and password, because these are fully visible in the URL query string as well as potentially stored in the client browser’s memory as a visited page.
Because the GET method assigns data to a server environment variable, the length of the URL is limited. So, there is a limitation for the total data to be sent.
Python-requests
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Enumerate() in Python
How to Install PIP on Windows ?
Different ways to create Pandas Dataframe
Python String | replace()
sum() function in Python
Create a Pandas DataFrame from Lists
How to drop one or multiple columns in Pandas Dataframe
*args and **kwargs in Python
Graph Plotting in Python | Set 1
Print lists in Python (4 Different Ways)
PyQt5 QSpinBox - Getting bounding rectangle of the character - GeeksforGeeks

26 May, 2020
In this article we will see how we can get the bounding rectangle of given character of the spin box, i.e rectangle that is covered by ink if character ‘ch’ were to be drawn at the origin of the coordinate system. The bounding rectangle may extend to the left of (0, 0) (e.g., for italicized fonts), and that the text output may cover all pixels in the bounding rectangle. For a space character the rectangle will usually be empty.
In order to do this we use boundingRect method with the spin box’s QFontMetrics object.
Syntax : font_metrics.boundingRect(ch)
Argument : It takes string as argument
Return : It returns QRect object
Note : This method can be used to get the bounding rectangle of the whole text as well
Below is the implementation
# 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 widgets    def UiComponents(self):        # creating spin box        self.spin = QSpinBox(self)          # setting geometry to spin box        self.spin.setGeometry(100, 100, 250, 40)          # setting range to the spin box        self.spin.setRange(0, 999999)          # setting prefix to spin        self.spin.setPrefix("PREFIX ")          # setting suffix to spin        self.spin.setSuffix(" SUFFIX")          # creating a label        label = QLabel(self)          # making label multi line        label.setWordWrap(True)          # setting geometry to the label        label.setGeometry(100, 200, 300, 60)          # getting font metrics        f_metrics = self.spin.fontMetrics()          # getting average character width        rec = f_metrics.boundingRect('S')          # setting text to the label        label.setText("Rect : " + str(rec))    # create pyqt5 appApp = QApplication(sys.argv)  # create the instance of our Windowwindow = Window()  # start the appsys.exit(App.exec())
Output :
Python PyQt-SpinBox
Python-gui
Python-PyQt
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Install PIP on Windows ?
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | Pandas dataframe.groupby()
Defaultdict in Python
Python | Get unique values from a list
Python Classes and Objects
Python | os.path.join() method
Create a directory in Python
C++ program to convert Fahrenheit to Celsius

In this program we will see how to convert Celsius to Fahrenheit using C++. As we know the formula is simple.
Begin
Take the Celsius temperature in C
calculate F = (9C/5)+32
return F
End
#include<iostream>
using namespace std;
main() {
   float f, c;
   cout << "Enter temperature in Celsius: ";
   cin >> c;
   f = (9.0*c/5.0)+32;
   cout << "Equivalent Fahrenheit temperature is: " << f;
}
Enter temperature in Celsius: 37
Equivalent Fahrenheit temperature is: 98.6
Can a constructor be overridden in java?

If super class and sub class have same methods including name, return type and parameters, and if you try to call it using the object of the sub class
Then the method in the sub class is invoked.
Constructor looks like method but it is not. It does not have a return type and its name is same as the class name.
But, a constructor cannot be overridden. If you try to write a super class’s constructor in the sub class compiler treats it as a method and expects a return type and generates a compile time error.
class DemoTest{
   DemoTest(){
      System.out.println("This is the constructor of the demo class");
   }
}
public class OverridingConstructor extends DemoTest {
   DemoTest(){
      System.out.println("This is the constructor of the demo class");
   }
}
C:\Sample>javac Example.java
Example.java:2: error: class Sample is public, should be declared in a file named Sample.java
public class Sample {
^
1 error
Reverse a String | Practice | GeeksforGeeks

You are given a string s. You need to reverse the string.
Example 1:
Input:
s = Geeks
Output: skeeG

Example 2:
Input:
s = for
Output: rof
Your Task:
You only need to complete the function reverseWord() that takes s as parameter and returns the reversed string.
Expected Time Complexity: O(|S|).
Expected Auxiliary Space: O(1).
Constraints:
1 <= |s| <= 10000
0
20h51a050717 hours ago
#include <iostream>using namespace std;
int main() { string str;   cin>>str;   string str_rev;   getline(cin,str_rev);   for(int i=str.size()-1;i>=0;--i)   {       str_rev=str_rev+str[i];   }   cout<<str_rev;   }
0
atharvaminajgi1 day ago
string reverseWord(string str){    //Your code here int s = 0; int e = str.length() - 1;  while(s<e){          swap(str[s++],str[e--]); } return str;}
+1
shreyshah17120022 days ago
def reverseWord(s):   #your code here   ans=""   i=len(s)-1   while i>=0:       ans+=s[i]       i-=1   return ans
0
imabhishek023 days ago
Using recursion: C++ in 0.01sec
void rev(string &st,int s,int e)
{
    if(s>e)
    {
        return; 
    }
    swap(st[s],st[e]);
    s++;
    e--;
    
    rev(st,s,e);
}

string reverseWord(string str){
    rev(str,0,str.length()-1);
    return str;
    }
0
visionsameer393 days ago
IN PYTHON
1 approch: using slicing .
1 approch: using slicing .
def reverseWord(s):   return s[::-1]
 
 
2 approach: using revesed() method.
2 approach: using revesed() method.
 
def reverseWord(s):   s1=reversed(s)   return "".join(s1)       
0
pradeepmallipudi34 days ago
string reverseWord(string str){      int n=str.length();       int start=0;    int end=n-1;    while(start<=end){        swap(str[start], str[end]);        start++;        end--;    }        return str;}
0
nitingoud594 days ago
def 
0
visionsameer395 days ago
python 
 
def rever(s):
    return s[::-1]
0
vikassinghwow5 days ago
//Java
 
class Reverse{   // Complete the function   // str: input string   public static String reverseWord(String str)   {       // Reverse the string str       String reverse="";       for(int i=str.length()-1;i>=0;i--)       {           reverse=reverse+str.charAt(i);       }       return reverse;   }}
+1
rahilarahman5 days ago
python program without using any built in functions easiest ones with only logicdef reverseWord(s):      string=""   for i in s:       string=i+string   return string 
We strongly recommend solving this problem on your own before viewing its editorial. Do you still
                    want to view the editorial?
 Login to access your submissions. 

Problem


Contest

Reset the IDE using the second button on the top right corner.
Avoid using static/global variables in your code as your code is tested against multiple test cases and these tend to retain their previous values.
Passing the Sample/Custom Test cases does not guarantee the correctness of code. On submission, your code is tested against multiple test cases consisting of all possible corner cases and stress constraints.
You can access the hints to get an idea about what is expected of you as well as the final solution code.
You can view the solutions submitted by other users from the submission tab.
How to use Lua Programming to check if a file exists?

Lua provides us with different functions and methods that we can use when we want to work with files. These methods or functions do different operations, like from opening a file, to closing a file, to opening a file with a specific mode also.
While many of these functions that Lua provides to work with files, two of them are more subtle to use and work with.
In this article we will explore these two approaches, where in the first approach we will simply open a file by passing the name of the file and the mode in which we want to open the file, and then we will print whether the file is present or not.
It should be noted that if the file was found by Lua, then only the address will be printed where the file is located, but if no file was found, then nil will be printed.
Consider the example shown below −
print(io.open("sample.txt", "r"))
If we have a file named “sample.txt” present inside the same directory where the above Lua file is present, then we will get the following output to the terminal.
file (0x22ac2b0)
If we don’t have a file named the above Lua file is present, “sample.txt” present inside the same directory where then we will get the following output to the terminal.
nil sample.txt: No such file or directory2
A better way to write this code is to make a separate function to check whether the file is present or not, and in that function we can also close the file once we open it and can also return true if we encounter the file, or false if we don’t.
Consider the example shown below −
 Live Demo
function file_exists(name)
   local f=io.open(name,"r")
   if f~=nil then io.close(f) return true else return false end
end
ans = file_exists("sample.txt")
print(ans)
false
Rename all tables and columns to lower case in MySQL?

You can achieve this with the help of INFORMATION_SCHEMA.COLUMNS. The syntax is as follows −
SELECT CONCAT('ALTER TABLE ', TABLE_NAME, ' CHANGE `', COLUMN_NAME, '` `',
LOWER(COLUMN_NAME), '` ', COLUMN_TYPE, ';') AS anyAliasName
FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = ‘yourDatabaseName’;
Now use the database which has two tables. The database name is as follows “bothinnodbandmyisam”. This database is having the following tables −
employee
student
The description of the employee table is as follows −
mysql> desc employee;
The following is the output. Let’s say we have the following columns in the employee table which are not in lowercase −
+--------------+-------------+------+-----+---------+-------+
| Field        | Type        | Null | Key | Default | Extra |
+--------------+-------------+------+-----+---------+-------+
| EmployeeId   | int(11)     |  YES |     | NULL    |       |
| EmployeeName | varchar(30) | YES  |     | NULL    |       |
+--------------+-------------+------+-----+---------+-------+
2 rows in set (0.00 sec)
The description of the student table is as follows. The query is as follows −
mysql> desc student;
The following is the output. Let’s say we have the following columns in the student table which are not in lowercase −
+-------------+-------------+------+-----+---------+-------+
| Field       | Type        | Null | Key | Default | Extra |
+-------------+-------------+------+-----+---------+-------+
| StudentId   | int(11)     | YES  |     | NULL    |       |
| StudentName | varchar(20) | YES  |     | NULL    |       |
+-------------+-------------+------+-----+---------+-------+
2 rows in set (0.00 sec)
Here is the query to change column names of all tables to lowercase. The query is as follows −
mysql> SELECT CONCAT('ALTER TABLE ', TABLE_NAME, ' CHANGE `', COLUMN_NAME, '` `',
   -> LOWER(COLUMN_NAME), '` ', COLUMN_TYPE, ';') AS changeColumnNameToLower
   -> FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = 'bothinnodbandmyisam';
The following is the output displaying the ALTER TABLE command that shows the updated column names −
+------------------------------------------------------------------------+
| changeColumnNameToLower                                                |
+------------------------------------------------------------------------+
| ALTER TABLE employee CHANGE `EmployeeId` `employeeid` int(11);         |
| ALTER TABLE employee CHANGE `EmployeeName` `employeename` varchar(30); |
| ALTER TABLE student CHANGE `StudentId` `studentid` int(11);            |
| ALTER TABLE student CHANGE `StudentName` `studentname` varchar(20);    |
+------------------------------------------------------------------------+
4 rows in set (0.00 sec)
Look at the above sample output, all column names have been changed in lowercase.