code-rag-bench/online-tutorials huggingface dataset:
Python - Eliminate Capital Letter Starting words from String - GeeksforGeeks

16 Feb, 2022
Sometimes, while working with Python Strings, we can have a problem in which we need to remove all the words beginning with capital letters. Words that begin with capital letters are proper nouns and their occurrence mean different meaning to the sentence and can be sometimes undesired. Let’s discuss certain ways in which this task can be performed. 
Input : test_str = ‘GeeksforGeeks is best for Geeks’ Output : ‘ is best for ‘Input : test_str = ‘GeeksforGeeks Is Best For Geeks’ Output : ”  
Method #1 : Using join() + split() + isupper() The combination of the above functions can provide one of the ways in which this problem can be solved. In this, we perform the task of extracting individual strings with an upper case using isupper() and then perform join() to get the resultant result. 
Python3
# Python3 code to demonstrate working of# Eliminate Capital Letter Starting words from String# Using join() + split() + isupper()     # initializing stringtest_str = 'GeeksforGeeks is Best for Geeks' # printing original stringprint("The original string is : " + str(test_str)) # Eliminate Capital Letter Starting words from String# Using join() + split() + isupper()temp = test_str.split()res = " ".join([ele for ele in temp if not ele[0].isupper()]) # printing resultprint("The filtered string : " + str(res))
The original string is : GeeksforGeeks is Best for Geeks
The filtered string : is for
 
 Method #2 : Using regex() Using regex is one of the ways in which this problem can be solved. In this, we extract all the elements that are upper case using appropriate regex. 
Python3
# Python3 code to demonstrate working of# Eliminate Capital Letter Starting words from String# Using regex()import re     # initializing stringtest_str = 'GeeksforGeeks is Best for Geeks' # printing original stringprint("The original string is : " + str(test_str)) # Eliminate Capital Letter Starting words from String# Using regex()res = re.sub(r"\s*[A-Z]\w*\s*", " ", test_str).strip() # printing resultprint("The filtered string : " + str(res))
The original string is : GeeksforGeeks is Best for Geeks
The filtered string : is for
 
reenadevi98412200
Python string-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python Classes and Objects
How to drop one or multiple columns in Pandas Dataframe
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Split string into list of characters
Python | Convert a list to dictionary
How to print without newline in Python?
Java Program To Jumble an Array - GeeksforGeeks

24 Nov, 2020
Given an array of size N, and the task is to shuffle the elements of the array or any other permutation. Using Java think of stuffing the array by generating random sequences of the elements present in the array is possible. This Algorithm is called Fisher-Yates Shuffle Algorithm.
Fisher–Yates shuffle Algorithm Works in O(n) time complexity. The assumption is that a give a function rand() generates a random number in O(1) time. Start from the last element, swap it with a randomly selected element from the whole array. Now consider the array from 0 to n-2 (size reduced by 1), and repeat till we hit the first element.
Example:
Input : arr[] = {1, 2, 3, 4}
Output: arr[] = {3, 2, 4, 1}

Input : arr[] = {5, 2, 3, 4}
Output: arr[] = {2, 4, 3, 5}

Algorithm:
  for i from n - 1 downto 1 do
       j = random integer with 0 <= j <= i
       exchange a[j] and a[i]

Below is the implementation of the above approach:
Java
// Program to jumble an array  using Javaimport java.util.Random;import java.io.*;  public class GFG {    public static void shuffleanarray(int[] a)    {        int n = a.length;        Random random = new Random();        // generating random number from list        random.nextInt();                for (int i = 0; i < n; i++) {                        // using random generated number            int change = i + random.nextInt(n - i);                        // swapping elements to shuffle            int holder = a[i];            a[i] = a[change];            a[change] = holder;        }    }    public static void main(String[] args)    {        int[] a = new int[] { 0, 1, 2, 3, 4, 5, 6 };        shuffleanarray(a);        System.out.print("arr[] = {");        for (int i : a) {            System.out.print(i + " ");        }        System.out.print("}");    }}
arr[] = {4 0 6 1 5 3 2 }

Time Complexity: O(N), where N is the size of an array.
Java-Array-Programs
Java
Java Programs
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Object Oriented Programming (OOPs) Concept in Java
HashMap in Java with Examples
Stream In Java
Interfaces in Java
How to iterate any Map in Java
Initializing a List in Java
Convert a String to Character Array in Java
Java Programming Examples
Convert Double to Integer in Java
Implementing a Linked List in Java using Class
GATE | GATE-CS-2006 | Question 26 - GeeksforGeeks

