code-rag-bench/online-tutorials huggingface dataset:
Errors and Exceptions in Python - GeeksforGeeks

22 Oct, 2021
Errors are the problems in a program due to which the program will stop the execution. On the other hand, exceptions are raised when some internal events occur which changes the normal flow of the program. Two types of Error occurs in python.  
Syntax errorsLogical errors (Exceptions)  
Syntax errors
Logical errors (Exceptions)  
 
When the proper syntax of the language is not followed then a syntax error is thrown.Example  
Python3
# initialize the amount variableamount = 10000  # check that You are eligible to#  purchase Dsa Self Paced or notif(amount>2999)    print("You are eligible to purchase Dsa Self Paced")     
Output: 
It returns a syntax error message because after the if statement a colon: is missing. We can fix this by writing the correct syntax. 
When in the runtime an error that occurs after passing the syntax test is called exception or logical type. For example, when we divide any number by zero then the ZeroDivisionError exception is raised, or when we import a module that does not exist then ImportError is raised.Example 1:  
Python3
# initialize the amount variablemarks = 10000  # perform division with 0a = marks / 0print(a)
Output: 
In the above example the ZeroDivisionError as we are trying to divide a number by 0.Example 2: When indentation is not correct.  
Python3
if(a<3):print("gfg")
Output: 
Some of the common built-in exceptions are other than above mention exceptions are: 
 
Note: For more information, refer to Built-in Exceptions in Python 
When an error and an exception are raised then we handle that with the help of the Handling method. 
Handling Exceptions with Try/Except/Finally We can handle errors by the Try/Except/Finally method. we write unsafe code in the try, fall back code in except and final code in finally block.Example  
Python3
# put unsafe operation in try blocktry:     print("code start")               # unsafe operation perform     print(1 / 0)  # if error occur the it goes in except blockexcept:     print("an error occurs")  # final code in finally blockfinally:     print("GeeksForGeeks")
Output:  
code start
an error occurs
GeeksForGeeks
 
Raising exceptions for a predefined condition When we want to code for the limitation of certain conditions then we can raise an exception. Example  
Python3
# try for unsafe codetry:    amount = 1999    if amount < 2999:                  # raise the ValueError        raise ValueError("please add money in your account")    else:        print("You are eligible to purchase DSA Self Paced course")              # if false then raise the value errorexcept ValueError as e:        print(e)
Output:  
please add money in your account
punamsingh628700
Python-exceptions
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Read JSON file using Python
Adding new column to existing DataFrame in Pandas
Python map() function
How to get column names in Pandas dataframe
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()
numpy.concatenate() function | Python - GeeksforGeeks

22 Apr, 2020
numpy.concatenate() function concatenate a sequence of arrays along an existing axis.
Syntax : numpy.concatenate((arr1, arr2, ...), axis=0, out=None)Parameters :arr1, arr2, ... : [sequence of array_like] The arrays must have the same shape, except in the dimension corresponding to axis.axis : [int, optional] The axis along which the arrays will be joined. If axis is None, arrays are flattened before use. Default is 0.out : [ndarray, optional] If provided, the destination to place the result. The shape must be correct, matching that of what concatenate would have returned if no out argument were specified.Return : [ndarray] The concatenated array.
Code #1 :
# Python program explaining# numpy.concatenate() function  # importing numpy as geek import numpy as geek  arr1 = geek.array([[2, 4], [6, 8]])arr2 = geek.array([[3, 5], [7, 9]])  gfg = geek.concatenate((arr1, arr2), axis = 0)  print (gfg)
Output :
[[2 4]
 [6 8]
 [3 5]
 [7 9]]

 Code #2 :
# Python program explaining# numpy.concatenate() function  # importing numpy as geek import numpy as geek  arr1 = geek.array([[2, 4], [6, 8]])arr2 = geek.array([[3, 5], [7, 9]])  gfg = geek.concatenate((arr1, arr2), axis = 1)  print (gfg)
Output :
[[2 4 3 5]
 [6 8 7 9]]

 Code #3 :
# Python program explaining# numpy.concatenate() function  # importing numpy as geek import numpy as geek  arr1 = geek.array([[2, 4], [6, 8]])arr2 = geek.array([[3, 5], [7, 9]])  gfg = geek.concatenate((arr1, arr2), axis = None)  print (gfg)
Output :
[2 4 6 8 3 5 7 9]

Python numpy-arrayManipulation
Python-numpy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Python | os.path.join() method
Python | Get unique values from a list
Create a directory in Python
Defaultdict in Python
Python | Pandas dataframe.groupby()
wxPython - Set window in center of screen - GeeksforGeeks

10 Mar, 2022
In this article we are going to learn that, how can we show window in the center of the screen. We can do this by using a Centre() function in wx.Frame module.  
Syntax:  
wx.Frame.Centre(self, direction = wx.BOTH)
Parameters:  
 
Example #1:  
Python3
# import wxPythonimport wx class Example(wx.Frame):     def __init__(self, parent, title):         super(Example, self).__init__(parent, title = title,                                           size =(300, 200))         # Centre frame using Centre() function        self.Centre() def main():     app = wx.App()    ex = Example(None, title ='Centering')    ex.Show()    app.MainLoop()  if __name__ == '__main__':    main()
Output:  
Example #2:  
Python3
# import wxPythonimport wx class Example(wx.Frame):     def __init__(self, parent, title):        super(Example, self).__init__(parent, title = title,                                          size =(300, 200))         # Centre frame using Centre() function        self.Centre(direction = wx.VERTICAL)  def main():     app = wx.App()    ex = Example(None, title ='Centering')    ex.Show()    app.MainLoop()  if __name__ == '__main__':    main()
Output:  
 
