code-rag-bench/online-tutorials huggingface dataset:
Dart Programming - Boolean

Dart provides an inbuilt support for the Boolean data type. The Boolean data type in DART supports only two values – true and false. The keyword bool is used to represent a Boolean literal in DART.
The syntax for declaring a Boolean variable in DART is as given below −
bool var_name = true;  
OR  
bool var_name = false 

void main() { 
   bool test; 
   test = 12 > 5; 
   print(test); 
}
It will produce the following output −
true 

Unlike JavaScript, the Boolean data type recognizes only the literal true as true. Any other value is considered as false.  Consider the following example −
var str = 'abc'; 
if(str) { 
   print('String is not empty'); 
} else { 
   print('Empty String'); 
} 
The above snippet, if run in JavaScript, will print the message ‘String is not empty’ as the if construct will return true if the string is not empty.
However, in Dart, str is converted to false as str != true. Hence the snippet will print the message ‘Empty String’ (when run in unchecked mode).
The above snippet if run in checked mode will throw an exception. The same is illustrated below −
void main() { 
   var str = 'abc'; 
   if(str) { 
      print('String is not empty'); 
   } else { 
      print('Empty String'); 
   } 
}
It will produce the following output, in Checked Mode −
Unhandled exception: 
type 'String' is not a subtype of type 'bool' of 'boolean expression' where 
   String is from dart:core 
   bool is from dart:core  
#0 main (file:///D:/Demos/Boolean.dart:5:6) 
#1 _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:261) 
#2 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:148)

It will produce the following output, in Unchecked Mode −
Empty String

Note − The WebStorm IDE runs in checked mode, by default.

    44 Lectures 
     4.5 hours 

 Sriyank Siddhartha

    34 Lectures 
     4 hours 

 Sriyank Siddhartha

    69 Lectures 
     4 hours 

 Frahaan Hussain

    117 Lectures 
     10 hours 

 Frahaan Hussain

    22 Lectures 
     1.5 hours 

 Pranjal Srivastava

    34 Lectures 
     3 hours 

 Pranjal Srivastava
 Print
 Add Notes
 Bookmark this page
How to set country code to column values with phone numbers in MySQL?