11 Oct, 2021
Which one of the first order predicate calculus statements given below correctly express the followingEnglish statement?
Tigers and lions attack if they are hungry or threatened. 
(A) A(B) B(C) C(D) DAnswer: (D)Explanation: The statement “Tigers and lions attack if they are hungry or threatened” means that if an animal is either tiger or lion, then if it is hungry or threatened, it will attack. So option (D) is correct.Don’t get confused by “and” between tigers and lions in the statement. This “and” doesn’t mean that we will write “tiger(x) ∧ lion(x) “, because that would have meant that an animal is both tiger and lion, which is not what we want.
Source: www.cse.iitd.ac.in/~mittal/gate/gate_math_2006.html
YouTubeGeeksforGeeks GATE Computer Science16.4K subscribersGate PYQ's on Propositional and First order Logic with Sakshi Singhal | GeeksforGeeks GATEWatch laterShareCopy linkInfoShoppingTap to unmuteIf playback doesn't begin shortly, try restarting your device.You'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.CancelConfirmMore videosMore videosSwitch cameraShareInclude playlistAn error occurred while retrieving sharing information. Please try again later.Watch on0:000:0030:03 / 41:23•Live•<div class="player-unavailable"><h1 class="message">An error occurred.</h1><div class="submessage"><a href="https://www.youtube.com/watch?v=ID4_2ewAGE0" 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-CS-2006
GATE-GATE-CS-2006
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | Gate IT 2007 | Question 25
GATE | GATE-CS-2001 | Question 39
GATE | GATE-CS-2000 | Question 41
GATE | GATE-CS-2005 | Question 6
GATE | GATE MOCK 2017 | Question 21
GATE | GATE-CS-2006 | Question 47
GATE | GATE MOCK 2017 | Question 24
GATE | Gate IT 2008 | Question 43
GATE | GATE-CS-2009 | Question 38
GATE | GATE-CS-2003 | Question 90
Internal static variable vs. External static variable with Examples in C - GeeksforGeeks

20 Nov, 2019
The static variable may be internal or external depending on the place of declaration. Static variables are stored in initialised data segments.
Internal Static Variables: Internal Static variables are defined as those having static variables which are declared inside a function and extends up to the end of the particular function.
Syntax:
 
main( ) 
{
  static datatype variable;
  // other statements
}

Example:
// C program to demonstrate// Internal Static Variables  #include <stdio.h>  int value();  int main(){    printf("%d", value());    return 0;}  int value(){    static int a = 5;    return a;}
5

External Static Variables: External Static variables are those which are declared outside a function and set globally for the entire file/program.
Syntax:
 
static datatype variable;

main()
{
  statements
}

function1()
{
  statements
}

Example:
// C program to demonstrate// External Static Variables  #include <stdio.h>  int add(int, int);  static int a = 5;  int main(){    int c;    printf("%d", add(a, c));}  int add(int c, int b){    b = 5;    c = a + b;    return c;}
10

Difference between internal static variables and External static variables:
Static Keyword
C Language
Difference Between
Technical Scripter
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
TCP Server-Client implementation in C
Exception Handling in C++
Multithreading in C
'this' pointer in C++
Arrow operator -> in C/C++ with Examples
Difference between BFS and DFS
Class method vs Static method in Python
Differences between TCP and UDP
Difference between var, let and const keywords in JavaScript
Differences between IPv4 and IPv6
towlower() function in C/C++ - GeeksforGeeks

30 Aug, 2018
The towlower() is a built-in function in C/C++ which converts the given wide character into lowercase. It is defined within the cwctype header file of C++.
It is a function in header file , so it is mandatory to use this header file if using this function
It is the wide-character equivalent of the tolower() function.
Syntax:
wint_t towlower( wint_t ch )
Parameter: The function accepts a single mandatory parameter ch which specifies the wide character which we have to convert into lowercase.
Return Value: The function returns the lowercase equivalent to c, if such value exists, or c (unchanged) otherwise. The value is returned as a wint_t value that can be implicitly casted to wchar_t.
Below programs illustrates the above function.
Program 1:
// Program to illustrate// towlower() function#include <cwchar>#include <cwctype>#include <iostream>using namespace std;int main(){      wchar_t str[] = L"GeeksforGeeks";    wcout << L"The lowercase version of \""          << str << L"\" is ";      for (int i = 0; i < wcslen(str); i++)        // Function to convert the character        // into the lowercase version, if exists        putwchar(towlower(str[i]));      return 0;}
Output:
The lowercase version of "GeeksforGeeks" is geeksforgeeks

Program 2:
// Program to illustrate// towlower() function#include <cwchar>#include <cwctype>#include <iostream>using namespace std;int main(){      wchar_t str[] = L"hello Ishwar 123!@#";    wcout << L"The lowercase version of \""          << str << L"\" is ";      for (int i = 0; i < wcslen(str); i++)        // Function to convert the character        // into the lowercase version, if exists        putwchar(towlower(str[i]));      return 0;}
Output:
The lowercase version of "hello Ishwar 123!@#" is hello ishwar 123!@#

C-Library
CPP-Functions
STL
C++
STL
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Inheritance in C++
Map in C++ Standard Template Library (STL)
C++ Classes and Objects
Bitwise Operators in C/C++
Virtual Function in C++
Templates in C++ with Examples
Constructors in C++
Operator Overloading in C++
Socket Programming in C/C++
vector erase() and clear() in C++
Java Examples - Check equality of two arrays

How to check if two arrays are equal or not?
Following example shows how to use equals () method of Arrays to check if two arrays are equal or not.
import java.util.Arrays;

public class Main {
   public static void main(String[] args) throws Exception {
      int[] ary = {1,2,3,4,5,6};
      int[] ary1 = {1,2,3,4,5,6};
      int[] ary2 = {1,2,3,4};
      System.out.println("Is array 1 equal to array 2?? " +Arrays.equals(ary, ary1));
      System.out.println("Is array 1 equal to array 3?? " +Arrays.equals(ary, ary2));
   }
}
The above code sample will produce the following result.
Is array 1 equal to array 2?? true
Is array 1 equal to array 3?? false

Another sample example of Array compare
import java.util.Arrays;

