code-rag-bench/online-tutorials huggingface dataset:
Make image round with Bootstrap

Use the img-circle Bootstrap class to style your image and make it completely round.
You can try to run the following code to make an image round
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <title>Bootstrap Images</title>
      <link href = "/bootstrap/css/bootstrap.min.css" rel = "stylesheet">
      <script src = "/scripts/jquery.min.js"></script>
      <script src = "/bootstrap/js/bootstrap.min.js"></script>
   </head>
   <body>
      <p>Styling images with Bootstrap</p>
      <h1>Original Image</h1>
      <img src = "https://www.tutorialspoint.com/videotutorials/images/numerical_ability_home.jpg">
      <h1>Rounded Image</h1>
      <img src = "https://www.tutorialspoint.com/videotutorials/images/numerical_ability_home.jpg" class = "img-circle">
   </body>
</html>
GATE | GATE-CS-2015 (Set 3) | Question 65 - GeeksforGeeks

28 Jun, 2021
For the processes listed in the following table, which of the following scheduling schemes will give the lowest average turnaround time?
Process    Arrival Time    Processing Time
  A              0              3
  B              1              6
  C              4              4
  D              6              2
(A) First Come First Serve(B) Non-preemptive Shortest Job First(C) Shortest Remaining Time(D) Round Robin with Quantum value twoAnswer: (C)Explanation: Turnaround time is the total time taken between the submission of a program/process/thread/task (Linux) for execution and the return of the complete output to the customer/user.
Turnaround Time = Completion Time – Arrival Time.
FCFS = First Come First Serve (A, B, C, D)SJF = Non-preemptive Shortest Job First (A, B, D, C)SRT = Shortest Remaining Time (A(3), B(1), C(4), D(2), B(5))RR = Round Robin with Quantum value 2 (A(2), B(2), A(1),C(2),B(2),D(2),C(2),B(2)
 
Pr  Arr.Time  P.Time   FCFS     SJF      SRT    RR
A      0       3      3-0=3    3-0=3    3-0=3   5-0=5
B      1       6      9-1=8    9-1=8    15-1=14 15-1=14         
C      4       4      13-4=9   15-4=11  8-4=4   13-4=9 
D      6       2      15-6=9   11-6=5   10-6=4  11-6=5 

Average                7.25     6.75     6.25    8.25

Shortest Remaining Time produces minimum average turn-around time.
 Quiz of this Question
GATE-CS-2015 (Set 3)
GATE-GATE-CS-2015 (Set 3)
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
GATE | GATE-IT-2004 | Question 83
GATE | GATE-CS-2014-(Set-3) | Question 38
GATE | GATE CS 2018 | Question 37
GATE | GATE-CS-2016 (Set 1) | Question 65
GATE | GATE-CS-2016 (Set 1) | Question 63
GATE | GATE-CS-2016 (Set 2) | Question 48
GATE | GATE-CS-2014-(Set-3) | Question 65
GATE | GATE-CS-2007 | Question 17
GATE | GATE CS 2019 | Question 37
GATE | GATE-CS-2014-(Set-3) | Question 65
HTML | async Attribute

06 Dec, 2021
The HTML async attribute is a boolean attribute. When present, it specifies that the script will be executed asynchronously when it is available. This attribute only works for external scripts (and used only in when src attribute is present ).Note: There are so many ways in which external script execute:  
when async is present: The script is executed asynchronously with the rest of the page (the script will be executed while the page continues the parsing)
when async is not present and defer is present: The script is executed when the page has finished parsing
If neither async or defer is present: The script is fetched and executed immediately before the browser continues parsing the page
Syntax: 
<script async>
Applicable:  
<script>
Example: Index.html  
html
<!DOCTYPE html><html> <body>    <center>        <h1 style="color:green">          Geeksforgeeks      </h1>        <p id="p1">Hello GFG</p>         <script src="geeks.js" async></script>    </center></body> </html>
geeks.js  
javascript
alert("Hello GFG"); 
Output:  
Supported Browsers: The browsers supported by HTML async attribute are listed below  
Google Chrome 4.0
Firefox 4.0
Apple Safari 4.0
Opera 10.5
Edge
 
ManasChhabra2
HTML-Attributes
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Get the type of a variable in MySQL?

You cannot get the type of variable in MySQL. Cast the type of variable into another using CAST operator. The syntax is as follows −
SET @yourVariableName:=’anyValue’
Use the CAST operator to cast to another type. The syntax is as follows −
SELECT CAST( @yourVariableName AS SIGNED);
To understand the above syntax, let us cast to another type.
Case 1: String to unsigned −
mysql> set @StringToInt:='12345';
Query OK, 0 rows affected (0.00 sec)
The query is as follows to another type −
mysql> select CAST(@StringToInt as UNSIGNED);
The following is the output −
+--------------------------------+
| CAST(@StringToInt as UNSIGNED) |
+--------------------------------+
| 12345                          |
+--------------------------------+
1 row in set (0.00 sec)
Case 2: Int to char
The query is as follows −
mysql> set @IntTochar:=CAST(65 as CHAR);
Query OK, 0 rows affected (0.00 sec)
The query is as follows −
mysql> select @IntTochar;
The following is the output −
+------------+
| @IntTochar |
+------------+
| 65         |
+------------+
1 row in set (0.00 sec)
How to select the first and last row based on group column in an R data frame?

Extraction of data is necessary in data analysis because extraction helps us to keep the important information about a data set. This important information could be the first row and the last row of groups as well, also we might want to use these rows for other type of analysis such as comparing the initial and last data values among groups. We can extract or select the first and last row based on group column by using slice function of dplyr package.
 Live Demo
Consider the below data frame:
> x1<-rep(1:4,each=10)
> x2<-rpois(40,5)
> df1<-data.frame(x1,x2)
> head(df1,12)
  x1 x2
1  1  3
2  1  4
3  1  6
4  1  6
5  1  3
6  1  4
7  1  7
8  1  8
9  1  7
10 1  2
11 2  8
12 2  7
> tail(df1,12)
x1 x2
29 3 4
30 3 5
31 4 4
32 4 6
33 4 7
34 4 5
35 4 5
36 4 4
37 4 9
38 4 4
39 4 3
40 4 6
Loading dplyr package −
> library(dplyr)
Attaching package: ‘dplyr’
The following objects are masked from ‘package:stats’ −
filter, lag
The following objects are masked from ‘package:base’ −
intersect, setdiff, setequal, union
Selecting first and last row based on group column x1 −
> df1%>%group_by(x1)%>%slice(c(1,n()))
# A tibble: 8 x 2
# Groups: x1 [4]
   x1 x2
<int> <int>
1 1 3
2 1 2
3 2 8
4 2 4
5 3 5
6 3 5
7 4 4
8 4 6
Let’s have a look at another example −
 Live Demo
> y1<-rep(c("A","B","C"),each=10)
> y2<-rnorm(30)
> df2<-data.frame(y1,y2)
> head(df2,12)
   y1 y2
1 A -1.1640927
2 A 0.3146504
3 A -1.5213974
4 A -1.3728970
5 A -0.9964678
6 A -0.5022738
7 A -0.4225463
8 A -0.3501037
9 A 0.3043838
10 A -1.5216102
11 B -0.2425732
12 B 0.5554217
> tail(df2,12)
   y1 y2
19 B 0.30172320
20 B 1.68341427
21 C 0.55127997
22 C -1.77840803
23 C 0.03001296
24 C -1.19246335
25 C 0.03612258
26 C -0.35468216
27 C -0.63579743
28 C -1.90074403
29 C 0.50072577
30 C 0.31911138
> df2%>%group_by(y1)%>%slice(c(1,n()))
# A tibble: 6 x 2
# Groups: y1 [3]
   y1 y2
<fct> <dbl>
1 A -1.16
2 A -1.52
3 B -0.243
4 B 1.68
5 C 0.551
6 C 0.319
Java Examples - Display Date in different formats

How to display date in different formats?
This example displays the names of the weekdays in short form with the help of DateFormatSymbols().getWeekdays() method of DateFormatSymbols class.
import java.text.*;
import java.util.*;

public class Main {
   public static void main(String[] args) {
      Date dt = new Date(1000000000000L);
      DateFormat[] dtformat = new DateFormat[6];
      
      dtformat[0] = DateFormat.getInstance();
      dtformat[1] = DateFormat.getDateInstance();
      dtformat[2] = DateFormat.getDateInstance(DateFormat.MEDIUM);
      dtformat[3] = DateFormat.getDateInstance(DateFormat.FULL);
      dtformat[4] = DateFormat.getDateInstance(DateFormat.LONG);
      dtformat[5] = DateFormat.getDateInstance(DateFormat.SHORT);
      
      for(DateFormat dateform : dtformat) System.out.println(dateform.format(dt));
   }
}
The above code sample will produce the following result.
9/9/01 7:16 AM
Sep 9, 2001
Sep 9, 2001
Sunday, September 9, 2001
September 9, 2001
9/9/01

The following is an another sample example of date in another format.
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

public class SimpleDateFormatExample {
   public static void main(String[] args) {
      Date curDate = new Date();
      SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd");
      
      String DateToStr = format.format(curDate);
      System.out.println(DateToStr);
      
      format = new SimpleDateFormat("dd-M-yyyy hh:mm:ss");
      DateToStr = format.format(curDate);
      System.out.println(DateToStr);
      
      format = new SimpleDateFormat("dd MMMM yyyy zzzz", Locale.ENGLISH);
      DateToStr = format.format(curDate);
      System.out.println(DateToStr);
      
      format = new SimpleDateFormat("E, dd MMM yyyy HH:mm:ss z");
      DateToStr = format.format(curDate);
      System.out.println(DateToStr);
      
      try {
         Date strToDate = format.parse(DateToStr);
         System.out.println(strToDate);
      } catch (ParseException e) {
         e.printStackTrace();
      } 
   } 
}
The above code sample will produce the following result.
2016/11/11
11-11-2016 07:12:27
11 November 2016 Coordinated Universal Time
Fri, 11 Nov 2016 07:12:27 UTC
Fri Nov 11 07:12:27 UTC 2016
GATE | GATE-CS-2009 | Question 56

17 Dec, 2021
Consider the following relational schema:
Suppliers(sid:integer, sname:string, city:string, street:string)
Parts(pid:integer, pname:string, color:string)
Catalog(sid:integer, pid:integer, cost:real)
Assume that, in the suppliers relation above, each supplier and each street within a city has a unique name, and (sname, city) forms a candidate key. No other functional dependencies are implied other than those implied by primary and candidate keys. Which one of the following is TRUE about the above schema?(A) The schema is in BCNF(B) The schema is in 3NF but not in BCNF(C) The schema is in 2NF but not in 3NF(D) The schema is not in 2NFAnswer: (A)Explanation: A relation is in BCNF if for every one of its dependencies X → Y, at least one of the following conditions hold:
    X → Y is a trivial functional dependency (Y ⊆ X)
    X is a superkey for schema R 
Since (sname, city) forms a candidate key, there is no non-trivial dependency X → Y where X is not a superkeyQuiz of this Question
sweetyty
GATE-CS-2009
GATE-GATE-CS-2009
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | GATE-CS-2014-(Set-2) | Question 65
GATE | Sudo GATE 2020 Mock I (27 December 2019) | Question 33
GATE | GATE-CS-2014-(Set-3) | Question 20
GATE | GATE CS 2008 | Question 46
GATE | GATE-CS-2015 (Set 3) | Question 65
GATE | GATE-CS-2014-(Set-3) | Question 65
GATE | GATE CS 2008 | Question 40
GATE | GATE-CS-2014-(Set-1) | Question 51
GATE | GATE CS 1996 | Question 63
GATE | GATE-CS-2015 (Set 2) | Question 55
Tuple as function arguments in Python

01 Aug, 2020
Tuples have many applications in all the domains of Python programming. They are immutable and hence are important containers to ensure read-only access, or keeping elements persistent for more time. Usually, they can be used to pass to functions and can have different kinds of behavior. Different cases can arise.
   Case 1: fnc(a, b) – Sends a and b as separate elements to fnc.
   Case 2: fnc((a, b)) – Sends (a, b), whole tuple as 1 single entity, one element.
   Case 3: fnc(*(a, b)) – Sends both, a and b as in Case 1, as separate integers.
The code below demonstrates the working of all cases :
Python3
# Python3 code to demonstrate working of # Tuple as function arguments  # function with default arguments def fnc(a=None, b=None):    print("Value of a : " + str(a))    print("Value of b : " + str(b))  # Driver codeif __name__ == "__main__" :      # initializing a And b  a = 4  b = 7    # Tuple as function arguments  # Case 1 - passing as integers  print("The result of Case 1 : ")  fnc(a, b)    # Tuple as function arguments  # Case 2 - Passing as tuple  print("The result of Case 2 : ")  fnc((a, b))    # Tuple as function arguments  # Case 3 - passing as pack/unpack   # operator, as integer  print("The result of Case 3 : ")  fnc(*(a, b))
Output :
The result of Case 1 : 
Value of a : 4
Value of b : 7
The result of Case 2 : 
Value of a : (4, 7)
Value of b : None
The result of Case 3 : 
Value of a : 4
Value of b : 7

Python tuple-programs
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Iterate over a list in Python
Python OOPs Concepts
Introduction To PYTHON
How to set a value to an input file using HTML ?

13 May, 2020
In HTML, we will use the type attribute to take input in a form and when we have to take the file as an input, the file value of the type attribute allows us to define an element for the file uploads. It displays a browse button on our computer screen, and when we click on this browse button, it asks the user for permission to select the file from his local computer.
Basic Syntax:
<input type="file">
Example:
<!DOCTYPE html><html>  <head></head>  <body>    <form>        <!--We tried to set the "file"            value to attribute "type"-->        <input type="file">    </form></body>  </html>
Output:
But when we want to take file input by default, then we cannot do it. It means we cannot set a value to a file input due to some security reasons in HTML.
Example:
<!DOCTYPE html><html>  <head></head>  <body>    <form name="htmltest">        <!--Here, by default we have tried            to implement a file path using             the value attribute. But it             will not work here. -->        <input type="file" value="c:/amrit.txt">    </form></body>  </html><!--We can implement the submit     button using javascript. --><!--script>document.htmltest.submit();</script-->
The above code will give the same output as the previous code because here we want to set value, but it doesn’t work due to security reasons. Hence, in HTML, there is the only way to take file input.
HTML-Misc
Picked
HTML
JavaScript
Web Technologies
Write From Home
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)
CSS to put icon inside an input element in a form
Types of CSS (Cascading Style Sheet)
Design a Tribute Page using HTML & CSS
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
Difference Between PUT and PATCH Request
How to append HTML code to a div using JavaScript ?
Python | sympy.Interval().contains() method