To set country code to phone numbers would mean to concatenate. You can use CONCAT() for this.
Let us first create a table −
mysql> create table DemoTable769 (MobileNumber varchar(100));
Query OK, 0 rows affected (0.54 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable769 values('8799432434');
Query OK, 1 row affected (0.24 sec)
mysql> insert into DemoTable769 values('9899996778');
Query OK, 1 row affected (0.15 sec)
mysql> insert into DemoTable769 values('7890908989');
Query OK, 1 row affected (0.21 sec)
mysql> insert into DemoTable769 values('9090898987');
Query OK, 1 row affected (0.20 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable769;
This will produce the following output -
+--------------+
| MobileNumber |
+--------------+
| 8799432434   |
| 9899996778   |
| 7890908989   |
| 9090898987   |
+--------------+
4 rows in set (0.00 sec)
Following is the query to set country code to column values with phone numbers in MySQL −
mysql> update DemoTable769
   set MobileNumber=concat('+91',MobileNumber);
Query OK, 4 rows affected (0.20 sec)
Rows matched: 4 Changed: 4 Warnings: 0
Let us check the description of the view −
mysql> select *from DemoTable769;
This will produce the following output -
+---------------+
| MobileNumber  |
+---------------+
| +918799432434 |
| +919899996778 |
| +917890908989 |
| +919090898987 |
+---------------+
4 rows in set (0.00 sec)
C# | Check if two StringCollection objects are equal - GeeksforGeeks

01 Feb, 2019
Equals(Object) Method which is inherited from the Object class is used to check if a specified StringCollection object is equal to another StringCollection object or not.
Syntax:
public virtual bool Equals (object obj);
Here, obj is the object which is to be compared with the current object.
Return Value: This method return true if the specified object is equal to the current object otherwise it returns false.
Below programs illustrate the use of above-discussed method:
Example 1:
// C# code to check if two// StringCollections are equal or notusing System;using System.Collections.Specialized;  class GFG {      // Driver code    public static void Main()    {          // creating a StringCollection named myCol        StringCollection myCol = new StringCollection();          // Adding elements in StringCollection        myCol.Add("A");        myCol.Add("B");        myCol.Add("C");        myCol.Add("D");        myCol.Add("E");          // Checking whether myCol is        // equal to itself or not        Console.WriteLine(myCol.Equals(myCol));    }}
True

Example 2:
// C# code to check if two// StringCollections are equal or notusing System;using System.Collections.Specialized;  class GFG {      // Driver code    public static void Main()    {          // creating a StringCollection named my1        StringCollection my1 = new StringCollection();          // Adding elements in StringCollection        my1.Add("GFG");        my1.Add("Noida");        my1.Add("DS");        my1.Add("Geeks");        my1.Add("Classes");          // Creating a StringCollection named my2        StringCollection my2 = new StringCollection();          my2.Add("Australia");        my2.Add("Belgium");        my2.Add("Netherlands");        my2.Add("China");        my2.Add("Russia");        my2.Add("India");          // Checking whether my1 is        // equal to my2 or not        Console.WriteLine(my1.Equals(my2));          // Creating a new StringCollection        StringCollection my3 = new StringCollection();          // Assigning my2 to my3        my3 = my2;          // Checking whether my3 is        // equal to my2 or not        Console.WriteLine(my3.Equals(my2));    }}
False
True

Note: If the current instance is a reference type, the Equals(Object) method checks for reference equality.
CSharp-method
CSharp-Specialized-Namespace
CSharp-Specialized-StringCollection
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Extension Method in C#
Destructors in C#
HashSet in C# with Examples
Top 50 C# Interview Questions & Answers
C# | How to insert an element in an Array?
C# | List Class
C# | Inheritance
Partial Classes in C#
Lambda Expressions in C#
Convert String to Character Array in C#
Passing two dimensional array to a C++ function

C++ does not allow to pass an entire array as an argument to a function. However, You can pass a pointer to an array by specifying the array's name without an index. There are three ways to pass a 2D array to a function −
Specify the size of columns of 2D array
void processArr(int a[][10]) {
   // Do something
}
Pass array containing pointers
void processArr(int *a[10]) {
   // Do Something
}

// When callingint *array[10];
for(int i = 0; i < 10; i++)
   array[i] = new int[10];
processArr(array);
Pass a pointer to a pointer
void processArr(int **a) {
   // Do Something
}
// When calling:
int **array;
array = new int *[10];
for(int i = 0; i <10; i++)
   array[i] = new int[10];
processArr(array);
#include<iostream>
using namespace std;

void processArr(int a[][2]) {
   cout << "element at index 1,1 is " << a[1][1];
}
int main() {
   int arr[2][2];
   arr[0][0] = 0;
   arr[0][1] = 1;
   arr[1][0] = 2;
   arr[1][1] = 3;

   processArr(arr);
   return 0;
}
This will give the output −
element at index 1,1 is 3
PHP - json_encode() Function

The json_encode() function can return the JSON representation of a value. 
string json_encode( mixed $value [, int $options = 0 [, int $depth = 512 ]] )

The json_encode() function can return a string containing the JSON representation of supplied value. The encoding is affected by supplied options, and additionally, the encoding of float values depends on the value of serialize_precision. 
The json_encode() function can return a JSON encoded string on success or false on failure. 
<?php
   $post_data = array(
      "item" => array(
            "item_type_id" => 1,
            "tring_key" => "AA",
            "string_value" => "Hello",   
            "string_extra" => "App",
            "is_public" => 1,
            "is_public_for_contacts" => 0
      )
   );
   echo json_encode($post_data)."\n";
?>
{"item":{"item_type_id":1,"tring_key":"AA","string_value":"Hello","string_extra":"App","is_public":1,"is_public_for_contacts":0}}

<?php
   $array = array("Coffee", "Chocolate", "Tea");

   // The JSON string created from the array
   $json = json_encode($array, JSON_PRETTY_PRINT);

   echo $json;
?>
[
    "Coffee",
    "Chocolate",
    "Tea"
]

<?php
   class Book {
      public $title = "";
      public $author = "";
      public $yearofpublication = "";
   }

   $book = new Book();
   $book->title = "Java";
   $book->author = "James Gosling";
   $book->yearofpublication = "1995";

   $result = json_encode($book);
   echo "The JSON representation is:".$result."\n";

   echo "************************". "\n";
   echo "Decoding the JSON data format into an PHP object:"."\n";
   $decoded = json_decode($result);

   var_dump($decoded);

   echo $decoded->title."\n";
   echo $decoded->author."\n";
   echo $decoded->yearofpublication."\n";

   echo "************************"."\n";
   echo "Decoding the JSON data format into an PHP array:"."\n";
   $json = json_decode($result,true);

   // listing the array
   foreach($json as $prop => $value)
      echo $prop ." : ". $value;
?>
The JSON representation is:{"title":"Java","author":"James Gosling","yearofpublication":"1995"}
************************
Decoding the JSON data format into an PHP object:
object(stdClass)#2 (3) {
  ["title"]=>
  string(4) "Java"
  ["author"]=>
  string(13) "James Gosling"
  ["yearofpublication"]=>
  string(4) "1995"
}
Java
James Gosling
1995
************************
Decoding the JSON data format into an PHP array:
title : Javaauthor : James Goslingyearofpublication : 1995


    45 Lectures 
     9 hours 

 Malhar Lathkar

    34 Lectures 
     4 hours 

 Syed Raza

    84 Lectures 
     5.5 hours 

 Frahaan Hussain

    17 Lectures 
     1 hours 

 Nivedita Jain

    100 Lectures 
     34 hours 

 Azaz Patel

    43 Lectures 
     5.5 hours 

 Vijay Kumar Parvatha Reddy
 Print
 Add Notes
 Bookmark this page
Algorithm Specification-Introduction in Data Structure

An algorithm is defined as a finite set of instructions that, if followed, performs a particular task. All algorithms must satisfy the following criteria
Input. An algorithm has zero or more inputs, taken or collected from a specified set of objects.
Output. An algorithm has one or more outputs having a specific relation to the inputs.
Definiteness. Each step must be clearly defined; Each instruction must be clear and unambiguous.
Finiteness. The algorithm must always finish or terminate after a finite number of steps.
Effectiveness. All operations to be accomplished must be sufficiently basic that they can be done exactly and in finite length.
We can depict an algorithm in many ways.
Natural language: implement a natural language like English
Flow charts: Graphic representations denoted flowcharts, only if the algorithm is small and simple.
Pseudo code: This pseudo code skips most issues of ambiguity; no particularity regarding syntax programming language.
Example 1: Algorithm for calculating factorial value of a number
Step 1: a number n is inputted
Step 2: variable final is set as 1
Step 3: final<= final * n
Step 4: decrease n
Step 5: verify if n is equal to 0
Step 6: if n is equal to zero, goto step 8 (break out of loop)
Step 7: else goto step 3
Step 8: the result final is printed
A recursive algorithm calls itself which generally passes the return value as a parameter to the algorithm again. This parameter indicates the input while the return value indicates the output.
Recursive algorithm is defined as a method of simplification that divides the problem into sub-problems of the same nature. The result of one recursion is treated as the input for the next recursion. The repletion is in the self-similar fashion manner. The algorithm calls itself with smaller input values and obtains the results by simply accomplishing the operations on these smaller values. Generation of factorial, Fibonacci number series are denoted as the examples of recursive algorithms.
Example: Writing factorial function using recursion
intfactorialA(int n)
{
   return n * factorialA(n-1);
}
C# | How to check whether a List contains a specified element - GeeksforGeeks

01 Feb, 2019
List<T>.Contains(T) Method is used to check whether an element is in the List<T> or not.
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.
Syntax:
public bool Contains (T item);
Here, item is the object which is to be locate in the List<T>. The value can be null for reference types.
Return Value: This method returns True if the item is found in the List<T> otherwise returns False.
Below programs illustrate the use of List<T>.Contains(T) Method:
Example 1:
// C# Program to check whether the// element is present in the List// or notusing System;using System.Collections;using System.Collections.Generic;  class Geeks {      // Main Method    public static void Main(String[] args)    {          // Creating an List<T> of Integers        List<int> firstlist = new List<int>();          // Adding elements to List        firstlist.Add(1);        firstlist.Add(2);        firstlist.Add(3);        firstlist.Add(4);        firstlist.Add(5);        firstlist.Add(6);        firstlist.Add(7);          // Checking whether 4 is present        // in List or not        Console.Write(firstlist.Contains(4));    }}
Output:
True

Example 2:
// C# Program to check whether the// element is present in the List// or notusing System;using System.Collections;using System.Collections.Generic;  class Geeks {      // Main Method    public static void Main(String[] args)    {          // Creating an List<T> of String        List<String> firstlist = new List<String>();          // Adding elements to List        firstlist.Add("Geeks");        firstlist.Add("For");        firstlist.Add("Geeks");        firstlist.Add("GFG");        firstlist.Add("C#");        firstlist.Add("Tutorials");        firstlist.Add("GeeksforGeeks");          // Checking whether Java is present        // in List or not        Console.Write(firstlist.Contains("Java"));    }}
Output:
False

Reference:
https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1.contains?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
Destructors in C#
Extension Method in C#
C# | Constructors
C# | Abstract Classes
Introduction to .NET Framework
C# | Class and Object
C# | Data Types
C# | Encapsulation
HashSet in C# with Examples
Insert values in two tables with a single stored procedure call in MySQL

Following is the syntax to insert values in two tables with a stored procedure −
DELIMITER //
CREATE PROCEDURE yourProcedureName(anyVariableName int)
   BEGIN
   insert into yourTableName1(yourColumnName1) values(yourVariableName);
   insert into yourTableName2(yourColumnName2) values(yourVariableName);
   END
//
Let us first create a table −
mysql> create table DemoTable1
   -> (
   -> StudentScore int
   -> );
Query OK, 0 rows affected (0.58 sec)
Following is the second table −
mysql> create table DemoTable2
   -> (
   -> PlayerScore int
   -> );
Query OK, 0 rows affected (0.52 sec)
Here is the query to create a stored procedure and insert values in two tables −
mysql> DELIMITER //
mysql> CREATE PROCEDURE insert_proc(value int )
   -> BEGIN
   -> insert into DemoTable1(StudentScore) values(value);
   -> insert into DemoTable2(PlayerScore) values(value);
   -> END
-> //
Query OK, 0 rows affected (0.16 sec)
mysql> DELIMITER ;
Now you can call the stored procedure using CALL command −
mysql> call insert_proc(89);
Query OK, 1 row affected (0.29 sec)
Display all records from both the tables using select statement −
mysql> select * from DemoTable1333;
+--------------+
| StudentScore |
+--------------+
|           89 |
+--------------+
1 row in set (0.00 sec)
mysql> select * from DemoTable1334;
+-------------+
| PlayerScore |
+-------------+
|          89 |
+-------------+
1 row in set (0.00 sec)
Exporting DTA File Using pandas.DataFrame.to_stata() function in Python - GeeksforGeeks

14 Sep, 2021
This method is used to writes the DataFrame to a Stata dataset file. “dta” files contain a Stata dataset. DTA file is a database file and it is used by IWIS Chain Engineering. 
Syntax : DataFrame.to_stata(path, convert_dates=None, write_index=True, time_stamp=None)
Parameters :
path : str, buffer or path object
convert_dates : dict
write_index : bool
time_stamp : datetime
Returns : DataFrame object to Stata dta format. Means return .dta file.
Example 1: Create DTA file
Here we will create dataframe and then saving into the DTA format using DataFrame.to_stata().
Python3
# importing packageimport numpyimport pandas as pd  # create and view datadf = pd.DataFrame({    'person': ["Rakesh", "Kishan", "Adesh", "Nitish"],    'weight': [50, 60, 70, 80]})display(df)  # use pandas.DataFrame.to_stata method# to extract .dta filedf.to_stata('person.dta')
Output : 
Example 2:
Python3
# importing packageimport pandas as pd  # create and view datadf = pd.DataFrame({    'mobiles': ["Apple", "MI", "Karban", "JIO"],    'prizes': [75000, 9999, 6999, 5999]})display(df)  # use pandas.DataFrame.to_stata method# to extract .dta filedf.to_stata('mobiles.dta')
Output : 
Python pandas-dataFrame-methods
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Check if element exists in list in Python
Python | os.path.join() method
Selecting rows in pandas DataFrame based on conditions
Defaultdict in Python
Python | Get unique values from a list
Create a directory in Python
Python | Pandas dataframe.groupby()
Tryit Editor v3.7

Tryit: Responsive image on responsive webpage
Python - List XOR - GeeksforGeeks

29 Dec, 2019
Sometimes, while programming, we have a problem in which we might need to perform certain bitwise operations among list elements. This is an essential utility as we come across bitwise operations many times. Let’s discuss certain ways in which XOR can be performed.
Method #1 : Using reduce() + lambda + “^” operatorThe above functions can be combined to perform this task. We can employ reduce() to accumulate the result of XOR logic specified by the lambda function. Works only with Python2.
# Python code to demonstrate working of# List XOR# Using reduce() + lambda + "^" operator  # initializing listtest_list = [4, 6, 2, 3, 8, 9]  # printing original listprint("The original list is : " + str(test_list))  # List XOR# Using reduce() + lambda + "^" operatorres = reduce(lambda x, y: x ^ y, test_list)  # printing result print("The Bitwise XOR of list elements are : " + str(res))
The original list is : [4, 6, 2, 3, 8, 9]
The Bitwise XOR of list elements are : 2

 
Method #2 : Using reduce() + operator.ixorThis task can also be performed using this method. In this the task performed by lambda function in above method is performed using ior function for cumulative XOR operation. Works with Python2 only.
# Python code to demonstrate working of# List XOR# Using reduce() + operator.ixorfrom operator import ixor  # initializing listtest_list = [4, 6, 2, 3, 8, 9]  # printing original listprint("The original list is : " + str(test_list))  # List XOR# Using reduce() + operator.ixorres = reduce(ixor, test_list)  # printing result print("The Bitwise XOR of list elements are : " + str(res))
The original list is : [4, 6, 2, 3, 8, 9]
The Bitwise XOR of list elements are : 2

Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Python String | replace()
Python program to convert a list to string
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?
How to replace innerHTML of a div using jQuery? - GeeksforGeeks

23 Apr, 2019
For replacing innerHTML of a div with jquery, html() function is used.
Syntax:
$(selector).html()

Example:
<!DOCTYPE html><html lang="en">  <head>    <meta charset="UTF-8">    <title>      changing-innerhtml-using-jquery  </title>    <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"           rel="stylesheet">    <style>        body {            margin-top: 5%;        }                  div {            text-align: center;        }    </style>    <script src="https://code.jquery.com/jquery-3.4.0.min.js"            type="text/javascript">  </script></head>  <body>      <div class="div_1">        <h1>Geeksforgeeks</h1>        <h1 style="color: green">          This is the content inside the div before changing      </h1>    </div>    <div class="div_2">        <button class="btn btn-primary"                type="submit">          Click here for changing innerHTML      </button>    </div>  </body><script>    $(document).ready(function() {        $('.btn').click(function() {            $("div.div_1").html(              "<h1><span style='color: green;'>GeeksforGeeks"+              "</span><br>This is the content inside the div"+              " after changing innerHTML</h1>");        })      })</script>  </html>
After loading the web page, on clicking the button content inside the div will be replaced by the content given inside the html() function.Output:
Before clicking button:
After clicking button:
jQuery-Misc
Picked
JQuery
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Form validation using jQuery
How to Dynamically Add/Remove Table Rows using jQuery ?
Scroll to the top of the page using JavaScript/jQuery
jQuery | children() with Examples
How to Show and Hide div elements using radio buttons?
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to effectively hide Href From a Link in PHP?

This is not possible. A href can’t be hidden from a link. But the files can be rewritten and the request URL can be changed to look like this − name.php/5001
Other than this, a post request can be used in the below way −
<form method="post" action="name.php">
<input type="hidden" name="packageID" value="5001">
<button type="submit">Go</button>
</form>
This will expose a single button in the browser.
Java for loop

A for loop is a repetition control structure that allows you to efficiently write a loop that needs to be executed a specific number of times.
A for loop is useful when you know how many times a task is to be repeated.
The syntax of a for loop is −
for(initialization; Boolean_expression; update) {
   // Statements
}
Here is the flow of control in a for loop −
The initialization step is executed first, and only once. This step allows you to declare and initialize any loop control variables and this step ends with a semicolon (;).
The initialization step is executed first, and only once. This step allows you to declare and initialize any loop control variables and this step ends with a semicolon (;).
Next, the Boolean expression is evaluated. If it is true, the body of the loop is executed. If it is false, the body of the loop will not be executed and control jumps to the next statement past them for a loop.
Next, the Boolean expression is evaluated. If it is true, the body of the loop is executed. If it is false, the body of the loop will not be executed and control jumps to the next statement past them for a loop.
After the body of the for loop gets executed, the control jumps back up to the update statement. This statement allows you to update any loop control variables. This statement can be left blank with a semicolon at the end.
After the body of the for loop gets executed, the control jumps back up to the update statement. This statement allows you to update any loop control variables. This statement can be left blank with a semicolon at the end.
The Boolean expression is now evaluated again. If it is true, the loop executes and the process repeats (body of the loop, then update step, then Boolean expression). After the Boolean expression is false, the for loop terminates.
The Boolean expression is now evaluated again. If it is true, the loop executes and the process repeats (body of the loop, then update step, then Boolean expression). After the Boolean expression is false, the for loop terminates.
Following is an example code of the for loop in Java.
 Live Demo
public class Test {
   public static void main(String args[]) {
      for(int x = 10; x < 20; x = x + 1) {
         System.out.print("value of x : " + x );
         System.out.print("\n");
      }
   }
}
This will produce the following result −
value of x : 10
value of x : 11
value of x : 12
value of x : 13
value of x : 14
value of x : 15
value of x : 16
value of x : 17
value of x : 18
value of x : 19
Using Py-Feat to Plot Facial Expression Predictions | by Cole Hagen | Towards Data Science

Py-feat is a free, open-source, and easy-to-use tool for working with facial expressions data, which provides a toolkit to easily detect facial expressions from images and videos, preprocess & analyze facial expression data, and visualize facial expression data. You can learn more about Py-feat by exploring the links below:
py-feat.org
github.com
In this tutorial, we explore how to use Py-Feat on a single face image.
!pip install py-feat
First, load the detector class. You can specify which models you want to use. You can explore the models included in the Py-feat toolkit here.
from feat import Detectorface_model = "retinaface"landmark_model = "mobilenet"au_model = "rf"emotion_model = "resmasknet"detector = Detector(face_model = face_model, landmark_model = landmark_model, au_model = au_model, emotion_model = emotion_model)
Find the file you want to process. In our case, we’ll use our test image face.png.
# Find the file you want to process.test_image = os.path.join("face.png")
Here is what our test image looks like.
from PIL import Imageimport matplotlib.pyplot as pltf, ax = plt.subplots()im = Image.open(test_image)ax.imshow(im);
Now we use our initialized detector instance to make predictions with the detect_image() method.
image_prediction = detector.detect_image(test_image)# Show resultsimage_prediction
1 rows × 170 columns
The output is a Fex class instance which allows you to run the built-in methods for Fex.
Now, you can easily plot the detection results.
image_prediction.plot_detections();
There you have it! In this example, we used facial expression and emotion predictions from a machine learning model on a single image and plotted the results. Py-feat is a useful tool for computer vision and human behavior researchers to interpret and analyze facial expression data. To try it for yourself, check out the full code below.
https://colab.research.google.com/drive/1D64vLwbnhrD9wE9tNlZ8L1LNofLZN5vd?usp=sharing
towardsdatascience.com
towardsdatascience.com
towardsdatascience.com
Thank you for reading!
Continuous Subarray Sum in C++

Suppose we have a list of non-negative numbers and a target integer k, we have to write a function to check whether the array has a continuous subarray of size at least 2 that sums up to a multiple of k, sums up to n*k where n is also an integer. So if the input is like [23,2,4,6,7], and k = 6, then the result will be True, as [2,4] is a continuous subarray of size 2 and sums up to 6.
To solve this, we will follow these steps −
Make a map m, set m[0] := -1 and sum := 0, n := size of nums array
for i in range 0 to n – 1sum := sum + nums[i]if k is non zero, then sum := sum mod kif m has sum, and i – m[sum] >= 2, then return trueif m does not has sum, set m[sum] := i
sum := sum + nums[i]
if k is non zero, then sum := sum mod k
if m has sum, and i – m[sum] >= 2, then return true
if m does not has sum, set m[sum] := i
return false
Let us see the following implementation to get better understanding −
 Live Demo
#include <bits/stdc++.h>
using namespace std;
class Solution {
   public:
   bool checkSubarraySum(vector<int>& nums, int k) {
      unordered_map<int, int> m;
      m[0] = -1;
      int sum = 0;
      int n = nums.size();
      for(int i = 0; i < n; i++){
         sum += nums[i];
         if(k)
         sum %= k;
         if(m.count(sum) && i - m[sum] >= 2){
            return true;
         }
         if(!m.count(sum)) m[sum] = i;
      }
      return false;
   }
};
main(){
   vector<int> v = {23,2,4,6,7};
   Solution ob;
   cout << (ob.checkSubarraySum(v, 6));
}
[23,2,4,6,7]
6
1
C++ program for length of the longest word in a sentence

Given with the sentence of multiple strings and the task is to find the length of the longest string in the sentence.
Input-: hello I am here
Output-: maximum length of a word is: 5
Input-: tutorials point is the best learning platform
Output-: maximum length of a word is: 9
Approach used in the below program is as follows −
Input the string in an array of strings
Traverse the loop till the end of a sentence is not found
Traverse one particular string of a sentence and calculate its length. Store the length in a variable
Pass the integer values of length of strings stored in a temporary variable to a max() function that will return the maximum value from the given lengths of a string.
Display the maximum length returned by a max() function
Start
Step 1-> declare function to calculate longest word in a sentence
   int word_length(string str)
      set int len = str.length()
      set int temp = 0
      set int newlen = 0
         Loop For int i = 0 and i < len and i++
            IF (str[i] != ' ')
               Increment newlen++
            End
            Else
               Set temp = max(temp, newlen)
               Set newlen = 0
            End
            return max(temp, newlen)
step 2-> In main()
   declare string str = "tutorials point is the best learning platfrom"
   call word_length(str)
Stop
 Live Demo
#include <iostream>
using namespace std;
//function to find longest word
int word_length(string str) {
   int len = str.length();
   int temp = 0;
   int newlen = 0;
   for (int i = 0; i < len; i++) {
      if (str[i] != ' ')
         newlen++;
      else {
         temp = max(temp, newlen);
         newlen = 0;
      }
   }
   return max(temp, newlen);
}
int main() {
   string str = "tutorials point is the best learning platfrom";
   cout <<"maximum length of a word is : "<<word_length(str);
   return 0;
}
IF WE RUN THE ABOVE CODE IT WILL GENERATE FOLLOWING OUTPUT
maximum length of a word is : 9
Minimum Insertion Steps to Make a String Palindrome in C++

Suppose we have a string s, we have to make this string palindrome. in each step we can insert any character at any position, we have to find minimum number of characters that require to make this palindrome. If the string is like “mad”, then the answer will be 2 as we can add “da” before “mad”, or “am” after “mad” to make this palindrome.
To solve this, we will follow these steps −
Define a function lcs(), this will take s, x := s
n := size of s
reverse the string x
s := concatenate space before s, x := concatenate space before x
Define one 2D array dp of size (n + 1) x (n + 1)
for initialize i := 1, when i <= n, update (increase i by 1), do −for initialize j := 1, when j <= n, update (increase j by 1), do −dp[i, j] := maximum of dp[i – 1, j] and dp[i, j - 1]if s[i] is same as x[j], then −dp[i, j] := maximum of dp[i, j] and dp[i – 1, j - 1] + 1
for initialize j := 1, when j <= n, update (increase j by 1), do −dp[i, j] := maximum of dp[i – 1, j] and dp[i, j - 1]if s[i] is same as x[j], then −dp[i, j] := maximum of dp[i, j] and dp[i – 1, j - 1] + 1
dp[i, j] := maximum of dp[i – 1, j] and dp[i, j - 1]
if s[i] is same as x[j], then −dp[i, j] := maximum of dp[i, j] and dp[i – 1, j - 1] + 1
dp[i, j] := maximum of dp[i, j] and dp[i – 1, j - 1] + 1
return dp[n, n]
From the main method return size of s – lcs(s)
Let us see the following implementation to get better understanding −
 Live Demo
#include <bits/stdc++.h>
using namespace std;
class Solution {
public:
   int lcs(string s){
      string x = s;
      int n = s.size();
      reverse(x.begin(), x.end());
      s = " " + s;
      x = " " + x;
      vector < vector <int> > dp(n + 1, vector <int>(n + 1));
      for(int i = 1; i <= n; i++){
         for(int j = 1; j <= n; j++){
            dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            if(s[i] == x[j]){
               dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 1);
            }
         }
      }
      return dp[n][n];
   }
   int minInsertions(string s) {
      return s.size() - lcs(s);
   }
};
main(){
   Solution ob;
   cout << (ob.minInsertions("mad"));
}
“mad”
2
Python – Remove String from String List