public class HelloWorld {
   public static void main (String[] args) {
      int arr1[] = {1, 2, 3};
      int arr2[] = {1, 2, 3};
      if (Arrays.equals(arr1, arr2)) System.out.println("Same");
      else System.out.println("Not same");
   }
}
The above code sample will produce the following result.
Same   

Another sample example of Array compare
public class HelloWorld {
   public static void main (String[] args) {
      int arr1[] = {1, 2, 3};
      int arr2[] = {1, 2, 3};
      
      if (arr1 == arr2) System.out.println("Same");
      else System.out.println("Not same");
   }
}
The above code sample will produce the following result.
Not same   

 Print
 Add Notes
 Bookmark this page
What is late binding in C#?

In static polymorphism, the response to a function is determined at the compile time. In dynamic polymorphism, it is decided at run-time. Dynamic polymorphism is what we call late binding.
Dynamic polymorphism is implemented by abstract classes and virtual functions. The following is an example showing an example of dynamic polymorphism −
 Live Demo
using System;

namespace PolymorphismApplication {
   class Shape {
      protected int width, height;

      public Shape( int a = 0, int b = 0) {
         width = a;
         height = b;
      }

      public virtual int area() {
         Console.WriteLine("Parent class area :");
         return 0;
      }
   }

   class Rectangle: Shape {
      public Rectangle( int a = 0, int b = 0): base(a, b) {}
      public override int area () {
         Console.WriteLine("Rectangle class area :");
         return (width * height);
      }
   }

   class Triangle: Shape {
      public Triangle(int a = 0, int b = 0): base(a, b) {}
      public override int area() {
         Console.WriteLine("Triangle class area :");
         return (width * height / 2);
      }
   }

   class Caller {
      public void CallArea(Shape sh) {
         int a;
         a = sh.area();
         Console.WriteLine("Area: {0}", a);
      }
   }

   class Tester {
      static void Main(string[] args) {
         Caller c = new Caller();
         Rectangle r = new Rectangle(10, 7);
         Triangle t = new Triangle(10, 5);
         c.CallArea(r);
         c.CallArea(t);
         Console.ReadKey();
      }
   }
}
Rectangle class area :
Area: 70
Triangle class area :
Area: 25
C++ program to reverse an array elements (in place)

Suppose we have an array with n different elements. We shall have to reverse the elements present in the array and display them. (Do not print them in reverse order, reverse elements in place).
So, if the input is like n = 9 arr = [2,5,6,4,7,8,3,6,4], then the output will be [4,6,3,8,7,4,6,5,2]
To solve this, we will follow these steps −
for initialize i := 0, when i < quotient of n/2, update (increase i by 1), do:temp := arr[i]arr[i] := arr[n - i - 1]arr[n - i - 1] := temp
for initialize i := 0, when i < quotient of n/2, update (increase i by 1), do:
temp := arr[i]
temp := arr[i]
arr[i] := arr[n - i - 1]
arr[i] := arr[n - i - 1]
arr[n - i - 1] := temp
arr[n - i - 1] := temp
for initialize i := 0, when i < n, update (increase i by 1), do:display arr[i]
for initialize i := 0, when i < n, update (increase i by 1), do:
display arr[i]
display arr[i]
Let us see the following implementation to get better understanding −
#include <iostream>
using namespace std;
int main(){
    int n = 9;
    int arr[n] = {2,5,6,4,7,8,3,6,4};
    int temp;
    for(int i = 0; i<n/2; i++){
        temp = arr[i];
        arr[i] = arr[n-i-1];
        arr[n-i-1] = temp;
    }
    for(int i = 0; i < n; i++){
        cout << arr[i] << " ";
    }
}

9, {2,5,6,4,7,8,3,6,4}
4 6 3 8 7 4 6 5 2
Creating views in MongoDB

To create views in MongoDB, use createView(). Let us create a collection with documents −
> db.demo113.insertOne(
... { _id: 1, StudentId: "101", "Details": { Name: "Chris", Age: 21 }, Subject: "MySQL" }
... );
{ "acknowledged" : true, "insertedId" : 1 }
Display all documents from a collection with the help of find() method −
> db.demo113.find().pretty();
This will produce the following output −
{
   "_id" : 1,
   "StudentId" : "101",
   "Details" : {
      "Name" : "Chris",
      "Age" : 21
   },
   "Subject" : "MySQL"
}
Following is the query to create views in MongoDB −
> db.createView(
...    "firstView",
...    "demo113",
...    [ { $project: { "Name": "$Details.Name", Subject: 1 } } ]
... )
{ "ok" : 1 }
Display fields from a view with the help of find() method −
> db.firstView.find();
This will produce the following output −
{ "_id" : 1, "Subject" : "MySQL", "Name" : "Chris" }
How to add custom ExpectedConditions for Selenium?

