code-rag-bench/online-tutorials huggingface dataset:
How to select all elements without a given class using jQuery ? - GeeksforGeeks

07 Nov, 2019
All elements that do not match the given selector can be selected using jQuery( “:not(selector)” ). For example, the first example selects all the <li> elements which are not active.
Example 1: This example selects <li> elements which does not contains the class active.
<!DOCTYPE html><html>      <head>    <title>        How to select all elements without        a given class using jQuery ?    </title>          <meta charset="utf-8">          <script src=        "https://code.jquery.com/jquery-1.10.2.js">    </script></head>  <body>    <h1 style="color:green">GeeksforGeeks</h1>          <b>        Select all elements without a<br>        given class using jQuery    </b>          <ul>        <li class="active">element 1</li>        <li>element 2</li>        <li>element 3</li>        <li>element 4</li>    </ul>          <script>        $("li:not(.active)").css(                "background-color", "yellow" );    </script></body>  </html>
Output:
It can also be done using .not(selector).
Example 2: This example selects <div> elements which does not contains the class green or id blue.
<!DOCTYPE html><html>  <head>    <meta charset="utf-8">          <script src=        "https://code.jquery.com/jquery-1.10.2.js">    </script>          <style>        div {            width: 50px;            height: 50px;            margin: 10px;            float: left;            border: 2px solid black;        }        .green {            background: #8f8;        }        .orange {            background: orange;        }        #blue {            background: #99f;        }    </style></head>  <body>    <h1 style="color:green">GeeksforGeeks</h1>          <b>        Select all elements without a        given class using jQuery    </b>    <br><br>      <div></div>    <div id="blue"></div>    <div></div>    <div class="green"></div>    <div class="green"></div>    <div class="orange"></div>    <div></div>          <script>        $("div").not(".green, #blue")            .css("border-color", "red");    </script></body>  </html>
Output:
jQuery-Misc
Picked
JQuery
Technical Scripter
Web Technologies
Web technologies Questions
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Scroll to the top of the page using JavaScript/jQuery
jQuery | children() with Examples
How to Show and Hide div elements using radio buttons?
How to prevent Body from scrolling when a modal is opened using jQuery ?
How to redirect to a particular section of a page using HTML or jQuery?
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
Python | Get a set of places according to search query using Google Places API - GeeksforGeeks

27 Nov, 2019
Google Places API Web Service allow the user to query for place information on a variety of categories, such as establishments, prominent points of interest, geographic locations, and more. One can search for places either by proximity or a text string. A Place Search returns a list of places along with summary information about each place; additional information is available via a Place Details query.
Text Search Service of Google Places Api is used here, which is a web service that returns information about a set of places based on a string. For example “Hotels in Delhi” or “shoe stores near Oshawa”. The service responds with a list of places matching the text string and any location bias that has been set.
To use this service, the user must need an API key, which one can get form here.
Let’s try to use this API service using Python. The modules which will be used are requests and json.
Below is the implementation :
# Python program to get a set of # places according to your search # query using Google Places API  # importing required modulesimport requests, json  # enter your api key hereapi_key = 'Your_API_key'  # url variable store urlurl = "https://maps.googleapis.com/maps/api/place/textsearch/json?"  # The text string on which to searchquery = input('Search query: ')  # get method of requests module# return response objectr = requests.get(url + 'query=' + query +                        '&key=' + api_key)  # json method of response object convert#  json format data into python format datax = r.json()  # now x contains list of nested dictionaries# we know dictionary contain key value pair# store the value of result key in variable yy = x['results']  # keep looping upto length of yfor i in range(len(y)):          # Print value corresponding to the    # 'name' key at the ith index of y    print(y[i]['name'])
Output :
Search query: Hotels in delhi

ITC Maurya
Le Meridien New Delhi
The Imperial New Delhi
Radisson Blu Hotel New Delhi Paschim Vihar
The Lalit New Delhi
Crowne Plaza New Delhi Rohini
Shangri-La's Eros Hotel, New Delhi
Pride Plaza Hotel Aerocity, New Delhi
The Claridges
The Leela Ambience Convention Hotel, Delhi
Radisson Blu Plaza Delhi Airport
Hotel City Park
Radisson Blu New Delhi Dwarka
The Ashok Hotel
Novotel New Delhi Aerocity
Mapple Emerald
The Metropolitan Hotel and Spa
The Umrao
Pullman New Delhi Aerocity
Welcome Hotel Dwarka

ManasChhabra2
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
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Split string into list of characters
Python | Convert a list to dictionary
Output of Python program | Set 17 - GeeksforGeeks

11 Aug, 2021
Prerequisite – Tuples and Dictionaryin Python Predict the output of the following Python programs. 
1.What is the output of the following program? 
Python
numberGames = {}numberGames[(1,2,4)] = 8numberGames[(4,2,1)] = 10numberGames[(1,2)] = 12  sum = 0for k in numberGames:    sum += numberGames[k]  print len(numberGames) + sum
Output: 
33
Explanation: Tuples can be used for keys into dictionary. The tuples can have mixed length and the order of the items in the tuple is considered when comparing the equality of the keys.  
2.What is the output of the following program? 
Python
my_tuple = (1, 2, 3, 4)my_tuple.append( (5, 6, 7) )print len(my_tuple)
Output: 
Error !
Explanation: Tuples are immutable and don’t have an append method as in case of Lists.Hence an error is thrown in this case.  
3.What is the output of the following program? 
Python
t = (1, 2)print 2 * t
Output: 
(1, 2, 1, 2)
Explanation: Asterick Operator (*) operator concatenates tuple. 
4.What is the output of the following program? 
Python3
d1 = {"john":40, "peter":45}d2 = {"john":466, "peter":45}print (d1 > d2)
Output: 
TypeError
Explanation: The ‘>’ operator is not supported between instances of ‘dict’ and ‘dict’.  
5.What is the output of the following program?  
Python
my_tuple = (6, 9, 0, 0)my_tuple1 = (5, 2, 3, 4)print my_tuple > my_tuple1
Output: 
True
Explanation: Each elements of the tuples are compared one by one and if maximum number of elements are there in tuple1 which are greater of equal to corresponding element of tuple2 then tuple1 is said to be greater than tuple2. 
This article is contributed by Avinash Kumar Singh. If you like GeeksforGeeks and would like to contribute, you can also write an article using write.geeksforgeeks.org or mail your article to review-team@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above. 
surinderdawra388
sooda367
Python-Output
Program Output
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Output of Java program | Set 18 (Overriding)
Output of Java Program | Set 11
Output of Java programs | Set 13 (Collections)
Output of C++ programs | Set 34 (File Handling)
Different ways to copy a string in C/C++
Output of Java Program | Set 3
Runtime Errors
Output of Java program | Set 28
Output of Java program | Set 5
Output of Java Programs | Set 12
Python Program to Find Numbers Divisible by 7 and Multiple of 5 in a Given Range - GeeksforGeeks

04 Dec, 2020
Given a range of numbers, the task is to write a Python program to find numbers divisible by 7 and multiple of 5.
Example:
Input:Enter minimum 100
Enter maximum 200

Output:
105  is divisible by 7 and 5.
140  is divisible by 7 and 5.
175  is divisible by 7 and 5.


Input:Input:Enter minimum 29
Enter maximum 36

Output:
35  is divisible by 7 and 5.
A set of integers can be checked for divisibility by 7 and 5 by performing the modulo operation of the number with 7 and 5 respectively, and then checking the remainder. This can be done in the following ways : 
Python3
# enter the starting range numberstart_num = int(29)  # enter the ending range numberend_num = int(36)  # initialise counter with starting numbercnt = start_num  # check until end of the range is achievedwhile cnt <= end_num:        # if number divisible by 7 and 5    if cnt % 7 == 0 and cnt % 5 == 0:        print(cnt, " is divisible by 7 and 5.")              # increment counter    cnt += 1
Output:
35  is divisible by 7 and 5.
This can also be done by checking if the number is divisible by 35, since the LCM of 7 and 5 is 35 and any number divisible by 35 is divisible by 7 and 5 and vice versa also. 
Python3
# enter the starting range numberstart_num = int(68)  # enter the ending range numberend_num = int(167)  # initialise counter with starting numbercnt = start_num  # check until end of the range is achievedwhile cnt <= end_num:      # check if number is divisible by 7 and 5    if(cnt % 35 == 0):        print(cnt, "is divisible by 7 and 5.")      # incrementing counter    cnt += 1
Output:
70 is divisible by 7 and 5.
105 is divisible by 7 and 5.
140 is divisible by 7 and 5.
Numbers
Python
Python Programs
Numbers
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Split string into list of characters
Python | Convert a list to dictionary
How to print without newline in Python?
How not to delete a function inside an object when JSON.stringify() method is operated?

JSON.stringify() method not only stringifies an object but also removes any function if found inside that object. So to make the function not to be deleted it should be converted into a string and then only JSON.stringify() method should be applied.
In the following example since the function is not converted into a string, it is deleted when operated by JSON.stringify() method and other properties were displayed as shown in the output.
Live Demo
<html>
<body>
<p id="stringify"></p>
<script>
   var person = { name: function () {return Ram + Rahim;},
   designation:"Developer" , city: "Hyderabad" };
   var myJSON = JSON.stringify(person);
   document.getElementById("stringify").innerHTML = myJSON;
</script>
</body>
</html>
{"designation":"Developer","city":"Hyderabad"}
 
In the following example, before getting operated by JSON.stringify() method, the function was converted to a string using toString() method. So the function was not deleted when operated by JSON.stringify() method.
Live Demo
<html>
<body>
<p id="stringify"></p>
<script>
   var obj = { name: function () {return Ram + Rahim;},
   designation:"Developer" , city: "Hyderabad" };
   obj.name = obj.name.toString();
   var myJSON = JSON.stringify(obj);
   document.getElementById("stringify").innerHTML = myJSON;
</script>
</body>
</html>
{"name":"function () {return Ram + Rahim;}","designation":"Developer","city":"Hyderabad"}
How can I extract minute from time in BigQuery in MySQL?

Extract using extract() method along with cast(). Following is the syntax −
select extract(minute from cast(yourColumnName as time)) as anyAliasName from yourTableName;
Let us create a table −
mysql> create table demo15
−> (
−> value time
−> );
Query OK, 0 rows affected (2.11 sec)
Insert some records into the table with the help of insert command −
mysql> insert into demo15 values('10:30:45');
Query OK, 1 row affected (0.09 sec)

mysql> insert into demo15 values('06:34:55');
Query OK, 1 row affected (0.17 sec)
Display records from the table using select statement −
mysql> select *from demo15;
This will produce the following output −
+----------+
| value    |
+----------+
| 10:30:45 |
| 06:34:55 |
+----------+
2 rows in set (0.00 sec)
Following is the query to extract minute from time −
mysql> select extract(minute from cast(value as time)) as Minute from demo15;
This will produce the following output −
+--------+
| Minute |
+--------+
|     30 |
|     34 |
+--------+
2 rows in set (0.00 sec)
How to find mean and standard deviation from frequency table in R?

To find the mean and standard deviation from frequency table, we would need to apply the formula for mean and standard deviation for frequency data. For example, if we have a data frame called df that contains a column x for units and frequency for counts then the mean and standard deviation can be calculated as −
Mean = sum(df$x*df$frequency)/sum(df$frequency)
SD = sqrt(sum((df$x−Mean)**2*df$frequency)/(sum(df$frequency)−1)) respectively.
 Live Demo
x<−rpois(20,5)
frequency<−sample(1:100,20)
df1<−data.frame(x,frequency)
df1
 x frequency
1 6   4
2 7  26
3 1  86
4 2  6
5 4  52
6 4  61
7 1  55
8 4  23
9 8  38
10 3 40
11 8  54
12 10 56
13 7  74
14 9  70
15 7  59
16 16 95
17 4 20
18 5 9
19 4 82
20 9 45
Mean=sum(df1$x*df1$frequency)/sum(df1$frequency)
Mean
[1] 6.55288
SD=sqrt(sum((df1$x−Mean)**2*df1$frequency)/(sum(df1$frequency)−1))
SD
[1] 4.172396
 Live Demo
y<−rnorm(20,25,3.24)
frequency<−rpois(20,10)
df2<−data.frame(y,frequency)
df2
y frequency
1 27.44960 7
2 25.80343 5
3 22.64088 8
4 22.39061 7
5 24.55087 7
6 24.41826 16
7 23.24647 11
8 25.61511 9
9 22.42244 11
10 26.77522 14
11 21.89209 11
12 22.95852 8
13 25.79808 16
14 22.39654 6
15 21.20728 12
16 28.25911 17
17 26.67983 8
18 25.24964 12
19 20.92070 8
20 28.25806 7
Mean=sum(df2$y*df2$frequency)/sum(df2$frequency)
Mean
[1] 24.58724
SD=sqrt(sum((df2$y−Mean)**2*df2$frequency)/(sum(df2$frequency)−1))
SD
[1] 2.284964
Break a Palindrome in C++

Suppose we have a palindromic string palindrome, we have to replace exactly one character by any lowercase English letter so that the string becomes the lexicographically smallest possible string that isn't a palindrome. Now after doing so, we have to find the final string. If there is no way to do so, then return the empty string. So if the input is like “abccba”, then the output will be “aaccba”.
To solve this, we will follow these steps −
changed := false
changed := false
if the size of a string is 1, then return a blank string
if the size of a string is 1, then return a blank string
i := 0 and j := length of s – 1
i := 0 and j := length of s – 1
leftA := True and rightA := True
leftA := True and rightA := True
 while i < j −if s[i] is not ‘a’, then set s[i] as ‘a’ and return sincrease i by 1 and decrease j by 1
 while i < j −
if s[i] is not ‘a’, then set s[i] as ‘a’ and return s
if s[i] is not ‘a’, then set s[i] as ‘a’ and return s
increase i by 1 and decrease j by 1
increase i by 1 and decrease j by 1
s[size of s - 1] := ‘b’
s[size of s - 1] := ‘b’
return s
return s
Let us see the following implementation to get a better understanding −
 Live Demo
#include <bits/stdc++.h>
using namespace std;
class Solution {
public:
   string breakPalindrome(string s) {
      bool changed = false;
      if(s.size() == 1)return "";
      int i = 0, j = s.size() - 1;
      bool leftA = true;
      bool rightA= true;
      while(i < j){
         if(s[i] != 'a'){
            s[i] = 'a';
            return s;
         }
         i++;
         j--;
      }
      s[s.size() - 1] = 'b';
      return s;
   }
};
main(){
   Solution ob;
   cout << (ob.breakPalindrome("abccba"));
}
"abccba"
aaccba
Python - Append Dictionary Keys and Values ( In order ) in dictionary - GeeksforGeeks

01 Aug, 2020
Given a dictionary, perform append of keys followed by values in list.
Input : test_dict = {“Gfg” : 1, “is” : 2, “Best” : 3}Output : [‘Gfg’, ‘is’, ‘Best’, 1, 2, 3]Explanation : All the keys before all the values in list.
Input : test_dict = {“Gfg” : 1, “Best” : 3}Output : [‘Gfg’, ‘Best’, 1, 3]Explanation : All the keys before all the values in list.
Method #1 : Using list() + keys() + values()
This is one of the ways in which this task can be performed. In this, we extract keys and values using keys() and values(), convert then to list using list() and perform append in order.
Python3
# Python3 code to demonstrate working of # Append Dictionary Keys and Values ( In order ) in dictionary# Using values() + keys() + list()  # initializing dictionarytest_dict = {"Gfg" : 1, "is" :  3, "Best" : 2}  # printing original dictionaryprint("The original dictionary is : " + str(test_dict))  # + operator is used to perform adding keys and valuesres = list(test_dict.keys()) + list(test_dict.values())  # printing result print("The ordered keys and values : " + str(res)) 
The original dictionary is : {'Gfg': 1, 'is': 3, 'Best': 2}
The ordered keys and values : ['Gfg', 'is', 'Best', 1, 3, 2]

Method #2 : Using chain() + keys() + values()
This is one of the ways in which this task can be performed. In this, we bind keys with values together in order using chain().
Python3
# Python3 code to demonstrate working of # Append Dictionary Keys and Values ( In order ) in dictionary# Using chain() + keys() + values()from itertools import chain  # initializing dictionarytest_dict = {"Gfg" : 1, "is" :  3, "Best" : 2}  # printing original dictionaryprint("The original dictionary is : " + str(test_dict))  # chain() is used for concatenationres = list(chain(test_dict.keys(), test_dict.values()))  # printing result print("The ordered keys and values : " + str(res)) 
The original dictionary is : {'Gfg': 1, 'is': 3, 'Best': 2}
The ordered keys and values : ['Gfg', 'is', 'Best', 1, 3, 2]

Python dictionary-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
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 program to convert a list to string
Defaultdict in Python
Python | Split string into list of characters
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Matplotlib.axes.Axes.matshow() in Python - GeeksforGeeks

13 Apr, 2020
Matplotlib is a library in Python and it is numerical – mathematical extension for NumPy library. The Axes Class contains most of the figure elements: Axis, Tick, Line2D, Text, Polygon, etc., and sets the coordinate system. And the instances of Axes supports callbacks through a callbacks attribute.
The Axes.matshow() function in axes module of matplotlib library is also used to plot the values of a 2D matrix or array as color-coded image.
Syntax:
Axes.matshow(self, Z, **kwargs)
Parameters: This method accept the following parameters that are described below:
z: This parameter contains the matrix which is to be displayed.
Returns: This returns the following:
image : This returns the AxesImage
Below examples illustrate the matplotlib.axes.Axes.imshow() function in matplotlib.axes:
Example-1:
# Implementation of matplotlib functionimport matplotlib.pyplot as pltimport numpy as npfrom matplotlib.colors import LogNorm      dx, dy = 0.015, 0.05y, x = np.mgrid[slice(-4, 4 + dy, dy),                slice(-4, 4 + dx, dx)]z = (1 - x / 3. + x ** 5 + y ** 5) * np.exp(-x ** 2 - y ** 2)z = z[:-1, :-1]  z_min, z_max = -np.abs(z).max(),np.abs(z).max()    fig, ax = plt.subplots()      c = ax.matshow(z, cmap ='Greens',               vmin = z_min,               vmax = z_max,              extent =[x.min(),                       x.max(),                        y.min(),                       y.max()],              interpolation ='nearest',               origin ='lower')  fig.colorbar(c, ax = ax)ax.set_title('matplotlib.axes.Axes.matshow() Examples\n')plt.show()
Output:
Example-2:
# Implementation of matplotlib functionimport matplotlib.pyplot as pltimport numpy as np    def samplemat(dims):    """Make a matrix with all zeros and increasing        elements on the diagonal"""      aa = np.zeros(dims)    for i in range(min(dims)):        aa[i, i] = np.sin(i**3)**2 + i**3    return aa    # Display matrix  fig, ax = plt.subplots()ax.matshow(samplemat((9, 9)), cmap ="Accent")  ax.set_title('matplotlib.axes.Axes.matshow() Examples\n')plt.show()
Output:
Python-matplotlib
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Read a file line by line in Python
Enumerate() in Python
How to Install PIP on Windows ?
Iterate over a list in Python
Different ways to create Pandas Dataframe
Python String | replace()
Create a Pandas DataFrame from Lists
Reading and Writing to text files in Python
*args and **kwargs in Python
N-ary Tree Preorder Traversal in C++

Suppose we have one n-ary tree, we have to find the preorder traversal of its nodes.
So, if the input is like
then the output will be [1,3,5,6,2,4]
To solve this, we will follow these steps −
Define an array ans
Define an array ans
Define a method called preorder(), this will take root
Define a method called preorder(), this will take root
if root is null, then −return empty list
if root is null, then −
return empty list
return empty list
insert value of root at the end of ans
insert value of root at the end of ans
for all child i in children array of rootpreorder(i)
for all child i in children array of root
preorder(i)
preorder(i)
return ans
return ans
Let us see the following implementation to get a better understanding −
 Live Demo
#include <bits/stdc++.h>
using namespace std;
void print_vector(vector<auto> v){
   cout << "[";
   for(int i = 0; i<v.size(); i++){
      cout << v[i] << ", ";
   }
   cout << "]"<<endl;
}
class Node {
public:
   int val;
   vector<Node*> children;
   Node() {}
   Node(int _val) {
      val = _val;
   }
   Node(int _val, vector<Node*> _children) {
      val = _val;
      children = _children;
   }
};
class Solution {
public:
   vector<int&g; ans;
   vector<int> preorder(Node* root) {
      if (!root)
         return {};
      ans.emplace_back(root->val);
      for (auto i : root->children)
         preorder(i);
      return ans;
   }
};
main(){
   Solution ob;
   Node *node5 = new Node(5), *node6 = new Node(6);
   vector<Node*> child_of_3 = {node5, node6};
   Node* node3 = new Node(3, child_of_3);
   Node *node2 = new Node(2), *node4 = new Node(4);l
   vector<Node*> child_of_1 = {node3, node2, node4};
   Node *node1 = new Node(1, child_of_1);
   print_vector(ob.preorder(node1));
}
Node *node5 = new Node(5), *node6 = new Node(6);
vector<Node*> child_of_3 = {node5, node6};
Node* node3 = new Node(3, child_of_3);
Node *node2 = new Node(2), *node4 = new Node(4);
vector<Node*> child_of_1 = {node3, node2, node4};
Node *node1 = new Node(1, child_of_1);
[1, 3, 5, 6, 2, 4, ]
Difference Between PHP and JavaScript

In this post, we will understand the differences between PHP and JavaScript −
JavaScript
It helps work with frond end as well as back end
It is asynchronous, which means it doesn't wait for the input and output operations.
It can be run in browsers and since 'Node' has been released, JavaScript can also run be run on the command line.
It can be combined with HTML, AJAX and XML.
It is a single threaded language which is event-driven. This means it doesn't block everything and runs concurrently.
The statements are placed within the <script> and </script> tags.
These tags can be present anywhere within the webpage, but it is recommended to keep them within the <head> tags.
The <head> tag tells the browser to start the interpretation of text within these tags as JavaScript code.
A sample JavaScript code −
Live Demo
<!DOCTYPE html>
<html>
<body>
<h2> JavaScript code</h2>
<script>
   var n;
   n=2;
   for(var i=0; i<n; i++){
      document.write("Hi " +"<br>");
   }
</script>
</body>
</html>
JavaScript code
Hi
Hi
It can be written in HTML code, as well as within the .php file.
PHP requires a server to run.
XAMPP or a local server application can be installed to run PHP.
The code in PHP starts with <?php and ends with ?>.
This tells the server that PHP code begins here.
A sample PHP code −
Live Demo
<!DOCTYPE html>
<html>
<body>
<h1>PHP Code </h1>
<?php
   $str= "Hi";
   $x = 2;
   for( $i = 0; $i<2; $i++ ) {
      echo ("Hi");
   }
?>
</body>
</html>
Hi
Hi
Conclusion
In this post, we understood about the significant differences between PHP and Javascript.
How to show soft Keyboard based on Android EditText is focused?

This example demonstrates how do I show soft keyboard based on Android EditText is focused.
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"
   tools:context=".MainActivity">
   <EditText
      android:id="@+id/editText"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_centerInParent="true" />
</RelativeLayout>
Step 3 − Add the following code to src/MainActivity.java
import android.content.Context;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
public class MainActivity extends AppCompatActivity {
   EditText editText;
   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      editText = findViewById(R.id.editText);
      showSoftKeyboard(editText);
   }
   public void showSoftKeyboard(View view) {
      if(view.requestFocus()){
         InputMethodManager imm =(InputMethodManager)
         getSystemService(Context.INPUT_METHOD_SERVICE);
         imm.showSoftInput(view,InputMethodManager.SHOW_IMPLICIT);
      }
   }
}
Step 4 − Add the following code to androidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest
   xmlns:android="http://schemas.android.com/apk/res/android"
   package="app.com.sample">

   <application
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:supportsRtl="true"
      android:theme="@style/AppTheme">
      <activity android:name=".MainActivity">
         <intent-filter>
            <action
               android:name="android.intent.action.MAIN" />
            <category
               android:name="android.intent.category.LAUNCHER" />
         </intent-filter>
      </activity>
   </application>