ysachin2314
ManasChhabra2
Python-gui
Python-wxPython
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Enumerate() in Python
Python Dictionary
Defaultdict in Python
sum() function in Python
Python String | replace()
Read a file line by line in Python
How to Install PIP on Windows ?
Deque in Python
Different ways to create Pandas Dataframe
Iterate over a list in Python
Josephus Problem | (Iterative Solution) - GeeksforGeeks

22 Jan, 2020
There are N Children are seated on N chairs arranged around a circle. The chairs are numbered from 1 to N. The game starts going in circles counting the children starting with the first chair. Once the count reaches K, that child leaves the game, removing his/her chair. The game starts again, beginning with the next chair in the circle. The last child remaining in the circle is the winner. Find the child that wins the game.
Examples:
Input : N = 5, K = 2
Output : 3
Firstly, the child at position 2 is out, 
then position 4 goes out, then position 1
Finally, the child at position 5 is out. 
So the position 3 survives.

Input : 7 4
Output : 2

We have discussed a recursive solution for Josephus Problem . The given solution is better than the recursive solution of Josephus Solution which is not suitable for large inputs as it gives stack overflow. The time complexity is O(N).
Approach – In the algorithm, we use sum variable to find out the chair to be removed. The current chair position is calculated by adding the chair count K to the previous position i.e. sum and modulus of the sum. At last we return sum+1 as numbering starts from 1 to N.
C++
Java
// Iterative solution for Josephus Problem #include <bits/stdc++.h>using namespace std;  // Function for finding the winning child.long long int find(long long int n, long long int k){    long long int sum = 0, i;      // For finding out the removed     // chairs in each iteration    for (i = 2; i <= n; i++)        sum = (sum + k) % i;      return sum + 1;}  // Driver function to find the winning childint main(){    int n = 14, k = 2;    cout << find(n, k);    return 0;}
// Iterative solution for Josephus Problemclass Test {      // Method for finding the winning child.    private int josephus(int n, int k)     {        int sum = 0;          // For finding out the removed         // chairs in each iteration         for(int i = 2; i <= n; i++)         {            sum = (sum + k) % i;        }          return sum+1;    }      // Driver Program to test above method     public static void main(String[] args)    {         int n = 14;         int k = 2;         Test obj = new Test();        System.out.println(obj.josephus(n, k));     }}  // This code is contributed by Kumar Saras
13

KumarSaras
programming-puzzle
Game Theory
Searching
Searching
Game Theory
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Classification of Algorithms with Examples
A Binary String Game
Random Number Memory Game in C
Two player game in which a player can remove all occurrences of a number
Find the winner of the Game to Win by erasing any two consecutive similar alphabets
Binary Search
Maximum and minimum of an array using minimum number of comparisons
Linear Search
Search an element in a sorted and rotated array
Find the Missing Number
Storage Definition Languages (SDL) - GeeksforGeeks

11 Sep, 2020
DBMS supports many languages out of which (SDL) is one of them. SDL stands for Storage Definition Language. SDL matter is almost anything that’s not specified by SQL standard. It is different in every DBMS which specifies anything to do with how or where data in relevant table is stored. It’s applications are as follows :
Used to define internal schema.
It defines physical structure of database.
The order of fields.
Bytes per field will be used.
How records will be accesses etc.
The mapping between two schema may also be defined.
Example : Let us take some examples to understand how Storage Definition Language (SDL) works.
Example-1 :
CREATE TABLE geeksforgeeks (no_of_articles INT) ENGINE = INNODB;

In the above example, we specify storage engine to be used by adding ENGINE option. InnoDB is default storage engine for MySQL 8.0.
Example-2 :
CREATE TABLE geeksforgeeks (article_titile varchar(65000) ENGINE = MEMORY;

This time, engine used is MEMORY. MEMORY storage engine (also known as HEAP) creates tables for particular purpose with contents that are stored in memory. Because the data is vulnerable to power outages, crashes or hardware issues, only use these tables as temporary work areas or read-only caches for data pulled from other tables.
Example-3 :
CREATE TABLE f (x int, y varchar(25));

In the above statement, Storage Definition Language (SDL) defines storage of row int, varchar(25).
Indeed, In most relational database management systems (RDBMS) there is no specific language that performs the role of SDL. Instead, combination of functions, parameters, and specifications related to storage of files define internal schema.
Picked
DBMS
DBMS
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Deadlock in DBMS
Types of Functional dependencies in DBMS
KDD Process in Data Mining
Conflict Serializability in DBMS
What is Temporary Table in SQL?
Two Phase Locking Protocol
Introduction of Relational Algebra in DBMS
MySQL | Regular expressions (Regexp)
Difference between Where and Having Clause in SQL
Difference between File System and DBMS
Codes Conversion

There are many methods or techniques which can be used to convert code from one format to another. We'll demonstrate here the following
Binary to BCD Conversion
BCD to Binary Conversion
BCD to Excess-3
Excess-3 to BCD
Steps
Step 1 -- Convert the binary number to decimal.
Step 1 -- Convert the binary number to decimal.
Step 2 -- Convert decimal number to BCD.
Step 2 -- Convert decimal number to BCD.
Example − convert (11101)2 to BCD.
Binary Number − 111012
Calculating Decimal Equivalent −
Binary Number − 111012 = Decimal Number − 2910
Decimal Number − 2910
Calculating BCD Equivalent. Convert each digit into groups of four binary digits equivalent.
Result
(11101)2 =  (00101001)BCD

Steps
Step 1 -- Convert the BCD number to decimal.
Step 1 -- Convert the BCD number to decimal.
Step 2 -- Convert decimal to binary.
Step 2 -- Convert decimal to binary.
Example − convert (00101001)BCD to Binary.
BCD Number − (00101001)BCD
Calculating Decimal Equivalent. Convert each four digit into a group and get decimal equivalent for each group.
BCD Number − (00101001)BCD = Decimal Number − 2910
Used long division method for decimal to binary conversion.
Decimal Number − 2910
Calculating Binary Equivalent −
As mentioned in Steps 2 and 4, the remainders have to be arranged in the reverse order so that the first remainder becomes the least significant digit (LSD) and the last remainder becomes the most significant digit (MSD).
Decimal Number − 2910 = Binary Number − 111012
Result
(00101001)BCD = (11101)2

Steps
Step 1 -- Convert BCD to decimal.
Step 1 -- Convert BCD to decimal.
Step 2 -- Add (3)10 to this decimal number.
Step 2 -- Add (3)10 to this decimal number.
Step 3 -- Convert into binary to get excess-3 code.
Step 3 -- Convert into binary to get excess-3 code.
Example − convert (0110)BCD to Excess-3.
(0110)BCD = 610
(6)10 + (3)10 = (9)10
(9)10 = (1001)2
Result
(0110)BCD = (1001)XS-3

Steps
Step 1 -- Subtract (0011)2 from each 4 bit of excess-3 digit to obtain the corresponding BCD code.
Step 1 -- Subtract (0011)2 from each 4 bit of excess-3 digit to obtain the corresponding BCD code.
Example − convert (10011010)XS-3 to BCD.
Given XS-3 number  = 1 0 0 1 1 0 1 0 
Subtract (0011)2   = 1 0 0 1 0 1 1 1
                    --------------------
               BCD = 0 1 1 0   0 1 1 1

Result
(10011010)XS-3 = (01100111)BCD


    107 Lectures 
     13.5 hours 

 Arnab Chakraborty

    106 Lectures 
     8 hours 

 Arnab Chakraborty

    99 Lectures 
     6 hours 

 Arnab Chakraborty

    46 Lectures 
     2.5 hours 

 Shweta

    70 Lectures 
     9 hours 

 Abhilash Nelson

    52 Lectures 
     7 hours 

 Abhishek And Pukhraj
 Print
 Add Notes
 Bookmark this page
How to match any one uppercase character in python using Regular Expression?



The following code matches and prints any uppercase character in the given string using python regular expression as follows.
import re
foo = 'MozamBiQuE'
match = re.findall(r'[A-Z]', foo)
print match
This gives the output
['M', 'B', 'Q', 'E']
Python Program for Fibonacci numbers

In this article, we will learn about the solution and approach to solve the given problem statement.
Problem statement −Our task to compute the nth Fibonacci number.
The sequence Fn of Fibonacci numbers is given by the recurrence relation given below
Fn = Fn-1 + Fn-2
with seed values (standard)
F0 = 0 and F1 = 1.
We have two possible solutions to the problem
Recursive approach
Dynamic approach
 Live Demo
#recursive approach
def Fibonacci(n):
   if n<0:
      print("Fibbonacci can't be computed")
   # First Fibonacci number
   elif n==1:
      return 0
   # Second Fibonacci number
   elif n==2:
      return 1
   else:
      return Fibonacci(n-1)+Fibonacci(n-2)
# main
n=10
print(Fibonacci(n))
34
All the variables are declared in global scope as shown in the image below
 Live Demo
#dynamic approach
Fib_Array = [0,1]

def fibonacci(n):
   if n<0:
      print("Fibbonacci can't be computed")
   elif n<=len(Fib_Array):
      return Fib_Array[n-1]
   else:
      temp = fibonacci(n-1)+fibonacci(n-2)
      Fib_Array.append(temp)
      return temp
# Driver Program
n=10
print(fibonacci(n))
34
All the variables are declared in global scope as shown in the image below
In this article, we learnt about the approach to compute Fibonacci numbers
Break Statement Implementation

The break statement is used to alter the flow of control inside loops within any programming language. The break statement is normally used in looping constructs and is used to cause immediate termination of the innermost enclosing loop.
The Batch Script language does not have a direct ‘for’ statement which does a break but this can be implemented by using labels. The following diagram shows the diagrammatic explanation of the break statement implementation in Batch Script.
The key thing to note about the above implementation is the involvement of two ‘if’ conditions. The second ‘if’ condition is used to control when the break is implemented. If the second ‘if’ condition is evaluated to be true, then the code block is not executed and the counter is directly implemented.
Following is an example of how to carry out the implementation of the break statement.
@echo off 
SET /A "index=1" 
SET /A "count=5" 
:while 
if %index% leq %count% ( 
   if %index%==2 goto :Increment 
      echo The value of index is %index% 
:Increment 
   SET /A "index=index + 1" 
   goto :while 
)
The key thing to note about the above program is the addition of a label called :Increment. When the value of index reaches 2, we want to skip the statement which echoes its value to the command prompt and directly just increment the value of index.
The above command produces the following output.
The value of index is 1 
The value of index is 3 
The value of index is 4 
The value of index is 5

 Print
 Add Notes
 Bookmark this page
The new operator in Java

The new operator is used in Java to create new objects. It can also be used to create an array object.
Let us first see the steps when creating an object from a class −
Declaration − A variable declaration with a variable name with an object type.
Declaration − A variable declaration with a variable name with an object type.
Instantiation − The 'new' keyword is used to create the object.
Instantiation − The 'new' keyword is used to create the object.
Initialization − The 'new' keyword is followed by a call to a constructor. This call initializes the new object.
Initialization − The 'new' keyword is followed by a call to a constructor. This call initializes the new object.
Now, let us see an example −
public class Puppy {
   public Puppy(String name) {
      // This constructor has one parameter, name.
      System.out.println("Passed Name is : " + name );
   }
   public static void main(String []args) {
      // Following statement would create an object myPuppy
      Puppy myPuppy = new Puppy( "jackie" );
   }
}
Passed Name is : jackie
Now, let us see an example to create an array using the new operator −
public class Main {
   public static void main(String[] args) {
      double[] myList = new double[] {1.9, 2.9, 3.4, 3.5};
      // Print all the array elements
      for (int i = 0; i < myList.length; i++) {
         System.out.println(myList[i] + " ");
      }
      // Summing all elements
      double total = 0;
      for (int i = 0; i < myList.length; i++) {
         total += myList[i];
      }
      System.out.println("Total is " + total);
      // Finding the largest element
      double max = myList[0];
      for (int i = 1; i < myList.length; i++) {
         if (myList[i] > max) max = myList[i];
      }
      System.out.println("Max is " + max);
   }
}
1.9
2.9
3.4
3.5
Total is 11.7
Max is 3.5
CopyOnWriteArrayList Class in Java

public class CopyOnWriteArrayList
   extends Object
implements List, RandomAccess, Cloneable, Serializable
CopyOnWriteArrayList is a thread-safe variant of ArrayList where operations which can change the ArrayList (add, update, set methods) creates a clone of the underlying array.
CopyOnWriteArrayList is a thread-safe variant of ArrayList where operations which can change the ArrayList (add, update, set methods) creates a clone of the underlying array.
CopyOnWriteArrayList is to be used in a Thread based environment where read operations are very frequent and update operations are rare.
CopyOnWriteArrayList is to be used in a Thread based environment where read operations are very frequent and update operations are rare.
Iterator of CopyOnWriteArrayList will never throw ConcurrentModificationException.
Iterator of CopyOnWriteArrayList will never throw ConcurrentModificationException.
Any type of modification to CopyOnWriteArrayList will not reflect during iteration since the iterator was created.
Any type of modification to CopyOnWriteArrayList will not reflect during iteration since the iterator was created.
List modification methods like remove, set and add are not supported in the iteration. This method will throw UnsupportedOperationException.
List modification methods like remove, set and add are not supported in the iteration. This method will throw UnsupportedOperationException.
null can be added to the list.
null can be added to the list.
Following is the list of important methods available in the CopyOnWriteArrayList class.
The following program illustrates several of the methods supported by ArrayList −
Live Demo
import java.util.Iterator;
import java.util.concurrent.CopyOnWriteArrayList;
public class Tester {

   public static void main(String args[]) {
      // create an array list
      CopyOnWriteArrayList al = new CopyOnWriteArrayList();
      System.out.println("Initial size of al: " + al.size());

      // add elements to the array list
      al.add("C");
      al.add("A");
      al.add("E");
      al.add("B");
      al.add("D");
      al.add("F");
      al.add(1, "A2");
      System.out.println("Size of al after additions: " + al.size());

      // display the array list
      System.out.println("Contents of al: " + al);

      // Remove elements from the array list
      al.remove("F");
      al.remove(2);
      System.out.println("Size of al after deletions: " + al.size());
      System.out.println("Contents of al: " + al);

      try {
         Iterator iterator = al.iterator();
         while(iterator.hasNext()) {
            iterator.remove();
         }
      }catch(UnsupportedOperationException e) {
         System.out.println("Method not supported:");
      }
      System.out.println("Size of al: " + al.size());
   }
}
This will produce the following result −
Initial size of al: 0
Size of al after additions: 7
Contents of al: [C, A2, A, E, B, D, F]
Size of al after deletions: 5
Contents of al: [C, A2, E, B, D]
Method not supported:
Size of al: 5
PyTorch - Installation

PyTorch is a popular deep learning framework. In this tutorial, we consider “Windows 10” as our operating system. The steps for a successful environmental setup are as follows −
The following link includes a list of packages which includes suitable packages for PyTorch.
All you need to do is download the respective packages and install it as shown in the following screenshots −
It involves verifying the installation of PyTorch framework using Anaconda Framework.
Following command is used to verify the same −
conda list

“Conda list” shows the list of frameworks which is installed.
The highlighted part shows that PyTorch has been successfully installed in our system.
 Print
 Add Notes
 Bookmark this page
Tryit Editor v3.7

CSS 2D Transforms
Tryit: The matrix() method
BigDecimal max() Method in Java - GeeksforGeeks

04 Dec, 2018
The java.math.BigDecimal.max(BigDecimal val) method in Java is used to compare two BigDecimal values and return the maximum of the two. This is opposite to BigDecimal max() method in Java.
Syntax:
public BigDecimal max(BigDecimal val)
Parameters: The function accepts a BigDecimal object val as parameter whose value is compared with that of this BigDecimal object and the maximum value is returned.
Return Values: This method returns the BigDecimal whose value is the greater of this BigDecimal and val. In case if both are equal, this BigDecimal is returned.
Examples:
Input :  a = 17.000041900, b = 17.0000418999
Output : 17.000041900

Input : a = 235900000146, b = 236000000000
Output : 236000000000

Below programs will illustrate max() function of BigDecimal class.
Program 1:
// Java program to illustrate use of// BigDecimal max() function in Java      import java.math.*;  public class GFG {      public static void main(String[] args)    {          // create 2 BigDecimal objects        BigDecimal a, b;          a = new BigDecimal("235900000146");        b = new BigDecimal("236000000000");          // print the maximum value        System.out.println("Maximum Value among " + a +                        " and " + b + " is " + a.max(b));    }}
Maximum Value among 235900000146 and 236000000000 is 236000000000

Program 2:
// Java program to illustrate use of BigDecimal max() // to display maximum length among two strings in Java  import java.math.*;  public class GFG {      public static void main(String[] args)    {          // Create 2 BigDecimal objects        BigDecimal a, b;        String s = "GeeksforGeeks";        String str = "GeeksClasses";          int l1, l2;        l1 = s.length();        l2 = str.length();          a = new BigDecimal(l1);        b = new BigDecimal(l2);          // Print the respective lengths        System.out.println("Length of string " + s + " is " + a);        System.out.println("Length of string " + str + " is " + b);                  // Print the maximum value        System.out.println("Maximum length is " + a.max(b));    }}
Length of string GeeksforGeeks is 13
Length of string GeeksClasses is 12
Maximum length is 13

Reference: https://docs.oracle.com/javase/7/docs/api/java/math/BigDecimal.html#max()
Java-BigDecimal
Java-Functions
java-math
Java-math-package
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Stream In Java
Different ways of Reading a text file in Java
Constructors in Java
Exceptions in Java
Functional Interfaces in Java
Generics in Java
Comparator Interface in Java with Examples
HashMap get() Method in Java
Introduction to Java
Difference between Abstract Class and Interface in Java
How can I get Webdriver Session ID in Selenium?

We can get the webdriver session id with Selenium webdriver using the SessionId class. A session id is a distinctive number that is given to the webdriver by the server.
This number is utilized by the webdriver to establish communication with the browser. The commands in our Selenium tests are directed to the browser with the help of this session id. The method getSessionId is used to obtain the webdriver session id.
SessionId s = ((RemoteWebDriver) driver).getSessionId();
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.remote.SessionId;
import org.openqa.selenium.remote.RemoteWebDriver;
public class BrwSessionId{
   public static void main(String[] args) {
      //set chromedriver.exe file path
      System.setProperty("webdriver.chrome.driver",
         "C:\\Users\\ghs6kor\\Desktop\\Java\\chromedriver.exe");
      WebDriver driver = new ChromeDriver();
      //implicit wait
      driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
      //URL launch
      driver.get("https://www.tutorialspoint.com/index.htm");
      //get webdriver session id
      SessionId s = ((RemoteWebDriver) driver).getSessionId();
      System.out.println("Session Id is: " + s);
      //browser close
      driver.quit();
   }
}
How do I cast a type to a BigInt in MySQL?

You need to use the CAST operator along with CONV() function. The CONV() function can be used to convert one base number system to another base system.
For Example, The 16 is one base system and 10 is another base system. The 16 base system is hexadecimal and 10 is a decimal.
The syntax is as follows −
SELECT CAST(CONV('yourColumnName',16,10) AS UNSIGNED INTEGER) as anyAliasName FROM yourTableName;
To understand the above syntax, let us create a table. The query to create a table is as follows −
mysql> create table castTypeToBigIntDemo
   -> (
   -> Id int NOT NULL AUTO_INCREMENT,  
   -> Value varchar(100),
   -> PRIMARY KEY(Id)
   -> );
Query OK, 0 rows affected (1.19 sec)
Insert some records in the table using insert command. The query is as follows −
mysql> insert into castTypeToBigIntDemo(Value) values('AB5');
Query OK, 1 row affected (0.13 sec)
mysql> insert into castTypeToBigIntDemo(Value) values('55244A5562C5566354');
Query OK, 1 row affected (0.15 sec)
mysql> insert into castTypeToBigIntDemo(Value) values('4546575765ABD78');
Query OK, 1 row affected (0.15 sec)
mysql> insert into castTypeToBigIntDemo(Value) values('5979787DEFAB');
Query OK, 1 row affected (0.19 sec)
mysql> insert into castTypeToBigIntDemo(Value) values('86868686856ABD');
Query OK, 1 row affected (0.17 sec)
Display all records from the table using a select statement. The query is as follows −
mysql> select *from castTypeToBigIntDemo;
The following is the output −
+----+--------------------+
| Id | Value              |
+----+--------------------+
|  1 | AB5                |
|  2 | 55244A5562C5566354 |
|  3 | 4546575765ABD78    |
|  4 | 5979787DEFAB       |
|  5 | 86868686856ABD     |
+----+--------------------+
5 rows in set (0.00 sec)
Here is the query to cast a type to a BigInt in MySQL −
mysql> SELECT CAST(CONV(Value,16,10) AS UNSIGNED INTEGER) as BigNumber from castTypeToBigIntDemo;
The following is the output −
+----------------------+
| BigNumber            |
+----------------------+
| 2741                 |
| 18446744073709551615 |
| 311985829366644088   |
| 98378247434155       |
| 37865559219858109    |
+----------------------+
5 rows in set, 1 warning (0.00 sec)
EmberJS - Template Condition Unless

It executes only false block of statements.
{{#unless falsy_condition}}
   //block of statement
{{/unless}}

The example given below shows the use of the unless conditional helper in the Ember.js. Create a template called application.hbs under app/templates/ with the following code −
{{#unless check}}
   <h3> boolean value is {{check}}</h3>
{{/unless}}
Now create the controller called application.js file, which will be defined under app/controller/ with the following code −
import Ember from 'ember';

export default Ember.Controller.extend ({
   bool: false,
   check: function () {
      return this.bool;
   }.property('content.check')
});
Run the ember server and you will receive the following output −
 Print
 Add Notes
 Bookmark this page
How to write Python regular expression to get zero or more occurrences within the pattern?



*      An asterisk meta-character  in a regular expression indicates 0 or more occurrences of the pattern to its left
The following code matches and prints the zero or more occurrences of the pattern '\w' in the string 'chihua huahua'
import re
s = 'chihua huahua'
result = re.findall(r'\w*', s)
print result
This gives the output
['chihua', '', 'huahua', '']
Print all pairs with given sum in C++

In this problem, we are given an array of integers and an integer sum and we have to print all pairs of integers whose sum is equal to the sum value.
Let’s take an example to understand the problem :
Input − array = {1, 6, -2, 3} sum = 4
Output − (1, 3) , (6, -2)
Here, we need pairs with the given sum value.
A simple solution to the problem will be checking pairs of elements that generate the sum. This can be done by traversing array and find the number in array that sums up to sum value.
This program will illustrate the solution −
 Live Demo
#include <iostream>
using namespace std;
int printPairsWithSum(int arr[], int n, int sum){
   int count = 0;
   for (int i = 0; i < n; i++)
      for (int j = i + 1; j < n; j++)
         if (arr[i] + arr[j] == sum)
            cout<<"[ "<<arr[i]<<", "<<arr[j]<<" ]\n";
}
int main(){
   int arr[] = {1, 6, -2, 3};
   int n = 4;
   int sum = 4;
   cout<<"Pairs with Sum "<<sum<<" are :\n";
   printPairsWithSum(arr, n, sum);
   return 0;
}
Pairs with Sum 4 are :
[ 1, 3 ]
[ 6, -2 ]
This method is easy to understand but not quite efficient. Another way will be using hashing.
We will initialise a hash table and traverse the array and find pairs in it. On match, we will print the array :
The following program will make you understand the algorithm better −
 Live Demo
#include <bits/stdc++.h>
using namespace std;
void printPairsWithSum(int arr[], int n, int sum){
   unordered_map<int, int> pair;
   for (int i = 0; i < n; i++) {
      int rem = sum - arr[i];
      if (pair.find(rem) != pair.end()) {
         int count = pair[rem];
         for (int j = 0; j < count; j++)
         cout<<"["<<rem<<", "<<arr[i]<<" ]\n";
      }
      pair[arr[i]]++;
   }
}
int main(){
   int arr[] = {1, 6, -2, 3};
   int n = 4;
   int sum = 4;
   cout<<"The pair with sum is \n";
   printPairsWithSum(arr, n, sum);
   return 0;
}
Pairs with Sum 4 are :
[ 1, 3 ]
[ 6, -2 ]
Find maximum length sub-list in a nested list in Python

we often deal with nested lists when doing data analysis in python. In this article, we will see how to find out the longest list among the elements in a nested list and then print this along with its length.
We declare a nested list and give it as input to the lambda function along with its length. Finally, we apply the max function to get the list with maximum length as well as the length of such list.
 Live Demo
def longest(lst):
   longestList = max(lst, key = lambda i: len(i))
   maxLength = max(map(len, listA))
   return longestList, maxLength
# Driver Code
listA = [[1,2], [2,45,6,7], [11,65,2]]
print("Longest List and its length:\n",longest(listA))

Running the above code gives us the following result −
Longest List and its length:
([2, 45, 6, 7], 4)
In this approach, we first find the sub-list with maximum length and then loop through the elements of the list to find out which sublist match that length. We use the max and len function to do this calculation.
 Live Demo
def longest(lst):
   longestList = []
   maxLength = max(len(x) for x in listA)
   for i in listA:
      if len(i) == maxLength :
         longestList = i
   return longestList, maxLength
# Driver Code
listA = [[1,2], [2,45,6,7], [11,6,2]]
print("Longest List and its length:\n",longest(listA))

Running the above code gives us the following result −
Longest List and its length:
([2, 45, 6, 7], 4)
This is a similar approach as the above program but we are using the map function to find out the sublist with maximum length.
 Live Demo
def longest(lst):
   longestList = []
   maxLength = max(map(len,listA))
   for i in listA:
      if len(i) == maxLength :
         longestList = i
   return longestList, maxLength
# Driver Code
listA = [[1,2], [2,45,6,7], [11,6,2]]
print("Longest List and its length:\n",longest(listA))
Running the above code gives us the following result −
Longest List and its length:
([2, 45, 6, 7], 4)
Bootstrap 3 Tutorial

Bootstrap is the most popular HTML, CSS, and JavaScript framework for developing responsive, mobile-first websites.
Bootstrap is completely free to download and use!
This Bootstrap tutorial contains hundreds of Bootstrap examples.
With our online editor, you can edit the code, and click on a button to view the result.
Click on the "Try it Yourself" button to see how it works.
Add the correct class name to transform the list below into a pagination menu.
<ul class="">
  <li><a href="#">1</a></li>
  <li><a href="#">2</a></li>
  <li><a href="#">3</a></li>
  <li><a href="#">4</a></li>
  <li><a href="#">5</a></li>
</ul>

Start the Exercise
Test your Bootstrap skills at W3Schools!
Start Bootstrap Quiz!
At W3Schools you will find a complete Bootstrap reference of all CSS classes, 
Components, and JavaScript plugins - all with "Try it Yourself" examples:
We have made some Bootstrap Templates you can play around with. They are completely free to use:
Browse Themes
Browse Basic Templates
This tutorial follows Bootstrap 3, which was released in 2013. However, we also cover newer versions; Bootstrap 4 (released 2018) and Bootstrap 5 (released 2021).
Bootstrap 5 is the newest version of Bootstrap; 
with new components, faster stylesheets, more responsiveness etc. It supports the latest, stable releases of all major browsers and 
platforms. However, Internet Explorer 11 and down is not supported.
The main differences between Bootstrap 5 and Bootstrap 3 & 4, is that 
Bootstrap 5 has switched to JavaScript instead of jQuery.
Note: Bootstrap 3 and Bootstrap 4 is still supported by the team for critical bugfixes and documentation changes, 
and it is perfectly safe to continue to use them. However, new features will NOT be added to 
them.
W3.CSS is an excellent alternative to Bootstrap.
W3.CSS is smaller, faster, and easier to use.
If you want to learn W3.CSS, go to our W3.CSS 
Tutorial.
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.
continue - Unix, Linux Command

continue - To resume the next iteration of an enclosing for, while, until, or select loop.
continue [n]
Create a Utility Class to use continue.
#continuesample
for myloop in 1 2 3 4 5 
do 
  echo -n "$myloop"
  if [ "$myloop" -eq 3 ] 
   then 
   continue # Skip rest of this particular loop iteration.
  fi
done

Run the utility
$ chmod a+x continuesample
$ ./continuesample
1245


    129 Lectures 
     23 hours 

 Eduonix Learning Solutions

    5 Lectures 
     4.5 hours 

 Frahaan Hussain

    35 Lectures 
     2 hours 

 Pradeep D

    41 Lectures 
     2.5 hours 

 Musab Zayadneh

    46 Lectures 
     4 hours 

 GUHARAJANM

    6 Lectures 
     4 hours 

 Uplatz
 Print
 Add Notes
 Bookmark this page
Valid Parentheses in C++

Suppose we have an expression. The expression has some parentheses; we have to check the parentheses are balanced or not. The order of the parentheses are (), {} and []. Suppose there are two strings. “()[(){()}]” this is valid, but “{[}]” is invalid.
The task is simple; we will use the stack to do this. We should follow these steps to get the solution −
Traverse through the expression until it has exhaustedif the current character is opening bracket like (, { or [, then push into stackif the current character is closing bracket like ), } or ], then pop from stack, and check whether the popped bracket is corresponding starting bracket of the current character, then it is fine, otherwise, that is not balanced.
Traverse through the expression until it has exhausted
if the current character is opening bracket like (, { or [, then push into stack
if the current character is opening bracket like (, { or [, then push into stack
if the current character is closing bracket like ), } or ], then pop from stack, and check whether the popped bracket is corresponding starting bracket of the current character, then it is fine, otherwise, that is not balanced.
if the current character is closing bracket like ), } or ], then pop from stack, and check whether the popped bracket is corresponding starting bracket of the current character, then it is fine, otherwise, that is not balanced.
After the string is exhausted, if there are some starting bracket left into the stack, then the string is not balanced.
After the string is exhausted, if there are some starting bracket left into the stack, then the string is not balanced.
 Live Demo
#include <iostream>
#include <stack>
using namespace std;
bool isBalancedExp(string exp) {
   stack<char> stk;
   char x;
   for (int i=0; i<exp.length(); i++) {
      if (exp[i]=='('||exp[i]=='['||exp[i]=='{') {
         stk.push(exp[i]);
         continue;
      }
      if (stk.empty())
         return false;
      switch (exp[i]) {
      case ')':
         x = stk.top();
         stk.pop();
         if (x=='{' || x=='[')
            return false;
         break;
      case '}':
         x = stk.top();
         stk.pop();
         if (x=='(' || x=='[')
            return false;
         break;
      case ']':
         x = stk.top();
         stk.pop();
         if (x =='(' || x == '{')
            return false;
         break;
      }
   }
   return (stk.empty());
}
int main() {
   string expresion = "()[(){()}]";
   if (isBalancedExp(expresion))
      cout << "This is Balanced Expression";
   else
      cout << "This is Not Balanced Expression";
}
"()[(){()}]"
This is Balanced Expression
How to convert ISO 8601 string to Date/time object in Android?

This example demonstrates how do I convert ISO 8601 string to date/time object in android.
Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.
Step 2 − Add the following code to res/layout/activity_main.xml.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:tools="http://schemas.android.com/tools"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:gravity="center"
   tools:context=".MainActivity">
   <TextView
      android:padding="20sp"
      android:id="@+id/textView"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_centerInParent="true"
      android:textSize="12sp"
      android:textStyle="bold"/>
</RelativeLayout>
Step 3 − Add the following code to src/MainActivity.java
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class MainActivity extends AppCompatActivity {
   TextView textView;
   @Override
   public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      textView = findViewById(R.id.textView);
      String dtStart = "2019-08-15T09:27:37Z";
      SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
      try {
         Date date = format.parse(dtStart);
         textView.setText("ISO 1801 date/time: " + date);
      } catch (ParseException e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
      }
   }
}
Step 4 − Add the following code to androidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
   package="app.com.sample">
   <application
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:supportsRtl="true"
      android:theme="@style/AppTheme">
      <activity android:name=".MainActivity">
         <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
         </intent-filter>
      </activity>
   </application>
</manifest>
Let's try to run your application. I assume you have connected your actual Android Mobile device with your computer. To run the app from android studio, open one of your project's activity files and click Run  icon from the toolbar. Select your mobile device as an option and then check your mobile device which will display your default screen –
How to Align Column DIVs as Left-Center-Right with CSS Flex

To align items of a flex container along its main axis by distributing space around it, we use the justify-content property of CSS.
The syntax of CSS justify-content property is as follows −
Selector {
   display: flex;
   justify-content: /*value*/
}
The following examples illustrate CSS justify-content property.
 Live Demo
<!DOCTYPE html>
<html>
   <head>
      <style>
         #root {
            margin: 5%;
            display: flex;
            justify-content: space-between;
         }
         #one {
            float:left;
            box-shadow: inset 0 0 34px #b798e1;
         }
         #two {
            box-shadow: inset 0 0 34px #236fa0;
         }
         #three {
            box-shadow: inset 0 0 34px #43946a;
         }
         .element {
            padding: 7%;
            border-radius: 15%;
         }
      </style>
   </head>
   <body>
      <div id="root">
         <div class="element" id="one">1</div>
         <div class="element" id="two">2</div>
         <div class="element" id="three">3</div>
      </div>
   </body>