27 Feb, 2020
This particular article is indeed a very useful one for Machine Learning enthusiast as it solves a good problem for them. In Machine Learning we generally encounter this issue of getting a particular string in huge amount of data and handling that sometimes becomes a tedious task. Lets discuss certain way outs to solve this problem.
Method #1 : Using remove()This particular method is quite naive and not recommended to use, but is indeed a method to perform this task. remove() generally removes the first occurrence of K string and we keep iterating this process until no K string is found in list.
# Python 3 code to demonstrate # Remove K String from String List# using remove()  # initializing list test_list = ["bad", "GeeksforGeeks", "bad", "is", "best", "bad"]  # Printing original listprint ("Original list is : " + str(test_list))  # initializing K K = "bad"  # using remove() to# Remove K String from String Listwhile(K in test_list) :    test_list.remove(K)      # Printing modified list print ("Modified list is : " + str(test_list))
Original list is : ['bad', 'GeeksforGeeks', 'bad', 'is', 'best', 'bad']
Modified list is : ['GeeksforGeeks', 'is', 'best']

 
Method #2 : Using List ComprehensionMore concise and better approach to remove all the K strings, it just checks if the string is not K and re-makes the list with all strings that are not K.
# Python 3 code to demonstrate # Remove K String from String List# using list comprehension  # initializing list test_list = ["bad", "GeeksforGeeks", "bad", "is", "best", "bad"]  # Printing original listprint ("Original list is : " + str(test_list))  # initializing K K = "bad"  # using list comprehension to# Remove K String from String Listtest_list = [i for i in test_list if i != K]      # Printing modified list print ("Modified list is : " + str(test_list))
Original list is : ['bad', 'GeeksforGeeks', 'bad', 'is', 'best', 'bad']
Modified list is : ['GeeksforGeeks', 'is', 'best']

Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | GATE CS 2012 | Question 25

