code-rag-bench/online-tutorials huggingface dataset:
How to draw text On image in Android using Kotlin?

This example demonstrates how to draw text On image in Android using Kotlin.
Step 1 − Create a new project in Android Studio, go to File? New Project and fill all required details to create a new project.
Step 2 − Add the following code to res/layout/activity_main.xml.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:tools="http://schemas.android.com/tools"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:padding="8dp"
   tools:context=".MainActivity">
<ImageView
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:background="@drawable/image" />
<TextView
   android:id="@+id/text"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:layout_alignParentBottom="true"
   android:layout_marginBottom="16sp"
   android:padding="4dp"
   android:textSize="24sp"
   android:textStyle="bold|italic" />
</RelativeLayout>
Step 3 − Add the following code to src/MainActivity.kt
import android.graphics.Color
import android.os.Bundle
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
class MainActivity : AppCompatActivity() {
   override fun onCreate(savedInstanceState: Bundle?) {
      super.onCreate(savedInstanceState)
      setContentView(R.layout.activity_main)
      title = "KotlinApp"
      val textView: TextView = findViewById(R.id.text)
      textView.text = "Into the wild!"
      textView.setTextColor(Color.WHITE)
   }
}
Step 4 − Add the following code to androidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.q11">
   <application
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:supportsRtl="true"
      android:theme="@style/AppTheme">
      <activity android:name=".MainActivity">
         <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
         </intent-filter>
      </activity>
   </application>
</manifest>
Let's try to run your application. I assume you have connected your actual Android Mobile device with your computer. To run the app from android studio, open one of your project's activity files and click the Run icon from the toolbar. Select your mobile device as an option and then check your mobile device which will display your default screen
Click here to download the project code.
C++ Permutations of a Given String Using STL

A permutation of a string is formed when the character of the given strings are rearranged in any form. In this tutorial, we are going to discuss how we can print all the permutations of a given string using C++’s Standard Template Library, for example
Input : s = “ADT”

Output : “ADT”, “ATD”, “DAT”, “DTA”, “TAD”, “TDA”

Explanation : In the given output as you can see all the string are made up of same three character present in our string and are just rearranged thus they fit in the definition of a permutation of a string now there is one more thing to note these are all the permutations possible of string s.
There are two methods by which we can print all the permutations of a given string
The first method we are going to use is by using the rotate method. In this method, we will use the rotate function of STL, which is used to rotate our string, and we are going to use recursion for printing the permutations.
C++ Code for the Above method 
#include<bits/stdc++.h>
using namespace std;
void permutations(string s, string ans){
    if(s.size() == 0) {
// when our string which needs to
//be rotated becomes empty then it means
//that our permutation is stored in ans
        cout << ans << "\n";
        return ;
    }
    for(int i = 0; i < s.size(); i++){
        permutations(s.substr(1), ans + s[0]);
        // we are adding the
        // first character in our ans
        // passing all elements from index 1 in our
        // rotate string for next function.
        rotate(s.begin(), s.begin()+1, s.end());
        //rotating such that our second element becomes first
    }
}
int main(){
    string s = "ADT"; // given string
    permutations(s, "");
    return 0;
}
ADT
ATD
DTA
DAT
TAD
TDA
Now we will use another function of STL, namely as next_Permutation as the name suggests, this function's return turn is whether the next permutation of this string exists or not. If no, then it returns false.
As you know, this function checks the next permutation; thus, we need first to sort the string lexicographically so that we get all the possible permutations.
C++ Code for the Above Method
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s = "ADT"; // given string
    sort(s.begin(), s.end()); // sorting the string
    do{
        cout << s << "\n"; // printing the permutations
    }while(next_permutation(s.begin(), s.end())); // till next_permutations returns false
    return 0;
}
ADT
ATD
DAT
DTA
TAD
TDA
In the above program, we sort our string, and then with the help of the next_permutation function, we print all the possible permutations.
In this tutorial, we print all the possible permutations of the given string using the help of STL in C++. We also learned the C++ program for this problem and some essential STL functions and their uses. We hope you find this tutorial helpful.
Class method vs static method in Python

The class method in Python is a method, which is bound to the class but not the object of that class. The static methods are also same but there are some basic differences. For class methods, we need to specify @classmethod decorator, and for static method @staticmethod decorator is used.
Syntax for Class Method.
class my_class:
   @classmethod
  deffunction_name(cls, arguments):
      #Function Body
      return value

Syntax for Static Method.
class my_class:
   @staticmethod
   deffunction_name(arguments):
      #Function Body
      return value

The Static methods are used to do some utility tasks, and class methods are used for factory methods. The factory methods can return class objects for different use cases.
from datetime import date as dt
class Employee:
   def __init__(self, name, age):
      self.name = name
      self.age = age
   @staticmethod
   defisAdult(age):
      if age > 18:
         return True
      else:
         return False
   @classmethod
   defemp_from_year(emp_class, name, year):
      return emp_class(name, dt.today().year - year)
   def __str__(self):
      return 'Employee Name: {} and Age: {}'.format(self.name, self.age)
e1 = Employee('Dhiman', 25)
print(e1)
e2 = Employee.emp_from_year('Subhas', 1987)
print(e2)
print(Employee.isAdult(25))
print(Employee.isAdult(16))
Employee Name: Dhiman and Age: 25
Employee Name: Subhas and Age: 31
True
False
How to convert a .wav file to a spectrogram in Python3?

