code-rag-bench/online-tutorials huggingface dataset:
MySQL LIKE query with dynamic array?

To implement LIKE query with dynamic array, the syntax is as follows −
select *from yourTableName
   where yourColumnName2 like "%yourValue%"
   order by yourColumnName1 asc
   limit yourLimitValue;
Let us create a table −
mysql> create table demo74
   -> (
   -> user_id int not null auto_increment primary key,
   -> user_names varchar(250)
   -> )
   -> ;
Query OK, 0 rows affected (0.67
Insert some records into the table with the help of insert command −
mysql> insert into demo74(user_names) values("John Smith1,John Smith2,John Smith3");
Query OK, 1 row affected (0.18

mysql> insert into demo74(user_names) values("John Smith1");
Query OK, 1 row affected (0.15

mysql> insert into demo74(user_names) values("David Smith1");
Query OK, 1 row affected (0.12

mysql> insert into demo74(user_names) values("John Smith1,John Smith2,John Smith3,John Smith4");
Query OK, 1 row affected (0.10
Display records from the table using select statement −
mysql> select *from demo74;
This will produce the following output −
+---------+-------------------------------------------------+| user_id | user_names                                      |+---------+-------------------------------------------------+|       1 | John Smith1,John Smith2,John Smith3             ||       2 | John Smith1                                     ||       3 | David Smith1                                    ||       4 | John Smith1,John Smith2,John Smith3,John Smith4 |+---------+-------------------------------------------------+
+---------+-------------------------------------------------+
| user_id | user_names                                      |
+---------+-------------------------------------------------+
|       1 | John Smith1,John Smith2,John Smith3             |
|       2 | John Smith1                                     |
|       3 | David Smith1                                    |
|       4 | John Smith1,John Smith2,John Smith3,John Smith4 |
+---------+-------------------------------------------------+
Following is the MySQL LIKE query with dynamic array −
mysql> select *from demo74
-> where user_names like "%John Smith1%"
-> order by user_id asc
-> limit 100;
This will produce the following output −
+---------+-------------------------------------------------+| user_id | user_names                                      |+---------+-------------------------------------------------+|       1 | John Smith1,John Smith2,John Smith3             ||       2 | John Smith1                                     ||       4 | John Smith1,John Smith2,John Smith3,John Smith4 |+---------+-------------------------------------------------+3 rows in set (0.00 sec)
+---------+-------------------------------------------------+
| user_id | user_names                                      |
+---------+-------------------------------------------------+
|       1 | John Smith1,John Smith2,John Smith3             |
|       2 | John Smith1                                     |
|       4 | John Smith1,John Smith2,John Smith3,John Smith4 |
+---------+-------------------------------------------------+
3 rows in set (0.00 sec)
C# program to remove all duplicates words from a given sentence

Set a string with duplicate words.
string str = "One Two Three One";
Above, you can see the word “One” comes twice.
To remove dulicate words, you can try to run the following code in C# −
 Live Demo
using System;
using System.Linq;
public class Program {
   public static void Main() {
      string str = "One Two Three One";
      string[] arr = str.Split(' ');
      Console.WriteLine(str);
      var a =
      from k in arr
      orderby k
      select k;
      Console.WriteLine("After removing duplicate words...");
      foreach(string res in a.Distinct()) {
         Console.Write(" " + res.ToLower());
      }
      Console.ReadLine();
   }
}
One Two Three One
After removing duplicate words...
one three two
Python | os.path.splitext() method - GeeksforGeeks

22 May, 2019
OS module in Python provides functions for interacting with the operating system. OS comes under Python’s standard utility modules. This module provides a portable way of using operating system dependent functionality. os.path module is submodule of OS module in Python used for common pathname manipulation.
os.path.splitext() method in Python is used to split the path name into a pair root and ext. Here, ext stands for extension and has the extension portion of the specified path while root is everything except ext part.ext is empty if specified path does not have any extension. If the specified path has leading period (‘.’), it will be ignored.
For example consider the following path names:
      path name                          root                        ext
/home/User/Desktop/file.txt    /home/User/Desktop/file              .txt
/home/User/Desktop             /home/User/Desktop                  {empty}
file.py                               file                          .py
.txt                                  .txt                         {empty}   

Syntax: os.path.splitext(path)
Parameter:path: A path-like object representing a file system path. A path-like object is either a str or bytes object representing a path.
Return Type: This method returns a tuple that represents root and ext part of the specified path name.
# Python program to explain os.path.splitext() method     # importing os module import os  # pathpath = '/home/User/Desktop/file.txt'  # Split the path in # root and ext pairroot_ext = os.path.splitext(path)  # print root and ext# of the specified pathprint("root part of '% s':" % path, root_ext[0])print("ext part of '% s':" % path, root_ext[1], "\n")    # pathpath = '/home/User/Desktop/'  # Split the path in # root and ext pairroot_ext = os.path.splitext(path)  # print root and ext# of the specified pathprint("root part of '% s':" % path, root_ext[0])print("ext part of '% s':" % path, root_ext[1])
root part of '/home/User/Desktop/file.txt': /home/User/Desktop/file
ext part of '/home/User/Desktop/file.txt': .txt 

root part of '/home/User/Desktop/': /home/User/Desktop/
ext part of '/home/User/Desktop/': 

Reference: https://docs.python.org/3/library/os.path.html
Python OS-path-module
python-os-module
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Read a file line by line in Python
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Iterate over a list in Python
Python String | replace()
*args and **kwargs in Python
Reading and Writing to text files in Python
Create a Pandas DataFrame from Lists
Node.js nodemon Module - GeeksforGeeks

15 Oct, 2020
The nodemon Module is a module that develop node.js based applications by automatically restarting the node application when file changes in the directory are detected. Nodemon does not require any change in the original code and method of development.
Advantages of Using nodemon Module:
It is easy to use and easy to get started.It does not affect the original code and no instance require to call it.It help to reduce the time of typing the default syntax node <file name> for execution again and again.
It is easy to use and easy to get started.
It does not affect the original code and no instance require to call it.
It help to reduce the time of typing the default syntax node <file name> for execution again and again.
Installation: Install the module using the following command:
npm install -g nodemon
After installing the module you can check the current version of the module by typing on console as shown below:
nodemon version
Usage:
The nodemon wraps your application, so you can pass all the arguments you would normally pass to your app:nodemon [your node app]
Options available for nodemon are shown below:nodemon -h

The nodemon wraps your application, so you can pass all the arguments you would normally pass to your app:nodemon [your node app]

nodemon [your node app]

Options available for nodemon are shown below:nodemon -h

nodemon -h

Steps to run the program: Use the following command to run the file as shown below:
nodemon index.js
It automatically check the statements and the syntax of the program while writing new statements and show the result on the console.
Node.js-Misc
Node.js
Web Technologies
Web technologies Questions
Write From Home
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Node.js fs.writeFile() Method
Node.js fs.readFile() Method
How to install the previous version of node.js and npm ?
Difference between promise and async await in Node.js
How to use an ES6 import in Node.js?
Remove elements from a JavaScript Array
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
GATE | GATE-CS-2009 | Question 55 - GeeksforGeeks

04 Feb, 2020
Consider the following relational schema:
Suppliers(sid:integer, sname:string, city:string, street:string)
Parts(pid:integer, pname:string, color:string)
Catalog(sid:integer, pid:integer, cost:real)
Consider the following relational query on the above database:
SELECT S.sname
    FROM Suppliers S
        WHERE S.sid NOT IN (SELECT C.sid
                            FROM Catalog C
                            WHERE C.pid NOT IN (SELECT P.pid  
                                                FROM Parts P
                                                WHERE P.color<> 'blue'))
Assume that relations corresponding to the above schema are not empty. Which one of the following is the correct interpretation of the above query?(A) Find the names of all suppliers who have supplied a non-blue part.(B) Find the names of all suppliers who have not supplied a non-blue part.(C) Find the names of all suppliers who have supplied only blue parts.(D) Find the names of all suppliers who have not supplied only blue parts.Answer: (D)Explanation: None option matched because given query returns suppliers who have not supplied any blue parts. That means it can include other than blue parts.
(A): False, as this may include blue parts and may not include “null” parts.
(B): Obviously false because it returning other than any blue part.
(C): Obviously false because it does not return this.
(D): Correct. Please try here: http://sqlfiddle.com/#!9/9ae12d/1/0
This explanation is contributed by Archit Garg.Quiz of this Question
Ashish Goyal 4
ArchitGarg4
GATE-CS-2009
GATE-GATE-CS-2009
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | Gate IT 2007 | Question 25
GATE | GATE-CS-2000 | Question 41
GATE | GATE-CS-2001 | Question 39
GATE | GATE-CS-2005 | Question 6
GATE | GATE MOCK 2017 | Question 21
GATE | GATE-CS-2006 | Question 47
GATE | GATE MOCK 2017 | Question 24
GATE | Gate IT 2008 | Question 43
GATE | GATE-CS-2009 | Question 38
GATE | GATE-CS-2003 | Question 90
Hive - Drop Database

This chapter describes how to drop a database in Hive. The usage of SCHEMA and DATABASE are same.
Drop Database is a statement that drops all the tables and deletes the database. Its syntax is as follows:
DROP DATABASE StatementDROP (DATABASE|SCHEMA) [IF EXISTS] database_name 
[RESTRICT|CASCADE];
The following queries are used to drop a database. Let us assume that the database name is userdb.
hive> DROP DATABASE IF EXISTS userdb;
The following query drops the database using CASCADE. It means dropping respective tables before dropping the database.
hive> DROP DATABASE IF EXISTS userdb CASCADE;
The following query drops the database using SCHEMA.
hive> DROP SCHEMA userdb;
This clause was added in Hive 0.6.
The JDBC program to drop a database is given below.
import java.sql.SQLException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.DriverManager;

public class HiveDropDb {
   private static String driverName = "org.apache.hadoop.hive.jdbc.HiveDriver";
   
   public static void main(String[] args) throws SQLException {
   
      // Register driver and create driver instance
      Class.forName(driverName);
      
      // get connection
      Connection con = DriverManager.getConnection("jdbc:hive://localhost:10000/default", "", "");
      Statement stmt = con.createStatement();
      stmt.executeQuery("DROP DATABASE userdb");
      
      System.out.println(“Drop userdb database successful.”);
      
      con.close();
   }
}
Save the program in a file named HiveDropDb.java. Given below are the commands to compile and execute this program.
$ javac HiveDropDb.java
$ java HiveDropDb
Drop userdb database successful.


    50 Lectures 
     4 hours 

 Navdeep Kaur

    67 Lectures 
     4 hours 

 Bigdata Engineer

    109 Lectures 
     2 hours 

 Bigdata Engineer
 Print
 Add Notes
 Bookmark this page
HTML Window pageYOffset Property

The HTML Window pageYOffset property returns the value in pixel the current document has been scrolled vertically from the left corner.
Following is the syntax −
window.pageYOffset
Let us see an example of HTML Window pageYOffset Property −
 Live Demo
<!DOCTYPE html>
<html>
<style>
   body {
      color: #000;
      height: 100vh;
      background-color: #8BC6EC;
      background-image: linear-gradient(135deg, #8BC6EC 0%, #9599E2 100%) no-repeat;
      text-align: center;
   }
   .btn {
      background: #db133a;
      border: none;
      height: 2rem;
      border-radius: 2px;
      width: 40%;
      display: block;
      color: #fff;
      outline: none;
      cursor: pointer;
      margin: 1rem auto;
   }
   .box {
      width: 1000px;
      height: 1000px;
      background: teal;
      color: #fff;
      font-size: 1.5rem;
      text-align: left;
      padding: 20px;
   }
</style>
<body>
<h1>HTML Window pageYOffset Property Demo</h1>
<button onclick="scrollFn()" class="btn">Scroll</button>
<button onclick="display()" class="btn">Show pageYOffset value</button>
<div class="box"></div>
<script>
   function display() {
      document.querySelector('.box').innerHTML = 'The value of pageYOffset is: ' + window.pageYOffset + 'px';
   }
   function scrollFn() {
      window.scrollBy(0, 10);
   }
</script>
</body>
</html>
Click on “Show pageYOffset value” button to display the value of pageYOffset property:
Now click on “Scroll” button to scroll the page −
And then again click on “Show pageYOffset value” button to display the value of pageYOffset −
KeyPairGenerator genKeyPair() method in Java with Examples - GeeksforGeeks

12 May, 2021
The genKeyPair() method of java.security.KeyPairGenerator class is used to generate a key pair.If this KeyPairGenerator has not been initialized explicitly, provider-specific defaults will be used for the size and other (algorithm-specific) values of the generated keys.
This will generate a new key pair every time it is called.
Syntax: 
public final KeyPair genKeyPair()
Return Value: This method returns the generated key pair
Below are the examples to illustrate the genKeyPair() method
Note: These programs wont run in online IDE.
Example 1: With initialization  
Java
// Java program to demonstrate// genKeyPair() method import java.security.*;import java.util.*; public class GFG1 {    public static void main(String[] argv) throws Exception    {        try {             // creating the object of KeyPairGenerator            KeyPairGenerator kpg = KeyPairGenerator                                       .getInstance("RSA");             // initializing with 1024            kpg.initialize(1024);             // getting key pairs            // using genKeyPair() method            KeyPair kp = kpg.genKeyPair();             // printing the Keypair            System.out.println("Keypair : " + kp);        }         catch (NoSuchAlgorithmException e) {             System.out.println("Exception thrown : " + e);        }    }}
Output: 
Keypair : java.security.KeyPair@12a3a380
Example 2: Without Initialization
Java
// Java program to demonstrate// genKeyPair() method import java.security.*;import java.util.*; public class GFG1 {    public static void main(String[] argv) throws Exception    {        try {             // creating the object of KeyPairGenerator            KeyPairGenerator kpg = KeyPairGenerator                                       .getInstance("RSA");             // getting key pairs            // using generateKeyPair() method            KeyPair kp = kpg.genKeyPair();             // printing the number of byte            System.out.println("Keypair : " + kp);        }         catch (NoSuchAlgorithmException e) {             System.out.println("Exception thrown : " + e);        }    }}
Output: 
Keypair : java.security.KeyPair@12a3a380
 
anikakapoor
Java-Functions
Java-KeyPairGenerator
Java-security package
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Stream In Java
Constructors in Java
Exceptions in Java
Functional Interfaces in Java
Different ways of Reading a text file in Java
Generics in Java
Introduction to Java
Comparator Interface in Java with Examples
PriorityQueue in Java
How to remove an element from ArrayList in Java?
Training Custom NER. This blog explains, how to train and... | by Nishanth N | Towards Data Science

The article explains what is spacy, advantages of spacy, and how to get the named entity recognition using spacy. Now, all is to train your training data to identify the custom entity from the text.
SpaCy is an open-source software library for advanced natural language processing, written in the programming languages Python and Cython. The library is published under the MIT license and its main developers are Matthew Honnibal and Ines Montani, the founders of the software company Explosion.
Unlike NLTK, which is widely used for teaching and research, spaCy focuses on providing software for production usage. As of version 1.0, spaCy also supports deep learning workflows that allow connecting statistical models trained by popular machine learning libraries like Tensor Flow, PyTorch, or MXNet through its machine learning library Thinc.
While NLTK provides access to many algorithms to get something done, spaCy provides the best way to do it. It provides the fastest and most accurate syntactic analysis of any NLP library released to date. It also offers access to larger word vectors that are easier to customize.
After installation, you need to download a language model
You can start the training once you completed the first step.
→ Initially, import the necessary packages required for the custom creation process.
→ Now, the major part is to create your custom entity data for the input text where the named entity is to be identified by the model during the testing period.
→ Define the variables required for the training model to be processed.
→ Next, load a blank model for the process to carry out the NER action and set up the pipeline with only NER using create_pipe function.
→ Here, we want to train the recognizer by disabling the unnecessary pipeline except for NER. The nlp_update function can be used to train the recognizer.
Output: Training losses
100%|██████████| 3/3 [00:00<00:00, 32.00it/s]{'ner': 10.165919601917267}100%|██████████| 3/3 [00:00<00:00, 30.38it/s]{'ner': 8.44960543513298}100%|██████████| 3/3 [00:00<00:00, 28.11it/s]{'ner': 7.798196479678154}100%|██████████| 3/3 [00:00<00:00, 33.42it/s]{'ner': 6.569828731939197}100%|██████████| 3/3 [00:00<00:00, 29.20it/s]{'ner': 6.784278305480257}
→ To test the trained model,
→ Finally, save the model to your path which stored in the output_dir variable.
The full source code available on GitHub.
I hope you have now understood how to train your own NER model on top of the spaCy NER model. Thanks for reading!
Binary String With Substrings Representing 1 To N in C++

Suppose we have a binary string S and a positive integer N, we have to say true if and only if for every integer X from 1 to N, the binary representation of X is a substring of the given S. So if S = “0110” and N = 3, then the result will be true, as 1, 10 and 11 all are present in 0110.
To solve this, we will follow these steps −
Define a method to convert(), that will take n as input
Define a method to convert(), that will take n as input
ret := an empty string
ret := an empty string
while n is not 0ret := ret concatenate n mod 2n := n / 2
while n is not 0
ret := ret concatenate n mod 2
ret := ret concatenate n mod 2
n := n / 2
n := n / 2
reverse ret and return
reverse ret and return
From the main method, do the following
From the main method, do the following
for i := N, when i >= N/2, decrease i by 1temp := convert(i)if temp is not in S, return false
for i := N, when i >= N/2, decrease i by 1
temp := convert(i)
temp := convert(i)
if temp is not in S, return false
if temp is not in S, return false
return true.
return true.
Let us see the following implementation to get better understanding −
 Live Demo
#include <bits/stdc++.h>
using namespace std;
class Solution {
   public:
   string convert(int n){
      string ret = "";
      while(n){
         ret += (n % 2) + '0';
         n /= 2;
      }
      reverse(ret.begin(), ret.end());
      return ret;
   }
   bool queryString(string S, int N) {
      for(int i = N; i >= N/2; i-- ){
         string temp = convert(i);
         if(S.find(temp) == string::npos) return false;
      }
      return true;
   }
};
main(){
   Solution ob;
   cout << (ob.queryString("0110", 3));
}
"0110"
3
1
Can we pass objects as an argument in Java?

Yes, you can pass objects as arguments in Java. Consider the following example: Here we have a class with name Employee
In the following Java example, we a have a class with two instance variables name and age and a parameterized constructor initializing these variables.
We have a method coypObject() which accepts an object of the current class and initializes the instance variables with the variables of this object and returns it.
In the main method we are instantiating the Student class and making a copy by passing it as an argument to the coypObject() method.
 Live Demo
import java.util.Scanner;
public class Student {
   private String name;
   private int age;
   public Student(){
   }
   public Student(String name, int age){
      this.name = name;
      this.age = age;
   }
   public Student copyObject(Student std){
      this.name = std.name;
      this.age = std.age;
      return std;
   }
   public void displayData(){
      System.out.println("Name : "+this.name);
      System.out.println("Age : "+this.age);
   }
   public static void main(String[] args) {
      Scanner sc =new Scanner(System.in);
      System.out.println("Enter your name ");
      String name = sc.next();
      System.out.println("Enter your age ");
      int age = sc.nextInt();
      Student std = new Student(name, age);
      System.out.println("Contents of the original object");
      std.displayData();
      System.out.println("Contents of the copied object");
      Student copyOfStd = new Student().copyObject(std);
      copyOfStd.displayData();
   }
}
Enter your name
Krishna
Enter your age
20
Contents of the original object
Name : Krishna
Age : 20
Contents of the copied object
Name : Krishna
Age : 20
How to add multiple values in the Hashtable using PowerShell?

For example, we have a below-created hashtable.
PS C:\> $servicehash = @{Name='Spooler';State='Stopped';StartType='Automatic'}

PS C:\> $servicehash
Name       Value
----       -----
Name       Spooler
StartType  Automatic
State      Stopped
We need to add multiple values to the Name Key. If we directly append the value to the key it will treat it as a string and we will not get the desired output. See the example below.
PS C:\> $servicehash.Name += "Winrm"
PS C:\> $servicehash
Name Value
----       -----
Name       SpoolerWinrm
StartType  Automatic
State      Stopped
So to add the multiple values, we first need to declare a key as an array but by doing so it will clear the previous value so we have to add the previous value as well to the array.
PS C:\> $servicehash.Name = @()
PS C:\> $servicehash.Name += "Spooler"
PS C:\> $servicehash.Name += "Winrm"
PS C:\> $servicehash
Name      Value
----      -----
Name      {Spooler, Winrm}
StartType Automatic
State Stopped
PS C:\> $servicehash.Name
Spooler
Winrm
set copy() in python - GeeksforGeeks

02 Jan, 2018
The copy() method returns a shallow copy of the set in python. If we use “=” to copy a set to another set, when we modify in the copied set, the changes are also reflected in the original set. So we have to create a shallow copy of the set such that when we modify something in the copied set, changes are not reflected back in the original set.
Syntax:
set_name.copy()

set_name: Name of the set whose copy
          we want to generate.

Parameters:The copy() method for sets doesn’t take any parameters.
Return value:The function returns a shallow copy of the original set.
Below is the implementation of the above function:
# Python3 program to demonstrate the use# of join() function   set1 = {1, 2, 3, 4}   # function to copy the setset2 = set1.copy()   # prints the copied setprint(set2)       
Output:
{1, 2, 3, 4} 

Shallow Copy Example :
# Python program to demonstrate that copy # created using set copy is shallowfirst = {'g', 'e', 'e', 'k', 's'}second = first.copy()  # before addingprint 'before adding: 'print 'first: ',firstprint 'second: ', second   # Adding element to second, first does not# change.second.add('f')  # after addingprint 'after adding: 'print 'first: ', firstprint 'second: ', second 
Output:
before adding: 
first:  set(['s', 'e', 'k', 'g'])
second:  set(['s', 'e', 'k', 'g'])
after adding: 
first:  set(['s', 'e', 'k', 'g'])
second:  set(['s', 'e', 'k', 'g', 'f'])

python-set
Python
python-set
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Read JSON file using Python
Adding new column to existing DataFrame in Pandas
Python map() function
How to get column names in Pandas dataframe
Python Dictionary
Taking input in Python
Read a file line by line in Python
How to Install PIP on Windows ?
Enumerate() in Python
Iterate over a list in Python
How to verify if an element is displayed on screen in Selenium?

We can verify the visibility of web elements like edit box, checkbox, radio buttons and so on with the help of method listed bels −
isDisplayed()This method checks if a webelement is present on the screen.Syntax −Boolean result = driver.findElement(By.xpath("//span[text()=’Coding Ground’]")).isDispayed();
isDisplayed()
This method checks if a webelement is present on the screen.
Syntax −
Boolean result = driver.findElement(By.xpath("//span[text()=’Coding Ground’]")).isDispayed();
isSelected()This method checks the status of the radio button, check box and options in the static dropdown.Syntax −Boolean btnresult = driver.findElement(By.xpath("//xpath[contains(@class,’gsc-search-button’)]")).isSelected();
isSelected()
This method checks the status of the radio button, check box and options in the static dropdown.
Syntax −
Boolean btnresult = driver.findElement(By.xpath("//xpath[contains(@class,’gsc-search-button’)]")).isSelected();
isEnabled()Syntax −Boolean btnresult = driver.findElement(By.xpath("//xpath[contains(@class,’gsc-search-button’)]")).isEnabled();
isEnabled()
Syntax −
Boolean btnresult = driver.findElement(By.xpath("//xpath[contains(@class,’gsc-search-button’)]")).isEnabled();
This method if an element is enabled or not.
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 ElementStatus{
   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/tutor_connect/index.php";
      // to verify if a static dropdown is selected with option isSelected()
      boolean drpdwnStatus = driver.findElement(By.xpath("//select[@name=’selType’]"))
      .isSelected();
      // to verify if an element is present on page with isDisplayed()
      boolean editStatus = driver.findElement(By.xpath("//input[@id=’txtSearchText’]"))
      .isDisplayed();
      // to verify if a button is enabled with isEnabled()
      boolean butnStatus = driver.findElement(By.xpath("//input[@id=’searchSubmit’]"))
      .isEnabled();
      System.out.println("The button status is " + butnStatus);
      System.out.println
      ("The dropdown selected status is" + drpdwnStatus);
      System.out.println("The edit box display status is " + editStatus);
      driver.close();
   }
}
UGC-NET | UGC NET CS 2018 Dec – II | Question 2 - GeeksforGeeks

02 Nov, 2021
Suppose a system has 12 instances of some resources with n processes competing for that resource. Each process may require 4 instances of the resource. The maximum value of n for which the system never enters into deadlock is(A) 3(B) 4(C) 5(D) 6Answer: (A)Explanation: Given,Number of resources (R) = 12Max need for each resource (N) = 3
Since deadlock-free condition is:
R ≥ P(N − 1) + 1 
Where R is total number of resources,P is the number of processes, andN is the max need for each resource.
12 ≥ P(4 − 1) + 1
11 ≥ 3P
11/3 ≥ P
P ≤ 3.66 
(Take, floor value for maximum)Therefore, the largest value of P that will always avoid deadlock is 3.
Option (A) is correct.Quiz of this Question
UGC-NET
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
UGC-NET | UGC NET CS 2017 Jan - II | Question 29
UGC-NET | UGC NET CS 2018 July - II | Question 52
UGC-NET | UGC NET CS 2016 July – III | Question 31
UGC-NET | UGC NET CS 2017 Jan - II | Question 19
UGC-NET | UGC NET CS 2017 Jan - II | Question 25
UGC-NET | UGC-NET CS 2017 Nov - III | Question 34
UGC-NET | UGC NET CS 2017 Jan - III | Question 28
UGC-NET | UGC NET CS 2015 Jun - II | Question 40
UGC-NET | UGC NET CS 2015 Jun - III | Question 32
UGC-NET | UGC NET CS 2018 Dec – II | Question 9
Python Program for n\’th multiple of a number in Fibonacci Series

14 Feb, 2022
Given two integers n and k. Find position the n\’th multiple of K in the Fibonacci series. Examples:
Input : k = 2, n = 3
Output : 9
3\'rd multiple of 2 in Fibonacci Series is 34 
which appears at position 9.

Input  : k = 4, n = 5 
Output : 30
5\'th multiple of 5 in Fibonacci Series is 832040 
which appears at position 30.
An Efficient Solution is based on below interesting property. Fibonacci series is always periodic under modular representation. Below are examples.  
F (mod 2) = 1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,
            1,1,0,1,1,0,1,1,0,1,1,0,1,1,0 
Here 0 is repeating at every 3rd index and 
the cycle repeats at every 3rd index. 

F (mod 3) = 1,1,2,0,2,2,1,0,1,1,2,0,2,2,1,0
            ,1,1,2,0,2,2,1,0,1,1,2,0,2,2
Here 0 is repeating at every 4th index and 
the cycle repeats at every 8th index.

F (mod 4) = 1,1,2,3,1,0,1,1,2,3,1,0,1,1,2,3,
           1,0,1,1,2,3,1,0,1,1,2,3,1,0 
Here 0 is repeating at every 6th index and 
the cycle repeats at every 6th index.

F (mod 5) = 1,1,2,3,0,3,3,1,4,0,4,4,3,2,0,
            2,2,4,1,0,1,1,2,3,0,3,3,1,4,0
Here 0 is repeating at every 5th index and
the cycle repeats at every 20th index.

F (mod 6) = 1,1,2,3,5,2,1,3,4,1,5,0,5,5,4,
            3,1,4,5,3,2,5,1,0,1,1,2,3,5,2
Here 0 is repeating at every 12th index and 
the cycle repeats at every 24th index.

F (mod 7) = 1,1,2,3,5,1,6,0,6,6,5,4,2,6,1,
            0,1,1,2,3,5,1,6,0,6,6,5,4,2,6 
Here 0 is repeating at every 8th index and 
the cycle repeats at every 16th index.

F (mod 8) = 1,1,2,3,5,0,5,5,2,7,1,0,1,1,2,
            3,5,0,5,5,2,7,1,0,1,1,2,3,5,0 
Here 0 is repeating at every 6th index and 
the cycle repeats at every 12th index.

F (mod 9) = 1,1,2,3,5,8,4,3,7,1,8,0,8,8,7,
            6,4,1,5,6,2,8,1,0,1,1,2,3,5,8 
Here 0 is repeating at every 12th index and 
the cycle repeats at every 24th index.

F (mod 10) = 1,1,2,3,5,8,3,1,4,5,9,4,3,7,0,
             7,7,4,1,5,6,1,7,8,5,3,8,1,9,0.
Here 0 is repeating at every 15th index and
the cycle repeats at every 60th index.
 
Python3
# Python Program to find position of n\'th multiple# of a number k in Fibonacci Series def findPosition(k, n):    f1 = 0    f2 = 1    i =2;    while i!=0:        f3 = f1 + f2;        f1 = f2;        f2 = f3;         if f2%k == 0:            return n*i         i+=1             return  # Multiple no.n = 5;# Number of whose multiple we are findingk = 4; print("Position of n\'th multiple of k in"                "Fibonacci Series is", findPosition(k,n)); # Code contributed by Mohit Gupta_OMG
Output:  
Position of n'th multiple of k inFibonacci Series is 30
Please refer complete article on n’th multiple of a number in Fibonacci Series for more details! 
abhishek0719kadiyan
rkbhola5
arorakashish0911
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | GATE-CS-2000 | Question 15

28 Jun, 2021
Let s be a sorted array of n integers. Let t(n) denote the time taken for the most efficient algorithm to determined if there are two elements with sum less than 1000 in s. which of the following statements is true?
a) t (n) is O(1)
b) n < t (n) < n 
c) n log 2 n < t (n) < 
d) t (n) = [/Tex]{n \choose 2} [/Tex] 
(A) a(B) b(C) c(D) dAnswer: (A)Explanation: Let array be sorted in ascending order, if sum of first two elements is less than 1000 then there are two elements with sum less than 1000 otherwise not. For array sorted in descending order we need to check last two elements. For an array data structure, number of operations are fixed in both the cases and not dependent on n, complexity is O(1)Quiz of this Question
GATE-CS-2000
GATE-GATE-CS-2000
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to plot Bar Graph in Python using CSV file?

25 Feb, 2021
CSV stands for “comma separated values”, that means the values are distinguished by putting commas and newline characters. A CSV file provides a table like format that can be read by almost every spreadsheet reader like Microsoft Excel and Google Spreadsheet.
A Bar Graph uses labels and values where label is the name of a particular bar and value represent the height of the bar. A Bar Graph is commonly used in data analytics where we want to compare the data and extract the most common or highest groups.
In this post, we will learn how to plot a bar graph using a CSV file. There are plenty of modules available to read a .csv file like csv, pandas, etc. But in this post we will manually read the .csv file to get an idea of how things work.
Pandas read_csv() function is used to read a csv file.
Syntax:
read_csv(“file path”)
Matplotlib’s bar() function is used to create a bar graph
Syntax:
plt.bar(x, height, width, bottom, align)
Approach
Import module
Read file using read_csv() function
Plot bar graph
Display graph
Example:
Dataset in use: Click here
Python3
# Import the necessary modulesimport matplotlib.pyplot as pltimport pandas as pd    # Initialize the lists for X and Ydata = pd.read_csv('C:\\Users\\Vanshi\\Desktop\\data.csv')  df = pd.DataFrame(data)  X = list(df.iloc[:, 0])Y = list(df.iloc[:, 1])  # Plot the data using bar() methodplt.bar(X, Y, color='g')plt.title("Students over 11 Years")plt.xlabel("Years")plt.ylabel("Number of Students")  # Show the plotplt.show()
Output:
Approach
Import module
Open file
Read data
Plot bar graph
Display graph
Program:
Dataset in use: Click here to download this file.
Python3
# Import the modulesimport matplotlib.pyplot as plt  # Initialize a dictionary for monthsdata = dict()  # Read the datawith open('electronics.csv', 'r') as f:    for line in f.readlines():                # Store each line in the dictionary        month, item, quantity = line.split(',')                  if month not in data:            data[month] = []        data[month].append((item, int(quantity)))  # Position of each subplot where 221 means 2 row,# 2 columns, 1st indexpositions = [221, 222, 223, 224]  # Colors to distinguish the plotcolors = ['r', 'g', 'b', 'y']  # Plot the subgraphsfor i, l in enumerate(data.keys()):    plt.subplot(positions[i])    data_i = dict(data[l])    plt.bar(data_i.keys(), data_i.values(), color=colors[i])    plt.xlabel(l)  # Show the plotsplt.show()
Output:
Data Visualization
Picked
Python-matplotlib
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install MySQL on AWS EC2?

16 Dec, 2021
AWS or Amazon web services is a cloud service platform that provides on-demand computational services, databases, storage space, and many more services. EC2 or Elastic Compute Cloud is a scalable computing service launched on the AWS cloud platform. In simpler words, EC2 is nothing but a virtual computer on which we can perform all our tasks and we have the authority to configure, launch or even dissipate this virtual computer.
In this article, we will learn how to install MySQL on AWS EC2.
AWS account.EC2 Instance.User with privileges to create Instance.
AWS account.
EC2 Instance.
User with privileges to create Instance.
Follow the steps below to install MySQL on AWS EC2:
Step 1: Create an AWS Elastic Cloud Compute Instance..
Step 2: Start the EC2 instance that you have created in Step 1.
Step 3: Connect to your EC2 Instance by clicking on Connect Button.
Step 4: A prompt will pop up after connecting.
Step 5: If MySQL is not installed on your virtual machine then install the MySQL server using the following command.
sudo apt install mysql-server
Step 6: A prompt will appear asking you for confirmation, press ‘y’ to confirm.
Step 7: We have successfully installed MySQL server on our EC2  instance, to check if the MySQL server is running or not, verify using the following command.
sudo systemctl status mysql
In this way, we can install MySQL on our EC2 instance using EC2 Instance Connect. And if you also use a free tier account, make sure you delete all the resources you have used before logging out. 
how-to-install
Picked
How To
Installation Guide
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | GATE CS 2020 | Question 18

01 Oct, 2021
Consider the following statements.
I. If L1∪L2 is regular, then both L1 and L2 must be regular.II. The class of regular languages is closed under infinite union.
Which of the above statements is/are TRUE ?(A) I only(B) II only(C) Both I and II(D) Neither I nor IIAnswer: (D)Explanation: Counter examples for given statements:
I. (anbn) ∪ (a*b*) = a*b*  
where, a*b* is regular but (anbn) is not regular language.
II. Φ ∪ (ab) ∪ (a2b2) ∪ (a3b3) ..... (infinite union) = (anbn)  
where, each language in left side are regular language, but language in right side (anbn) is not regular language.
So, both statements are false.
Option (D) is true.
GATE PYQ's on Regular Language with Praddyumn Shukla | GeeksforGeeks GATE - YouTubeGeeksforGeeks GATE Computer Science17.6K subscribersGATE PYQ's on Regular Language with Praddyumn Shukla | GeeksforGeeks GATEWatch laterShareCopy linkInfoShoppingTap to unmuteIf playback doesn't begin shortly, try restarting your device.More videosMore videosYou're signed outVideos you watch may be added to the TV's watch history and influence TV recommendations. To avoid this, cancel and sign in to YouTube on your computer.CancelConfirmSwitch cameraShareInclude playlistAn error occurred while retrieving sharing information. Please try again later.Watch on0:000:0026:29 / 49:02•Live•<div class="player-unavailable"><h1 class="message">An error occurred.</h1><div class="submessage"><a href="https://www.youtube.com/watch?v=f9wyQ3j5AZg" target="_blank">Try watching this video on www.youtube.com</a>, or enable JavaScript if it is disabled in your browser.</div></div>Quiz of this Question
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between reshape() and resize() method in Numpy - GeeksforGeeks

05 Sep, 2020
Both the numpy.reshape() and numpy.resize() methods are used to change the size of a NumPy array. The difference between them is that the reshape() does not changes the original array but only returns the changed array, whereas the resize() method returns nothing and directly changes the original array.
Example 1: Using reshape()
Python3
# importing the moduleimport numpy as np     # creating an array gfg = np.array([1, 2, 3, 4, 5, 6]) print("Original array:")display(gfg)    # using reshape()print("Changed array")display(gfg.reshape(2, 3))     print("Original array:")display(gfg)
       
Output:
      
Example 2: Using resize()
Python3
# importing the moduleimport numpy as np     # creating an array gfg = np.array([1, 2, 3, 4, 5, 6]) print("Original array:")display(gfg)    # using resize()print("Changed array")# this will print nothing as None is returneddisplay(gfg.resize(2, 3))     print("Original array:")display(gfg)
Output:
Python numpy-arrayManipulation
Python-numpy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Python Dictionary
Read a file line by line in Python
How to Install PIP on Windows ?
Enumerate() in Python
Iterate over a list in Python
Different ways to create Pandas Dataframe
Python String | replace()
Python program to convert a list to string
Create a Pandas DataFrame from Lists
Reading and Writing to text files in Python
Tryit Editor v3.7

CSS Text Effects
Tryit: The word-wrap property
How to add table footer in HTML ? - GeeksforGeeks

13 Jan, 2022
To add a table footer on an HTML table you can use the HTML tfoot tag. The footer is required when the developer wants to show the conclusion or the result of the table data in a single row.
Syntax:
<tfoot> // Table footer contents... </tfoot>
Below example will illustrate the concept of table footer and clear your thoughts about how to create a table footer in HTML.
Example: In this example, we will create a table that contains 2 courses and a price with the total price at the table footer.
HTML
<!DOCTYPE html><html>   <head>      <style>         h1 {         color: green;         }         table, th, td {         border: 2px solid black;         }      </style>   </head>   <body>      <center>         <h1>GeeksforGeeks</h1>         <h2>How to create table footer in HTML</h2>         <table>            <thead>               <tr>                  <th>Course</th>                  <th>Price</th>               </tr>            </thead>            <tbody>               <tr>                  <td>ReactJS</td>                  <td>$39</td>               </tr>               <tr>                  <td>JavaScript</td>                  <td>$23</td>               </tr>            </tbody>            <tfoot>               <tr>                  <td>Total</td>                  <td>$62</td>               </tr>            </tfoot>         </table>      </center>   </body></html>
Output:
Table Footer
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
HTML-Questions
Picked
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
REST API (Introduction)
Design a web page using HTML and CSS
Angular File Upload
Form validation using jQuery
How to auto-resize an image to fit a div container using CSS?
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Convert a string to an integer in JavaScript
How to calculate the number of days between two dates in javascript?
C# | Getting the keys in a SortedList object - GeeksforGeeks

01 Feb, 2019
SortedList.Keys Property is used to get the keys in a SortedList object.
Syntax:
public virtual System.Collections.ICollection Keys { get; }
Property Value: An ICollection object containing the keys in the SortedList object.
Below programs illustrate the use of above-discussed property:
Example 1:
// C# code to get an ICollection containing// the keys in the SortedListusing System;using System.Collections;  class GFG {      // Driver code    public static void Main()    {          // Creating a SortedList        SortedList mylist = new SortedList();          // Adding elements in SortedList        mylist.Add("4", "Even");        mylist.Add("9", "Odd");        mylist.Add("5", "Odd and Prime");        mylist.Add("2", "Even and Prime");          // Get a collection of the keys.        ICollection c = mylist.Keys;          // Displaying the contents        foreach(string str in c)            Console.WriteLine(str + ": " + mylist[str]);    }}
2: Even and Prime
4: Even
5: Odd and Prime
9: Odd

Example 2:
// C# code to get an ICollection containing// the keys in the SortedList.using System;using System.Collections;  class GFG {      // Driver code    public static void Main()    {          // Creating a SortedList        SortedList mylist = new SortedList();          // Adding elements in SortedList        mylist.Add("India", "Country");        mylist.Add("Chandigarh", "City");        mylist.Add("Mars", "Planet");        mylist.Add("China", "Country");          // Get a collection of the keys.        ICollection c = mylist.Keys;          // Displaying the contents        foreach(string str in c)            Console.WriteLine(str + ": " + mylist[str]);    }}
Chandigarh: City
China: Country
India: Country
Mars: Planet

Note:
The ICollection object is a read-only view of the keys of the SortedList object. Modifications made to the underlying SortedList are immediately reflected in the ICollection.
The elements of the ICollection are sorted in the same order as the keys of the SortedList.
This property is similar to the GetKeyList method but returns an ICollection object instead of an IList object.
This method is an O(1) operation.
Reference:
https://docs.microsoft.com/en-us/dotnet/api/system.collections.sortedlist.keys?view=netframework-4.7.2
CSharp-Collections-Namespace
CSharp-Collections-SortedList
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Destructors in C#
Extension Method in C#
HashSet in C# with Examples
Top 50 C# Interview Questions & Answers
C# | How to insert an element in an Array?
Partial Classes in C#
C# | Inheritance
C# | List Class
Difference between Hashtable and Dictionary in C#
Lambda Expressions in C#
Gray Code in C++

As we know that the gray code is a binary numeral system where two successive values differ in only one bit. Suppose we have a non-negative integer n representing the total number of bits in the code. We have to print the sequence of gray code. A gray code sequence must begin with 0. So if the input is 2, then the result will be [0,1,3,2], this is because gray of 0 is 00, gray of 1 is 01, gray of 2 is 11, and gray of 3 is 10.
To solve this, we will follow these steps −
create one array ans
find gray code for each number and add them into ans array.
To convert into gray, we will take the number and perform XOR after shifting the number 1 bit to the right.
Let us see the following implementation to get a better understanding −
 Live Demo
#include <bits/stdc++.h>
using namespace std;
void print_vector(vector<int> v){
   cout << "[";
   for(int i = 0; i<v.size(); i++){
      cout << v[i] << ", ";
   }
   cout << "]"<<endl;
}
class Solution {
public:
   vector<int> grayCode(int n) {
      vector <int> ans;
      for(int i =0; i<1<<n; i++){
         ans.push_back(i^(i>>1));
      }
      return ans;
   }
};
main(){
   Solution ob;
   print_vector(ob.grayCode(4));
}
4
[0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, ]