28 Jun, 2021
Consider the following transactions with data items P and Q initialized to zero:
T1: read (P) ;
    read (Q) ;
    if P = 0 then Q : = Q + 1 ;
    write (Q) ;
T2: read (Q) ;
    read (P) ;
    if Q = 0 then P : = P + 1 ;
    write (P) ;
Any non-serial interleaving of T1 and T2 for concurrent execution leads to(A) A serializable schedule(B) A schedule that is not conflict serializable(C) A conflict serializable schedule(D) A schedule for which a precedence graph cannot be drawnAnswer: (B)Explanation:
See https://www.geeksforgeeks.org/database-management-system-set-3/
Quiz of this Question
GATE-CS-2012
GATE-GATE CS 2012
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | GATE-CS-2014-(Set-2) | Question 65
GATE | Sudo GATE 2020 Mock I (27 December 2019) | Question 33
GATE | GATE-CS-2015 (Set 3) | Question 65
GATE | GATE-CS-2014-(Set-3) | Question 65
GATE | GATE CS 2008 | Question 46
GATE | GATE CS 1996 | Question 63
GATE | Gate IT 2005 | Question 52
GATE | GATE CS 2012 | Question 18
GATE | GATE CS 2008 | Question 40
GATE | GATE-CS-2001 | Question 50
Python | Pandas Series.kurtosis()