17 Sep, 2019
With the help of method, we can check whether a value is present in the interval or not by using sympy.Interval().contains() method.
Syntax : sympy.Interval(x, y).contains(value)
Return : Return the boolean value True or False.
Example #1 :In this example we can see that by using sympy.Interval().contains() method, we are able to get the boolean values if value is present in the interval or not.
# import sympy, Intervalfrom sympy import Interval  # Using sympy.Interval().contains() methodgfg = Interval(5, 10).contains(7)  print(gfg)
Output :
True
Example #2 :
# import sympy, Intervalfrom sympy import Interval  # Using sympy.Interval().contains() methodgfg = Interval(0, 1).contains(1.5)  print(gfg)
Output :
False
SymPy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Iterate over a list in Python
Python OOPs Concepts
Introduction To PYTHON
Linestyles in Matplotlib Python

24 Jan, 2021
Matplotlib is an amazing visualization library in Python for 2D plots of arrays. Matplotlib is a multi-platform data visualization library built on NumPy arrays and designed to work with the broader SciPy stack.
The default linestyle while plotting data is solid linestyle in matplotlib. We can change this linestyle by using linestyle or ls argument of plot() method.
Using linestyle Argument:
Solid
Dashed
Dotted
Dashdot
None
Using ls Argument:
‘-‘
‘:’
‘–‘
‘-.’
‘ ‘
Import module.
Create data.
Normally plot the data by setting linestyle or ls argument of plot() method.
Display plot.
Example 1: Program to depict dotted line style in a plot.
Python3
# importing librariesimport matplotlib.pyplot as plt  # creating dataxdata = [0, 2, 4, 6, 8, 10, 12, 14]ydata = [4, 2, 8, 6, 10, 5, 12, 6]  # plotting dataplt.plot(xdata, ydata, linestyle='dotted')  # Displaying plotplt.show()
Output:
Example 2: Program to depict dash dot line style in a plot.
Python3
# importing librariesimport matplotlib.pyplot as plt  # creating dataxdata = [0, 2, 4, 6, 8, 10, 12, 14]ydata = [4, 2, 8, 6, 10, 5, 12, 6]  # plotting dataplt.plot(xdata, ydata, linestyle='dashdot')  # Displaying plotplt.show()
Output:
Example 3: Program to depict dashed line style in a plot using ls argument.
Python3
# importing librariesimport matplotlib.pyplot as plt  # creating dataxdata = [0, 2, 4, 6, 8, 10, 12, 14]ydata = [4, 2, 8, 6, 10, 5, 12, 6]  # plotting dataplt.plot(xdata, ydata, ls='--')  # Displaying plotplt.show()
Output:
Example 4: Program to depict solid line style in a plot using ls argument.
Python3
# importing librariesimport matplotlib.pyplot as plt  # creating dataxdata = [0, 2, 4, 6, 8, 10, 12, 14]ydata = [4, 2, 8, 6, 10, 5, 12, 6]  # plotting dataplt.plot(xdata, ydata, ls='-')  # Displaying plotplt.show()
Output:
All the above types of line styles can be visualized using the linestyle or ls argument. The none or ‘ ‘ when visualized will generate a blank plot. 
Picked
Python-matplotlib
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Iterate over a list in Python
Python OOPs Concepts
How to set the font family for text with JavaScript?