</manifest>
Let's try to run your application. I assume you have connected your actual Android Mobile device with your computer. To run the app from android studio, open one of your project's activity files and click Run  icon from the toolbar. Select your mobile device as an option and then check your mobile device which will display your default screen −
Check if the Object is a Data Frame in R Programming - is.data.frame() Function - GeeksforGeeks

12 Jun, 2020
is.data.frame() function in R Language is used to return TRUE if the specified data type is a data frame else return FALSE. R data.frame is a powerful data type, especially when processing table (.csv). It can store the data as row and columns according to the table.
Syntax: is.data.frame(x)
Parameters:x: specified data.frame
Example 1:
# R program to illustrate# is.data.frame function  # Specifying "Biochemical oxygen demand"# data setx <- BOD  # Calling is.data.frame() functionis.data.frame(x)
Output:
[1] TRUE

Example 2:
# R program to illustrate# is.data.frame function  # Calling is.data.frame() function # over different data typesis.data.frame(4)is.data.frame("34")is.data.frame("a")is.data.frame(2.7)
Output:
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE

R DataFrame-Function
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Filter data by multiple conditions in R using Dplyr
Loops in R (for, while, repeat)
Change Color of Bars in Barchart using ggplot2 in R
How to change Row Names of DataFrame in R ?
Group by function in R using Dplyr
How to Change Axis Scales in R Plots?
How to Split Column Into Multiple Columns in R DataFrame?
K-Means Clustering in R Programming
Replace Specific Characters in String in R
Remove rows with NA in one column of R DataFrame
How to Do a Left Join in R? - GeeksforGeeks