11 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.kurtosis() function returns an unbiased kurtosis over requested axis using Fisher’s definition of kurtosis (kurtosis of normal == 0.0). The final result is normalized by N-1.
Syntax: Series.kurtosis(axis=None, skipna=None, level=None, numeric_only=None, **kwargs)
Parameter :axis : Axis for the function to be applied on.skipna : Exclude NA/null values when computing the result.level : If the axis is a MultiIndex (hierarchical), count along a particular level, collapsing into a scalar.numeric_only : Include only float, int, boolean columns.**kwargs : Additional keyword arguments to be passed to the function.
Returns : kurt : scalar or Series (if level specified)
Example #1: Use Series.kurtosis() function to find the kurtosis of the underlying data in the given series object.
# importing pandas as pdimport pandas as pd  # Creating the Seriessr = pd.Series([10, 25, 3, 25, 24, 6])  # Create the Indexindex_ = ['Coca Cola', 'Sprite', 'Coke', 'Fanta', 'Dew', 'ThumbsUp']  # set the indexsr.index = index_  # Print the seriesprint(sr)
Output :
Now we will use Series.kurtosis() function to find the kurtosis of the underlying data in the given series object.
# return the kurtosisresult = sr.kurtosis()  # Print the resultprint(result)
Output :
As we can see in the output, the Series.kurtosis() function has returned the kurtosis of the given series object. Example #2 : Use Series.kurtosis() function to find the kurtosis of the underlying data in the given series object. The given series object contains some missing values.
# importing pandas as pdimport pandas as pd  # Creating the Seriessr = pd.Series([19.5, 16.8, None, 22.78, 16.8, 20.124, None, 64, 89])  # Print the seriesprint(sr)
Output :
Now we will use Series.kurtosis() function to find the kurtosis of the underlying data in the given series object.
# return the kurtosis# skip the missing valuesresult = sr.kurtosis(skipna = True)  # Print the resultprint(result)
Output :As we can see in the output, the Series.kurtosis() function has returned the kurtosis of the given series 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.
Display the sum of positive and negative values from a column in separate columns with MySQL