To set the font family, use the fontFamily property in JavaScript.
You can try to run the following code to set the font family for text with JavaScript −
Live Demo
<!DOCTYPE html>
<html>
   <body>
      <h1>Heading 1</h1>
      <p id="myID">
         This is Demo Text. This is Demo Text. This is Demo Text. This is Demo Text.
         This is Demo Text. This is Demo Text. This is Demo Text. This is Demo Text.
      </p>
      <button type="button" onclick="display()">Set Font Family</button>
      <script>
         function display() {
            document.getElementById("myID").style.fontFamily = "verdana,sans-serif";
         }
      </script>
   </body>
</html>
numpy.isfinite() in Python

28 Mar, 2022
The numpy.isfinite() function tests element-wise whether it is finite or not(not infinity or not Not a Number) and return the result as a boolean array. Syntax : 
numpy.isfinite(array [, out])
Parameters : 
array : [array_like]Input array or object whose elements, 
        we need to test for infinity
out   : [ndarray, optional]Output array placed with result.
       Its type is preserved and it must be of the right 
       shape to hold the output.
Return : 
boolean array containing the result
Code 1 : 
Python
# Python Program illustrating# numpy.isfinite() method  import numpy as geek print("Finite : ", geek.isfinite(1), "\n") print("Finite : ", geek.isfinite(0), "\n") # not a numberprint("Finite : ", geek.isfinite(geek.nan), "\n") #  infinityprint("Finite : ", geek.isfinite(geek.inf), "\n") print("Finite : ", geek.isfinite(geek.NINF), "\n") 
Output : 
Finite :  True 