</html>
This gives the following output
 Live Demo
<!DOCTYPE html>
<html>
   <head>
      <style>
         #root {
            margin: 5%;
            padding: 2%;
            display: flex;
            justify-content: space-evenly;
            box-shadow: inset 0 10px 40px magenta;
            font-weight: bold;
         }
         div > div {
            padding: 2%;
            border-radius: 15%;
         }
         div:nth-of-type(even) {
            box-shadow: inset 2px 2px 20px orange;
         }
         div > div:nth-of-type(odd) {
            box-shadow: inset 2px 2px 20px lightblue;
         }
      </style>
   </head>
   <body>
      <div id="root">
         <div>1</div>
         <div>2</div>
         <div>3</div>
         <div>4</div>
         <div>5</div>
         <div>6</div>
      </div>
   </body>
</html>
This gives the following output
Find Duplicates of array using bit array in C++

We have an array of n numbers, where n is maximum 32,000. Now the given array may have duplicate entries and we do not know what n is. Now the question is arisen that with only4 Kilobytes of memory available, how would display or print all duplicates elements in the array?
arr[] = {2, 6, 2, 11, 13, 11}
2 11
2 and 11 appear more than once in given array.
arr[] = {60, 50, 60}
60
Now we have 4 Kilobytes of memory which indicates we can address up to 8 * 4 * 210 bits.It should be noted that 32 * 210 bits is larger than 32000. So we can generate a bit with32000 bits, where each bit represents one integer.
Again it should be noted that if we require generating a bit with more than 32000 bits then we can
generate easily more and more than 32000; implementing this bit vector, we can be able to iterate through the array, flagging each element v by setting bit v to 1. In this case, when we traverse a duplicate element, we print it.
 Live Demo