21 Dec, 2021
In this article, we will discuss how to do a left join in R programming language.
A left join is used to join the table by selecting all the records from the first dataframe and only matching records in the second dataframe.
This function is used to join the dataframes based on the x parameter that specifies left join.
Syntax:
merge(dataframe1,dataframe2, all.x=TRUE)
where,
dataframe1 is the first dataframe
dataframe2 is the second dataframe
Example: R program to perform two dataframes and perform left join on name column
R
# create first dataframedata1=data.frame('name'=c('siva','ramu','giri','geetha'),                 'age'=c(21,23,21,20)) # displayprint(data1) # create second dataframedata2=data.frame('name'=c('siva','ramya','giri','geetha','pallavi'),                 'marks'=c(21,23,21,20,30)) # displayprint(data2) print("=========================") # left join on name columnprint(merge(data1, data2, by='name', all.x=TRUE))
Output:
This performs left join on two dataframes which are available in dplyr() package.
Syntax: 
left_join(df1, df2, by='column_name')
where 
df1 and df2 are the two dataframes
column_name specifies on which column they are joined
Example: R program to find a let join
R
# load the librarylibrary("dplyr") # create first dataframedata1=data.frame('name'=c('siva','ramu','giri','geetha'),                 'age'=c(21,23,21,20)) # displayprint(data1) # create second dataframedata2=data.frame('name'=c('siva','ramya','giri','geetha','pallavi'),                 'marks'=c(21,23,21,20,30)) # displayprint(data2) print("=========================") # left join on name columnprint(left_join(data1, data2, by='name'))
Output:
sagartomar9927
Picked
R Dplyr
R-DataFrame
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Change Color of Bars in Barchart using ggplot2 in R
Group by function in R using Dplyr
How to Change Axis Scales in R Plots?
How to Split Column Into Multiple Columns in R DataFrame?
Replace Specific Characters in String in R
How to filter R DataFrame by values in a column?
How to import an Excel File into R ?
Time Series Analysis in R
R - if statement
How to filter R dataframe by multiple conditions?
HTML | <p> align Attribute - GeeksforGeeks

