code-rag-bench/online-tutorials huggingface dataset:
PostgreSQL – Continue

20 Sep, 2021
In PostgreSQL ,The continue statement is used to skip the current iteration prematurely and directly move on to the next iteration. The continue statement is used in conjecture with all types of loops including unconditional loops, while loops and for loops.
Syntax:
CONTINUE [ label ] [ WHEN boolean-expression ];
If we analyze the above syntax:
label: If no label is present, the next iteration of the loop starts. That is, all statements remaining in the loop body are skipped, and control returns to the loop control expression.However, if the label is present, it specifies the label of the loop whose execution will be continued. 
WHEN condition: It is simply a boolean expression that specifies the condition to skip the current iteration of the loop. If the condition is true, then the current loop iteration will be skipped. However, if it is false, the loop follows the normal flow pattern.
Both the label and WHEN condition is optional and may or may not be used with the continue statement;
Example 1 : 
The following example will be used to display the even numbers from 1 to 10.
do
$$
declare
  cnt int = 0;
begin
 loop
 -- increment of cnt
    cnt = cnt + 1;
 -- exit the loop if cnt > 10
 exit when cnt > 10;
 -- skip the iteration if cnt is an odd number
 continue when mod(cnt,2) = 1;
 -- print out the cnt
 raise notice '%', cnt;
 end loop;
end;
$$;
Output:
In the above example, we use the continue statement to skip the odd numbers by using the fact that the remainder when an odd number is divided by 2 is 1.  
The following example will be used to display all numbers from 1 to 10 without displaying the number 6.
do
$$
declare
  cnt int = 0;
begin 
 loop
 -- increment of cnt
    cnt = cnt + 1;
 -- exit the loop if cnt > 10
 exit when cnt > 10;
 -- skip the iteration if cnt is an odd number
 continue when cnt = 6;
 -- print out the cnt
 raise notice '%', cnt;
 end loop;
end;
$$;
Output:
In the above example, we use the continue statement to skip the iteration when the value of the cnt variable reaches 6.
anikaseth98
Picked
postgreSQL-clauses
Technical Scripter 2020
PostgreSQL
Technical Scripter
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
PostgreSQL - Psql commands
PostgreSQL - Change Column Type
PostgreSQL - For Loops
PostgreSQL - Function Returning A Table
PostgreSQL - LIMIT with OFFSET clause
PostgreSQL - ARRAY_AGG() Function
PostgreSQL - DROP INDEX
PostgreSQL - Create Auto-increment Column using SERIAL
PostgreSQL - Copy Table
How to use PostgreSQL Database in Django?
Binary Trees - GeeksforGeeks

06 Sep, 2021
     12
   /  
  20
 /
30
     12
   /   \
  20    30
 /
30
     12
   /   \
  20    30
       /  \  
      20   40

      12
    /   \
   20    30
  /  \  
 10   40

             o
        /    |    \
      o      o      o
   / | \          / | \
  o  o  o        o  o  o
                  / | \
                 o  o  o

k = 3
Number of internal nodes n = 4
Number of leaf nodes = (k-1)*n  + 1
                     = (3-1)*4 + 1
                     = 9 

             O
          /     \
        O        O
           (i)

            O
          /
       O
     /
   O
        (ii)

         O
       /
     O
        \
          O
       (iii)

  O
     \
       O
          \
           O
    (iv)

       O
          \
            O
          /
       O
    (v)
  L = (3-1)I + 1 = 2I + 1
  n = L + I
   H(n) = H(2n/3) + 1     

1)	Choose an i uniformly at random from 1..n; 
2)	If A[i] = x then Stop else Goto 1; 
number_of_comparisons_for_a_case * probability_for_the_case 

  If A[i] is found in the first attempt 
  number of comparisons = 1
  probability of the case  = 1/n

  If A[i] is found in the second attempt 
  number of comparisons = 2
  probability of the case  = (n-1)/n*1/n

  If A[i] is found in the third attempt 
  number of comparisons = 2
  probability of the case  = (n-1)/n*(n-1)/n*1/n

E  = 1/n + [(n-1)/n]*[1/n]*2 + [(n-1)/n]*[(n-1)/n]*[1/n]*3 + ....  (1)

E (n-1)/n = [(n-1)/n]*[1/n] + [(n-1)/n]*[(n-1)/n]*[1/n]*2 + 
                                 [(n-1)/n]*[(n-1)/n]*[(n-1)/n]*[1/n]*3 ..........(2)

E/n = 1/n + (n-1)/n*1/n + (n-1)/n*(n-1)/n*1/n + ............

  E/n = [1/n]/[1-(n-1)/n]  = 1
  E = n

    L = (n-1)*I + 1
  L = 41 , I = 10
  41 = 10*(n-1) + 1
  (n-1) = 4
  n = 5
Writing code in comment? Please use ide.geeksforgeeks.org, generate link and share the link here.
Comments
Old Comments
Must Do Coding Questions for Product Based Companies
Axios in React: A Guide for Beginners
Implementation of Bit Stuffing and Bit Destuffing
How to set background images in ReactJS ?
BigInt (BIG INTEGERS) in C++ with Example
How to Install Flutter on Visual Studio Code?
How to calculate MOVING AVERAGE in a Pandas DataFrame?
How to Show Images on Click using HTML ?
How to install bootstrap in React.js ?
Microsoft Interview Experience for Internship (Via Engage)
Tryit Editor v3.7