For this, you can use CASE statement. Let us first create a table −
mysql> create table DemoTable(
   Id int,
   Value int
);
Query OK, 0 rows affected (0.51 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values(10,100);
Query OK, 1 row affected (0.15 sec)
mysql> insert into DemoTable values(10,-110);
Query OK, 1 row affected (0.10 sec)
mysql> insert into DemoTable values(10,200);
Query OK, 1 row affected (0.10 sec)
mysql> insert into DemoTable values(10,-678);
Query OK, 1 row affected (0.17 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+------+-------+
| Id   | Value |
+------+-------+
|   10 |   100 |
|   10 |  -110 |
|   10 |   200 |
|   10 |  -678 |
+------+-------+
4 rows in set (0.00 sec)
Following is the query to display the sum of positive and negative values from a column in separate columns −
mysql> select Id,
   sum(case when Value>0 then Value else 0 end) as Positive_Value,
   sum(case when Value<0 then Value else 0 end) as Negative_Value
   from DemoTable
   group by Id;
This will produce the following output −
+------+----------------+----------------+
| Id   | Positive_Value | Negative_Value |
+------+----------------+----------------+
|   10 |            300 |           -788 |
+------+----------------+----------------+
1 row in set (0.00 sec)
Aggregation in MongoDB for nested documents?

For aggregation in MongoDB, use aggregate(). Let us create a collection with documents −
> db.demo199.insertOne(
...   {
...      "details1":{
...         "details2":{
...            "details3":{
...               "Name":"Chris",
...               "details4":{
...                  "details5":{
...                     "v1":10,
...                     "v2":20,
...                     "v3":30
...                  }
...               }
...    }}}}
... );
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e3c24aa03d395bdc21346e2")
}
>
> db.demo199.insertOne(
...   {
...      "details1":{
...         "details2":{
...            "details3":{
...               "Name":"Chris",
...               "details4":{
...                  "details5":{
...                     "v1":30,
...                     "v2":40,
...                     "v3":50
...                  }
...               }
...   }}}}
...);
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e3c24ab03d395bdc21346e3")
}
Display all documents from a collection with the help of find() method −
> db.demo199.find();
This will produce the following output −
{ "_id" : ObjectId("5e3c24aa03d395bdc21346e2"), "details1" : { "details2" : { "details3" : { "Name" : "Chris", "details4" : { "details5" : { "v1" : 10, "v2" : 20, "v3" : 30 } } } } } }
{ "_id" : ObjectId("5e3c24ab03d395bdc21346e3"), "details1" : { "details2" : { "details3" : { "Name" : "Chris", "details4" : { "details5" : { "v1" : 30, "v2" : 40, "v3" : 50 } } } } } }
Following is the query for aggregation in MongoDB for nested documents −
> var out = [
...   {
...      "$unwind": "$details1.details2"
...   },
...   {
...      "$group": {
...         "_id": "$details1.details2._id",
...         "v1": { "$sum": "$details1.details2.details3.details4.details5.v1" },
...         "v2": { "$sum": "$details1.details2.details3.details4.details5.v2" },
...         "v3": { "$sum": "$details1.details2.details3.details4.details5.v3" },
...      }
...   }
...]
> result = db.demo199.aggregate(out);
This will produce the following output −
{ "_id" : null, "v1" : 40, "v2" : 60, "v3" : 80 }
Implement case sensitivity in MySQL SELECT statements