22 Feb, 2022
The HTML <p> align Attribute is used to specify the alignment of paragraph text content.
Syntax:
<p align="left | right | center | justify">
Attribute Values:
left: It sets the text left-align. It is a default value.
right: It sets the text right-align.
center: It sets the text center-align.
justify: It stretch the text of paragraph to set the width of all lines equal.
Note: The <p> align attribute is not supported by HTML 5.
Example:
<!DOCTYPE html><html>  <head>    <title>        HTML p align Attribute    </title></head>  <body>    <h1>GeeksforGeeks</h1>      <h2>HTML p align Attribute</h2>      <p align="left">      Left align content  </p>    <p align="center">      center align content  </p>    <p align="right">      Right align content  </p></body>  </html>
Output:
Supported Browsers: The browser supported by HTML <p> align attribute are listed below:
Google Chrome
Internet Explorer
Firefox
Safari
Opera
HTML is the foundation of webpages, is used for webpage development by structuring websites and web apps.You can learn HTML from the ground up by following this HTML Tutorial and HTML Examples.
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
chhabradhanvi
HTML-Attributes
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to update Node.js and NPM to next version ?
REST API (Introduction)
How to Insert Form Data into Database using PHP ?
CSS to put icon inside an input element in a form
Types of CSS (Cascading Style Sheet)
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 ?
Difference between var, let and const keywords in JavaScript
Python - Test if List contains elements in Range - GeeksforGeeks