We can add custom ExpectedConditions for Selenium webdriver. We require this custom ExpectedConditions when the default expected conditions provided by webdriver are not enough to satisfy some scenarios.
The method until is used which is a part of the WebDriverWait class. Here, the ExpectedConditions are used to wait for a specific criteria to be satisfied. This method pauses whenever one of the below incidents happen −
The timeout duration specified has elapsed.
The timeout duration specified has elapsed.
The criteria defined yields neither false nor null.
The criteria defined yields neither false nor null.
We can have a custom ExpectedCondition by creating an object of expected criteria and by taking the help of apply method.
Let us take an example of the below page. Let us click on the Team link.
On clicking on Team, a corresponding paragraph appears on right. Let us verify if the paragraph has appeared and also verify the text India appears within that paragraph.
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.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class CustomExpCondition{
   public static void main(String[] args)
      throws InterruptedException{
      System.setProperty("webdriver.chrome.driver",
      "C:\\Users\\ghs6kor\\Desktop\\Java\\chromedriver.exe");
      WebDriver driver = new ChromeDriver();
      driver.manage().timeouts().implicitlyWait(4, TimeUnit.SECONDS);
      driver.get("https://www.tutorialspoint.com/about/about_careers.htm");
      // identify element
      WebElement l=driver.findElement(By.linkText("Team"));
      l.click();
      //object of WebDriverWait class with wait time
      WebDriverWait w = new WebDriverWait(driver,7);
      //custom expected condition with until method
      w.until(new ExpectedCondition <Boolean> (){
         public Boolean apply(WebDriver driver) {
            //identify paragraph
            WebElement e= driver.findElement(By.tagName("p"));
            if (e!= null){
               //to check if paragraph is displayed and has text India
               if (e.isDisplayed() && e.getText().contains("India")) {
                  System.out.println("Element found");
                  return true;
               }
               else {
                  System.out.println("Element not found");
                  return false;
               }  
            }
            return false;
         }
      });
      driver.close();
   }
}
How to create a long multi-line string in Python?

To create multiline strings, instead of using one pair of single/double quotes, we use three pairs. For example,
multiline_str = """
My
multi-line
string
"""
print multiline_str
 This will give the output:
  My
  multi-line
  string
 Note that you cannot interpolate strings using this notation. This notation is also used to define docstrings in Python.
R - Switch Statement

A switch statement allows a variable to be tested for equality against a list of values. Each value is called a case, and the variable being switched on is checked for each case.
The basic syntax for creating a switch statement in R is −
switch(expression, case1, case2, case3....)

The following rules apply to a switch statement −
If the value of expression is not a character string it is coerced to integer.
If the value of expression is not a character string it is coerced to integer.
You can have any number of case statements within a switch. Each case is followed by the value to be compared to and a colon.
You can have any number of case statements within a switch. Each case is followed by the value to be compared to and a colon.
If the value of the integer is between 1 and nargs()−1 (The max number of arguments)then the corresponding element of case condition is evaluated and the result returned.
If the value of the integer is between 1 and nargs()−1 (The max number of arguments)then the corresponding element of case condition is evaluated and the result returned.
If expression evaluates to a character string then that string is matched (exactly) to the names of the elements.
If expression evaluates to a character string then that string is matched (exactly) to the names of the elements.
If there is more than one match, the first matching element is returned.
If there is more than one match, the first matching element is returned.
No Default argument is available.
No Default argument is available.
In the case of no match, if there is a unnamed element of ... its value is returned. (If there is more than one such argument an error is returned.)
In the case of no match, if there is a unnamed element of ... its value is returned. (If there is more than one such argument an error is returned.)
x <- switch(
   3,
   "first",
   "second",
   "third",
   "fourth"
)
print(x)
When the above code is compiled and executed, it produces the following result −
[1] "third"


    12 Lectures 
     2 hours 

 Nishant Malik

    10 Lectures 
     1.5 hours 

 Nishant Malik

    12 Lectures 
     2.5 hours 

 Nishant Malik

    20 Lectures 
     2 hours 

 Asif Hussain

    10 Lectures 
     1.5 hours 

 Nishant Malik

    48 Lectures 
     6.5 hours 

 Asif Hussain
 Print
 Add Notes
 Bookmark this page
Data Structures | Heap | Question 6 - GeeksforGeeks

28 Jun, 2021
What is the content of the array after two delete operations on the correct answer to the previous question?(A) 14,13,12,10,8(B) 14,12,13,8,10(C) 14,13,8,12,10(D) 14,13,12,8,10Answer: (D)Explanation: For Heap trees, deletion of a node includes following two operations.
1) Replace the root with last element on the last level.2) Starting from root, heapify the complete tree from top to bottom..
Let us delete the two nodes one by one:1) Deletion of 25:Replace 25 with 12
          12
        /    \
      /       \
    14        16
   / \         /
 /     \      /
13     10    8
Since heap property is violated for root (16 is greater than 12), make 16 as root of the tree.
           16
        /     \
      /        \
    14         12
   / \         /
  /   \       /
13     10    8
2) Deletion of 16:Replace 16 with 8
           8
        /    \
       /      \
    14         12
   / \
  /   \
 13     10
Heapify from root to bottom.
           14
         /    \
       /       \
     8         12
    / \
   /   \
 13     10
            14
         /     \
        /       \
     13         12
    / \
   /   \
  8    10
Quiz of this Question
Data Structures
Data Structures-Heap
Heap Quizzes
Data Structures
Data Structures
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Count of triplets in an Array (i, j, k) such that i < j < k and a[k] < a[i] < a[j]
Advantages and Disadvantages of Linked List
C program to implement Adjacency Matrix of a given Graph
Introduction to Data Structures | 10 most commonly used Data Structures
Difference between Singly linked list and Doubly linked list
FIFO vs LIFO approach in Programming
Data Structures | Stack | Question 6
Bit manipulation | Swap Endianness of a number
Advantages of vector over array in C++
Data Structures | Queue | Question 11
SQL | ALTER (ADD, DROP, MODIFY) - GeeksforGeeks