To convert a .wav file to a spectrogram in python3, we can take the following steps −
Load a .wav file from local machine.
Load a .wav file from local machine.
Compute a spectrogram with consecutive Fourier transforms using spectrogram() method.
Compute a spectrogram with consecutive Fourier transforms using spectrogram() method.
Create a pseudocolor plot with a non-regular rectangular grid using pcolormesh() method.
Create a pseudocolor plot with a non-regular rectangular grid using pcolormesh() method.
Use imshow() method with spectrogram.
Use imshow() method with spectrogram.
To display the figure, use show() method.
To display the figure, use show() method.
import matplotlib.pyplot as plt
from scipy import signal
from scipy.io import wavfile
plt.rcParams["figure.figsize"] = [7.00, 3.50]
plt.rcParams["figure.autolayout"] = True
sample_rate, samples = wavfile.read('test.wav')
frequencies, times, spectrogram = signal.spectrogram(samples, sample_rate)
plt.pcolormesh(times, frequencies, spectrogram, shading='flat')
plt.imshow(spectrogram)
plt.show()
Array To Stream in Java

With Java 8, Arrays class has a stream() methods to generate a Stream using the passed array as its source.
The java.util.Arrays.stream() method returns a sequential Stream with the specified array as its source. −
Arrays.stream(array)
Following is the declaration for java.util.Arrays.stream() method
public static <T> Stream<T> stream(T[] array)
T − This is the type of the array elements.
T − This is the type of the array elements.
array − This is the source array to be used.
array − This is the source array to be used.
This method returns a stream for the array.
The following example shows the usage of java.util.Arrays.stream() method.
Live Demo
import java.util.Arrays;

public class Tester {
   public static void main(String args[]) {
      int data[] = { 1, 2, 3, 4, 5 };

      //iterative way to compute sum and average of an array
      int sum = 0;

      for(int i = 0; i< data.length; i++) {
         sum+= data[i];
      }

      System.out.println("Sum : " + sum);
      System.out.println("Average : " + sum/data.length);

      //declarative way to compute sum and average of an array
      sum = Arrays.stream(data).sum();

      System.out.println("Sum : " + sum);
      System.out.println("Average : " + sum/data.length);
   }
}
Compile and Run the file to verify the result.
Sum : 15
Average : 3
Sum : 15
Average : 3
Check whether a field is empty or null in MySQL?

NULL and empty string ‘ ’ both aren’t similar in MySQL. To check the field is empty like ‘ ’or is null, you need to use the IS NULL property or something else. You can check all the conditions with CASE statement. The syntax is as follows:
SELECT *, CASE
WHEN yourColumnName =’ ‘ THEN ‘yourMessage1’
WHEN yourColumnName IS NULL THEN ‘yourMessage2’
ELSE CONCAT(yourColumnName ,' is a Name')
END AS anyVariableName
FROM yourTableName;
To understand the above syntax, let us create a table. The query to create a table is as follows:
mysql> create table checkFieldDemo
   -> (
   -> Id int NOT NULL AUTO_INCREMENT,
   -> Name varchar(10),
   -> PRIMARY KEY(Id)
   -> );
Query OK, 0 rows affected (0.64 sec)
Insert some records in the table using insert command. The query is as follows:
mysql> insert into checkFieldDemo(Name) values(NULL);
Query OK, 1 row affected (0.17 sec)
mysql> insert into checkFieldDemo(Name) values('John');
Query OK, 1 row affected (0.15 sec)
mysql> insert into checkFieldDemo(Name) values(NULL);
Query OK, 1 row affected (0.10 sec)
mysql> insert into checkFieldDemo(Name) values('');
Query OK, 1 row affected (0.51 sec)
mysql> insert into checkFieldDemo(Name) values('Carol');
Query OK, 1 row affected (0.14 sec)
mysql> insert into checkFieldDemo(Name) values('');
Query OK, 1 row affected (0.17 sec)
mysql> insert into checkFieldDemo(Name) values(NULL);
Query OK, 1 row affected (0.10 sec)
Display all records from the table using select statement. The query is as follows:
mysql> select *from checkFieldDemo;
The following is the output:
+----+-------+
| Id | Name  |
+----+-------+
|  1 | NULL  |
|  2 | John  |
|  3 | NULL  |
|  4 |       |
|  5 | Carol |
|  6 |       |
|  7 | NULL  |
+----+-------+
7 rows in set (0.00 sec)
Here is the query to check field is empty or null or something else using case statement. The query is as follows:
mysql> select *,case
   -> when Name='' then 'It is an empty string'
   -> when Name is null then 'It is a NULL value'
   -> else concat(Name,' is a Name')
   -> END as ListOfValues
   -> from checkFieldDemo;
The following is the output:
+----+-------+-----------------------+
| Id | Name  | ListOfValues          |
+----+-------+-----------------------+
|  1 | NULL  | It is a NULL value    |
|  2 | John  | John is a Name        |
|  3 | NULL  | It is a NULL value    |
|  4 |       | It is an empty string |
|  5 | Carol | Carol is a Name       |
|  6 |       | It is an empty string |
|  7 | NULL  | It is a NULL value    |
+----+-------+-----------------------+
7 rows in set (0.00 sec)
Converting Emojis to Text. Using Emot to convert emoticons to text... | by Himanshu Sharma | Towards Data Science