Finite :  True 

Finite :  False 

Finite :  False 

Finite :  False 
Code 2 : 
Python
# Python Program illustrating# numpy.isfinite() method   import numpy as geek  # Returns True/False value for each elementb = geek.arange(20).reshape(5, 4)                print("\n",b)print("\nIs Finite : \n", geek.isfinite(b))  b = [[1j],     [geek.inf]]print("\nIs Finite : \n", geek.isfinite(b))
Output : 
 [[ 0  1  2  3]
 [ 4  5  6  7]
 [ 8  9 10 11]
 [12 13 14 15]
 [16 17 18 19]]

Is Finite : 
 [[ True  True  True  True]
 [ True  True  True  True]
 [ True  True  True  True]
 [ True  True  True  True]
 [ True  True  True  True]]

Is Finite : 
 [[ True]
 [False]]
References : https://docs.scipy.org/doc/numpy-dev/reference/generated/numpy.isfinite.html 
Note : These codes won’t run on online IDE’s. So please, run them on your systems to explore the working.  This article is contributed by Mohit Gupta_OMG . 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.
vinayedula
Python numpy-Logic Functions
Python-numpy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python PIL | ImageEnhance.Color() and ImageEnhance.Contrast() method

27 Jun, 2019
PIL is the Python Imaging Library which provides the python interpreter with image editing capabilities. The ImageEnhance module contains a number of classes that can be used for image enhancement.
This class can be used to adjust the color balance of an image, in a manner similar to the controls on a color TV set. An enhancement factor of 0.0 gives a black and white image. A factor of 1.0 gives the original image.
Syntax: ImageEnhance.Color(image)
First, it is required to create an object of corresponding class in order to enhance image.
# This will import Image and ImageEnhance modulesfrom PIL import Image, ImageEnhance  # Opening Imageim = Image.open(r"C:\Users\Admin\Pictures\images.png")  # Creating object of Color classim3 = ImageEnhance.Color(im)  # showing resultant imageim3.enhance(0.0).show()
Output:For first image factor = 0.0 and for second image factor is 5.0.
This class can be used to control the contrast of an image, similar to the contrast control on a TV set. An enhancement factor of 0.0 gives a solid grey image. A factor of 1.0 gives the original image.
Syntax:
obj = ImageEnhance.Contrast(image)obj.enhance(factor)
First, it is required to create an object of corresponding class in order to enhance image.
# This will import Image and ImageEnhance modulesfrom PIL import Image, ImageEnhance  # Opening Imageim = Image.open(r"C:\Users\Admin\Pictures\images.png")  # Creating object of Contrast classim3 = ImageEnhance.Contrast(im)  # showing resultant imageim3.enhance(0.0).show()
Output:For first image factor is 5.0 and for second 0.0
Image-Processing
python-utility
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Iterate over a list in Python
Python OOPs Concepts
PyQt - Layout Management