SELECT is by default case-insensitive. For case-sensitive implementation, the BINARY operator is used. Following is the syntax :
select *from yourTableName where BINARY yourColumnName=yourValue;
Let us first create a table −
mysql> create table DemoTable
(
   Name varchar(40)
);
Query OK, 0 rows affected (0.74 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('Chris');
Query OK, 1 row affected (0.17 sec)
mysql> insert into DemoTable values('CHRIS');
Query OK, 1 row affected (0.14 sec)
mysql> insert into DemoTable values('chris');
Query OK, 1 row affected (0.10 sec)
mysql> insert into DemoTable values('CHris');
Query OK, 1 row affected (0.11 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+-------+
| Name  |
+-------+
| Chris |
| CHRIS |
| chris |
| CHris |
+-------+
4 rows in set (0.00 sec)
Following is the query for case-sensitive select −
mysql> select *from DemoTable where BINARY Name='Chris';
This will produce the following output −
+-------+
| Name  |
+-------+
| Chris |
+-------+
1 row in set (0.04 sec)
What is “where 1=1” statement in MySQL?

In MySQL “Where 1=1” results in all the rows of a table as this statement is always true. An
example to better unerstand this statement is given as follows −
First, a table is created with the help of the create command. This is given as follows −
mysql> CREATE table WhereConditon
-> (
-> id int,
-> name varchar(100)
-> );
Query OK, 0 rows affected (0.43 sec)
After successfully creating a table, some records are inserted with the help of insert command
The query for this is given as follows −
mysql> INSERT into WhereConditon values(1,'John');
Query OK, 1 row affected (0.16 sec)

mysql> INSERT into WhereConditon values(2,'Smith');
Query OK, 1 row affected (0.15 sec)

mysql> INSERT into WhereConditon values(3,'Bob');
Query OK, 1 row affected (0.16 sec)

mysql> INSERT into WhereConditon values(4,'David');
Query OK, 1 row affected (0.13 sec)
Now that the records are inserted successfully, the number of records in the table can be
checked with the help of the select statement. This is given as follows −
mysql> SELECT * from WhereConditon;

After executing the above query, all the records from the table can be seen as follows −
+------+-------+
| id   | name  |
+------+-------+
| 1    | John  |
| 2    | Smith |
| 3    | Bob   |
| 4    | David |
+------+-------+
4 rows in set (0.00 sec)
Now, the statement 1=1 is used along with the select statement to display the names in the
table. All the names will be displayed as 1=1 is always true.
The query for this is given as follows −
mysql> select name from WhereConditon where 1=1;

The following is the output of the above query
+-------+
| name  |
+-------+
| John  |
| Smith |
| Bob   |
| David |
+-------+
4 rows in set (0.00 sec)
What is the generic functional interface in Java?

A lambda expression can't specify type parameters, so it's not generic. However, a functional interface associated with lambda expression is generic. In this case, the target type of lambda expression has determined by the type of argument(s) specified when a functional interface reference is declared.
interface SomeFunc {
 T func(T t);
}
interface MyGeneric<T> {
   T compute(T t);
}
public class LambdaGenericFuncInterfaceTest {
   public static void main(String args[]) {
      MyGeneric<String> reverse = (str) -> {   // Lambda Expression
         String result = "";
         for(int i = str.length()-1; i >= 0; i--)
            result += str.charAt(i);
         return result;
         };
      MyGeneric<Integer> factorial = (Integer n) -> {   // Lambda Expression
         int result = 1;
         for(int i=1; i <= n; i++)
            result = i * result;
         return result;
      };
      System.out.println(reverse.compute("Lambda Generic Functional Interface"));
      System.out.println(factorial.compute(7));
   }
}
ecafretnI lanoitcnuF cireneG adbmaL
5040
SQLSERVER Tryit Editor v1.0

SELECT Abs(-243.5) AS AbsNum;
​
        
Edit the SQL Statement, and click "Run SQL" to see the result.
This SQL-Statement is not supported in the WebSQL Database.
The example still works, because it uses a modified version of SQL.
Your browser does not support WebSQL.
Your are now using a light-version of the Try-SQL Editor, with a read-only Database.
If you switch to a browser with WebSQL support, you can try any SQL statement, and play with the Database as much as you like. The Database can also be restored at any time.
Our Try-SQL Editor uses WebSQL to demonstrate SQL.
A Database-object is created in your browser, for testing purposes.
You can try any SQL statement, and play with the Database as much as you like. The Database can be restored at any time, simply by clicking the "Restore Database" button.
WebSQL stores a Database locally, on the user's computer. Each user gets their own Database object.
WebSQL is supported in Chrome, Safari, and Opera.
If you use another browser you will still be able to use our Try SQL Editor, but a different version, using a server-based ASP application, with a read-only Access Database, where users are not allowed to make any changes to the data.