code-rag-bench/online-tutorials huggingface dataset:
Using Random Forest to tell if you have a representative Validation Set | by Alessandro Kosciansky | Towards Data Science

When running a predictive model — be that during a Kaggle competition or the real world — you need a representative validation set to check whether the model you are training, generalises well — that is, the model can make good predictions on data it has never seen before.
So what do I mean by ‘representative’? Well, all it really means is that your training and validation data sets are similar, i.e. follow the same distributions or patterns. If that is not the case then you’re training your model on apples, but then try to predict on oranges. The result will be very poor predictions.
You could do lots of Exploratory Data Analysis (EDA) and check that each feature behaves similar across both datasets. But that could be really time consuming. A neat and quick way of testing whether you have a representative or good validation set is to run a Random Forest Classifier.
In this Kaggle kernel I did exactly that. I first prepared both training and validation data and then added an extra column ‘train’, which takes the value of 1 when the data is training data and 0 when it is validation data. This is the target that the Random Forest Classifier is going to predict.
# Create the new targettrain_set['train'] = 1validation_set['train'] = 0# Concatenate the two datasetstrain_validation = pd.concat([train_set, validation_set], axis=0)
The next step is to get your indepdent (X) and dependent (y) features ready, set up the Random Forest Classifier, and run cross validation.
I am using the metric ROC AUC, which is a common metric for classification tasks. If the metric is 1 then you’re predicting perfectly. If the score is 0.5 then you’re as good as the baseline, which is the score that you would get if you always predicted the most common outcome. If the score is below 0.5 then you’re doing something wrong.
# Import the librariesfrom sklearn.ensemble import RandomForestClassifierfrom sklearn.model_selection import cross_val_score# Split up the dependent and independent variablesX = train_validation.drop('train', axis=1)y = train_validation['train']# Set up the modelrfc = RandomForestClassifier(n_estimators=10, random_state=1)# Run cross validationcv_results = cross_val_score(rfc, X, y, cv=5, scoring='roc_auc')
Now, what do you think the ROC AUC should be if training and validation set behave the same way? ...That’s right, 0.5! If the score is 0.5 then it means that training and validation data are indistinguishable, which is what we want.
Once we have run cross validation, let’s get the scores... And great news! The score is indeed 0.5. That means the Kaggle hosts have set up a representative validation set for us. Sometimes that’s not the case and this is a great quick way of checking this. In real life, however, you have to come up with a validation set yourself and this will hopefully come in handy to make sure that you set up a correct validation set.
print(cv_results)print(np.mean(cv_results))[0.5000814  0.50310124 0.50416737 0.49976049 0.50078978]0.5015800562639847
Update data in one table from data in another table in MySQL?

For this, you can use UPDATE command along with JOIN.
Let us create the first table −
mysql> create table demo54
−> (
−> firstName varchar(20),
−> lastName varchar(20)
−> );
Query OK, 0 rows affected (0.57 sec)
Insert some records into the table with the help of insert command −
mysql> insert into demo54 values('John','Smith');
Query OK, 1 row affected (0.09 sec)

mysql> insert into demo54 values('John','Smith');
Query OK, 1 row affected (0.09 sec)

mysql> insert into demo54 values('David','Smith');
Query OK, 1 row affected (0.11 sec)
Display records from the table using select statement −
mysql> select *from demo54;
This will produce the following output −
+-----------+----------+
| firstName | lastName |
+-----------+----------+
| John      | Smith    |
| John      | Smith    |
| David     | Smith    |
+-----------+----------+
3 rows in set (0.00 sec)
Following is the query to create second table −
mysql> create table demo55
−> (
−> firstName varchar(20),
−> lastName varchar(20)
−> );
Query OK, 0 rows affected (1.93 sec)
Insert some records into the table with the help of insert command −
mysql> insert into demo55 (firstName) values('John');
Query OK, 1 row affected (0.10 sec)

mysql> insert into demo55 (firstName) values('David');
Query OK, 1 row affected (0.13 sec)

mysql> insert into demo55 (firstName) values('Bob');
Query OK, 1 row affected (0.10 sec)
Display records from the table using select statement −
mysql> select *from demo55;
This will produce the following output −
+-----------+----------+
| firstName | lastName |
+-----------+----------+
| John      | NULL     |
| David     | NULL     |
| Bob       | NULL     |
+-----------+----------+
3 rows in set (0.00 sec)
Following is the query to update data in one table from another table.
mysql> UPDATE demo55 tbl1
−> JOIN demo54 tbl2 ON tbl1.firstName = tbl2.firstName
−> set tbl1.lastName = tbl2.lastName;
Query OK, 2 rows affected (0.10 sec)
Rows matched: 2 Changed: 2 Warnings: 0
Display records from the table using select statement −
mysql> select *from demo55;
This will produce the following output −
+-----------+----------+
| firstName | lastName |
+-----------+----------+
| John      | Smith    |
| David     | Smith    |
| Bob       | NULL     |
+-----------+----------+
3 rows in set (0.00 sec)
Cryptography with Python - Affine Cipher

Affine Cipher is the combination of Multiplicative Cipher and Caesar Cipher algorithm. The basic implementation of affine cipher is as shown in the image below −
In this chapter, we will implement affine cipher by creating its corresponding class that includes two basic functions for encryption and decryption.
You can use the following code to implement an affine cipher −
class Affine(object):
   DIE = 128
   KEY = (7, 3, 55)
   def __init__(self):
      pass
   def encryptChar(self, char):
      K1, K2, kI = self.KEY
      return chr((K1 * ord(char) + K2) % self.DIE)
		
   def encrypt(self, string):
      return "".join(map(self.encryptChar, string))
   
   def decryptChar(self, char):
      K1, K2, KI = self.KEY
      return chr(KI * (ord(char) - K2) % self.DIE)
   
   def decrypt(self, string):
      return "".join(map(self.decryptChar, string))
		affine = Affine()
print affine.encrypt('Affine Cipher')
print affine.decrypt('*18?FMT')
You can observe the following output when you implement an affine cipher −
The output displays the encrypted message for the plain text message Affine Cipher and decrypted message for the message sent as input abcdefg.

    10 Lectures 
     2 hours 

 Total Seminars

    10 Lectures 
     2 hours 

 Stone River ELearning
 Print
 Add Notes
 Bookmark this page
Check if a given year is leap year in PL/SQL

Here we will see how to check given year is leap year or not, using PL/SQL. In PL/SQL code, some group of commands are arranged within a block of related declaration of statements.
The leap year checking algorithm is like below.
isLeapYear(year):
begin
   if year is divisible by 4 and not divisible by 100, then
      it is leap year
   else if the number is divisible by 400, then
      it is leap year
   else
      it is not leap year
end
DECLARE
   year NUMBER := 2012;
BEGIN
   IF MOD(year, 4)=0
      AND
      MOD(year, 100)!=0
      OR
      MOD(year, 400)=0 THEN
      dbms_output.Put_line(year || ' is leap year ');
   ELSE
      dbms_output.Put_line(year || ' is not leap year.');
   END IF;
END;
2012 is leap year
What is Is-a relationship in Java?

IS-A is a way of saying: This object is a type of that object. Let us see how the extends keyword is used to achieve inheritance.
public class Animal {
}
public class Mammal extends Animal {
}
public class Reptile extends Animal {
}
public class Dog extends Mammal {
}
Now, based on the above example, in Object-Oriented terms, the following are true −
Animal is the superclass of Mammal class.
Animal is the superclass of Reptile class.
Mammal and Reptile are subclasses of Animal class.
Dog is the subclass of both Mammal and Animal classes.
 Live Demo
class Animal {
}
class Mammal extends Animal {
}
class Reptile extends Animal {
}
public class Dog extends Mammal {
public static void main(String args[]) {
Animal a = new Animal();
Mammal m = new Mammal();
Dog d = new Dog();

System.out.println(m instanceof Animal);
System.out.println(d instanceof Mammal);
System.out.println(d instanceof Animal);
}
}
true
true
true
Pascal - Continue Statement

The continue statement in Pascal works somewhat like the break statement. Instead of forcing termination, however, continue forces the next iteration of the loop to take place, skipping any code in between.
For the for-do loop, continue statement causes the conditional test and increment portions of the loop to execute. For the while-do and repeat...until loops, continue statement causes the program control to pass to the conditional tests.
The syntax for a continue statement in Pascal is as follows −
continue;

program exContinue; 
var
   a: integer;

begin
   a := 10;
   (* repeat until loop execution *)
   repeat
      if( a = 15) then
      
      begin
         (* skip the iteration *)
         a := a + 1;
         continue;
      end;
      
      writeln('value of a: ', a);
      a := a+1;
   until ( a = 20 );
end.
When the above code is compiled and executed, it produces the following result −
value of a: 10
value of a: 11
value of a: 12
value of a: 13
value of a: 14
value of a: 16
value of a: 17
value of a: 18
value of a: 19


    94 Lectures 
     8.5 hours 

 Stone River ELearning
 Print
 Add Notes
 Bookmark this page
Finding the only unique string in an array using JavaScript

We are required to write a JavaScript function that takes in an array of strings.
All the strings in the array contain the same characters, or the repetition of characters, and just one string contains a different set of characters. Our function should find and return that string.
For example
If the array is −
[‘ba’, 'abc', 'acb', 'bac', 'foo', 'bca', 'cab', 'cba' ]
Then the required string is ‘foo’.
Strings may contain spaces. Spaces are not significant, only non-spaces symbols matter. Example, a string that contains only spaces is like an empty string. It’s guaranteed that the array contains more than 3 strings.
Following is the code −
 Live Demo
const arr = ['ba', 'abc', 'acb', 'bac', 'foo', 'bca', 'cab', 'cba' ];
const findOnlyUnique = (arr = []) => {
   const first = [];
   for(i = 0; i < arr.length; i++){
      first.push(arr[i].toLowerCase().replace(/\s/g, '').split(''));
      for (j = 0; j < arr[i].length; j++){
         first[i].sort();
      }
   }
   const second = [];
   for (k = 0; k < arr.length; k++){
      second.push(first[k].join());
   }
   second.sort();
   const third = [];
   if (second[1] !== second[second.length - 1]) {
      third.push(second[second.length - 1]);
   }else{
      third.push(second[0]);
   }
   const last = [];
   for(let n = 0; n < first.length; n++){
      last.push(first[n].join(','));
   }
   return (arr[last.indexOf(third[0])]);
};
console.log(findOnlyUnique(arr));
foo
Assembly - Loops

The JMP instruction can be used for implementing loops. For example, the following code snippet can be used for executing the loop-body 10 times.
MOV	CL, 10
L1:
<LOOP-BODY>
DEC	CL
JNZ	L1
The processor instruction set, however, includes a group of loop instructions for implementing iteration. The basic LOOP instruction has the following syntax −
LOOP 	label

Where, label is the target label that identifies the target instruction as in the jump instructions. The LOOP instruction assumes that the ECX register contains the loop count. When the loop instruction is executed, the ECX register is decremented and the control jumps to the target label, until the ECX register value, i.e., the counter reaches the value zero.
The above code snippet could be written as −
mov ECX,10
l1:
<loop body>
loop l1
The following program prints the number 1 to 9 on the screen −
section	.text
   global _start        ;must be declared for using gcc
	
_start:	                ;tell linker entry point
   mov ecx,10
   mov eax, '1'
	
l1:
   mov [num], eax
   mov eax, 4
   mov ebx, 1
   push ecx
	
   mov ecx, num        
   mov edx, 1        
   int 0x80
	
   mov eax, [num]
   sub eax, '0'
   inc eax
   add eax, '0'
   pop ecx
   loop l1
	
   mov eax,1             ;system call number (sys_exit)
   int 0x80              ;call kernel
section	.bss
num resb 1
When the above code is compiled and executed, it produces the following result −
123456789:


    46 Lectures 
     2 hours 

 Frahaan Hussain

    23 Lectures 
     12 hours 

 Uplatz
 Print
 Add Notes
 Bookmark this page
Kotlin Constructors

In the previous chapter, we created an object of a class, and specified the properties inside the class, like this:
class Car {
  var brand = ""
  var model = ""
  var year = 0
}

fun main() {
  val c1 = Car()
  c1.brand = "Ford"
  c1.model = "Mustang"
  c1.year = 1969
}
In Kotlin, there's a faster way of doing this, by using a constructor.
A 
constructor is like a special function, and it is defined by using two parantheses () 
after the class name. You can specify the properties inside of the parantheses (like passing 
parameters into a regular function).
The constructor will initialize the properties when you create an object of a class. Just remember to specify the 
type of the property/variable:
class Car(var brand: String, var model: String, var year: Int)

fun main() {
  val c1 = Car("Ford", "Mustang", 1969)
}
Now it's even easier to specify multiple objects of one class:
class Car(var brand: String, var model: String, var year: Int)

fun main() {
  val c1 = Car("Ford", "Mustang", 1969)
  val c2 = Car("BMW", "X5", 1999)
  val c3 = Car("Tesla", "Model S", 2020)
}
We just launchedW3Schools videos
Get certifiedby completinga course today!
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com
Your message has been sent to W3Schools.
Select multiple columns in a Pandas DataFrame

To select multiple columns in a Pandas DataFrame, we can create new a DataFrame from the existing DataFrame
Create a two-dimensional, size-mutable, potentially heterogeneous tabular data, df.
Create a two-dimensional, size-mutable, potentially heterogeneous tabular data, df.
Print the input DataFrame.
Print the input DataFrame.
Create a new DataFrame, df1, with selection of multiple columns.
Create a new DataFrame, df1, with selection of multiple columns.
Print the new DataFrame with multiple selected columns.
Print the new DataFrame with multiple selected columns.
 Live Demo
import pandas as pd

df = pd.DataFrame(
   {
      "x": [5, 2, 1, 9],
      "y": [4, 1, 5, 10],
      "z": [4, 1, 5, 0]
   }
)

print "Input DataFrame is:\n", df

df1 = df[['x', 'y']]
print "After selecting multiple columns:\n", df1
Input DataFrame is:
   x  y  z
0  5  4  4
1  2  1  1
2  1  5  5
3  9 10  0

After selecting multiple columns:
   x  y
0  5  4
1  2  1
2  1  5
3  9 10
Convert ASCII TO UTF-8 Encoding in PHP?

If we know that the current encoding is ASCII, the 'iconv' function can be used to convert ASCII to UTF-8. The original string can be passed as a parameter to the iconv function to encode it to UTF-8.
 Live Demo
<?php
   $str = "ábrêcWtë";
   echo 'Original :', ("$str"), PHP_EOL;
   echo 'Plain :', iconv("UTF-8", "ISO-8859-1", $str), PHP_EOL;
?>
A string with special characters is assigned to ‘str’ variable. This is passed to the ‘iconv’ function, with the encoding that it currently is in, and the encoding to which it needs to be converted to.
This will produce the following output −
Original :ábrêcWtë Plain :�br�cWt�
Another method is to detect the encoding and then converting it to an appropriate encoding −
 Live Demo
$string = "ábrêcWtë";
print(mb_detect_encoding ($string));
$string = mb_convert_encoding($string, "UTF-8");
print(mb_detect_encoding ($string));
A string value with special characters is assigned to ‘string; variable. This is passed to the ‘mb_convert_encoding’ function that converts it to the target encoding.
This will produce the following output −
UTF-8UTF-8
What does “unsigned” in MySQL mean and when to use it?

The “unsigned” in MySQL is a data type. Whenever we write an unsigned to any column that means you cannot insert negative numbers. Suppose, for a very large number you can use unsigned type.
The maximum range with unsigned int is 4294967295.
Note: If you insert negative value you will get a MySQL error.
Here is the example demo of unsigned type. Let us first create a table with “unsigned” column. The following is the query to create a table −
mysql> create table UnsignedDemoWithPositiveValue
   -> (
   -> Distance int unsigned
   -> );
Query OK, 0 rows affected (0.86 sec)
If you will try to insert the upper value with unsigned 4294967295, then an error will generate since the value is out of range.
Inserting out of range value.
mysql> insert into UnsignedDemoWithPositiveValue values(4294967296);
ERROR 1264 (22003): Out of range value for column 'Distance' at row 1
In the above example, I have inserted 4294967296, which is out of range, therefore error generates.
Now I am inserting another value 4294967295 into the table.
mysql> insert into UnsignedDemoWithPositiveValue values(4294967295);
Query OK, 1 row affected (0.30 sec)
Above, you can see that the query executed successfully.
Now, let us see another example. If you insert negative records, then the following error can be seen −
mysql> insert into UnsignedDemoWithPositiveValue values(-124);
ERROR 1264 (22003): Out of range value for column 'Distance' at row 1
I will now insert only positive value with value 124. The query is as follows −
mysql> insert into UnsignedDemoWithPositiveValue values(124);
Query OK, 1 row affected (0.86 sec)
As you can see above, the query executed successfully.
Let us display the record with the help of select statement. The query is as follows −
mysql> select *from UnsignedDemoWithPositiveValue;
Here is the output −
+------------+
| Distance   |
+------------+
| 4294967295 |
| 124        |
+------------+
2 rows in set (0.00 sec)
Lodash _.round() Method - GeeksforGeeks

09 Sep, 2020
Lodash is a JavaScript library that works on the top of underscore.js. Lodash helps in working with arrays, strings, objects, numbers, etc.
The _.round() method is used to compute number rounded to precision.
Syntax:
_.round(number, [precision = 0])
Parameters: This method accepts two parameters as mentioned above and described below:
number: This parameter holds the number to round.
[precision = 0]: This parameter holds the precision to round to.
Return Value: This method returns the rounded number.
Example 1: Here, const _ = require(‘lodash’) is used to import the lodash library into the file.
Javascript
// Requiring the lodash library  const _ = require("lodash");      // Use of _.round()  // method let gfg = _.round(7.56);         // Printing the output  console.log(gfg);
Output:
8
Example 2:  
Javascript
// Requiring the lodash library  const _ = require("lodash");      // Use of _.round()  // method let gfg = _.round(9.005, 2);         // Printing the output  console.log(gfg);
Output:
9.01
Example 3:  
Javascript
// Requiring the lodash library  const _ = require("lodash");      // Use of _.round()  // method let gfg = _.round(1980, -2);         // Printing the output  console.log(gfg);
Output:
2000
JavaScript-Lodash
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Differences between Functional Components and Class Components in React
Convert a string to an integer in JavaScript
How to Open URL in New Tab using JavaScript ?
How to read a local text file using JavaScript?
Hide or show elements in HTML using display property
Express.js express.Router() Function
Installation of Node.js on Linux
How to set input type date in dd-mm-yyyy format using HTML ?
Differences between Functional Components and Class Components in React
How to create footer to stay at the bottom of a Web page?
Python program to find all Strong Numbers in given list

24 Jun, 2019
Given a list, write a Python program to find all the Strong numbers in a given list of numbers.
A Strong Number is a number that is equal to the sum of factorial of its digits.
Examples:
Input : [1, 2, 5, 145, 654, 34] 
Output : [1, 2, 145]

Input : [15, 58, 75, 675, 145, 2]
Output : [145, 2]

Explanation :
We defined 2 functions here: First is factorial() and second is strong_number().
As soon as strong_number() is called, the list is passed to the function and stored in the formal argument list.
For loop iterates for every element in list, temp is a temporary variable on which calculation is done, then factorial() function is called on the remainder of temp mod 10 and passed it to the factorial function.
Now when temp equates to 0, it exits the while loop and checks whether sum is equal to x or not. If True then it is added in the list using append() function which is predefined for list and is used to add elements in the list and if there is no strong number then it will return an empty list.
Below is the Python implementation:
# Python program to find all # Strong Numbers in given listdef factorial(number):    if(number == 0 or number == 1):        fact = 1    else:        fact = number * factorial(number - 1)    return fact  def strong_number(list):    new_list =[]      for x in list:        temp = x        sum = 0        while(temp):            rem = temp % 10            sum += factorial(rem)            temp = temp // 10        if(sum == x):            new_list.append(x)        else:            pass                    return new_list          # Driver Codeval_list = [1, 2, 5, 145, 654, 34]strong_num_list = strong_number(val_list)print(strong_num_list)
[1, 2, 145]

Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Python String | replace()
How to Install PIP on Windows ?
Python program to convert a list to string
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python | Convert string dictionary to dictionary
Volume of solid of revolution

20 Jun, 2020
A solid of revolution is generated by revolving a plane area R about a line L known as axis of revolution in the plane. Below image shows an example of solid of revolution.
We shall calculate the volume of solid of revolution when the equation of the curve is given in parametric form and polar form.
Parametric Form :If the equation of curve in parametric form is given by:x= f(t) and y= g(t) Where t varies from t1to t2, then the volume of revolution:About x-axis –About y-axis –Polar form:Given the equation of curve in polar form as r=f(θ), where θ varies from θ1 to θ2, the volume of revolution is calculated using the given formulas:About the initial line OX i.e., x-axis (θ=0) –About the line perpendicular to the initial line i.e. along OY (θ=π/2) –
Parametric Form :If the equation of curve in parametric form is given by:x= f(t) and y= g(t) Where t varies from t1to t2, then the volume of revolution:About x-axis –About y-axis –
x= f(t) and y= g(t) 
Where t varies from t1to t2, then the volume of revolution:
About x-axis –
About y-axis –
Polar form:Given the equation of curve in polar form as r=f(θ), where θ varies from θ1 to θ2, the volume of revolution is calculated using the given formulas:About the initial line OX i.e., x-axis (θ=0) –About the line perpendicular to the initial line i.e. along OY (θ=π/2) –
About the initial line OX i.e., x-axis (θ=0) –
About the line perpendicular to the initial line i.e. along OY (θ=π/2) –
Let us see the following examples.
Example-1:Determine the volume of solid of revolution generated by revolving the curve whose parametric equations are –
X= 2t+3 and y= 4t2-9 
About x-axis for t= -3/2 to 3/2.
Explanation :We know that volume of solid revolved about x-axis when equation is in parametric form is given byUsing this value we get
Example-2:Find the volume of solid generated by revolving curve r= 2a cos θ about the initial line OX.
Explanation :We know that volume of solid generated by revolving about OX in when equation is in polar form is given byAlso for OX, θ=0So Put Using these values we get
Engineering Mathematics
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
time.h localtime() function in C with Examples

07 Nov, 2019
The localtime() function is defined in the time.h header file. The localtime( ) function return the local time of the user i.e time present at the task bar in computer.
Syntax:
tm* localtime(const time_t* t_ptr);
Parameter: This function accepts a parameter t_ptr which represents the pointer to time_t object.
Return Value: This function returns a pointer to a struct tm object.
Below program illustrate the localtime() function in C:
// C program to demonstrate// example of localtime() function.  #include <stdio.h>#include <time.h>  int main(){      struct tm* local;    time_t t = time(NULL);      // Get the localtime    local = localtime(&t);      printf("Local time and date: %s\n",           asctime(local));      return 0;}
Local time and date: Mon Sep 23 08:25:53 2019

Note: To understand this function clearly, change the time and date of your computer system and run the code again.
C-Library
C Language
C Programs
C Quiz
Competitive Programming
Puzzles
Quizzes
Puzzles
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
SQL Query to Get Column Names From a Table

10 Oct, 2021
SQL stands for Structured Query Language. It is a language used to interact with the database, i.e to create a database, to create a table in the database, to retrieve data or update a table in the database, etc. SQL is an ANSI(American National Standards Institute) standard. Using SQL, we can do many things. For example – we can execute queries, we can insert records into a table, we can update records, we can create a database, we can create a table, we can delete a table, etc. 
In this article, we will look at how to get column names from a table.
Step 1: Creating Database
We are creating the database using CREATE query.
Query:
CREATE DATABASE Test
Output:
The command is completed successfully. It means the Database named Test is created. The next step is to create a table.
Step 2: Creating table
The Data table will have three fields FirstName, LastName, and Age. Using the below query we will be creating a table.
Query:
CREATE TABLE Data(FirstName varchar(40),
LastName varchar(30),Age int, );
Output:
The Data table is created in the database.
Step 3: Insert  Data into the Table
Using the below query we will be adding the data to our table.
Query:
INSERT INTO Data
VALUES ('Rahul','Sharma',15),
   ('Soha','Shaikh',24),
   ('Vivek','Rao',18),
   ('Sonali ','Rane',20);
Output:
We have added the data to our table. We can verify the data in the table using the SELECT query as below.
Step 4: View Table Data
Query:
SELECT * FROM Data
Output:
Step 5: Getting column names from the table
We will be using sys. columns to get the column names in a table. It is a system table and used for maintaining column information. It contains the following information about columns:
Name – Name of the column.
Object_id – ID of the object for the table in which column belongs.
Column_id – ID of the column.
user_type_id – ID of the user-defined column type.
max_length – Maximum length of the column (In bytes).
is_nullable – 1=Column is nullable.
Query:
SELECT name FROM sys.columns WHERE object_id = OBJECT_ID('Data')  
Output:
Picked
SQL-Query
SQL-Server
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Update Multiple Columns in Single Update Statement in SQL?
Window functions in SQL
What is Temporary Table in SQL?
SQL using Python
SQL | Sub queries in From Clause
SQL Query to Find the Name of a Person Whose Name Starts with Specific Letter
RANK() Function in SQL Server
SQL Query to Convert VARCHAR to INT
SQL Query to Compare Two Dates
SQL | DROP, TRUNCATE
How to create a ComboBox using JavaFX?

A combo box is similar to a choice box it holds multiple items and, allows you to select one of them. It can be formed by adding scrolling to a drop-down list. You can create a combo box by instantiating the javafx.scene.control.ComboBox class.
The following Example demonstrates the creation of a ComboBox.
import javafx.application.Application;
import javafx.collections.ObservableList;
import javafx.geometry.Insets;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.stage.Stage;
import javafx.scene.layout.HBox;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontPosture;
import javafx.scene.text.FontWeight;
public class ComboBoxExample extends Application {
   public void start(Stage stage) {
      //Setting the label
      Label label = new Label("Select Desired Course:");
      Font font = Font.font("verdana", FontWeight.BOLD, FontPosture.REGULAR, 12);
      label.setFont(font);
      //Creating a combo box
      ComboBox<String> combo = new ComboBox<String>();
      //Setting the prompt text of the combo box
      combo.setPromptText("Select Course");
      //Getting the observable list of the combo box
      ObservableList<String> list = combo.getItems();
      //Adding items to the combo box
      list.add("Java");
      list.add("C++");
      list.add("Python");
      list.add("Big Data");
      list.add("Machine Learning");
      HBox hbox = new HBox(15);
      //Setting the space between the nodes of a HBox pane
      hbox.setPadding(new Insets(75, 150, 50, 60));
      hbox.getChildren().addAll(label, combo);
      //Creating a scene object
      Scene scene = new Scene(new Group(hbox), 595, 280, Color.BEIGE);
      stage.setTitle("Combo Box");
      stage.setScene(scene);
      stage.show();
   }
   public static void main(String args[]){
      launch(args);
   }
}
SWING - WindowEvent Class

The object of this class represents the change in state of a window.This low-level event is generated by a Window object when it is opened, closed, activated, deactivated, iconified, or deiconified, or when the focus is transfered into or out of the Window.
Following is the declaration for java.awt.event.WindowEvent class −
public class WindowEvent
   extends ComponentEvent

Following are the fields for java.awt.event.WindowEvent class −
static int WINDOW_ACTIVATED − The window-activated event type.
static int WINDOW_ACTIVATED − The window-activated event type.
static int WINDOW_CLOSED − The window closed event.
static int WINDOW_CLOSED − The window closed event.
static int WINDOW_CLOSING − The "window is closing" event.
static int WINDOW_CLOSING − The "window is closing" event.
static int WINDOW_DEACTIVATED − The window-deactivated event type.
static int WINDOW_DEACTIVATED − The window-deactivated event type.
static int WINDOW_DEICONIFIED − The window deiconified event type.
static int WINDOW_DEICONIFIED − The window deiconified event type.
static int WINDOW_FIRST − The first number in the range of IDs used for window events.
static int WINDOW_FIRST − The first number in the range of IDs used for window events.
static int WINDOW_GAINED_FOCUS − The window-gained-focus event type.
static int WINDOW_GAINED_FOCUS − The window-gained-focus event type.
static int WINDOW_ICONIFIED − The window iconified event.
static int WINDOW_ICONIFIED − The window iconified event.
static int WINDOW_LAST − The last number in the range of IDs used for window events.
static int WINDOW_LAST − The last number in the range of IDs used for window events.
static int WINDOW_LOST_FOCUS − The window-lost-focus event type.
static int WINDOW_LOST_FOCUS − The window-lost-focus event type.
static int WINDOW_OPENED − The window opened event.
static int WINDOW_OPENED − The window opened event.
static int WINDOW_STATE_CHANGED − The window-state-changed event type.
static int WINDOW_STATE_CHANGED − The window-state-changed event type.
WindowEvent(Window source, int id)
Constructs a WindowEvent object.
WindowEvent(Window source, int id, int oldState, int newState)
Constructs a WindowEvent object with the specified previous and new window states.
WindowEvent(Window source, int id, Window opposite)
Constructs a WindowEvent object with the specified opposite Window.
WindowEvent(Window source, int id, Window opposite, int oldState, int newState)
Constructs a WindowEvent object.
int getNewState()
For WINDOW_STATE_CHANGED events returns the new state of the window.
int getOldState()
For WINDOW_STATE_CHANGED events returns the previous state of the window.
Window getOppositeWindow()
Returns the other Window involved in this focus or activation change.
Window getWindow()
Returns the originator of the event.
String paramString()
Returns a parameter string identifying this event.
This class inherits methods from the following classes −
p5.js | hide() Function

08 Jun, 2021
The hide() function is an inbuilt function which is used to hide the current element. Essentially display: none is used for this style.This function requires p5.dom library. So add the following line in the head section of the index.html file.  
javascript
<script language="javascript"    type="text/javascript" src="path/to/p5.dom.js"></script>
Syntax:  
hide()
Parameters: This function does not accepts any parameters.Below examples illustrate the hide() function in p5.js:Example 1: This example uses hide() function to hide the div element.  
javascript
function setup() {         // Create Canvas of given size    var cvs = createCanvas(600, 250);} function draw() {     // Set the background color  background('green');        // Use createDiv() function to  // create a div element  var myDiv1 = createDiv('GeeksforGeeks');     // Set the position of div element  myDiv1.position(170, 30);      // Set the div size  myDiv1.size(200, 100);     // Set the font-size of text  myDiv1.style('font-size', '36px');     // Use createDiv() function to  // create a div element  var myDiv = createDiv('A computer science portal for geeks');     // Set the position of div element  myDiv.position(180, 80);      // Set the div size  myDiv.size(200, 100);     // Set the font-size of text  myDiv.style('font-size', '24px');     // Set the font-size of text  myDiv.style('border', '1px solid black');     // Set the font-size of text  myDiv.style('text-align', 'center');     // Set the font color  myDiv.style('color', 'white');     // Hide the div element  myDiv.hide();   }
Output:  
Example 2: This example uses hide() and show() function to display the div element.  
javascript
function setup() {         // Create Canvas of given size    var cvs = createCanvas(600, 250);} function draw() {     // Set the background color  background('green');        // Use createDiv() function to  // create a div element  var myDiv1 = createDiv('GeeksforGeeks');     // Set the position of div element  myDiv1.position(170, 30);      // Set the div size  myDiv1.size(200, 100);     // Set the font-size of text  myDiv1.style('font-size', '36px');     // Use createDiv() function to  // create a div element  var myDiv = createDiv('A computer science portal for geeks');     // Set the position of div element  myDiv.position(180, 80);      // Set the div size  myDiv.size(200, 100);     // Set the font-size of text  myDiv.style('font-size', '24px');     // Set the font-size of text  myDiv.style('border', '1px solid black');     // Set the font-size of text  myDiv.style('text-align', 'center');     // Set the font color  myDiv.style('color', 'white');     // Hide the div element  myDiv.hide();     // Show the div element  myDiv.show();}
Output:  
 
anikaseth98
JavaScript-p5.js
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to count the frequency of unique values in NumPy array?

02 Sep, 2020
Let’s see How to count the frequency of unique values in NumPy array. Python’s numpy library provides a numpy.unique() function to find the unique elements and it’s corresponding frequency in a numpy array.
Syntax: numpy.unique(arr, return_counts=False)
Return: Sorted unique elements of an array with their corresponding frequency counts NumPy array.
Now, Let’s see examples:
Example 1:
Python3
# import libraryimport numpy as np  ini_array = np.array([10, 20, 5,                      10, 8, 20,                      8, 9])  # Get a tuple of unique values # and their frequency in# numpy arrayunique, frequency = np.unique(ini_array,                               return_counts = True)# print unique values arrayprint("Unique Values:",       unique)  # print frequency arrayprint("Frequency Values:",      frequency)
Output:
Unique Values: [ 5  8  9 10 20]
Frequency Values: [1 2 1 2 2]

Example 2:
Python3
# import libraryimport numpy as np  # create a 1d-arrayini_array = np.array([10, 20, 5,                    10, 8, 20,                    8, 9])  # Get a tuple of unique values # amnd their frequency # in numpy arrayunique, frequency = np.unique(ini_array,                              return_counts = True)   # convert both into one numpy arraycount = np.asarray((unique, frequency ))  print("The values and their frequency are:\n",     count)
Output:
The values and their frequency are:
[[ 5  8  9 10 20]
[ 1  2  1  2  2]]
Example 3:
Python3
# import libraryimport numpy as np  # create a 1d-arrayini_array = np.array([10, 20, 5,                      10, 8, 20,                      8, 9])  # Get a tuple of unique values # and their frequency in# numpy arrayunique, frequency = np.unique(ini_array,                               return_counts = True)   # convert both into one numpy array # and then transpose itcount = np.asarray((unique,frequency )).T  print("The values and their frequency are in transpose form:\n",     count)
Output:
The values and their frequency are in transpose form:
[[ 5  1]
[ 8  2]
[ 9  1]
[10  2]
[20  2]]
Python numpy-Matrix Function
Python-numpy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Data Classes in Python (dataclasses)

The dataclasses is a new module added in Python's standard library since version 3.7. It defines @dataclass decorator that automatically generates constructor magic method __init__(), string representation method __repr__(), the __eq__() method which overloads == operator (and a few more) for a user defined class.
The dataclass decorator has following signature
dataclass(init=True, repr=True, eq=True, order=False, unsafe_hash=False, frozen=False)
All the arguments take a Boolean value indicating whether a respective magic method or methods will be automatically generated or not.
The 'init' argument is True by default. It will automatically generate __init__() method for the class.
Let us define Student class using dataclass decorator as follows
from dataclasses import dataclass

@dataclass
class Student(object):
   name : str
   age : int
   percent : float
The auto-generated __init__() method is like
def __init__(self, name: str, age: int, percent: float):
   self.name = name
   self.age = age
   self.percent = percent
If the class explicitly defines __init__() method, then init parameter is ignored.
The repr argument is true also by default. Hence __repr__() method will be generated automatically. The __repr__() is a formal string representation of object. If the class already defines __repr__(), this parameter is ignored.
The eq argument is by default true . This will auto-generate the __eq__() method. This method gets called in response to equals comparison operator (==). Again, if the class already defines __eq__(), this parameter is ignored.
If the 'order' parameter is true (the default is False), the magic methods for comparison, __lt__(), __le__(), __gt__(), and __ge__() methods will beauto- generated, they implement comparison operators < <= > ans >= respectively. If order is true and eq is false, a ValueError is raised. If the class already defines any ofthese methods), it reults into TypeError.
unsafe_hash argument if False (the default), a __hash__() method is generated according to how eq and frozen are set.
frozen argument: If true (the default is False), emulates read-only frozen instances.
>>> from data_class import Student
>>> s1=Student('Naveen', 21, 50.50)
>>> s2=Student('Mangesh', 20, 50.00)
>>> s1==s2
False
This function converts class instance into a dictionary object.
>>> import dataclasses
>>> dataclasses.asdict(s1)
{'name': 'Naveen', 'age': 21, 'percent': 50.5}
This function converts class instance into a tuple object.
>>> dataclasses.astuple(s2)
('Mahesh', 20, 50.0)
This function creates a new dataclass from the list of tuples given as fields argument.
>>> NewClass=dataclasses.make_dataclass('NewClass', [('x',int),('y',float)])
>>> n = NewClass(10,20)
>>> n
NewClass(x=10, y=20)
Batch Script - Renaming Folders

For renaming folders, Batch Script provides the REN or RENAME command.
RENAME [drive:][path][directoryname1 | filename1] [directoryname2 | filename2]

Let’s look at some examples of renaming folders.
ren Example Example1

The above command will rename the folder called Example in the current working directory to Example1.
ren C:\Example Example1

The above command will rename the folder called Example in C Drive to Example1.
 Print
 Add Notes
 Bookmark this page
How can I pass arguments to Tkinter button's callback command?

Tkinter Buttons are used for handling certain operations in the application. In order to handle such events, we generally pass the defined function name as the value in the callback command. For a particular event, we can also pass the argument to the function in the button’s command.
There are two ways to pass the argument to the tkinter button command −
Using Lambda or anonymous function
Using Partials
In this example, we will create a simple application that will contain a text label and a button to change the value of label text. We will pass the label as the argument in the button command by using lambda function.
#Import necessary Library
from tkinter import *
from tkinter import ttk
#Create an instance of tkinter window
win= Tk()
#Set the geometry of tkinter window
win.geometry("750x250")
#Define the function to change the value in label widget
def change_text(label):
   label.configure(text= "Hey, I am Label-2", background="gray91")
#Create a Label
label = Label(win, text= "Hey, I am Label-1", font= ('Helvetica 15 underline'), background="gray76")
label.pack(pady=20)
#Create a button
btn= ttk.Button(win, text= "Change", command= lambda:change_text(label))
btn.pack(pady=10)
win.mainloop()
Running the above code will display a window which contains a text label and a button to change the value of the label.
Now click on “Change” button to change the value of the label widget.
MongoDB query for capped sub-collection in an array

In MongoDB, you cannot use capped for sub-collection. However, use capped on the overall document. To display a specific number of values from an array, prefer $slice.
Let us create a collection with documents −
> db.demo319.insertOne({"Scores":[100,345,980,890]});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e50ecf6f8647eb59e562064")
}
> db.demo319.insertOne({"Scores":[903,10004,84575,844]});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e50ed01f8647eb59e562065")
}
Display all documents from a collection with the help of find() method −
> db.demo319.find().pretty();
This will produce the following output −
{
   "_id" : ObjectId("5e50ecf6f8647eb59e562064"),
   "Scores" : [
      100,
      345,
      980,
      890
   ]
}
{
   "_id" : ObjectId("5e50ed01f8647eb59e562065"),
   "Scores" : [
      903,
      10004,
      84575,
      844
   ]
}
Following is the query for capped sub-collection in an array −
> db.demo319.aggregate([
... { $project: {TwoScores: { $slice: [ "$Scores", 2 ] } } }
... ])
This will produce the following output −
{ "_id" : ObjectId("5e50ecf6f8647eb59e562064"), "TwoScores" : [ 100, 345 ] }
{ "_id" : ObjectId("5e50ed01f8647eb59e562065"), "TwoScores" : [ 903, 10004 ] }
How to add border to an element on mouse hover using CSS ? - GeeksforGeeks