21 Mar, 2018
ALTER TABLE is used to add, delete/drop or modify columns in the existing table. It is also used to add and drop various constraints on the existing table.
ALTER TABLE – ADD
ADD is used to add columns into the existing table. Sometimes we may require to add additional information, in that case we do not require to create the whole database again, ADD comes to our rescue.
Syntax:
 ALTER TABLE table_name
              ADD (Columnname_1  datatype,
              Columnname_2  datatype,
              ...
              Columnname_n  datatype);

ALTER TABLE – DROP
DROP COLUMN is used to drop column in a table. Deleting the unwanted columns from the table.
Syntax:
ALTER TABLE table_name
DROP COLUMN column_name;

ALTER TABLE-MODIFY
It is used to modify the existing columns in a table. Multiple columns can also be modified at once.*Syntax may vary slightly in different databases.
Syntax(Oracle,MySQL,MariaDB):
 ALTER TABLE table_name
MODIFY column_name column_type;

Syntax(SQL Server):
 ALTER TABLE table_name
ALTER COLUMN column_name column_type;


Queries
Sample Table:
Student
QUERY:
To ADD 2 columns AGE and COURSE to table Student.
 ALTER TABLE Student ADD (AGE number(3),COURSE varchar(40));
OUTPUT:
MODIFY column COURSE in table Student
 ALTER TABLE Student MODIFY COURSE varchar(20);

After running the above query maximum size of Course Column is reduced to 20 from 40.
DROP column COURSE in table Student.
 ALTER TABLE Student DROP COLUMN COURSE;
OUTPUT:
This article is contributed by Shubham Chaudhary. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
khushboogoyal499
SQL-Clauses-Operators
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
SQL Interview Questions
CTE in SQL
How to Update Multiple Columns in Single Update Statement in SQL?
Difference between DELETE, DROP and TRUNCATE
MySQL | Group_CONCAT() Function
How to Create a Table With Multiple Foreign Keys in SQL?
Difference between DELETE and TRUNCATE
SQL - ORDER BY
What is Temporary Table in SQL?
MySQL | Regular expressions (Regexp)
Check if two enums are equal or not in C# - GeeksforGeeks

28 May, 2019
Enum.Equals(Object) Method is used to check whether the current instance is equal to a specified object or not. This method overrides ValueType.Equals(Object) to define how enumeration members are evaluated for equality.
Syntax:
public override bool Equals (object obj);
Here, obj is an object to compare with the current instance, or null.
Returns: This method returns true if obj is an enumeration value of the same type and with the same underlying value as current instance otherwise, false.
Example:
// C# program to illustrate the// Enum.Equals(Object) Methodusing System;  class GFG {      // taking two enums    enum Clothes { Jeans,                   Shirt }    ;    enum Colors { Blue,                  Black }    ;      // Main Method    public static void Main()    {          Clothes cl1 = Clothes.Jeans;        Clothes cl2 = Clothes.Shirt;          Colors c1 = Colors.Blue;        Colors c2 = Colors.Black;        Colors c3 = Colors.Blue;          // using the method        Console.WriteLine(c1.Equals(c3));        Console.WriteLine(c1.Equals(c2));        Console.WriteLine(cl1.Equals(cl2));    }}
True
False
False

Reference:
https://docs.microsoft.com/en-us/dotnet/api/system.enum.equals?view=netframework-4.8
CSharp-method
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Destructors in C#
Difference between Ref and Out keywords in C#
C# | Delegates
C# | Constructors
C# | Class and Object
Extension Method in C#
Introduction to .NET Framework
C# | Abstract Classes
C# | Data Types
HashSet in C# with Examples
Watir - Working with Browsers

By default, Watir will open chrome browser in-case the browser name is not specified. The required browser drivers are installed along with Watir installation. In case you face any issues working with browsers, install the driver as shown in the Browsers drivers chapter and update the location in PATH variable.
In this chapter, we will understand how to open the browser using Watir.
Open the IDE RubyMine and create a new file: test1.rb
Select OK and click the file pattern as ruby as shown below −
Click on OK to create the file.
Now we will write a simple code that will open the browser as shown below −
require 'watir'
Watir::Browser.new
Click on the Run button that is highlighted in the IDE as shown above. On-click of Run, it will open browser as shown below −
The browser will open and close automatically. Let us now add some more code to the test1.rb.
We can specify the name of the browser as shown below −
require 'watir'
Watir::Browser.new :chrome
Now let us open a page-url in our test case.
require 'watir'
browser = Watir::Browser.new
browser.goto("https://www.google.com")
Click on Run to see the output as shown below −
Similarly, you can open firefox, safari, Internet explorer browser.
require 'watir'
Watir::Browser.new :firefox
Watir Code
require 'watir'
browser = Watir::Browser.new :ie
browser.goto("https://www.google.com")
When we run the code following error is displayed −
Unable to find IEDriverServer. Please download the server from
(Selenium::WebDriver::Error::WebDriverError)

http://selenium-release.storage.googleapis.com/index.html and place it
somewhere on your PATH.

More info at
https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver.

This means that watir package does not have InternetExplorer Driver. We have downloaded the same from here − https://docs.seleniumhq.org/download/ and updated in PATH variable.
Now run it again to see the Internet Explorer browser opening as shown below −
require 'watir'
browser = Watir::Browser.new :safari
browser.goto("https://www.google.com")
require 'watir'
browser = Watir::Browser.new :edge
browser.goto("https://www.google.com")
 Print
 Add Notes
 Bookmark this page
Comparing SH, BASH, KSH, and ZSH Speed | by Shinichi Okada | Towards Data Science

I often hear and read that Bash is slow. So I spent one weekend checking how slow it is. I used two methods. The first one is ShellBench. The ShellSpec created a benchmark utility for POSIX shell comparison. The second one is the sh-benchmark script created by @satoh_fumiyasu.
Read on to find out what I discovered.
I use a MacBook Pro.
And these are my sh, bash, ksh, and zsh versions:
❯ sh --versionGNU bash, version 3.2.57(1)-release (x86_64-apple-darwin20)Copyright (C) 2007 Free Software Foundation, Inc.❯ bash --versionGNU bash, version 5.1.4(1)-release (x86_64-apple-darwin20.2.0)Copyright (C) 2020 Free Software Foundation, Inc.License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>This is free software; you are free to change and redistribute it.There is NO WARRANTY, to the extent permitted by law.❯ ksh --version  version         sh (AT&T Research) 93u+ 2012-08-01❯ zsh --versionzsh 5.8 (x86_64-apple-darwin20.0)
You can run a test with any shells, sh, bash, ksh, mksh, posh, zsh, etc with ShellBench. It returns the number of executions per second. It provides eight sample benchmark tests.
The ShellBench counts the number of times a sample code is executed. The “assign sample test” tests assigning a variable in different ways, the “count sample test” tests different ways of counting, etc.
I used all sample tests for sh, bash, ksh, and zsh.
Here is a table from one of my results.
The tests return the number of executions per second and this means taller graphs are better results in the following graphs.
assign and cmp
sh: Blue, bash: Yellow, ksh: Green, zsh: Red.
count and eval
func and null
output and subshell
The ksh and zsh seems about seven times faster than bash. The ksh excelled in 17 tests and the zsh in six tests.
The sh-benchmark tests on parameter expansions, array parameter expansions, arithmetic evaluations, tests, and iterate parameters.
The script returns results relative to the bash results. All numbers are in percentage. So smaller numbers imply faster.
bash: Blue, ksh: Yellow, zsh: Green
The zsh was the fastest in six tests and the ksh was the fastest in seven tests.
Interestingly zsh was very slow for the Fork test.
If you want to test it yourself you can follow this.
Shellbench
You can clone Shellbench, make the shellbench file executable, and run the script:
$ ./shellbench -s sh,bash,ksh,zsh sample/count.sh sample/output.sh
sh-benchmark
Copy sh-benchmark.zsh and sh-benchmark-scripts into the same directory. Make the sh-benchmark.zsh executable and run it on your terminal:
$ sh-benchmark.zsh
According to my tests, ksh is the winner and zsh is the runner-up. Both shells are 2–30 times faster than bash depending on the test.
If you use bash for less than 100 lines as Google Shell Style Guide suggests, then I don’t think you will notice the difference. Although it will of course depend on the task.
Get full access to every story on Medium by becoming a member.
Create Two Columns with Two Nested Columns in Bootstrap

To create two columns in two nested columns, you can try to run the following code −
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <title>Bootstrap Example</title>
      <link href = "/bootstrap/css/bootstrap.min.css" rel = "stylesheet">
      <script src = "/scripts/jquery.min.js"></script>
      <script src = "/bootstrap/js/bootstrap.min.js"></script>
   </head>
   <body>
      <h2>Nested Columns</h2>
      <div class = "row">
         <div class = "col-sm-9" style = "background-color:orange;">
            Column1
            <div class="row">
               <div class = "col-sm-6" style="background-color:orange; color:white;">nested column</div>
               <div class = "col-sm-6" style="background-color:orange; color:white;">nested column</div>
            </div>
         </div>
         <div class = "col-sm-3" style="background-color:red;">Column2</div>
      </div>
   </body>
</html>
Org.Json - JSONException Handling

Utility classes of org.json throws JSONException in case of invalid JSON. Following example shows how to handle JSONException.
import org.json.JSONException;
import org.json.XML;

public class JSONDemo {
   public static void main(String[] args) {
      try {
         //XML tag name should not have space.
         String xmlText = "<Other Details>null</Other Details>";
         System.out.println(xmlText);

         //Convert an XML to JSONObject
         System.out.println(XML.toJSONObject(xmlText));
      } 
      catch(JSONException e){   
         System.out.println(e.getMessage());
      }
   }
}
<Other Details>null</Other Details>
Misshaped close tag at 34 [character 35 line 1]


    18 Lectures 
     1.5 hours 

 Dr. Saatya Prasad

    107 Lectures 
     13.5 hours 

 Arnab Chakraborty

    75 Lectures 
     5 hours 

 Revathi Ramachandran

    14 Lectures 
     44 mins

 Zach Miller

    12 Lectures 
     54 mins

 Prof. Paul Cline, Ed.D

    54 Lectures 
     4 hours 

 Gilad James, PhD
 Print
 Add Notes
 Bookmark this page
Python - cmp() Method

The cmp() is part of the python standard library which compares two integers. The result of comparison is -1 if the first integer is smaller than second and 1 if the first integer is greater than the second. If both are equal the result of cmp() is zero.
Below example illustrates different scenario showing the use of cmp() method.
 Live Demo
def cmp(x, y):
   return (x > y) - (x < y)
#x>y
x = 5
y = 3
print("The cmp value for x>y is : ",cmp(x, y),"\n")
#x<y
x = 7
y = 9
print("The cmp value for x<y is : ",cmp(x, y),"\n")
#x=y
x = 13
y = 13
print("The cmp value for x=y is : ",cmp(x, y))
#odd and even
k = 16
if cmp(0, k % 2):
   print("\n","The given number",k,"is odd number ")
else:
   print("\n","The given number",k,"is even number")
k= 31
if cmp(0, k % 2):
   print("\n","The given number",k,"is odd number")
else:
   print("\n","The given number",k,"is even number")
Running the above code gives us the following result −
The cmp value for x>y is : 1

The cmp value for x<y is : -1

The cmp value for x=y is : 0

The given number 16 is even number

The given number 31 is odd number
Swing Animation Effect with CSS

The swing animation effect move or cause to move back and forth or from side to side while suspended or on an axis to an element.
Live Demo
<html>
   <head>
      <style>
         .animated {
            background-image: url(/css/images/logo.png);
            background-repeat: no-repeat;
            background-position: left top;
            padding-top:95px;
            margin-bottom:60px;
            -webkit-animation-duration: 10s;
            animation-duration: 10s;
            -webkit-animation-fill-mode: both;
            animation-fill-mode: both;
         }

         @-webkit-keyframes swing {
            20%, 40%, 60%, 80%, 100% { -webkit-transform-origin: top center; }
            20% { -webkit-transform: rotate(15deg); }
            40% { -webkit-transform: rotate(-10deg); }
            60% { -webkit-transform: rotate(5deg); }
            80% { -webkit-transform: rotate(-5deg); }
            100% { -webkit-transform: rotate(0deg); }
         }

         @keyframes swing {
            20% { transform: rotate(15deg); }
            40% { transform: rotate(-10deg); }
            60% { transform: rotate(5deg); }
            80% { transform: rotate(-5deg); }
            100% { transform: rotate(0deg); }
         }

         .swing {
            -webkit-transform-origin: top center;
            transform-origin: top center;
            -webkit-animation-name: swing;
            animation-name: swing;
         }
      </style>

   </head>
   <body>

      <div id = "animated-example" class = "animated swing"></div>
      <button onclick = "myFunction()">Reload page</button>

      <script>
         function myFunction() {
            location.reload();
         }
      </script>
   </body>
</html>
Matplotlib.axes.Axes.set_xticks() in Python

19 Apr, 2020
Matplotlib is a library in Python and it is numerical – mathematical extension for NumPy library. The Axes Class contains most of the figure elements: Axis, Tick, Line2D, Text, Polygon, etc., and sets the coordinate system. And the instances of Axes supports callbacks through a callbacks attribute.
The Axes.set_xticks() function in axes module of matplotlib library is used to Set the x ticks with list of ticks.
Syntax: Axes.set_xticks(self, ticks, minor=False)
Parameters: This method accepts the following parameters.
ticks : This parameter is the list of x-axis tick locations.
minor : This parameter is used whether set major ticks or to set minor ticks
Return value: This method does not returns any value.
Below examples illustrate the matplotlib.axes.Axes.set_xticks() function in matplotlib.axes:
Example 1:
# Implementation of matplotlib functionimport numpy as npimport matplotlib.pyplot as pltfrom matplotlib.patches import Polygon      def func(x):    return (x - 4) * (x - 6) * (x - 5) + 100      a, b = 2, 9  # integral limitsx = np.linspace(0, 10)y = func(x)   fig, ax = plt.subplots()ax.plot(x, y, "k", linewidth = 2)ax.set_ylim(bottom = 0)   # Make the shaded regionix = np.linspace(a, b)iy = func(ix)verts = [(a, 0), *zip(ix, iy), (b, 0)]poly = Polygon(verts, facecolor ='green',               edgecolor ='0.5', alpha = 0.4)ax.add_patch(poly)   ax.text(0.5 * (a + b), 30,        r"$\int_a ^ b f(x)\mathrm{d}x$",        horizontalalignment ='center',        fontsize = 20)   fig.text(0.9, 0.05, '$x$')fig.text(0.1, 0.9, '$y$')   ax.spines['right'].set_visible(False)ax.spines['top'].set_visible(False) ax.set_xticks((a, b))   fig.suptitle('matplotlib.axes.Axes.set_xticks()\ function Example\n\n', fontweight ="bold")fig.canvas.draw()plt.show()
Output:
Example 2:
# Implementation of matplotlib functionimport numpy as npimport matplotlib.pyplot as plt   # Fixing random state for reproducibilitynp.random.seed(19680801)   x = np.linspace(0, 2 * np.pi, 100)y = np.sin(x)y2 = y + 0.2 * np.random.normal(size = x.shape)   fig, ax = plt.subplots()ax.plot(x, y)ax.plot(x, y2)  ax.set_xticks([0, np.pi, 2 * np.pi])   ax.spines['left'].set_bounds(-1, 1)ax.spines['right'].set_visible(False)ax.spines['top'].set_visible(False)   fig.suptitle('matplotlib.axes.Axes.set_xticks() \function Example\n\n', fontweight ="bold")fig.canvas.draw()plt.show()
Output:
Python-matplotlib
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
JavaScript | Symbol.for() function

29 Oct, 2021
The Symbol.for() is an inbuilt function in JavaScript which is used to search for the given symbol into a runtime-wide symbol registry and if found then it returns the same symbol otherwise it creates a new symbol with the same name of the given symbol into the global symbol registry and returns them.
Syntax:
Symbol.for(key);