Have you ever received an emoji that you don’t know or don’t understand what is it? I know that happens to all of us. There are a lot of emojis out there which we don’t understand, using that data in creating an NLP model can result in discrepancies.
What if I tell you that you can change these emojis to text? Yes, you heard that right you can do that. It will not only be easy to understand but also make the data ready for NLP modeling.
Emot is an open-source python library which we can use to convert emoticons to text description. In this article, we will explore how to use Emot.
Let’s get started...
We will start by installing Emot using pip. The command given below will do that.
pip install emot
In this step, we will import the required library i.e. Emot.
import emot as e
This is the final step in which we will pass some text containing emojis to the emot library and convert emojis to text.
text = "I am a coder😎"con = e.emoji(text)con
Here you can see how easily it converted the emoji to the text. Let’s try with some more emojis.
text = "😁😆😅😂😇🙃"con = e.emoji(text)con
You see how wonderful emot is, creating text out of emojis. Let’s try a last one with a very unique emoji.
text = "🤡"con = e.emoji(text)con
You can use this to preprocess your text data before passing it to NLP models. Go ahead try this with different emoticons and let me know your comments in the response section.
This article is in collaboration with Piyush Ingale.
Thanks for reading! If you want to get in touch with me, feel free to reach me at hmix13@gmail.com or my LinkedIn Profile. You can view my Github profile for different data science projects and packages tutorials. Also, feel free to explore my profile and read different articles I have written related to Data Science.
Swap Nodes in Pairs in C++

Consider we have a linked list. We have to swap every two adjacent nodes and return its head. The constraint is that we cannot modify the value of the nodes, only the node itself can be changed. So if the list is like [1,2,3,4], then the resultant list will be [2,1,4,3]
To solve this, we will follow these steps −
if head is not present, then return head
first := head, second := next of head, dummy is one new node with value -1
next of dummy := first, and prev := dummy
while second is not nulltemp := next of secondnext of first := next of secondnext of second := firstnext of prev := secondprev := firstif temp is not null, then first := temp and second := next of temp, otherwise break
temp := next of second
next of first := next of second
next of second := first
next of prev := second
prev := first
if temp is not null, then first := temp and second := next of temp, otherwise break
return next of dummy
Let us see the following implementation to get a better understanding −
 Live Demo
#include <bits/stdc++.h>
using namespace std;
class ListNode{
   public:
      int val;
      ListNode *next;
      ListNode(int data){
         val = data;
         next = NULL;
      }
};
ListNode *make_list(vector<int> v){
   ListNode *head = new ListNode(v[0]);
   for(int i = 1; i<v.size(); i++){
      ListNode *ptr = head;
      while(ptr->next != NULL){
         ptr = ptr->next;
      }
      ptr->next = new ListNode(v[i]);
   }
   return head;
}
void print_list(ListNode *head){
   ListNode *ptr = head;
   cout << "[";
   while(ptr->next){
      cout << ptr->val << ", ";
      ptr = ptr->next;
   }
   cout << "]" << endl;
}
class Solution {
public:
   ListNode* swapPairs(ListNode* head) {
      if(!head)return head;
      ListNode* first= head;
      ListNode* second = head->next;
      ListNode* dummy = new ListNode(-1);
      dummy->next = first;
      ListNode* prev = dummy;
      while(second){
         ListNode* temp = second->next;
         first->next = second->next;
         second->next = first;
         prev->next = second;
         prev = first;
         if(temp){
            first = temp;
            second = temp ->next;
         }
         else break;
      }
      return dummy->next;
   }
};
main(){
   Solution ob;
   vector<int> v = {1,2,3,4,5,6,7,8};
   ListNode *head = make_list(v);
   print_list(ob.swapPairs(head));
}
[1,2,3,4,5,6,7,8]
[2,1,4,3,6,5,8,7]
How to merge MySQL results?

To merge, use simple join. Following is the syntax −
select
aliasName1.yourColumnName1,
aliasName1.yourColumnName2,
.
.
.N
aliasName2.yourColumnName1
from yourTableName1 aliasName1
.
.
.
N
join
yourTableName2 aliasName2
on yourCondition;
Let us create a table −
mysql> create table demo8
−> (
−> id int,
−> name varchar(20)
−> );
Query OK, 0 rows affected (1.77 sec)
Insert some records into the table with the help of insert command −
mysql> insert into demo8 values(100,'John');
Query OK, 1 row affected (0.09 sec)

mysql> insert into demo8 values(101,'Mike');
Query OK, 1 row affected (0.16 sec)

mysql> insert into demo8 values(102,'Bob');
Query OK, 1 row affected (0.15 sec)
Display records from the table using select statement −
mysql> select *from demo8;
This will produce the following output −
+------+------+
| id   | name |
+------+------+
| 100  | John |
| 101  | Mike |
| 102  | Bob  |
+------+------+
3 rows in set (0.00 sec)
Following is the query to create second table −
mysql> create table demo9
−> (
−> id int,
−> age int
−> );
Query OK, 0 rows affected (1.90 sec)
Insert some records into the table with the help of insert command −
mysql> insert into demo9 values(100,27);
Query OK, 1 row affected (0.09 sec)

mysql> insert into demo9 values(101,24);
Query OK, 1 row affected (0.12 sec)