// C++ program to print all Duplicates in array
#include <bits/stdc++.h>
using namespace std;
// Shows a class to represent an array of bits using
// array of integers
class BitArray{
   int *arr1;
   public:
   BitArray() {}
   // Constructor
   BitArray(int n1){
      // Used to divide by 32. To store n bits, we require
      // n/32 + 1 integers (Assuming int is stored
      // using 32 bits)
      arr1 = new int[(n1 >> 5) + 1];
   }
   // Now get value of a bit at given position
   bool get(int pos1){
      // Used to divide by 32 to find position of
      // integer.
      int index1 = (pos1 >> 5);
      // Now determine bit number in arr[index]
      int bitNo1 = (pos1 & 0x1F);
      // Determine value of given bit number in
      // arr1[index1]
      return (arr1[index1] & (1 << bitNo1)) != 0;
   }
   // Used to set a bit at given position
   void set(int pos1){
      // Determine index of bit position
      int index1 = (pos1 >> 5);
      // Used to set bit number in arr1[index1]
      int bitNo1 = (pos1 & 0x1F);
      arr1[index1] |= (1 << bitNo1);
   }
   //Shows main function to print all Duplicates
   void checkDuplicates1(int arr1[], int n1){
      // Used to create a bit with 32000 bits
      BitArray ba1 = BitArray(320000);
      // Used to traverse array elements
      for (int i = 0; i < n1; i++){
         // Shows index in bit array
         int num1 = arr1[i];
         // Now if num is already present in bit array
         if (ba1.get(num1))
            cout << num1 << " ";
         // Otherwise or else insert num
         else
            ba1.set(num1);
      }
   }
};
// Driver code
int main(){
   int arr1[] = {2, 6, 2, 11, 13, 11};
   int n1 = sizeof(arr1) / sizeof(arr1[0]);
   BitArray obj1 = BitArray();
   obj1.checkDuplicates1(arr1, n1);
   return 0;
}
2 11