Here “Symbol” is the symbol which is to be searched into the runtime-wide symbol registry.
Parameters: This function accepts a parameter “key” which is the key to the symbol and used for the description of the symbol.
Return value: This function returns the given symbol is found in the runtime-wide symbol registry otherwise a new symbol is created with the same name as the given symbol and returned.
JavaScript code to show the working of this function:Example-1:
<script >    // Some symbols are created    const symbol1 = Symbol.for('Geeks');    const symbol2 = Symbol.for(123);    const symbol3 = Symbol.for("gfg");    const symbol4 = Symbol.for('789');      // Getting the same symbols if found     // in the global symbol registry    // otherwise a new created and returned    console.log(symbol1);    console.log(symbol2);    console.log(symbol3);    console.log(symbol4);</script>
Output:
> Symbol(Geeks)
> Symbol(123)
> Symbol(gfg)
> Symbol(789)

Example-2:
<script>    // Some symbols are created    const symbol1 = Symbol.for('a', 'b', 'c');    const symbol2 = Symbol.for(1, 2, 3);    const symbol3 = Symbol.for(1 + 2);    const symbol4 = Symbol.for("Geeks" + "for" + "Geeks");      // Getting the same symbols if found     // in the global symbol registry    // otherwise a new created and returned    console.log(symbol1);    console.log(symbol2);    console.log(symbol3);    console.log(symbol4); </script>
Output:
> Symbol(a)
> Symbol(1)
> Symbol(3)
> Symbol(GeeksforGeeks)

In the above code, the key should not be multiple otherwise it accepts the first element as the key and discard the remaining elements and if some arithmetic operator is used in place of the key then this function considers that key as the result of the operation.
Supported Browsers:
Google Chrome 40 and above
Edge 12 and above
Firefox 36 and above
Opera 27 and above
Safari 9 and above
Reference: https://devdocs.io/javascript/global_objects/symbol/for
ysachin2314
JavaScript-Symbol
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
Difference Between PUT and PATCH Request
How to append HTML code to a div using JavaScript ?
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
Merry Christmas (Program for Christmas Tree in C)

25 Dec, 2017
Since Christmas is right at the door, its time to celebrate it in the programmer’s way. Lets build a decorative Christmas tree in C.
To print a Christmas tree, we are printing pyramids of various sizes just one beneath the other.For the decoration, a random character is printed at each position.
Height and randomness can be adjusted. This is been repeated frame after frame to give the illusion of a true event.
Example:
Lets see the code.
// C program to print a  Christmas tree// It is recommended is try it with a desktop // compiler like CodeBlocks.#include <stdio.h>#include <stdlib.h>#include <time.h>#include <unistd.h>  #define RefRate 40000#define randomness 5 // high means less random  // Clear the shellvoid clrscr(){    system("@cls||clear");}  // Print a random character giving preference // to *void printRandLeaf(){    char leaftypes[5] = { '.', '*', '+', 'o', 'O' };    int temp = rand() % randomness;      // Giving preference to *    if (temp == 1)        printf("%c ", leaftypes[rand() % 5]);    else        printf("%c ", leaftypes[1]);}  void triangle(int f, int n, int toth){    int i, j, k = 2 * toth - 2;      for (i = 0; i < f - 1; i++)        k--;      // number of rows    for (i = f - 1; i < n; i++) {          // space handler        for (j = 0; j < k; j++)            printf(" ");          // decrementing k after each loop        k = k - 1;          // number of columns, printing stars        for (j = 0; j <= i; j++)            printRandLeaf();          printf("\n");    }}  // Prints multiple trianglesvoid printTree(int h){    int start = 1, stop = 0, diff = 3;    while (stop < h + 1) {        stop = start + diff;        triangle(start, stop, h);        diff++;        start = stop - 2;    }}  // Prints bottom part.void printLog(int n){    int i, j, k = 2 * n - 4;      for (i = 1; i <= 6; i++) {          // space handler        for (j = 0; j < k; j++)            printf(" ");          for (j = 1; j <= 6; j++)            printf("#");          printf("\n");    }}  // Driver codeint main(){    srand(time(NULL));    int ht = 6;      printf("\n*********MERRY CHRISTMAS*********\n\n");      // refresh loop    while (1) {        clrscr();        printTree(ht);          printLog(ht);        usleep(RefRate);    }      return 0;}
pattern-printing
C Language
School Programming
pattern-printing
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
ISRO | ISRO CS 2018 | Question 64

20 Nov, 2018
Given √224r = 13r the value of radix r is(A) 10(B) 8(C) 6(D) 5Answer: (D)Explanation:
√224r = 13r
taking square both sides

2r2 + 2r + 4 = r2 + 6r + 9
= r2 - 4r - 5 = 0
= (r - 5)(r + 1) = 0
r = 5 // since it can't be -1
So, option (D) is correct.Quiz of this Question
ISRO
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
ISRO | ISRO CS 2011 | Question 56
ISRO | ISRO CS 2018 | Question 44
ISRO | ISRO CS 2013 | Question 21
ISRO | ISRO CS 2018 | Question 74
ISRO | ISRO CS 2007 | Question 16
ISRO | ISRO CS 2009 | Question 30
ISRO | ISRO CS 2017 - May | Question 14
ISRO | ISRO CS 2014 | Question 64
ISRO | ISRO CS 2008 | Question 68
ISRO | ISRO CS 2015 | Question 13