14 Dec, 2020
We have given a web page containing elements and the task is to add border to an element on mouse move over (hover) using CSS. When we add a border to an element on hovering the mouse, it affects the position of the other nearest element. To remove this problem, we can use the CSS margin property.
Example:   
HTML
<!DOCTYPE html><html lang="en">  <head>    <meta charset="utf-8">      <title>        Add CSS Border on Mouse Hover         without Pushing Content    </title>          <style>        ul {            padding: 0;            list-style: none;        }          ul li {            float: left;            margin: 10px;        }          ul ul li {            display: block;        }          ul li:hover {            border: 5px solid green;            overflow: hidden;        }          ul ul li:hover img {            margin: -5px;        }    </style></head>  <body>    <h2>GeeksForGeeks</h2>          <h2>        How to apply border to an element         on mouse hover without affecting         the layout in CSS?    </h2>          <ul>        <li>Home</li>        <li>news</li>        <li>Images</li>        <li>Music</li>    </ul></body>  </html>
Output:
Supported Browsers:
Google Chrome
Internet Explorer
Firefox
Safari
Opera
 
 
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
CSS-Misc
HTML-Misc
CSS
HTML
Web Technologies
Web technologies Questions
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to apply style to parent if it has child with CSS?
Types of CSS (Cascading Style Sheet)
How to position a div at the bottom of its container using CSS?
Design a web page using HTML and CSS
How to Upload Image into Database and Display it using PHP ?
How to set the default value for an HTML <select> element ?
Hide or show elements in HTML using display property
How to Insert Form Data into Database using PHP ?
REST API (Introduction)
Types of CSS (Cascading Style Sheet)