mysql> insert into demo9 values(102,28);
Query OK, 1 row affected (0.29 sec)
Display records from the table using select statement −
mysql> select *from demo9;
This will produce the following output −
+------+------+
|  id  | age  |
+------+------+
|  100 | 27   |
|  101 | 24   |
|  102 | 28   |
+------+------+
3 rows in set (0.00 sec)
Following is the query to merge results −
mysql> select tbl1.id,tbl1.name,tbl2.age
−> from demo8 tbl1
−> join
−> demo9 tbl2
−> on tbl1.id=tbl2.id;
This will produce the following output −
+------+------+------+
|   id | name | age  |
+------+------+------+
|  100 | John |   27 |
|  101 | Mike |   24 |
|  102 | Bob  |   28 |
+------+------+------+
3 rows in set (0.00 sec)
Push vs pop in stack class in C#

Stack class represents a last-in, first out collection of object. It is used when you need a last-in, first-out access of items.
The following is the property of Stack class −
Count − Gets the number of elements in the stack.
Count − Gets the number of elements in the stack.
Add elements in the stack using the Push operation −
Stack st = new Stack();

st.Push('A');
st.Push('B');
st.Push('C');
st.Push('D');
The Pop operation removes elements from the stack starting from the element on the top.
Here is an example showing how to work with Stack class and its Push() and Pop() method −
Using System;
using System.Collections;

namespace CollectionsApplication {
   class Program {
      static void Main(string[] args) {
         Stack st = new Stack();

         st.Push('A');
         st.Push('B');
         st.Push('C');
         st.Push('D');

         Console.WriteLine("Current stack: ");
         foreach (char c in st) {
            Console.Write(c + " ");
         }
         Console.WriteLine();

         st.Push('P');
         st.Push('Q');
         Console.WriteLine("The next poppable value in stack: {0}", st.Peek());
         Console.WriteLine("Current stack: ");

         foreach (char c in st) {
            Console.Write(c + " ");
         }

         Console.WriteLine();
         Console.WriteLine("Removing values....");
         st.Pop();
         st.Pop();
         st.Pop();
         Console.WriteLine("Current stack: ");
         foreach (char c in st) {
            Console.Write(c + " ");
         }
      }
   }
}
How to show multiple images in one figure in Matplotlib?

To show multiple images in one figure in matplotlib, we can take the following steps −
Create random data using numpy.
Create random data using numpy.
Add a subplot to the current figure, nrows=1, ncols=4 and at index=1.
Add a subplot to the current figure, nrows=1, ncols=4 and at index=1.
Display data as an image, i.e., on a 2D regular raster, using imshow() method with cmap="Blues_r".
Display data as an image, i.e., on a 2D regular raster, using imshow() method with cmap="Blues_r".
Add a subplot to the current figure, nrows=1, ncols=4 and at index=2.
Add a subplot to the current figure, nrows=1, ncols=4 and at index=2.
Display data as an image, i.e., on a 2D regular raster, using imshow() method with cmap="Accent_r".
Display data as an image, i.e., on a 2D regular raster, using imshow() method with cmap="Accent_r".
Add a subplot to the current figure, nrows=1, ncols=4 and at index=3.
Add a subplot to the current figure, nrows=1, ncols=4 and at index=3.
Display data as an image, i.e., on a 2D regular raster, using imshow() method with cmap="terrain_r".
Display data as an image, i.e., on a 2D regular raster, using imshow() method with cmap="terrain_r".
Add a subplot to the current figure, nrows=1, ncols=4 and at index=4.
Add a subplot to the current figure, nrows=1, ncols=4 and at index=4.
Display data as an image, i.e., on a 2D regular raster, using imshow() method with cmap="twilight_shifted_r".
Display data as an image, i.e., on a 2D regular raster, using imshow() method with cmap="twilight_shifted_r".
To display the figure, use show() method.
To display the figure, use show() method.
import numpy as np
from matplotlib import pyplot as plt
plt.rcParams["figure.figsize"] = [7.00, 3.50]
plt.rcParams["figure.autolayout"] = True
data = np.random.rand(5, 5)
plt.subplot(1, 4, 1)
plt.imshow(data, cmap="Blues_r")
plt.subplot(1, 4, 2)
plt.imshow(data, cmap="Accent_r")
plt.subplot(1, 4, 3)
plt.imshow(data, cmap="terrain_r")
plt.subplot(1, 4, 4)
plt.imshow(data, cmap="twilight_shifted_r")
plt.show()
Find average of a list in python - GeeksforGeeks

21 Nov, 2018
Prerequisites: sum() function, len() function, round() function, reduce(), lambda, and mean().
Given a list of numbers, the task is to find average of that list. Average is the sum of elements divided by the number of elements.
Examples:
Input : [4, 5, 1, 2, 9, 7, 10, 8]
Output : Average of the list = 5.75
Explanation:
Sum of the elements is 4+5+1+2+9+7+10+8 = 46
and total number of elements is 8.
So average is 46 / 8 = 5.75

Input : [15, 9, 55, 41, 35, 20, 62, 49]
Output : Average of the list = 35.75
Explanation:
Sum of the elements is 15+9+55+41+35+20+62+49 = 286
and total number of elements is 8.
So average is 46 / 8 = 35.75


In Python we can find the average of a list by simply using the sum() and len() function.
sum() : Using sum() function we can get the sum of the list.
len() : len() function is used to get the length or the number of elements in a list.
# Python program to get average of a listdef Average(lst):    return sum(lst) / len(lst)  # Driver Codelst = [15, 9, 55, 41, 35, 20, 62, 49]average = Average(lst)  # Printing average of the listprint("Average of the list =", round(average, 2))
Output:
Average of the list = 35.75

We can use the reduce() to reduce the loop and by using the lambda function can compute summation of list. We use len() to calculate length as discussed above.
# Python program to get average of a list# Using reduce() and lambda   # importing reduce()from functools import reduce  def Average(lst):    return reduce(lambda a, b: a + b, lst) / len(lst)  # Driver Codelst = [15, 9, 55, 41, 35, 20, 62, 49]average = Average(lst)  # Printing average of the listprint("Average of the list =", round(average, 2))
Output:
Average of the list = 35.75

The inbuilt function mean() can be used to calculate the mean( average ) of the list.
# Python program to get average of a list# Using mean()  # importing mean()from statistics import mean  def Average(lst):    return mean(lst)  # Driver Codelst = [15, 9, 55, 41, 35, 20, 62, 49]average = Average(lst)  # Printing average of the listprint("Average of the list =", round(average, 2))
Output:
Average of the list = 35.75

manjeet_04
Python list-programs
python-list
Python
python-list
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
Enumerate() in Python
How to Install PIP on Windows ?
Iterate over a list in Python
Different ways to create Pandas Dataframe
Python String | replace()
Python program to convert a list to string
Create a Pandas DataFrame from Lists
Reading and Writing to text files in Python
MySQL Tryit Editor v1.0

SELECT IFNULL(NULL, 500);
​
        
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.
How do I list all the columns in a MySQL table?

To list all columns in a table, we can use the SHOW command. Let us first create a table.
mysql> create table ColumnsList
   -> (
   -> id int,
   -> Firstname varchar(200),
   -> LastName varchar(100),
   -> Age int,
   -> Address varchar(300),
   -> CollegeName varchar(100)
   -> );
Query OK, 0 rows affected (1.33 sec)
Syntax to list all column names.
show columns from yourTableName;

The following is the output.
mysql> show columns from ColumnsList;
The following output displays all the column names.
+-------------+--------------+------+-----+---------+-------+
| Field       | Type         | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+-------+
| id          | int(11)      | YES  |     | NULL    |       |
| Firstname   | varchar(200) | YES  |     | NULL    |       |
| LastName    | varchar(100) | YES  |     | NULL    |       |
| Age         | int(11)      | YES  |     | NULL    |       |
| Address     | varchar(300) | YES  |     | NULL    |       |
| CollegeName | varchar(100) | YES  |     | NULL    |       |
+-------------+--------------+------+-----+---------+-------+
6 rows in set (0.00 sec)
Decimal.Round() Method in C#

The Decimal.Round() method in C# is used to round a value to the nearest integer or specified number of decimal places.
Following is the syntax −
public static decimal Round (decimal d);
public static decimal Round (decimal d, int decimals);
public static decimal Round (decimal d, MidpointRounding mode);
public static decimal Round (decimal d, int decimals, MidpointRounding mode);
Let us now see an example to implement the Decimal.Round() method −
using System;
public class Demo {
   public static void Main(){
      Decimal val1 = 9.00m;
      Decimal val2 = 15.29m;
      Decimal val3 = 394949845.14245M;
      Console.WriteLine("Decimal 1 = "+val1);
      Console.WriteLine("Decimal 2 = "+val2);
      Console.WriteLine("Decimal 2 = "+val2);
      Console.WriteLine("Remainder = "+(Decimal.Remainder(val1,val2)));
      Console.WriteLine("Value 1 (Rounded) = "+(Decimal.Round(val1)));
      Console.WriteLine("Value 2 (Rounded) = "+(Decimal.Round(val2)));
      Console.WriteLine("Value 3 (Rounded) = "+(Decimal.Round(val3)));
   }
}
This will produce the following output −
Decimal 1 = 9.00
Decimal 2 = 15.29
Decimal 2 = 15.29
Remainder = 9.00
Value 1 (Rounded) = 9
Value 2 (Rounded) = 15
Value 3 (Rounded) = 394949845
Let us now see another example to implement the Decimal.Round() method −
using System;
public class Demo {
   public static void Main(){
      Decimal val1 = 6.59m;
      Decimal val2 = 30.12m;
      Decimal val3 = 6946649845.25245M;
      Console.WriteLine("Decimal 1 = "+val1);
      Console.WriteLine("Decimal 2 = "+val2);
      Console.WriteLine("Decimal 2 = "+val2);
      Console.WriteLine("Remainder = "+(Decimal.Remainder(val1,val2)));
      Console.WriteLine("Value 1 (Rounded) = "+(Decimal.Round(val1,1)));
      Console.WriteLine("Value 2 (Rounded) = "+(Decimal.Round(val2,1)));
      Console.WriteLine("Value 3 (Rounded) = "+(Decimal.Round(val3,2)));
   }
}
This will produce the following output −
Decimal 1 = 6.59
Decimal 2 = 30.12
Decimal 2 = 30.12
Remainder = 6.59
Value 1 (Rounded) = 6.6
Value 2 (Rounded) = 30.1
Value 3 (Rounded) = 6946649845.25
SQL Tryit Editor v1.6

SELECT Orders.OrderID, Customers.CustomerName
FROM Orders
INNER JOIN Customers ON Orders.CustomerID = Customers.CustomerID;
​
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, Opera, and Edge(79).
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.
Explain interface in PHP.

In this article, we will figure out how to utilize the PHP interface that is one of the most significant structure patterns in PHP object-oriented programming.
An Interface enables us to make programs, indicating the public methods that a class must execute, without including the complexities and procedure of how the specific methods are implemented. This implies that an interface can define method names and arguments, but not the contents of the methods. Any classes implementing an interface must implement all methods defined by the interface.
Interfaces are characterized similarly as a class, however, only the interface keyword replaces the class phrase in the declaration and without any of the methods having their contents defined.
Let' create an interface and implement it with a simple example.
<?php
   Interface MyInterface {
      public function getName();
      public function getAge();
   }
   class MyClass implements MyFirstInterface{
      public function getName() {
            echo "My name A".'<br>';
      }
      public function getAge(){
            echo "My Age 12";
      }
   }
   $obj = new MyClass;
   $obj->getName();
   $obj->getAge();
?>
My name A
My Age 12
Here we have declared an interface MyFirstInterface with two methods getName and getAge inside it without any content. Then the class MyClass implements this interface and uses the available methods according to requirement.
Let's learn some important Characteristic of the interface:
An interface comprises of methods that have no content, which means the interface methods are abstract methods.
Every one of the methods in interfaces must have public visibility scope.
Interfaces are not quite the same as classes as the class can inherit from one class but the class can implement one or more interfaces.
No variables cant be present inside interface.
We can achieve multiple inheritances utilizing interface because a class can implement more than one interface whereas it can extend only one class.
Let's test this with a simple example.
<?php
   interface a{
      public function printData();
   }
   interface b{
      public function getData();
   }
   interface c extends a, b{
      public function addData();
   }
   class d implements c{
      public function printData(){
         echo "I am printing";
      }
      public function getData(){
         echo "I am reading data";
      }
      public function addData(){
         echo "I am adding"
      }
   }
   $myobj = new class d();
   $myobj->printData();
   $myobj->addData();
?>
I am printing
I am adding
Here we have declared three interfaces i.e 'interface a',' interface b', 'interface c'.In this case interface c also extends the previous two interfaces. Then we have declared a class that implements only the interface c, but as interface c extends the previous two interfaces, all the methods declared in the 'interface a', 'interface b' and 'interface c'  are available for the use in class d. This is how we can achieve multiple inheritances by implementing the interface.
What is the type conversion operator ( ) in Java and how to use it?

Cast operator in java is used to convert one data type to other.
public class Sample {
   public static void main(String args[]) {
      double d = 20.3;
      int i = (int)d;
      System.out.println(i);
   }
}
20
getParameter() - Passing data from client to JSP - GeeksforGeeks

10 Jun, 2018
The familiarity of the getParameter() method in getting data, especially form data, from a client HTML page to a JSP page is dealt with here. The request.getParameter() is being used here to retrieve form data from client side.
Steps to be followed1) First, a html page exGetParameter.html accepts data from the client. The client enters text in the space provided and clicks on ‘Submit’.2) Immediately the getparam.jsp page gets called, it being mentioned in the action tag.3) This JSP page fetches the data using getParameter() method and displays the same to the user.
Note: Entire application has been developed and tested on NetBeans IDE 8.1.
Page to accept client data : exGetParameter.html page
<html>    <head>        <title>Get Parameter Example</title>        <meta charset="UTF-8">        <meta name="viewport" content="width=device-width,                                       initial-scale=1.0">    </head>    <body>        <!-- Here we specify that the from data will be sent to              getparam.jsp page using the action attribute          -->        <form name="testForm" action="getparam.jsp">           <label><h1>Enter a text and click Submit<h1/></label><br/>           <input type="text" name="testParam"><br/>           <input type="submit">        </form>    </body></html>
Page to fetch client data : getparam.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%><!DOCTYPE html><html>    <head>        <meta http-equiv="Content-Type" content="text/html;                                            charset=UTF-8">        <title>JSP Page</title>    </head>    <body>        <%-- Here we fetch the data using the name attribute              of the text from the previous page        --%>        <% String val = request.getParameter("testParam"); %>    </body>    <%-- Here we use the JSP expression tag to display value          stored in a variable    --%>    <h2>The text entered was : </h2><%=val%></html>
OutputsClient Data : exGetParameter.html
After clicking on ‘Submit’ the following screen appears.Fetched Data from Client : getparam.jsp
Java-JSP
Java
Java Programs
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Object Oriented Programming (OOPs) Concept in Java
HashMap in Java with Examples
How to iterate any Map in Java
Interfaces in Java
Initialize an ArrayList in Java
Convert a String to Character array in Java
Initializing a List in Java
Java Programming Examples
Convert Double to Integer in Java
Implementing a Linked List in Java using Class
How to sort an array of objects containing null elements in java?

Whenever we try to sort elements with null values using the sort method it throws an exception.
The sort() method of the Arrays class also accepts a Comparator along with the array. Using comparator, you need to specify the order in which the elements need to be sorted.
Using this method push all the null elements to last and sort the elements −
 Live Demo
import java.util.Arrays;
import java.util.Comparator;

public class ArrayWithNullsInOrder {
public static void main(String args[]) {
String[] myArray = {"JavaFX", null, "OpenCV", null, "Hadoop", null};

Arrays.sort(myArray,Comparator.nullsLast(String.CASE_INSENSITIVE_ORDER));
System.out.println(Arrays.toString(myArray));
}
}
[Hadoop, JavaFX, OpenCV, null, null, null]
How to get rid of grid lines when plotting with Seaborn + Pandas with secondary_y?

To get rid of grid lines when plotting with Pandas with secondary_y, we can take the following steps −
Create a data frame using DataFrame wth keys column1 and column2.
Create a data frame using DataFrame wth keys column1 and column2.
Use data frame data to plot the data frame. To get rid of gridlines, use grid=False.
Use data frame data to plot the data frame. To get rid of gridlines, use grid=False.
To display the figure, use show() method.
To display the figure, use show() method.
import pandas as pd
from matplotlib import pyplot as plt
plt.rcParams["figure.figsize"] = [7.00, 3.50]
plt.rcParams["figure.autolayout"] = True
data = pd.DataFrame({"column1": [4, 6, 7, 1, 8], "column2": [1, 5, 7, 8, 1]})
data.plot(secondary_y=[5], grid=False)
plt.show()
Hanning in Numpy | Python - GeeksforGeeks

22 Jul, 2021
The Hanning window is a taper formed by using a weighted cosine.
Syntax:  numpy.hamming(M)

Parameters: 
M :  Number of points in the output window.

Returns:  AN array
The window, with the maximum value normalized to one (the value one appears only if M is odd).
Code #1:
import numpy as np    print(np.hanning(12))
Output:
[ 0.          0.07937323  0.29229249  0.57115742  0.82743037  0.97974649
  0.97974649  0.82743037  0.57115742  0.29229249  0.07937323  0.        ]

Code #2: Plotting the window and its frequency response (requires SciPy and matplotlib).
import numpy as npimport matplotlib.pyplot as pltfrom numpy.fft import fft, fftshift  window = np.hanning(51)  plt.plot(window)plt.title("Hann window")plt.ylabel("Amplitude"")plt.xlabel("Sample")  plt.show()
Output:
For frequency:
import numpy as npimport matplotlib.pyplot as pltfrom numpy.fft import fft, fftshift  window = np.hanning(51)plt.figure()  A = fft(window, 2048) / 25.5mag = np.abs(fftshift(A))freq = np.linspace(-0.5, 0.5, len(A))response = 20 * np.log10(mag)response = np.clip(response, -100, 100)  plt.plot(freq, response)plt.title("Frequency response of Hanning window")plt.ylabel("Magnitude [dB]")plt.xlabel("Normalized frequency [cycles per sample]")plt.axis("tight")plt.show()
Output:
Python-numpy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Python Dictionary
Read a file line by line in Python
Enumerate() in Python
How to Install PIP on Windows ?
Iterate over a list in Python
Different ways to create Pandas Dataframe
Python String | replace()
Python program to convert a list to string
Reading and Writing to text files in Python
sum() function in Python
Google Colab - Installing ML Libraries

Colab supports most of machine learning libraries available in the market. In this chapter, let us take a quick overview of how to install these libraries in your Colab notebook.
To install a library, you can use either of these options −
!pip install

or
!apt-get install

Keras, written in Python, runs on top of TensorFlow, CNTK, or Theano. It enables easy and fast prototyping of neural network applications. It supports both convolutional networks (CNN) and recurrent networks, and also their combinations. It seamlessly supports GPU.
To install Keras, use the following command −
!pip install -q keras

PyTorch is ideal for developing deep learning applications. It is an optimized tensor library and is GPU enabled. To install PyTorch, use the following command −
!pip3 install torch torchvision

Apache MxNet is another flexible and efficient library for deep learning. To install MxNet execute the following commands −
!apt install libnvrtc8.0
!pip install mxnet-cu80

OpenCV is an open source computer vision library for developing machine learning applications. It has more than 2500 optimized algorithms which support several applications such as recognizing faces, identifying objects, tracking moving objects, stitching images, and so on. Giants like Google, Yahoo, Microsoft, Intel, IBM, Sony, Honda, Toyota use this library. This is highly suited for developing real-time vision applications.
To install OpenCV use the following command −
!apt-get -qq install -y libsm6 libxext6 && pip install -q -U opencv-python

XGBoost is a distributed gradient boosting library that runs on major distributed environments such as Hadoop. It is highly efficient, flexible and portable. It implements ML algorithms under the Gradient Boosting framework.
To install XGBoost, use the following command −
!pip install -q xgboost==0.4a30

Graphviz is an open source software for graph visualizations. It is used for visualization in networking, bioinformatics, database design, and for that matter in many domains where a visual interface of the data is desired.
To install GraphViz, use the following command −
!apt-get -qq install -y graphviz && pip install -q pydot

By this time, you have learned to create Jupyter notebooks containing popular machine learning libraries. You are now ready to develop your machine learning models. This requires high processing power. Colab provides free GPU for your notebooks.
In the next chapter, we will learn how to enable GPU for your notebook.

    20 Lectures 
     2.5 hours 

 Asif Hussain

    7 Lectures 
     1 hours 

 Aditya Kulkarni

    33 Lectures 
     2.5 hours 

 Sasha Miller

    22 Lectures 
     1.5 hours 

 Zach Miller

    16 Lectures 
     1.5 hours 

 Sasha Miller

    23 Lectures 
     2.5 hours 

 Sasha Miller
 Print
 Add Notes
 Bookmark this page
Can we compare numbers in a MySQL varchar field?

Yes, we can do this by first using CAST(). Let us first create a table −
mysql> create table DemoTable
   -> (
   -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   -> StudentScore varchar(100)
   -> );
Query OK, 0 rows affected (0.66 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable(StudentScore) values('90');
Query OK, 1 row affected (0.21 sec)

mysql> insert into DemoTable(StudentScore) values('100');
Query OK, 1 row affected (0.13 sec)

mysql> insert into DemoTable(StudentScore) values('56');
Query OK, 1 row affected (0.10 sec)

mysql> insert into DemoTable(StudentScore) values('98');
Query OK, 1 row affected (0.13 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+-----------+--------------+
| StudentId | StudentScore |
+-----------+--------------+
|         1 | 90           |
|         2 | 100          |
|         3 | 56           |
|         4 | 98           |
+-----------+--------------+
4 rows in set (0.00 sec)
Here is the query to compare in varchar fields −
mysql> select *from DemoTable where  CAST(StudentScore AS SIGNED) > 91;
This will produce the following output −
+-----------+--------------+
| StudentId | StudentScore |
+-----------+--------------+
|         2 | 100          |
|         4 | 98           |
+-----------+--------------+
2 rows in set (0.00 sec)
PostgreSQL - Bitwise Operators

Here are simple examples showing the usage of PostgreSQL Bitwise Operators.
Assume variable A holds 60 and variable B holds 13 then −
testdb=# select 60 | 13;
 ?column?
----------
       61
(1 row)


testdb=# select 60 & 13;
 ?column?
----------
       12
(1 row)


testdb=#  select  (~60);
 ?column?
----------
      -61
(1 row)


testdb=# select  (60 << 2);
 ?column?
----------
      240
(1 row)


testdb=# select  (60 >> 2);
 ?column?
----------
       15
(1 row)


testdb=#  select 60 # 13;
 ?column?
----------
       49
(1 row)

    23 Lectures 
     1.5 hours 

 John Elder

    49 Lectures 
     3.5 hours 

 Niyazi Erdogan

    126 Lectures 
     10.5 hours 

 Abhishek And Pukhraj

    35 Lectures 
     5 hours 

 Karthikeya T

    5 Lectures 
     51 mins

 Vinay Kumar

    5 Lectures 
     52 mins

 Vinay Kumar
 Print
 Add Notes
 Bookmark this page
KnockoutJS - removeAll() Method

The KnockoutJS Observable removeAll() method removes all items and returns them as an array.
arrayName.removeAll()

Does not accept any parameter.
<!DOCTYPE html>
   <head>
      <title>KnockoutJS ObservableArray removeAll method</title>
      <script src = "https://ajax.aspnetcdn.com/ajax/knockout/knockout-3.1.0.js"
         type = "text/javascript"></script>
   </head>

   <body>
      <p>Example to demonstrate removeAll() method.</p>
      <button data-bind = "click: removeallEmp">Remove All Emps</button>
      <p>Array of employees: <span data-bind = "text: empArray()" ></span></p>

      <script>
         function EmployeeModel() {
            this.empName = ko.observable("");
            this.chosenItem = ko.observableArray("");
            this.empArray = ko.observableArray(['Scott','James','Jordan','Lee',
               'RoseMary','Kathie']);

            this.removeallEmp = function() {
               this.empArray.removeAll();
            }
         }

         var em = new EmployeeModel();
         ko.applyBindings(em);
      </script>
      
   </body>
</html>
Let's carry out the following steps to see how the above code works −
Save the above code in array-removeall.htm file.
Save the above code in array-removeall.htm file.
Open this HTML file in a browser.
Open this HTML file in a browser.
Click the Remove All Emps Button.
Click the Remove All Emps Button.
Example to demonstrate removeAll() method.
Array of employees: Scott,James,Jordan,Lee,RoseMary,Kathie

    38 Lectures 
     2 hours 

 Skillbakerystudios
 Print
 Add Notes
 Bookmark this page
C Program for Extended Euclidean algorithms - GeeksforGeeks

05 Dec, 2018
GCD of two numbers is the largest number that divides both of them. A simple way to find GCD is to factorize both numbers and multiply common factors.
// C program to demonstrate working of extended// Euclidean Algorithm#include <stdio.h>  // C function for extended Euclidean Algorithmint gcdExtended(int a, int b, int* x, int* y){    // Base Case    if (a == 0) {        *x = 0;        *y = 1;        return b;    }      int x1, y1; // To store results of recursive call    int gcd = gcdExtended(b % a, a, &x1, &y1);      // Update x and y using results of recursive    // call    *x = y1 - (b / a) * x1;    *y = x1;      return gcd;}  // Driver Programint main(){    int x, y;    int a = 35, b = 15;    int g = gcdExtended(a, b, &x, &y);    printf("gcd(%d, %d) = %d", a, b, g);    return 0;}
gcd(35, 15) = 5

Please refer complete article on Basic and Extended Euclidean algorithms for more details!
C Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
C Program to read contents of Whole File
Producer Consumer Problem in C
C program to find the length of a string
Exit codes in C/C++ with Examples
Regular expressions in C
Handling multiple clients on server with multithreading using Socket Programming in C/C++
C / C++ Program for Dijkstra's shortest path algorithm | Greedy Algo-7
Conditional wait and signal in multi-threading
Difference between break and continue statement in C
C Hello World Program