HTML Input types
Tryit: HTML submit button
Python | Count of elements matching particular condition - GeeksforGeeks

30 Dec, 2018
Checking a number/element by a condition is a common problem one faces and is done in almost every program. Sometimes we also require to get the totals that match the particular condition to have a distinguish which to not match for further utilization. Lets discuss certain ways in which this task can be achieved.
Method #1 : Using sum() + generator expressionThis method uses the trick of adding 1 to the sum whenever the generator expression returns true. By the time list gets exhausted, summation of count of numbers matching a condition is returned.
# Python 3 code to demonstrate # to get count of elements matching condition # using sum() + generator expression  # initializing listtest_list = [3, 5, 1, 6, 7, 9]  # printing original listprint ("The original list is : " + str(test_list))  # using sum() + generator expression# to get count of elements matching condition # checks for oddres = sum(1 for i in test_list if i % 2 != 0)  # printing resultprint ("The number of odd elements: " + str(res))
Output :
The original list is : [3, 5, 1, 6, 7, 9]
The number of odd elements: 5

Method #2 : Using sum() + map()map() does the task almost similar to the generator expression, difference is just the internal data structure employed by it is different hence more efficient.
# Python 3 code to demonstrate # to get count of elements matching condition # using sum()+ map()  # initializing listtest_list = [3, 5, 1, 6, 7, 9]  # printing original listprint ("The original list is : " + str(test_list))  # using sum()+ map()# to get count of elements matching condition # checks for oddres = sum(map(lambda i: i % 2 != 0, test_list))  # printing resultprint ("The number of odd elements: " + str(res))
Output :
The original list is : [3, 5, 1, 6, 7, 9]
The number of odd elements: 5

Method #3 : Using reduce() + lamdareduce function does the task of accumulation as the sum function in the above used methods. lambda is used to perform the condition against which result needs to be checked.
# Python 3 code to demonstrate # to get count of elements matching condition # using reduce() + lambda  # initializing listtest_list = [3, 5, 1, 6, 7, 9]  # printing original listprint ("The original list is : " + str(test_list))  # using reduce() + lambda# to get count of elements matching condition # checks for oddres = reduce(lambda count, i: count + (i % 2 != 0), test_list, 0)  # printing resultprint ("The number of odd elements: " + str(res))
Output :
The original list is : [3, 5, 1, 6, 7, 9]
The number of odd elements: 5

Python list-programs
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Read a file line by line in Python
Enumerate() in Python
How to Install PIP on Windows ?
Iterate over a list in Python
Different ways to create Pandas Dataframe
Python String | replace()
Create a Pandas DataFrame from Lists
Reading and Writing to text files in Python
*args and **kwargs in Python
How to get a JSON array field in a nested JSON using Rest Assured?

We can get a JSON array field in a nested JSON using Rest Assured. First, we shall obtain a Response body which is in JSON format from a request. Then convert it to string.
Finally, to obtain a particular array value, we shall use the array index followed by the field name. We shall send a GET request via Postman on a mock API, and observe the Response.
Using Rest Assured, let us get the value of the second zip field having the value as 49086. It is part of the second JSON in the Location array. We shall get the value of the second zip by traversing the path - Location[1].zip.
Code Implementation
import static io.restassured.RestAssured.given;
import org.testng.annotations.Test;
import io.restassured.RestAssured;
import io.restassured.path.json.JsonPath;
import io.restassured.response.Response;
public class NewTest {
   @Test
   public void jsonAryValue() {

      //base URI with Rest Assured class
      RestAssured.baseURI = "https://run.mocky.io/v3";

      //obtain Response from GET request
      Response res = given()
      .when()
      .get("/8ec8f4f7-8e68-4f4b-ad18-4f0940d40bb7");

      //convert JSON to string
      JsonPath j = new JsonPath(res.asString());

      //Zip for 2nd Location array
      String zip = j.getString("Location[1].zip");
      System.out.println("Zip for 2nd Location array: " + zip);
   }
}
Finding the last occurrence of a character in a String in Java

Use the lastIndexOf() method to find the last occurrence of a character in a string in Java.
Let’s say the following is our string.
String myStr = "Amit Diwan";
In the above string, we will find the last occurrence of character ‘i’
myStr.lastIndexOf('i');
The following is the complete example.
 Live Demo
public class Demo {
 public static void main(String[] args) {
    String myStr = "Amit Diwan";
    int strLastIndex = 0;
    System.out.println("String: "+myStr);
    strLastIndex = myStr.lastIndexOf('i');
    System.out.println("The last index of character a in the string: "+strLastIndex);
 }
}
String: Amit Diwan
The last index of character a in the string: 6
Update multiple columns of a single row MySQL?

Let us first create a table −
mysql> create table DemoTable
   -> (
   -> FirstName varchar(100),
   -> Age int,
   -> Score int
   -> );
Query OK, 0 rows affected (0.62 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('Robert',21,78);
Query OK, 1 row affected (0.10 sec)

mysql> insert into DemoTable values('Bob',20,90);
Query OK, 1 row affected (0.21 sec)

mysql> insert into DemoTable values('Sam',22,69);
Query OK, 1 row affected (0.20 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
+-----------+------+-------+
| FirstName | Age  | Score |
+-----------+------+-------+
| Robert    | 21   | 78    |
| Bob       | 20   | 90    |
| Sam       | 22   | 69    |
+-----------+------+-------+
3 rows in set (0.00 sec)
Following is the query to update columns Age and Score for only a row with FirstName “Bob” −
mysql> update DemoTable
   -> set Age=25,
   -> Score=Score+9
   -> where FirstName='Bob';
Query OK, 1 row affected (0.17 sec)
Rows matched: 1  Changed: 1 Warnings: 0
Let us check the table records once again −
mysql> select *from DemoTable;
+-----------+------+-------+
| FirstName | Age  | Score |
+-----------+------+-------+
| Robert    | 21   | 78    |
| Bob       | 25   | 99    |
| Sam       | 22   | 69    |
+-----------+------+-------+
3 rows in set (0.00 sec)
Scala Collections - Seq

Scala Seq is a trait to represent immutable sequences. This structure provides index based access and various utility methods to find elements, their occurences and subsequences. A Seq maintains the insertion order.
The following is the syntax for declaring an Seq variable.
val seq: Seq[Int] = Seq(1, 2, 3, 4, 5)

Here, seq is declared as an Seq of numbers. Seq provides commands like the following −
val isPresent = seq.contains(4);
val contains = seq.endsWith(Seq(4,5));
var lastIndexOf = seq.lasIndexOf(5);

Below is an example program of showing how to create, initialize and process Seq −
import scala.collection.immutable.Seq
object Demo {
   def main(args: Array[String]) = {
      var seq = Seq(1, 2, 3, 4, 5, 3)
      // Print seq elements
      seq.foreach{(element:Int) => print(element + " ")}
      println()
      println("Seq ends with (5,3): " + seq.endsWith(Seq(5, 3)))
      println("Seq contains 4: " + seq.contains(4))
      println("Last index of 3: " + seq.lastIndexOf(3))
      println("Reversed Seq" + seq.reverse)           
   }
}
Save the above program in Demo.scala. The following commands are used to compile and execute this program.
\>scalac Demo.scala
\>scala Demo

1 2 3 4 5 3
Seq ends with (5,3): true
Seq contains 4: true
Last index of 3: 5
Reversed SeqList(3, 5, 4, 3, 2, 1)


    82 Lectures 
     7 hours 

 Arnab Chakraborty

    23 Lectures 
     1.5 hours 

 Mukund Kumar Mishra

    52 Lectures 
     1.5 hours 

 Bigdata Engineer

    76 Lectures 
     5.5 hours 

 Bigdata Engineer

    69 Lectures 
     7.5 hours 

 Bigdata Engineer

    46 Lectures 
     4.5 hours 

 Stone River ELearning
 Print
 Add Notes
 Bookmark this page
How to find the Sum of two Binary Numbers using C#?

To find the sum of two binary numbers, firstly set them.
val1 = 11110;
val2 = 11100;
Now call the displaySum() method, which created to display the sumL.
sum = displaySum(val1, val2);
We have set a new array in the method to display each bit of the binary number.
long[] sum = new long[30];
Now let us see the complete code to calculate the sum of binary numbers as shown in the code below −
 Live Demo
using System;
class Demo {
   public static void Main(string[] args) {
      long val1, val2, sum = 0;
      val1 = 11110;
      val2 = 11100;

      Console.WriteLine("Binary one: "+val1);
      Console.WriteLine("Binary two: "+val2);

      sum = displaySum(val1, val2);
      Console.WriteLine("Sum = {0}", sum);
   }

   static long displaySum (long val1, long val2) {
      long i = 0, rem = 0, res = 0;
      long[] sum = new long[30];

      while (val1 != 0 || val2 != 0) {
         sum[i++] =(val1 % 10 + val2 % 10 + rem) % 2;
         rem =(val1 % 10 + val2 % 10 + rem) / 2;
         val1 = val1 / 10;
         val2 = val2 / 10;
      }
      if (rem != 0)
      sum[i++] = rem;

      i = i-1;

      while (i >= 0)
      res = res * 10 + sum[i--];
      return res;
   }
}
Binary one: 11110
Binary two: 11100
Sum = 111010
Python | Pandas Index.size - GeeksforGeeks

20 Feb, 2019
Pandas Index is an immutable ndarray implementing an ordered, sliceable set. It is the basic object which stores the axis labels for all pandas objects.
Pandas Index.size attribute return the number of elements in the underlying data of the given Index object.
Syntax: Index.size
Parameter : None
Returns : number of elements in the Index
Example #1: Use Index.size attribute to find the number of elements in the underlying data of the given Index object.
# importing pandas as pdimport pandas as pd  # Creating the indexidx = pd.Index(['Melbourne', 'Sanghai', 'Lisbon', 'Doha', 'Moscow', 'Rio'])  # Print the indexprint(idx)
Output :
Now we will use Index.size attribute to find the number of elements in the given Index object.
# return the number of elementsresult = idx.size  # Print the resultprint(result)
Output :As we can see in the output, the Index.size attribute has returned the number of elements in the given Index object. Example #2 : Use Index.size attribute to find the number of elements in the underlying data of the given Index object.
# importing pandas as pdimport pandas as pd  # Creating the indexidx = pd.Index([900 + 3j, 700 + 25j, 620 + 10j, 388 + 44j, 900])  # Print the indexprint(idx)
Output :
Now we will use Index.size attribute to find the number of elements in the given Index object.
# return the number of elementsresult = idx.size  # Print the resultprint(result)
Output :As we can see in the output, the Index.size attribute has returned the number of elements in the given Index object.
Python pandas-indexing
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Python Dictionary
Read a file line by line in Python
How to Install PIP on Windows ?
Different ways to create Pandas Dataframe
Python program to convert a list to string
Python String | replace()
Reading and Writing to text files in Python
sum() function in Python
Create a Pandas DataFrame from Lists
How to drop one or multiple columns in Pandas Dataframe
Where do we use scope Resolution Operator (::) in C#?

In C++ the scope resolution operator i.e. :: is used for global variables, whereas in C# it is related to namespaces.
If you have a type that share an identifier in different namespace, then to identify them use the scope resolution operator.
For example, to reference System.Console class, use the global namespace alias with the scope resolution operator −
global::System.Console
Let us see an example −
 Live Demo
using myAlias = System.Collections;
namespace Program {

   class Demo {
      static void Main() {
         myAlias::Hashtable h = new myAlias::Hashtable();

         h.Add("M", "1");
         h.Add("N", "2");
         h.Add("O", "3");
         h.Add("P", "4");

         foreach (string n in h.Keys) {
            global::System.Console.WriteLine(n + " " + h[n]);
         }
      }
   }
}
N 2
O 3
M 1
P 4
How to change tabs on hover with CSS and JavaScript?

To change tabs on hover with CSS and JavaScript, the code is as follows −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
* {box-sizing: border-box}
.tab {
   float: left;
   border: 1px solid #ccc;
   background-color: #f1f1f1;
   width: 30%;
   height: 300px;
}
.tab button {
   display: block;
   background-color: inherit;
   color: black;
   padding: 22px 16px;
   width: 100%;
   border: none;
   outline: none;
   text-align: left;
   cursor: pointer;
   font-size: 17px;
}
.tab button:hover {
   background-color: #ddd;
}
.tab button.active {
   background-color: #ccc;
}
.tabcontent {
   float: left;
   padding: 0px 12px;
   border: 1px solid #ccc;
   width: 70%;
   border-left: none;
   height: 300px;
   display: none;
}
.clearfix::after {
   content: "";
   clear: both;
   display: table;
}
</style>
</head>
<body>
<h2>Demo Heading Tabs</h2>
<p>Get the Department info by hovering over tabs:</p>
<div class="tab">
<button class="tablinks" onmouseover="demo(event, 'Marketing')">Marketing</button>
<button class="tablinks" onmouseover="demo(event, 'Operations')">Operations</button>
<button class="tablinks" onmouseover="demo(event, 'Finance')">Finance</button>
<button class="tablinks" onmouseover="demo(event, 'IT')">IT</button>
</div>
<div id="Marketing" class="tabcontent">
   <h3>Marketing</h3>
</div>
<div id="Operations" class="tabcontent">
   <h3>Operations</h3>
</div>
<div id="Finance" class="tabcontent">
   <h3>Finance</h3>
</div>
<div id="IT" class="tabcontent">
   <h3>IT</h3>
</div>
<div class="clearfix"></div>
<script>
function demo(e, dept) {
   var i, content, links;
   content = document.getElementsByClassName("tabcontent");
   for (i = 0; i < content.length; i++) {
      content[i].style.display = "none";
   }
   links = document.getElementsByClassName("tablinks");
   for (i = 0; i < links.length; i++) {
      links[i].className = links[i].className.replace(" active", "");
   }
   document.getElementById(dept).style.display = "block";
   e.currentTarget.className += " active";
}
</script>
</body>
</html>
This will produce the following output −
Hover any of the tabs −
How to access the members of a class from another class in Java?

To access the members of a class from other class.
First of all, import the class.
Create an object of that class.
Using this object access, the members of that class.
Suppose there is a class in a package called myPackage with a method named display()
package myPackage;
public class Sample {
   public void display() {
      System.out.println("Hello");
   }
}
You can access it as.
import myPackage;
public class MyClass {
   public static void main(String args[]) {
      Sample s = new Sample();
      s.done();
   }
}
hello
C program to find palindrome number by using while loop

Palindrome number is a number which remains same when it reverses. In C language, the user is allowed to enter any positive integer and to check, whether the given number is palindrome number or not by using the while loop.
Following is the C Program to find Palindrome number by using the while loop −
 Live Demo
#include <stdio.h>
int main(){
   int num, temp, rem, rev = 0;
   printf("enter a number:\n");
   scanf("%d", &num);
   temp = num;
   while ( temp > 0){
      rem = temp %10;
      rev = rev *10+ rem;
      temp = temp /10;
   }
   printf("reversed number is = %d\n", rev);
   if ( num == rev )
      printf("\n%d is Palindrome Number.\n", num);
   else
      printf("%d is not the Palindrome Number.\n", num);
   return 0;
}
When the above program is executed, it produces the following result −
enter a number:
1234
reversed number is = 4321
1234 is not the Palindrome Number.
enter a number:
1221
reversed number is = 1221
1221 is Palindrome Number.
Consider another example for the C program to find palindrome number by using the while loop for strings.
 Live Demo
#include <stdio.h>
#include <string.h>
void pal(char string[]);
int main(){
   char string[100];
   printf("enter a string: ");
   gets(string);
   pal(string);
   return 0;
}
void pal(char string[]){
   int i = 0;
   int length = strlen(string) - 1;
   while (length > i){
      if(string[i++] != string[length--]){
         printf("\n %s is not a palindrome", string);
         return;
      }
   }
   printf("\n %s is a palindrome string", string);
}
When the above program is executed, it produces the following result −
enter a string: tutorial
tutorial is not a palindrome
enter a string: saas
saas is a palindrome string
8086 program to check whether a string is palindrome or not - GeeksforGeeks

03 Aug, 2021
Problem: Write an 8086 program to check whether a given string is palindrome or not.Examples:  
Input String: "abba"
Output: String is palindrome

Input String: "abbca"
Output: String is not palindrome 
Explanation:  
Create a stringTraverse to the end of the stringGet the address of the end of the string, DILoad the starting address of the string, SICompare the value stored at the addressIncrement the pointer, SIDecrements the pointer, DICompare again the value stored at si and diRepeat the steps until SI<=DIIf all the characters match print string is palindrome else print not palindrome
Create a string
Traverse to the end of the string
Get the address of the end of the string, DI
Load the starting address of the string, SI
Compare the value stored at the address
Increment the pointer, SI
Decrements the pointer, DI
Compare again the value stored at si and di
Repeat the steps until SI<=DI
If all the characters match print string is palindrome else print not palindrome
Program: 
CPP
.MODEL SMALL.STACK 100H.DATA ; The string to be printedSTRING DB 'abba', '$'STRING1 DB 'String is palindrome', '$'STRING2 DB 'String is not palindrome', '$' .CODEMAIN PROC FAR MOV AX, @DATA MOV DS, AX  ; check if the string is; ;palindrome or not CALL Palindrome  ;interrupt to exit MOV AH, 4CH INT 21H MAIN ENDP Palindrome PROC  ; load the starting address ; of the string MOV SI,OFFSET STRING  ; traverse to the end of; ;the string LOOP1 :    MOV AX, [SI]    CMP AL, '$'    JE LABEL1    INC SI    JMP LOOP1  ;load the starting address; ;of the string LABEL1 :    MOV DI,OFFSET STRING    DEC SI     ; check if the string is palindrome;    ;or not    LOOP2 :     CMP SI, DI     JL OUTPUT1     MOV AX,[SI]     MOV BX, [DI]     CMP AL, BL     JNE OUTPUT2     DEC SI    INC DI    JMP LOOP2  OUTPUT1:    ;load address of the string    LEA DX,STRING1     ; output the string;    ;loaded in dx    MOV AH, 09H    INT 21H    RET  OUTPUT2:    ;load address of the string    LEA DX,STRING2     ; output the string    ; loaded in dx    MOV AH,09H    INT 21H    RET Palindrome ENDPEND MAIN
Output:  
String is palindrome
Note: The program cannot be run on an online editor, please use MASM to run the program and use dos box to run MASM, you might use any 8086 emulator to run the program. 
andrew1234
as5853535
Computer Organization and Architecture
microprocessor
system-programming
Computer Organization & Architecture
microprocessor
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Architecture of 8086
Logical and Physical Address in Operating System
Computer Organization and Architecture | Pipelining | Set 1 (Execution, Stages and Throughput)
Addressing modes in 8085 microprocessor
Computer Organization | RISC and CISC
Architecture of 8085 microprocessor
8085 program to add two 8 bit numbers
Interrupts
Memory Hierarchy Design and its Characteristics
IEEE Standard 754 Floating Point Numbers
C# | Equals(String, String) Method

24 Sep, 2021
In C#, Equals(String, String) is a String method. It is used to determine whether two String objects have the same value or not. Basically, it checks for equality. If both strings have the same value, it returns true otherwise returns false. This method is different from Compare and CompareTo methods. This method compares two string on the basis of contents.Syntax :  
bool string.Equals(string str1, string str2)
Explanation: This method will take the two parameters in the form of string object and check them for equality. After checking, this method will return Boolean values. The return value type of this method is System.Boolean This method will return true if the value of str1 is the same as the value of str2 otherwise, false. If both str1 and str2 are null, then the method will return true.Example : 
Input:          string str1 = "ProGeek 2.0";
                string str2 = "ProGeek 2.0";
                string.Equals(str1, str2)
Output:         True

Input:          string str3 = "GFG";
                string str4 = "others";
                string.Equals(str3, str4)
Output:         False
Below are the programs to demonstrate the above method : 
Program 1:
CSharp
// C# program to illustrate the Equals() Methodusing System; class GFG {     // Main Method    public static void Main(string[] args)    {        string s1 = "ProGeek 2.0";        string s2 = "ProGeek 2.0";         // Equals() method return true        // as both string objects are equal        Console.WriteLine(s1.Equals(s2));    }}
True
 
Program 2:
CSharp
// C# program to illustrate the Equals() Methodusing System;class Geeks {     // Main Method    public static void Main(string[] args)    {        string s1 = "GFG";        string s2 = "others";             // this will give result false as        // both s1 and s2 are different        Console.WriteLine(s1.Equals(s2));    }}
False
 
adnanirshad158
CSharp-method
CSharp-string
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
C# | Multiple inheritance using interfaces
Introduction to .NET Framework
C# | Delegates
Differences Between .NET Core and .NET Framework
C# | Data Types
C# | Constructors
C# | Class and Object
C# | Replace() Method
Extension Method in C#
Difference between Ref and Out keywords in C#
Output of Python Program | Set 1

28 Jun, 2021
Predict the output of following python programs:
Program 1:
r = lambda q: q * 2s = lambda q: q * 3x = 2x = r(x)x = s(x)x = r(x)print (x)
Output:
24

Explanation : In the above program r and s are lambda functions or anonymous functions and q is the argument to both of the functions. In first step we have initialized x to 2. In second step we have passed x as argument to the lambda function r, this will return x*2 which is stored in x. That is, x = 4 now. Similarly in third step we have passed x to lambda function s, So x = 4*3. i.e, x = 12 now. Again in the last step, x is multiplied by 2 by passing it to function r. Therefore, x = 24.
 
Program 2:
a = 4.5b = 2print (a//b)
Output:
2.0
Explanation : This type of division is called truncating division where the remainder is truncated or dropped.
 
Program 3:
a = Trueb = Falsec = False  if a or b and c:    print ("GEEKSFORGEEKS")else:    print ("geeksforgeeks")
Output:
GEEKSFORGEEKS
Explanation : In Python, AND operator has higher precedence than OR operator. So, it is evaluated first. i.e, (b and c) evaluates to false.Now OR operator is evaluated. Here, (True or False) evaluates to True. So the if condition becomes True and GEEKSFORGEEKS is printed as output.
 
Program 4:
a = Trueb = Falsec = False  if not a or b:    print (1)elif not a or not b and c:    print (2)elif not a or b or not b and a:    print (3)else:    print (4)
Output:
3

Explanation: In Python the precedence order is first NOT then AND and in last OR. So the if condition and second elif condition evaluates to False while third elif condition is evaluated to be True resulting in 3 as output.
 
Program 5:
count = 1   def doThis():      global count      for i in (1, 2, 3):         count += 1  doThis()  print (count)
Output:
 4 
Explanation: The variable count declared outside the function is global variable and also the count variable being referenced in the function is the same global variable defined outside of the function. So, the changes made to variable in the function is reflected to the original variable. So, the output of the program is 4.
Python Quizzes
This article is contributed by Harsh Agarwal. If you like GeeksforGeeks and would like to contribute, you can also write an article using write.geeksforgeeks.org or mail your article to review-team@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.
DhawalJain1
Python-Output
Program Output
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Runtime Errors
Different ways to copy a string in C/C++
Output of C++ programs | Set 47 (Pointers)
Output of C++ Program | Set 1
Output of Java Programs | Set 12
Read JSON file using Python
Adding new column to existing DataFrame in Pandas
Python map() function
Python Dictionary
How to get column names in Pandas dataframe
Python | Max/Min value in Nth Column in Matrix

30 Dec, 2020
Sometimes, while working with Python Matrix, we may have a problem in which we require to find the minimum and maximum value of a particular column. This can have a possible application in day-day programming and competitive programming. Let’s discuss certain way in which this task can be performed.
Method : Using max()/min() + zip()This task can be solved using the combination of above functions. In this, we pass in the zip() the list, to access all columns and max()/min() to get maximum or minimum of columns.
# Python3 code to demonstrate working of# Max value in Nth Column in Matrix# using max() + zip()  # initialize listtest_list = [[5, 6, 7],             [9, 10, 2],              [10, 3, 4]]  # printing original listprint("The original list is : " + str(test_list))  # initialize N N = 2  # Max value in Nth Column in Matrix# using max() + zip()res = [max(i) for i in zip(*test_list)][N]   # printing resultprint("Max value of Nth column is : " + str(res))
The original list is : [[5, 6, 7], [9, 10, 2], [10, 3, 4]]
Max value of Nth column is : 7

Python list-programs
Python matrix-program
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
How to drop one or multiple columns in Pandas Dataframe
Python | os.path.join() method
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python | Get unique values from a list
Python | datetime.timedelta() function
Creating a Network in Docker and Connecting a Container to That Network

23 Oct, 2020
Networks are created so that the devices which are inside that network can connect to each other and transfer of files can take place. In docker also we can create a network and can create a container and connect to the respective network and two containers that are connected to the same network can communicate with each other. These containers can also communicate with the host in which the docker is deployed. The communication will take place by using the IP address of each other. A container can connect to one or more networks in that docker host.
Step 1: In the first step we run a command to see the list of networks in your docker host.
  sudo docker network ls

A bridge is the default network in docker.
Step 2: If you want to see the information regarding the particular network you can use the inspect command.
 sudo docker network inspect docker_name

Notice that there is no container currently connected to the bridge driver as the brackets are empty.
Step 3: First we connect the container to the default bridge which is a driver provide default DNS service to the containers attached to it by running the command.
sudo docker run -it ubuntu:latest /bin/bash

To exit from the Ubuntu container which we just created use Ctrl + p then Ctrl + q. Now again run the docker inspect command to see the attached containers to the bridge.
Step 4: Now in this step we are going to create our own network and then in the next step connect the container to that network.
 sudo docker network create --driver driver_name network_name

driver_name: name of the driver in this case we will use bridge driver.
network_name: name of the network you want to give to your network.
Now run the docker network ls command to see your created network. 
Step 5: In this step, we will connect a container to our network which we have created in the previous step.
sudo docker run -it --network=new_nw ubuntu:latest /bin/bash

Step 6: Now inspect the network we created. The container we attach to the respected network is mentioned there.
This is the complete process to create the network and connect the container to it.
Docker Container
linux
Advanced Computer Subject
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to convert first letter of a string to upper case using jQuery ?

27 Apr, 2020
The task is to capitalize the first letter of string without using toUpperCase() method with the help of jQuery. There are two approaches that are discussed below:
Approach 1: In this example, the css() method is used to used to set the text-transform property value to capitalize.
Example:
<!DOCTYPE HTML> <html>   <head>     <title>         How to convert first letter of a        string to upper case using jQuery?    </title>          <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js">    </script></head>   <body style = "text-align:center;">           <h1 style = "color:green;" >         GeeksForGeeks     </h1>          <p>        Click on the button to        perform the operation.    </p>          Type Here: <input id = "input"/>    <br><br>          <button onclick = "GFG_Fun()">        Click Here    </button>          <p id = "GFG"></p>          <script>        var geeks = document.getElementById('GFG');                  function GFG_Fun() {            $('#input').css('textTransform', 'capitalize');            geeks.innerHTML = "Text is capitalized";        }    </script> </body>   </html>
Output:
Approach 2: In this example, we are using CSS property to perform the operation. A new ID has been added to the element which sets the property text-transform to capitalize.
Example:
<!DOCTYPE HTML> <html>   <head>     <title>         How to convert first letter of a        string to upper case using jQuery?    </title>          <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js">    </script>          <style>        #capital {            text-transform: capitalize;        }    </style></head>   <body style = "text-align:center;">           <h1 style = "color:green;" >         GeeksForGeeks     </h1>          <p>        Click on the button to        perform the operation.    </p>          Type Here: <input id = "input"/>    <br><br>          <button onclick = "GFG_Fun()">        Click Here    </button>          <p id = "GFG"></p>          <script>        var geeks = document.getElementById('GFG');                  function GFG_Fun() {            $('#input').attr('id', 'capital');            geeks.innerHTML = "Text is capitalized";        }    </script> </body>   </html>
Output:
jQuery-Misc
JQuery
Web Technologies
Web technologies Questions
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Bokeh – Plotting Quadratic Curves on a Graph

10 Jul, 2020
Bokeh is a Python interactive data visualization. It renders its plots using HTML and JavaScript. It targets modern web browsers for presentation providing elegant, concise construction of novel graphics with high-performance interactivity.
Bokeh can be used to plot quadratic curves on a graph. Plotting quadratic curves on a graph can be done using the quadratic() method of the plotting module.
Syntax : quadratic(parameters)
Parameters :
x0 : x-coordinates of the starting points of the quadratic
y0 : y-coordinates of the starting points of the quadratic
x1 : x-coordinates of the ending points of the quadratic
y1 : y-coordinates of the ending points of the quadratic
cx : x-coordinates of the control points of the quadratic
cy : y-coordinates of the control points of the quadratic
Returns : an object of class GlyphRenderer
Example 1 : In this example we will be using the default values for plotting the graph.
# importing the modulesfrom bokeh.plotting import figure, output_file, show        # file to save the modeloutput_file("gfg.html")        # instantiating the figure objectgraph = figure(title = "Bokeh Quadratic Graph")      # the points to be plottedx0 = 1y0 = 4x1 = 5y1 = 4cx = 2.5cy = 8  # plotting the graphgraph.quadratic(x0, y0,                x1, y1,                cx, cy)      # displaying the modelshow(graph)
Output :
Example 2 : In this example we will be plotting multiple quadratic curves with various other parameters.
# importing the modules from bokeh.plotting import figure, output_file, show   # file to save the model output_file("gfg.html")        # instantiating the figure object graph = figure(title = "Bokeh Quadratic Graph")   # name of the x-axis graph.xaxis.axis_label = "x-axis"       # name of the y-axis graph.yaxis.axis_label = "y-axis"  # points to be plottedx0 = [1, 0, 0]y0 = [4, 8, 5]x1 = [5, 4, 4]y1 = [4, 8, 7]cx = [2.5, 2, 4]cy = [8, 3, 4]  # line color value of the quadraticline_color = ["yellow", "red", "purple"]  # line width value of the quadraticline_width = [10, 5, 8]  # plotting the graph graph.quadratic(x0, y0,                x1, y1,                cx, cy,                line_color = line_color,                line_width = line_width)        # displaying the model show(graph)
Output :
Data Visualization
Python Bokeh-plotting-figure-class
Python-Bokeh
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
How to drop one or multiple columns in Pandas Dataframe
Python | os.path.join() method
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python | Get unique values from a list
Python | datetime.timedelta() function
JavaScript string.localeCompare() Method

05 Oct, 2021
Below is the example of the string.localeCompare() Method.
Example:<script>    gfg = 'b'.localeCompare('a');     document.write(gfg + '<br>') </script>
<script>    gfg = 'b'.localeCompare('a');     document.write(gfg + '<br>') </script>
Output:1
1
The string.localeCompare() is an inbuilt method in JavaScript which is used to compare any two elements and returns a positive number if the reference string is lexicographically greater than the compare string and negative number if the reference string is lexicographically smaller than the compare string and zero (0) if the compare and reference strings are equivalent.Syntax:
referenceString.localeCompare(compareString)
Parameters: Here the parameter compareString is a string with which the reference string is compared.Return Values: It returns a positive number if the reference string is lexicographically greater than the compare string and negative number if the reference string is lexicographically smaller than the compare string and zero (0) if the compare and reference strings are equivalent.
JavaScript code to show the working of string.localeCompare() method:Code #1:
<script>      // An alphabet "n" comes before "z" which    // gives a negative value    a = 'n'.localeCompare('z');    document.write(a + '<br>')      // Alphabetically the word "gfg" comes after    // "geeksforgeeks" which gives a positive value    b = 'gfg'.localeCompare('geeksforgeeks');    document.write(b + '<br>')      // "gfg" and "gfg" are equivalent which    // gives a value of zero(0)    c = 'a'.localeCompare('a');    document.write(c)  </script>
Output:
-1
1
0
Code #2: This method also used to sort elements.
<script>      // Taking some elements to sort alphabetically    var elements = [ 'gfg', 'geeksforgeeks', 'cse', 'department' ];    a = elements.sort((a, b) => a.localeCompare(b));      // Returning sorted elements    document.write(a)  </script>
Output:
cse, department, geeksforgeeks, gfg
Supported Browsers:
Chrome 1 and above
Edge 12 and above
Firefox 1 and above
Internet Explorer 5.5 and above
Opera 7 and and above
Safari 3 and above
Akanksha_Rai
ysachin2314
JavaScript-Methods
javascript-string
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 ?
Python | Pandas Series.to_string()

05 Feb, 2019
Pandas series is a One-dimensional ndarray with axis labels. The labels need not be unique but must be a hashable type. The object supports both integer- and label-based indexing and provides a host of methods for performing operations involving the index.
Pandas Series.to_string() function render a string representation of the Series.
Syntax: Series.to_string(buf=None, na_rep=’NaN’, float_format=None, header=True, index=True, length=False, dtype=False, name=False, max_rows=None)
Parameter :buf : buffer to write tona_rep : string representation of NAN to use, default ‘NaN’float_format : formatter function to apply to columns’ elements if they are floats default Noneheader : Add the Series header (index name)index : Add index (row) labels, default Truelength : Add the Series lengthdtype : Add the Series dtypename : Add the Series name if not Nonemax_rows : Maximum number of rows to show before truncating.
Returns : Formatted string.
Example #1: Use Series.to_string() function to render a string representation of the given series object.
# importing pandas as pdimport pandas as pd  # Creating the Seriessr = pd.Series(['New York', 'Chicago', 'Toronto', 'Lisbon', 'Rio', 'Moscow'])  # Create the Datetime Indexdidx = pd.DatetimeIndex(start ='2014-08-01 10:00', freq ='W',                      periods = 6, tz = 'Europe/Berlin')   # set the indexsr.index = didx  # Print the seriesprint(sr)
Output :
Now we will use Series.to_string() function to render string representation to this series object.
# render to string formsr.to_string()
Output :
As we can see in the output, the Series.to_string() function has successfully rendered a string representation to the given object. Example #2: Use Series.to_string() function to render a string representation of the given series object.
# importing pandas as pdimport pandas as pd  # Creating the Seriessr = pd.Series([19.5, 16.8, 22.78, 20.124, 18.1002])  # Print the seriesprint(sr)
Output :
Now we will use Series.to_string() function to render string representation to this series object.
# render to string formsr.to_string()
Output :
As we can see in the output, the Series.to_string() function has successfully rendered a string representation to the given object.
Python pandas-series
Python pandas-series-methods
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Iterate over a list in Python
Python OOPs Concepts
Convert integer to string in Python
C# | Adding an element to the List

01 Feb, 2019
List.Add(T) Method is used to add an object to the end of the List.
Properties of List:
It is different from the arrays. A list can be resized dynamically but arrays cannot.
List class can accept null as a valid value for reference types and it also allows duplicate elements.
If the Count becomes equals to Capacity then the capacity of the List increases automatically by reallocating the internal array. The existing elements will be copied to the new array before the addition of the new element.
If the Count is less than Capacity then this method is an O(1) operation. If the capacity needs to be increased to accommodate the new element then this method becomes an O(n) operation.
Syntax:
public void Add (T item);
Parameter:
item: Specified object which is to be added to the end of the List of type System.Object.
Below programs illustrate how to add an element in List:
Example 1:
// C# program to add element in List<T>using System;using System.Collections.Generic;  class Geeks {      // Main Method    public static void Main(String[] args)    {          // Creating a List of integers        List<int> firstlist = new List<int>();          // adding elements in firstlist        for (int i = 4; i < 10; i++) {            firstlist.Add(i * 2);        }          // Displaying elements of firstlist        // by using foreach loop        foreach(int element in firstlist)        {            Console.WriteLine(element);        }    }}
Output:
8
10
12
14
16
18

Example 2:
// C# program to add element in List<T>using System;using System.Collections.Generic;  class Geeks {      // Main Method    public static void Main(String[] args)    {          // Creating a List of integers        List<int> firstlist = new List<int>();          // adding elements in firstlist        firstlist.Add(1);        firstlist.Add(2);        firstlist.Add(3);        firstlist.Add(4);          // Adding some duplicate        // elements in firstlist        firstlist.Add(3);        firstlist.Add(4);          // Displaying elements of firstlist        // by using foreach loop        foreach(int element in firstlist)        {            Console.WriteLine(element);        }    }}
Output:
1
2
3
4
3
4

Reference:
https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1.add?view=netframework-4.7.2
CSharp-Collections-Namespace
CSharp-Generic-List
CSharp-Generic-Namespace
CSharp-method
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
C# | Delegates
Introduction to .NET Framework
C# | Multiple inheritance using interfaces
Differences Between .NET Core and .NET Framework
C# | Data Types
C# | Constructors
C# | Class and Object
Extension Method in C#
C# | Replace() Method
Difference between Ref and Out keywords in C#