A GUI widget can be placed inside the container window by specifying its absolute coordinates measured in pixels. The coordinates are relative to the dimensions of the window defined by setGeometry() method.
QWidget.setGeometry(xpos, ypos, width, height)

In the following code snippet, the top level window of 300 by 200 pixels dimensions is displayed at position (10, 10) on the monitor.
import sys
from PyQt4 import QtGui

def window():
   app = QtGui.QApplication(sys.argv)
   w = QtGui.QWidget()
	
   b = QtGui.QPushButton(w)
   b.setText("Hello World!")
   b.move(50,20)
	
   w.setGeometry(10,10,300,200)
   w.setWindowTitle(“PyQt”)
   w.show()
   sys.exit(app.exec_())
	
if __name__ == '__main__':
   window()
A PushButton widget is added in the window and placed at a position 50 pixels towards right and 20 pixels below the top left position of the window.
This Absolute Positioning, however, is not suitable because of following reasons −
The position of the widget does not change even if the window is resized.
The position of the widget does not change even if the window is resized.
The appearance may not be uniform on different display devices with different resolutions.
The appearance may not be uniform on different display devices with different resolutions.
Modification in the layout is difficult as it may need redesigning the entire form.
Modification in the layout is difficult as it may need redesigning the entire form.
PyQt API provides layout classes for more elegant management of positioning of widgets inside the container. The advantages of Layout managers over absolute positioning are −
Widgets inside the window are automatically resized.
Widgets inside the window are automatically resized.
Ensures uniform appearance on display devices with different resolutions.
Ensures uniform appearance on display devices with different resolutions.
Adding or removing widget dynamically is possible without having to redesign.
Adding or removing widget dynamically is possible without having to redesign.
Here is the list of Classes which we will discuss one by one in this chapter.
QBoxLayout class lines up the widgets vertically or horizontally. Its derived classes are QVBoxLayout (for arranging widgets vertically) and QHBoxLayout (for arranging widgets horizontally).
A GridLayout class object presents with a grid of cells arranged in rows and columns. The class contains addWidget() method. Any widget can be added by specifying the number of rows and columns of the cell.
QFormLayout is a convenient way to create two column form, where each row consists of an input field associated with a label. As a convention, the left column contains the label and the right column contains an input field.
Ruby | Exception Handling in Threads | Set – 1

19 Dec, 2018
Threads can also contain exceptions. In Ruby threads, the only exception arose in the main thread is handled but if an exception arises in the thread(other than main thread) cause the termination of the thread. The arising of an exception in a thread other than the main thread depends upon abort_on_exception method. The default value of abort_on_exception is false. When the value of abort_on_exception is false it means the unhandled exception aborts the current thread and the rest of the threads will continue running.You can also change the setting of abort_on_exception by using abort_on_exception=true or $DEBUG to true. Ruby threads also provided a method to handle the exceptions, i.e. ::handle_interrupt. This will method handle exceptions asynchronously.
Example:
# Ruby program to illustrate # the exception in thread  #!/usr/bin/ruby    threads = []4.times do |value|      threads << Thread.new(value) do |a|          # raising an error when a become 2        raise "oops error!" if a == 2  print "#{a}\n"end  endthreads.each {|b| b.join }
Output:
0
3
1
main.rb:12:in `block (2 levels) in ': oops error! (RuntimeError)

Note: Thread.Join method is used to wait for the finishing of a particular thread. Because when a Ruby program terminates, all the thread are killed, irrespective of their states. We can also save the exception as shown in the below example:
Example:
# Ruby program to illustrate hwo to # escape the exception  #!/usr/bin/ruby    threads = []  5.times do |value|    threads << Thread.new(value) do |a|        raise "oops error!" if a == 3print "#{a}\n"end  end  threads.each do |x|begin  x.join  # using rescue methodrescue RuntimeError => y    puts "Failed:: #{y.message}"endend
Output:
0
1
4
2
Failed:: oops error!

Now set the value of abort_on_exception= true, it kills the thread which contains an exception. Once the thread is dead, no more output will produce.
Example:
# Ruby program to illustrate the killing# of thread in which exception raised   #!/usr/bin/ruby    # setting the value of abort_on_exceptionThread.abort_on_exception = true  threads = []  5.times do |value|    threads << Thread.new(value) do |a|    raise "oops error!" if a == 3  print "#{a}\n"end  end  # using Thread.Join Methodthreads.each {|b| b.join }
Output:
0
1
2
main.rb:13:in `block (2 levels) in ': oops error! (RuntimeError)