01 Mar, 2020
A lot of times, while working with data, we have a problem in which we need to make sure that a container or a list is having elements in just one range. This has application in Data Domains. Let’s discuss certain ways in which this task can be performed.
Method #1 : Using loopThis is brute force method in which this task can be performed. In this, we just check using if condition if element falls in range, and break if we find even one occurrence out of range.
# Python3 code to demonstrate # Test if List contains elements in Range# using loop  # Initializing loop test_list = [4, 5, 6, 7, 3, 9]  # printing original list print("The original list is : " + str(test_list))  # Initialization of range i, j = 3, 10  # Test if List contains elements in Range# using loopres = Truefor ele in test_list:    if ele < i or ele >= j :        res = False         break  # printing result print ("Does list contain all elements in range : " + str(res))
The original list is : [4, 5, 6, 7, 3, 9]
Does list contain all elements in range : True

 
Method #2 : Using all()This is alternative and shorter way to perform this task. In this we use check operation as a parameter to all() and returns True when all elements in range.
# Python3 code to demonstrate # Test if List contains elements in Range# using all()  # Initializing loop test_list = [4, 5, 6, 7, 3, 9]  # printing original list print("The original list is : " + str(test_list))  # Initialization of range i, j = 3, 10  # Test if List contains elements in Range# using all()res = all(ele >= i and ele < j for ele in test_list)   # printing result print ("Does list contain all elements in range : " + str(res))
The original list is : [4, 5, 6, 7, 3, 9]
Does list contain all elements in range : True

Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Split string into list of characters
Python | Convert a list to dictionary
How to print without newline in Python?
Scala | yield Keyword - GeeksforGeeks

07 Jun, 2019
yield keyword will returns a result after completing of loop iterations. The for loop used buffer internally to store iterated result and when finishing all iterations it yields the ultimate result from that buffer. It doesn’t work like imperative loop. The type of the collection that is returned is the same type that we tend to were iterating over, Therefore a Map yields a Map, a List yields a List, and so on.
Syntax:
var result = for{ var x <- List}
yield x
Note: The curly braces have been used to keep the variables and conditions and result is a variable wherever all the values of x are kept within the form of collection.
Example:
// Scala program to illustrate yield keyword  // Creating objectobject GFG {     // Main method    def main(args: Array[String])     {         // Using yield with for        var print = for( i <- 1 to 10) yield i         for(j<-print)        {             // Printing result            println(j)         }     } } 
Output:
1
2
3
4
5
6
7
8
9
10
In above example, the for loop used with a yield statement actually creates a sequence of list.
Example:
// Scala program to illustrate yield keyword  // Creating objectobject GFG {     // Main method    def main(args: Array[String])     {         val a = Array( 8, 3, 1, 6, 4, 5)                  // Using yield with for        var print=for (e <- a if e > 4) yield e        for(i<-print)        {             // Printing result            println(i)         }     } } 
Output:
8
6
5
In above example, the for loop used with a yield statement actually creates a array. Because we said yield e, it’s a Array[n1, n2, n3, ....]. e <- a is our generator and if (e > 4) could be a guard that filters out number those don't seem to be greater than 4.
Scala
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Inheritance in Scala
Scala | Traits
Scala ListBuffer
Scala | Case Class and Case Object
Hello World in Scala
Scala | Functions - Basics
Scala | Decision Making (if, if-else, Nested if-else, if-else if)
Scala List map() method with example
Comments In Scala
Abstract Classes in Scala
How to Trim White Spaces from input in ReactJS? - GeeksforGeeks

31 Dec, 2020
Trim white space means removing white spaces from the text input from both start and end. The following example shows how to trim white space from text input in ReactJS.
Creating React Application And Installing Module:
Step 1: Create a React application using the following command:
npx create-react-app foldername
Step 2: After creating your project folder i.e. foldername, move to it using the following command:
cd foldername
Step 3: After creating the ReactJS application, Install the validator module using the following command:
npm install validator
Project Structure: It will look like the following.
Project Structure
App.js: Now write down the following code in the App.js file. Here, App is our default component where we have written our code.
Javascript
import React, { useState } from "react";import validator from 'validator'  const App = () => {    const [value, setValue] = useState('')      const validate = (inputText) => {      setValue("#"+validator.trim(inputText)+"#")  }    return (    <div style={{      marginLeft: '200px',    }}>      <pre>        <h2>Trimming White Space in ReactJS</h2>        <span>Enter Text: </span><input type="text"         onChange={(e) => validate(e.target.value)}></input> <br />        <span style={{          fontWeight: 'bold',          color: 'red',        }}>{value}</span>      </pre>    </div>  );}  export default App
Step to Run Application: Run the application using the following command from the root directory of the project:
npm start
Output:
The following will be the output if the user enters input without any space. You can see that the text remains as it is because there is no white space present in the input text.
 
The following will be the output if the user enters input with white space from both the end. You can see that the final output text is trimmed from both the side by removing white space.
NOTE: In the above example, # is appended from both ends so that the user can see the result that white space is removed.
react-js
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Remove elements from a JavaScript Array
Difference between var, let and const keywords in JavaScript
Difference Between PUT and PATCH Request
JavaScript | Promises
How to get character array from string in JavaScript?
Remove elements from a JavaScript Array
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Difference between var, let and const keywords in JavaScript
java.time.Instant Class in Java - GeeksforGeeks

09 Mar, 2021
In Java language, the Instant Class is used to represent the specific time instant on the current timeline. The Instant Class extends the Object Class and implements the Comparable interface.
Declaration of the Instant Class
public final class Instant extends Object    
implements Temporal, TemporalAdjuster, Comparable<Instant>, Serializable  
Fields of the class:
Methods of the class:
Description
Example:
The following example shows how the different methods associated with the classwork
Java
import java.time.*;import java.time.temporal.*;public class GFG {    public static void main(String[] args)    {        // Parsing a string sequence to Instant        Instant inst1 = Instant.parse("2021-02-09T11:19:42.12Z");        System.out.println("Parsed instant is " + inst1);                // Using isSupported() method to check whether the        // specified field is supported or not        System.out.println(inst1.isSupported(ChronoUnit.DAYS));        System.out.println(inst1.isSupported(ChronoUnit.YEARS));                // Using Instant.now() to get current instant        Instant cur = Instant.now();        System.out.println("Current Instant is " + cur);                // Using minus() method to find instant value after        // subtraction        Instant diff = inst1.minus(Duration.ofDays(70));        System.out.println("Instant after subtraction : "+ diff);                // Using plus() method to find instant value after        // addition        Instant sum = inst1.plus(Duration.ofDays(10));        System.out.println("Instant after addition : "+ sum);    }}
Parsed instant is 2021-02-09T11:19:42.120Z
true
false
Current Instant is 2021-03-03T16:27:54.378693Z
Instant after subtraction : 2020-12-01T11:19:42.120Z
Instant after addition : 2021-02-19T11:19:42.120Z
Java-Instant
Java-time package
Picked
Technical Scripter 2020
Java
Technical Scripter
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Stream In Java
Constructors in Java
Exceptions in Java
Functional Interfaces in Java
Different ways of Reading a text file in Java
Generics in Java
Introduction to Java
Comparator Interface in Java with Examples
Internal Working of HashMap in Java
Strings in Java
How to Install OpenCV for Python in Linux? - GeeksforGeeks

06 Oct, 2021
Prerequisite: Python Language Introduction OpenCV is the huge open-source library for computer vision, machine learning, and image processing and now it plays a major role in real-time operation which is very important in today’s systems. By using it, one can process images and videos to identify objects, faces, or even the handwriting of a human. When it integrated with various libraries, such as Numpuy, python is capable of processing the OpenCV array structure for analysis. To Identify image patterns and its various features we use vector space and perform mathematical operations on these features.
To install OpenCV, one must have Python and PIP, preinstalled on their system. To check if your system already contains Python, go through the following instructions:
Open the terminal using Ctrl+Alt+T
Now run the following command:For Python2
python --version

For Python3.x
python3.x --version

If Python is already installed, it will generate a message with the Python version available.
If Python is not present, go through How to install Python on Linux? and follow the instructions provided. PIP is a package management system used to install and manage software packages/libraries written in Python. These files are stored in a large “on-line repository” termed as Python Package Index (PyPI).To check if PIP is already installed on your system, just go to the terminal and execute the following command:
pip3 --version
If PIP is not present, go through How to install PIP on Linux? and follow the instructions provided.
OpenCV can be directly downloaded and installed with the use of pip (package manager). To install OpenCV, just go to the terminal and type the following command:
pip3 install opencv-python
Beginning with the installation:
Type the command in the Terminal and proceed:
Collecting Information and downloading data:
Installing Packages:
Finished Installation:
To check if OpenCV is correctly installed, just run the following commands to perform a version check:
python3
>>>import cv2
>>>print(cv2.__version__)

how-to-install
OpenCV
python-basics
How To
Installation Guide
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install FFmpeg on Windows?
How to Add External JAR File to an IntelliJ IDEA Project?
How to Set Git Username and Password in GitBash?
How to Install Jupyter Notebook on MacOS?
How to Create and Setup Spring Boot Project in Eclipse IDE?
Installation of Node.js on Linux
How to Install FFmpeg on Windows?
How to Install Pygame on Windows ?
How to Add External JAR File to an IntelliJ IDEA Project?
How to Install Jupyter Notebook on MacOS?
Python program to display half diamond pattern of numbers with star border - GeeksforGeeks

02 Feb, 2021
Given a number n, the task is to write a Python program to print a half diamond pattern of numbers with a star border.
Examples:
Input: n = 5
Output:

*
*1*
*121*
*12321*
*1234321*
*123454321*
*1234321*
*12321*
*121*
*1*
*


Input: n = 3
Output:

*
*1*
*121*
*12321*
*121*
*1*
*
Approach:
Two for loops will be run in this program in order to print the numbers as well as stars.
First print * and then run for loop from 1 to (n+1) to print up to the rows in ascending order.
In this particular for loop * will be printed up to i and then one more for loop will run from 1 to i+1 in order to print the numbers in ascending order.
Now one more loop will run from i-1 to 0 in order to print the number in the reverse order.
Now one star will be printed and this for loop will end.
Now second for loop will run from n-1 to 0 to print the pattern as in the middle in which the numbers are in a reverse manner.
In this for loop also the same work will be done as in first for loop.
The required pattern will be displayed.
Below is the implementation of the above pattern:
Python3
# function to display the pattern up to ndef display(n):          print("*")          for i in range(1, n+1):        print("*", end="")                  # for loop to display number up to i        for j in range(1, i+1):              print(j, end="")          # for loop to display number in reverse direction            for j in range(i-1, 0, -1):              print(j, end="")          print("*", end="")        print()      # for loop to display i in reverse direction    for i in range(n-1, 0, -1):        print("*", end="")        for j in range(1, i+1):            print(j, end="")          for j in range(i-1, 0, -1):            print(j, end="")          print("*", end="")        print()      print("*")    # driver coden = 5print('\nFor n =', n)display(n)  n = 3print('\nFor n =', n)display(n)
Output: 
For n = 5
*
*1*
*121*
*12321*
*1234321*
*123454321*
*1234321*
*12321*
*121*
*1*
*

For n = 3
*
*1*
*121*
*12321*
*121*
*1*
*
Python Pattern-printing
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Split string into list of characters
Python | Convert a list to dictionary
How to print without newline in Python?