The execution of thread(other than main thread) as shown below:
Ruby-Exception-handling
Ruby-Multithreading
Ruby
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to find missing value between two MySQL Tables?

To find missing value between two MySQL tables, use NOT IN. Let us first create a table −
mysql> create table DemoTable1(Value int);
Query OK, 0 rows affected (0.56 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1 values(1);
Query OK, 1 row affected (0.15 sec)
mysql> insert into DemoTable1 values(2);
Query OK, 1 row affected (0.28 sec)
mysql> insert into DemoTable1 values(5);
Query OK, 1 row affected (0.23 sec)
mysql> insert into DemoTable1 values(6);
Query OK, 1 row affected (0.09 sec)
mysql> insert into DemoTable1 values(8);
Query OK, 1 row affected (0.16 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable1;
This will produce the following output −
+-------+
| Value |
+-------+
|     1 |
|     2 |
|     5 |
|     6 |
|     8 |
+-------+
5 rows in set (0.00 sec)
Following is the query to create second table −
mysql> create table DemoTable2(Value int);
Query OK, 0 rows affected (1.19 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable2 values(1);
Query OK, 1 row affected (0.11 sec)
mysql> insert into DemoTable2 values(2);
Query OK, 1 row affected (0.17 sec)
mysql> insert into DemoTable2 values(3);
Query OK, 1 row affected (0.12 sec)
mysql> insert into DemoTable2 values(4);
Query OK, 1 row affected (0.12 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable2;
This will produce the following output −
+-------+
| Value |
+-------+
|     1 |
|     2 |
|     3 |
|     4 |
+-------+
4 rows in set (0.00 sec)
Following is the query to find missing value between two MySQL Tables −
mysql> select Value from DemoTable1 where Value not in(select Value from DemoTable2);
This will produce the following output −
+-------+
| Value |
+-------+
|     5 |
|     6 |
|     8 |
+-------+
3 rows in set (0.07 sec)
How to send a PUT/DELETE request in jQuery ?

14 Dec, 2020
In jQuery, we can use the .get() method to make a get request and .post() method to make a post request but there is not .put() or .delete() methods available. In this article, we are going to see how we can make a PUT and DELETE request in jQuery.
Approach: To make a PUT or DELETE requests in jQuery we can use the .ajax() method itself. We can specify the type of request to be put or delete according to the requirement as given in the example below.
Example: We will create a code example in which we will create two buttons which are going to make PUT and DELETE requests to an unknown server. We are going to see from the Network tab of the Chrome Developer tools that the requests are working or not. We will create a file called test.html with a simple text GeeksforGeeks to which we are going to make the AJAX request and our main file is going to be index.html. When we click on any of the two buttons a new name will appear in Network tab, we can click on it to see the type of the request in Request Method option. We need to run this in a server, in the screenshots PHP server is being used.
Steps to open the Dev tools:
Press Ctrl + Shift + I.Click on Networks tab.
Press Ctrl + Shift + I.
Click on Networks tab.
HTML
<!DOCTYPE html><html lang="en">  <head>    <meta charset="UTF-8">    <meta name="viewport" content=          "width=device-width, initial-scale=1.0">        <!-- Importing the jQuery -->    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js">      </script></head>  <script>    function makePUTrequest() {        $.ajax({            url: 'test.html',            type: 'PUT',            success: function (result) {                // Do something with the result            }        });    }      function makeDELETErequest() {        $.ajax({            url: 'test.html',            type: 'DELETE',            success: function (result) {                // Do something with the result            }        });    }</script>  <body>    <button onclick="makePUTrequest()">        Click for PUT request    </button>    <button onclick="makeDELETErequest()">        Click for DELETE request    </button></body>  </html>
Output:
Output in the Network tab when we click on the PUT request button:
Output in the Network tab when we click on the DELETE request button:
HTML-Misc
jQuery-Misc
JQuery
Web Technologies
Web technologies Questions
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Java Program for Selection Sort

13 Jun, 2022
The selection sort algorithm sorts an array by repeatedly finding the minimum element (considering ascending order) from unsorted part and putting it at the beginning. The algorithm maintains two subarrays in a given array.
1) The subarray which is already sorted.
2) Remaining subarray which is unsorted.In every iteration of selection sort, the minimum element (considering ascending order) from the unsorted subarray is picked and moved to the sorted subarray.
Java
// Java program for implementation of Selection Sortclass SelectionSort{    void sort(int arr[])    {        int n = arr.length;         // One by one move boundary of unsorted subarray        for (int i = 0; i < n-1; i++)        {            // Find the minimum element in unsorted array            int min_idx = i;            for (int j = i+1; j < n; j++)                if (arr[j] < arr[min_idx])                    min_idx = j;             // Swap the found minimum element with the first            // element            int temp = arr[min_idx];            arr[min_idx] = arr[i];            arr[i] = temp;        }    }     // Prints the array    void printArray(int arr[])    {        int n = arr.length;        for (int i=0; i<n; ++i)            System.out.print(arr[i]+" ");        System.out.println();    }     // Driver code to test above    public static void main(String args[])    {        SelectionSort ob = new SelectionSort();        int arr[] = {64,25,12,22,11};        ob.sort(arr);        System.out.println("Sorted array");        ob.printArray(arr);    }}/* This code is contributed by Rajat Mishra*/
Time Complexity:  O(n2).
Auxiliary Space: O(1).
Please refer complete article on Selection Sort for more details!
chandramauliguptach
Java Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Factory method design pattern in Java
Java Program to Remove Duplicate Elements From the Array
Iterate through List in Java
Java program to count the occurrence of each character in a string using Hashmap
How to Iterate HashMap in Java?
Remove first and last character of a string in Java
Iterate Over the Characters of a String in Java
How to Convert Char to String in Java?
Java Program to find largest element in an array
How to Get Elements By Index from HashSet in Java?
Impala - Create Table Statement

The CREATE TABLE Statement is used to create a new table in the required database in Impala. Creating a basic table involves naming the table and defining its columns and each column's data type.
Following is the syntax of the CREATE TABLE Statement. Here, IF NOT EXISTS is an optional clause. If we use this clause, a table with the given name is created, only if there is no existing table in the specified database with the same name.
create table IF NOT EXISTS database_name.table_name (
   column1 data_type,
   column2 data_type,
   column3 data_type,
   .........
   columnN data_type
);
CREATE TABLE is the keyword that instructs the database system to create a new table. The unique name or identifier for the table follows the CREATE TABLE statement. Optionally you can specify database_name along with table_name.
Following is an example of the create table statement. In this example, we have created a table named student in the database my_db.
[quickstart.cloudera:21000] > CREATE TABLE IF NOT EXISTS my_db.student
   (name STRING, age INT, contact INT );

On executing the above statement, a table with the specified name will be created, displaying the following output.
Query: create table student (name STRING, age INT, phone INT) 

Fetched 0 row(s) in 0.48s

The show Tables query gives a list of tables in the current database in Impala. Therefore, you can verify whether the table is created, using the Show Tables statement.
First of all, you need to switch the context to the database in which the required table exists, as shown below.
[quickstart.cloudera:21000] > use my_db; 
Query: use my_db

Then, if you get the list of tables using the show tables query, you can observe the table named student in it as shown below.
[quickstart.cloudera:21000] > show tables;

Query: show tables 
+-----------+ 
| name      | 
+-----------+ 
| student   | 
+-----------+ 
Fetched 1 row(s) in 0.10s 
In order to create a database in HDFS file system, you need to specify the location where the database is to be created as shown below.
CREATE DATABASE IF NOT EXISTS database_name LOCATION hdfs_path;

Open impala Query editor and type the CREATE Table Statement in it. And click on the execute button as shown in the following screenshot.
After executing the query, gently move the cursor to the top of the dropdown menu and you will find a refresh symbol. If you click on the refresh symbol, the list of databases will be refreshed and the recent changes done are applied to it.
Click on the drop down under the heading DATABASE on the left-hand side of the editor. There you can see a list of databases. Select the database my_db as shown below.
On selecting the database my_db you can see a list of tables in it as shown below. Here you can find the newly created table student as shown below.
How to label bubble chart/scatter plot with column from Pandas dataframe?

To label bubble charts/scatter plot with column from Pandas dataframe, we can take the following steps −
Set the figure size and adjust the padding between and around the subplots.
Create a data frame, df, of two-dimensional, size-mutable, potentially heterogeneous tabular data.
Create a scatter plot with df.
Annotate each data point with a text.
To display the figure, use show() method.
import pandas as pd
from matplotlib import pyplot as plt

# Set the figure size
plt.rcParams["figure.figsize"] = [7.00, 3.50]
plt.rcParams["figure.autolayout"] = True

# Create a dataframe
df = pd.DataFrame(
   dict(
      x=[1, 3, 2, 4, 5],
      y=[0, 3, 1, 2, 5],
      points=['Kiran', 'Raju', 'Raja', 'Javed', 'Rishi']
   )
)

# Scatter plot
ax = df.plot.scatter(x='x', y='y', alpha=0.5)

# Annotate each data point
for i, txt in enumerate(df.points):
   ax.annotate(txt, (df.x.iat[i]+0.05, df.y.iat[i]))

plt.show()
It will produce the following output
Bootstrap Form Radio Button

Use radio class if you want to limit the user to just one selection i.e. adding radio buttons. Use.radio-inline class to a series of radios for controls appear on the same line.
You can try to run the following code to implement Bootstrap Forms radio button
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <title>Bootstrap Forms</title>
      <meta name = "viewport" content = "width = device-width, initial-scale = 1">
      <link rel = "stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css">
      <script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
      <script src = "https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script>
   </head>
   <body>
      <label for = "name">Favourite TV Series</label>
      <div class = "radio">
         <label>
            <input type = "radio" name = "optionsRadios" id = "optionsRadios1" value = "option1" checked> Suits
         </label>
      </div>
      <div class = "radio">
         <label>
            <input type = "radio" name = "optionsRadios" id = "optionsRadios2" value = "option2">
               House of Cards
         </label>
      </div>
   </body>
</html>
Implementation of Perceptron Algorithm for OR Logic Gate with 2-bit Binary Input

08 Jun, 2020
In the field of Machine Learning, the Perceptron is a Supervised Learning Algorithm for binary classifiers. The Perceptron Model implements the following function:
    
For a particular choice of the weight vector  and bias parameter , the model predicts output  for the corresponding input vector .
OR logical function truth table for 2-bit binary variables, i.e, the input vector  and the corresponding output  –
Now for the corresponding weight vector  of the input vector , the associated Perceptron Function can be defined as:
    
For the implementation, considered weight parameters are  and the bias parameter is .
Python Implementation:
# importing Python libraryimport numpy as np  # define Unit Step Functiondef unitStep(v):    if v >= 0:        return 1    else:        return 0  # design Perceptron Modeldef perceptronModel(x, w, b):    v = np.dot(w, x) + b    y = unitStep(v)    return y  # OR Logic Function# w1 = 1, w2 = 1, b = -0.5def OR_logicFunction(x):    w = np.array([1, 1])    b = -0.5    return perceptronModel(x, w, b)  # testing the Perceptron Modeltest1 = np.array([0, 1])test2 = np.array([1, 1])test3 = np.array([0, 0])test4 = np.array([1, 0])  print("OR({}, {}) = {}".format(0, 1, OR_logicFunction(test1)))print("OR({}, {}) = {}".format(1, 1, OR_logicFunction(test2)))print("OR({}, {}) = {}".format(0, 0, OR_logicFunction(test3)))print("OR({}, {}) = {}".format(1, 0, OR_logicFunction(test4)))
OR(0, 1) = 1
OR(1, 1) = 1
OR(0, 0) = 0
OR(1, 0) = 1

Here, the model predicted output () for each of the test inputs are exactly matched with the OR logic gate conventional output () according to the truth table for 2-bit binary input.Hence, it is verified that the perceptron algorithm for OR logic gate is correctly implemented.
Neural Network
Machine Learning
Python
Machine Learning
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
ML | Linear Regression
Reinforcement learning
Supervised and Unsupervised learning
Decision Tree Introduction with example
Search Algorithms in AI
Read JSON file using Python
Python map() function
Adding new column to existing DataFrame in Pandas
Python Dictionary
How to get column names in Pandas dataframe
Retrieve the position (X,Y) of an element using HTML

10 Jan, 2019
The position of (X, Y) means the co-ordinate of an element at the top-left point in a document. X represent the horizontal position and Y represent the vertical position. Use element.getBoundingClientRect() property to get the position of an element.
Example 1:
<!-- HTML program to get (x, y) coordinate of an element relative to the viewport --><!DOCTYPE html><html>    <head>        <title>            position of an element        </title>                  <!-- JavaScript code to display position -->        <script type="text/javascript">                      function getPositionXY(element) {                var rect = element.getBoundingClientRect();                document.getElementById('gfg').innerHTML =                 'X: ' + rect.x + ', ' + 'Y: ' + rect.y            }        </script>    </head>          <body>                  <!-- Click on button to get its co-ordinate -->        <button id = 'button1' onclick = "getPositionXY(this)">            Button 1        </button>                  <button id = 'button1' onclick = "getPositionXY(this)">            Button 2        </button>                  <br><br>        <button id = 'button1' onclick = "getPositionXY(this)">            Button 3        </button>                  <p id = 'gfg'></p>          </body></html>                    
Output:
Example 2: In this example, move the pointer over the document to get the position of an element.
<!-- HTML program to show (x, y) of an element by dragging mouse over it --><!DOCTYPE html><html>    <head>        <title>            position of an element        </title>                  <!-- scropt to get position -->        <script type = "text/javascript">            function getPositionXY(element) {                var rect = element.getBoundingClientRect();                document.getElementById('text').innerHTML                 = 'X: ' + rect.x + '<br>' + 'Y: ' + rect.y;            }        </script>    </head>          <body>        <p>Move the mouse over the text</p>                  <div onmouseover = "getPositionXY(this)">            Position:            <p id = 'text'></p>        </div>          </body></html>                    
Output:
HTML-Misc
Picked
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
REST API (Introduction)
Node.js fs.readFileSync() Method
How to set the default value for an HTML <select> element ?
How to set fullscreen mode for Java Swing Application?

To set fullscreen mode for your Java Swing application, use the setFullScreenWindow() method:
GraphicsDevice device = graphics.getDefaultScreenDevice();
JFrame frame = new JFrame("Fullscreen");
device.setFullScreenWindow(frame);
The following is an example to set fullscreen mode for Java Swing Application:
import java.awt.Color;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class SwingDemo {
   public static void main(String[] args) {
      GraphicsEnvironment graphics =
      GraphicsEnvironment.getLocalGraphicsEnvironment();
      GraphicsDevice device = graphics.getDefaultScreenDevice();
      JFrame frame = new JFrame("Fullscreen");
      JPanel panel = new JPanel();
      JLabel label = new JLabel("", JLabel.CENTER);
      label.setText("This is in fullscreen mode!");
      label.setOpaque(true);
      frame.add(panel);
      frame.add(label);
      frame.setUndecorated(true);
      frame.setResizable(false);
      device.setFullScreenWindow(frame);
   }
}
The output is as follows that displays the application in FullScreen: