code-rag-bench/online-tutorials huggingface dataset:
Java else Keyword

❮ Java Keywords

Use the else statement to specify a block of code to be executed if the condition is false.
int time = 20;
if (time < 18) {
  System.out.println("Good day.");
} else {
  System.out.println("Good evening.");
}
// Outputs "Good evening."


Try it Yourself »

The else statement specifies a block of Java code to be executed if a condition is false in an if statement.
Java has the following conditional statements:
Use if to specify a block of code to be executed, if a specified condition is true
Use else to specify a block of code to be executed, if the same condition is false
Use else if to specify a new condition to test, if the first condition is false
Use switch to specify many alternative blocks of code to be executed
Use the else if statement to specify a new condition if the first condition is false.
int time = 22;
if (time < 10) {
  System.out.println("Good morning.");
} else if (time < 20) {
  System.out.println("Good day.");
} else {
  System.out.println("Good evening.");
}
// Outputs "Good evening."


Try it Yourself »

Read more about conditions in our Java If...Else Tutorial.

❮ Java Keywords

We just launchedW3Schools videos
Get certifiedby completinga course today!
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com
Your message has been sent to W3Schools.
How to Insert Hyperlink in HTML Page?

With HTML, easily add hyperlinks to any HTML page. Link team page, about page, or even a test by creating it a hyperlink. You can also create a hyperlink for an external website. To make a hyperlink in an HTML page, use the <a> and </a> tags, which are the tags used to define the links.
The <a> tag indicates where the hyperlink starts and the </a> tag indicates where it ends. Whatever text gets added inside these tags, will work as a hyperlink. Add the URL for the link in the <a href=” ”>. Just keep in mind that you should use the <a>...</a> tags inside <body>...</body> tags.
You can try to run the following code to insert a hyperlink in an HTML page
<!DOCTYPE html>
<html>
   <head>
      <title>HTML Hyperlinks</title>
   </head>

   <body>
      <h1>Company</h1>
      <p>
         We are a <a href="/about/about_team.htm">team</a> of professionals working
         hard to provide free learning content.
      </p>
   </body>
</html>
Get the sum only from specific cells in MySQL?

For only specific cells, set a condition with WHERE and use aggregate function SUM() to add. Let us first create a table −
mysql> create table DemoTable1370
   -> (
   -> StudentName varchar(20),
   -> Marks int
   -> );
Query OK, 0 rows affected (0.87 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1370 values('Adam Smith',56);
Query OK, 1 row affected (0.20 sec)
mysql> insert into DemoTable1370 values('Chris Brown',67);
Query OK, 1 row affected (0.17 sec)
mysql> insert into DemoTable1370 values('Adam Smith',69);
Query OK, 1 row affected (0.20 sec)
mysql> insert into DemoTable1370 values('David Miller',98);
Query OK, 1 row affected (0.12 sec)
mysql> insert into DemoTable1370 values('John Smith',59);
Query OK, 1 row affected (0.13 sec)
mysql> insert into DemoTable1370 values('Adam Smith',79);
Query OK, 1 row affected (0.11 sec)
mysql> insert into DemoTable1370 values('Chris Brown',77);
Query OK, 1 row affected (0.17 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1370;
This will produce the following output −
+--------------+-------+
| StudentName  | Marks |
+--------------+-------+
| Adam Smith   |    56 |
| Chris Brown  |    67 |
| Adam Smith   |    69 |
| David Miller |    98 |
| John Smith   |    59 |
| Adam Smith   |    79 |
| Chris Brown  |    77 |
+--------------+-------+
7 rows in set (0.00 sec)
Here is the query that gets the sum from specific cells −
mysql> select sum(Marks) AS Total from DemoTable1370 where StudentName='Adam Smith';
This will produce the following output −
+-------+
| Total |
+-------+
|   204 |
+-------+
1 row in set (0.00 sec)
What is the difference between DB2 JOIN and UNION? Explain with the help of an example

Both JOIN and UNION are used to combine the data from one or more tables. In case of JOIN, the additional data appears in column while in case of UNION additional data appears in rows.
For example,
Suppose we have two DB2 tables, ORDERS and TRANSACTIONS. We have to extract TRANSACTION_ID for each ORDER_ID, then we will use INNER JOIN as below:
SELECT ORDER_ID, TRANSACTION_ID
   FROM ORDERS INNER JOIN TRANSACTIONS ON
   ORDERS.TRANSACTION_ID = TRANSACTIONS.TRANSACTION_ID
This query will result in 2 columns. One column will be from ORDERS table i.e., ORDER_ID and other column will be from TRANSACTIONS table i.e. TRANSACTION_ID.
We have 2 tables ORDERS and ORDER_HIST. The ORDERS table has all the current orders while ORDER_HIST table has all the archived orders. If we want to list down all the orders having total value more than 10000, then we have to use the below query.
SELECT ORDER_ID, ORDER_TOTAL FROM ORDERS WHERE ORDER_TOTAL > 10000
UNION
SELECT ORDER_ID, ORDER_TOTAL FROM ORDERS_HIST WHERE ORDER_TOTAL > 10000
Python | Check if all elements in a list are identical

18 Jan, 2019
Given a list, write a Python program to check if all the elements in that list are identical.
Examples:
Input : ['a', 'b', 'c']
Output : False

Input : [1, 1, 1, 1]
Output : True

Approach #1 : Using loopStart a for loop and check if first element is identical to all other elements in the list. This approach takes O(n) time complexity.
# Python3 program to check if # all elements in a list are identicaldef check(list):    return all(i == list[0] for i in list)      # Driver codeprint(check(['a', 'b', 'c']))print(check([1, 1, 1]))
False
True

 Approach #2 : Using SetConverting given list into set removes all duplicate elements, If the resultant set size is less than or equal to 1 then the list contains all identical elements.
# Python3 program to check if # all elements in a list are identicaldef check(list):   return len(set(list)) <= 1     # Driver codeprint(check(['a', 'b', 'c']))print(check([1, 1, 1]))
False
True

 Approach #3 : Using count()By counting the number of times the first element occurs in the list, we can check if the count is equal to the size of list or not. In simple words, check if the first element is repeated throughout the list or not.
# Python3 program to check if # all elements in a list are identicaldef check(list):   return list.count(list[0]) == len(list)     # Driver codeprint(check(['a', 'b', 'c']))print(check([1, 1, 1]))
False
True

 Approach #4 : Alternative methodAnother method is to take the first element and multiply it with the length of given list to form a new list, So that the new list contains identical elements to first elements of given list size, and then compare it with the given list.
# Python3 program to check if # all elements in a list are identicaldef check(x):    return x and [x[0]]*len(x) == x     # Driver codeprint(check(['a', 'b', 'c']))print(check([1, 1, 1]))
False
True

 Approach #5 : Using extended slicesPython slice notation is used to retrieve a subset of values. Thus, we compare the start to end of the list to end to start of the list.
# Python3 program to check if # all elements in a list are identicaldef check(list):   return list[1:] == list[:-1]     # Driver codeprint(check(['a', 'b', 'c']))print(check([1, 1, 1]))
False
True

Python list-programs
python-list
Python
Python Programs
python-list
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()
Python program to convert a list to string
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python | Convert string dictionary to dictionary
Python Program for Fibonacci numbers
numpy.ix_() function | Python

22 Apr, 2020
numpy.ix_() function construct an open mesh from multiple sequences. This function takes N 1-D sequences and returns N outputs with N dimensions each, such that the shape is 1 in all but one dimension and the dimension with the non-unit shape value cycles through all N dimensions.
Syntax : numpy.ix_(args)Parameters :args : [1-D sequences] Each sequence should be of integer or boolean type.Return : [tuple of ndarrays] N arrays with N dimensions each, with N the number of input sequences. Together these arrays form an open mesh.
Code #1 :
# Python program explaining# numpy.ix_() function  # importing numpy as geek import numpy as geek  gfg = geek.ix_([0, 1], [2, 4])  print (gfg)
Output :
(array([[0],
       [1]]), array([[2, 4]]))

 Code #2 :
# Python program explaining# numpy.ix_() function  # importing numpy as geek import numpy as geek  arr = geek.arange(10).reshape(2, 5)print("Initial array : \n", arr)   ixgrid = geek.ix_([0, 1], [2, 4])  print("New array : \n", arr[ixgrid]) 
Output :
Initial array : 
 [[0 1 2 3 4]
 [5 6 7 8 9]]
New array : 
 [[2 4]
 [7 9]]

Python numpy-arrayManipulation
Python-numpy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
How to drop one or multiple columns in Pandas Dataframe
Python | os.path.join() method
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python | Get unique values from a list
Python | datetime.timedelta() function
D3.js | d3.map.values() Function

28 Jun, 2019
The map.values() function in D3.js used to return an array of values for every entry in the created map. The order of the returned values are arbitrary.
Syntax:
d3.map.values()
Parameters: This function does not accept any parameters.
Return Value: This function returns an array of values for every entry in the created map. Order of those returned values are arbitrary.
Below programs illustrate the d3.map.values() function in D3.js:
Example 1:
<!DOCTYPE html><html>     <head>    <title> d3.map.values() Function</title>         <script src='https://d3js.org/d3.v4.min.js'></script></head>  <body>     <script>            // Creating a map     var map = d3.map({"Ram": 5, "Geeks": 10, "gfg": 15});            // Calling the map.values() function     A = map.values();            // Getting an array of values for     // every entry in the map.     console.log(A);  </script></body>  </html>
Output:
[5, 10, 15]

Example 2:
<!DOCTYPE html><html>     <head>    <title> d3.map.values() Function</title>         <script src='https://d3js.org/d3.v4.min.js'></script></head>  <body>  <script>            // Creating some maps     var map1 = d3.map({"Ram": 5});     var map2 = d3.map({"Geeks": 10});     var map3 = d3.map({"Ram": 5, "Geeks": 10});     var map4 = d3.map();            // Calling the map.values() function     A = map1.values();     B = map2.values();     C = map3.values();     D = map4.values();            // Getting an array of values for     // every entry in the map.     console.log(A);     console.log(B);     console.log(C);     console.log(D);  </script></body>  </html>
Output:
[5]
[10]
[5, 10]
[]

Ref: https://devdocs.io/d3~5/d3-collection#map_values
D3.js
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
Difference Between PUT and PATCH Request
How to Open URL in New Tab using JavaScript ?
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
UGC-NET | UGC NET CS 2017 Jan – III | Question 46

04 Apr, 2018
A software project was estimated at 352 Function Points (FP). A four person team will be assigned to this project consisting of an architect, two programmers, and a tester. The salary of the architect is ` 80,000 per month, the programmer ₹ 60,000 per month and the tester ₹ 50,000 per month. The average productivity for the team is 8 FP per person month. Which of the following represents the projected cost of the project ?(A) ₹ 28,16,000(B) ₹ 20,90,000(C) ₹ 26,95,000(D) ₹ 27,50,000Answer: (D)Explanation: In given question we have total 352 Function Points (FP)Average FP = 8 per person per month4 person team is assigned to the project which is consist of an architect(₹ 80,000 per month), two programmers(₹ 60,000 per person per month), and a tester(₹ 50,000 per month).
So, 352 / (8 * 4) = 11 months
projected cost of the project = (1 architect + 2 programmer + 1 tester) * 11 
                              = (80000 + 2 * 60000 + 50000) * 11 
                              = ₹ 2750000.
So, option (D) is correct.
Quiz of this Question
UGC-NET
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
UGC-NET | UGC NET CS 2015 Jun - III | Question 33
UGC-NET | UGC NET CS 2015 Jun - III | Question 35
UGC-NET | UGC NET CS 2016 Aug - III | Question 32
UGC-NET | UGC NET CS 2015 Jun - III | Question 31
UGC-NET | UGC NET CS 2015 Jun - III | Question 64
UGC-NET | UGC NET CS 2016 July – III | Question 32
UGC-NET | UGC NET CS 2016 July – II | Question 27
UGC-NET | UGC NET CS 2015 Dec – III | Question 34
UGC-NET | UGC NET CS 2015 Jun - II | Question 1
UGC-NET | UGC NET CS 2015 Jun - III | Question 34
Printing source code of a C program itself

11 Feb, 2018
How to print source code of a C program itself? Note this is different from Quine problem. Here we need to modify any C program in a way that it prints whole source code.
Explanation :We can use the concepts of file handling to print the source code of the program as output. The idea being : displaying the content from the same file you are writing the source code.
The location of a C programming file is contained inside a predefined macro __FILE__. For example:
   #include <stdio.h>int main(){   // Prints location of C this C code.   printf("%s",__FILE__);}
The output of the above program is the location of this C file.The following program displays the content of this particular C file(source code) because __FILE__ contains the location of this C file in a string.
   // A C program that prints its source code.#include <stdio.h>   int main(void){    // We can append this code to any C program    // such that it prints its source code.      char c;     FILE *fp = fopen(__FILE__, "r");       do    {        c = fgetc(fp);        putchar(c);    }    while (c != EOF);       fclose(fp);       return 0;}
Output :
// A C program that prints its source code.
#include <stdio.h>
 
int main(void)
{
    // We can append this code to any C program
    // such that it prints its source code.

    char c; 
    FILE *fp = fopen(__FILE__, "r");
 
    do
    {
        c = fgetc(fp);
        putchar(c);
    }
    while (c != EOF);
 
    fclose(fp);
 
    return 0;
}

Note : The above program may not work online compiler as fopen might be blocked.
This article is contributed by Rishav Raj. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@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.
C-File Handling
C Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Unordered Sets in C++ Standard Template Library
Operators in C / C++
Exception Handling in C++
What is the purpose of a function prototype?
TCP Server-Client implementation in C
Smart Pointers in C++ and How to Use Them
Storage Classes in C
'this' pointer in C++
Ways to copy a vector in C++
Arrow operator -> in C/C++ with Examples
jQuery element Selector

11 Jul, 2022
jQuery is an open-source JavaScript library that simplifies the interactions between an HTML/CSS document, or more precisely the Document Object Model (DOM), and JavaScript. Elaborating the terms, it simplifies HTML document traversing and manipulation, browser event handling, DOM animations, Ajax interactions, and cross-browser JavaScript development.
jQuery element selector is used to select and modify HTML elements based on the element name. 
Syntax:
$("element_name") 
Example 1: This example selects the “h2” element and adds border to it. 
HTML
<!DOCTYPE html><html><head>  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">  </script>  <script>    $(document).ready(function () {      $("h2").css("border",        "5px solid green");    });  </script></head><body>  <h2>GeeksForGeeks</h2></body></html>
Output: 
 
Example 2: This example changes text color of “h2” element on button click. 
HTML
<!DOCTYPE html><html><head>  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">  </script>  <script>    $(document).ready(function () {      $("button").click(function () {        $("h2").css("color",          "green");      });    });  </script></head><body>  <h2>GeeksForGeeks</h2>  <button>Change text color</button></body></html>
Output:
 
 
Supported Browsers:
Google Chrome 90.0+
Internet Explorer 9.0
Firefox 3.6
Safari 4.0
Opera 10.5
ysachin2314
sahilintern
jQuery-Selectors
Picked
JQuery
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
matplotlib.pyplot.polar() in Python

22 Apr, 2020
Matplotlib is a library in Python and it is numerical – mathematical extension for NumPy library. Pyplot is a state-based interface to a Matplotlib module which provides a MATLAB-like interface.
The polar() function in pyplot module of matplotlib library is used to make a polar plot.
Syntax: matplotlib.pyplot.polar(*args, **kwargs)
Parameters: This method does not accept any parameters.
Returns: This method does not returns any value.
Below examples illustrate the matplotlib.pyplot.polar() function in matplotlib.pyplot:
Example #1:
# Implementation of matplotlib functionimport matplotlib.pyplot as pltimport matplotlib.transforms as mtransformsimport numpy as np   from matplotlib.transforms import offset_copy   xs = np.arange(-2, 2)ys = np.cos(xs**2)plt.polar(xs, ys)    plt.title('matplotlib.pyplot.polar() function Example',                                    fontweight ="bold")plt.show()
Output:
Example #2:
# Implementation of matplotlib functionimport matplotlib.pyplot as pltimport matplotlib.transforms as mtransformsimport numpy as np  from matplotlib.transforms import offset_copy  xs = np.arange(8)ys = np.cos(xs**2)  fig = plt.figure(figsize =(5, 10))ax = plt.subplot(1, 1, 1)  trans_offset = mtransforms.offset_copy(ax.transData, fig = fig,                                       y = 6, units ='dots')  for x, y in zip(xs, ys):    plt.polar(x, y, 'go')    plt.text(x, y, '% d, % d' % (int(x), int(y)),                       transform = trans_offset,                  horizontalalignment ='center',                    verticalalignment ='bottom')      plt.title('matplotlib.pyplot.polar() function Example',                                     fontweight ="bold")plt.show()
Output:
Python-matplotlib
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Python | os.path.join() method
How to drop one or multiple columns in Pandas Dataframe
Introduction To PYTHON
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | datetime.timedelta() function
Python | Get unique values from a list
Creating a one-dimensional NumPy array

02 Sep, 2020
One dimensional array contains elements only in one dimension. In other words, the shape of the NumPy array should contain only one value in the tuple. Let us see how to create 1 dimensional NumPy arrays.
Method 1: First make a list then pass it in numpy.array()
Python3
# importing the moduleimport numpy as np  # creating the listlist = [100, 200, 300, 400]  # creating 1-d arrayn = np.array(list)print(n)
Output:
[100 200 300 400]
Method 2: fromiter() is useful for creating non-numeric sequence type array however it can create any type of array. Here we will convert a string into a NumPy array of characters.
Python3
# imporint gthe moduleimport numpy as np  # creating the stringstr = "geeksforgeeks"  # creating 1-d arrayx = np.fromiter(str, dtype = 'U2')print(x)
Output:
['g' 'e' 'e' 'k' 's' 'f' 'o' 'r' 'g' 'e' 'e' 'k' 's']
Method 3: arange() returns evenly spaced values within a given interval.
Python3
# importing the moduleimport numpy as np  # creating 1-d arrayx = np.arange(3, 10, 2)print(x)
Output:
[3 5 7 9]
Method 4: linspace() creates evenly space numerical elements between two given limits.
Python3
# importing the moduleimport numpy as np  # creating 1-d arrayx = np.linspace(3, 10, 3)print(x)
Output:
[ 3.   6.5 10. ]
Python numpy-arrayCreation
Python-numpy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
How to drop one or multiple columns in Pandas Dataframe
Python | os.path.join() method
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python | Get unique values from a list
Python | datetime.timedelta() function
MySQL Select Statement DISTINCT for Multiple Columns?

To understand the MySQL select statement DISTINCT for multiple columns, let us see an example and create a table. The query to create a table is as follows
mysql> create table selectDistinctDemo
   -> (
   -> InstructorId int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   -> StudentId int,
   -> TechnicalSubject varchar(100)
   -> );
Query OK, 0 rows affected (0.50 sec)
Insert some records in the table using insert command. The query is as follows
mysql> insert into selectDistinctDemo(StudentId,TechnicalSubject) values(121,'Java');
Query OK, 1 row affected (0.15 sec)
mysql> insert into selectDistinctDemo(StudentId,TechnicalSubject) values(121,'MongoDB');
Query OK, 1 row affected (0.16 sec)
mysql> insert into selectDistinctDemo(StudentId,TechnicalSubject) values(121,'MySQL');
Query OK, 1 row affected (0.15 sec)
mysql> insert into selectDistinctDemo(StudentId,TechnicalSubject) values(298,'Python');
Query OK, 1 row affected (0.11 sec)
mysql> insert into selectDistinctDemo(StudentId,TechnicalSubject) values(298,'SQL Server');
Query OK, 1 row affected (0.15 sec)
mysql> insert into selectDistinctDemo(StudentId,TechnicalSubject) values(397,'C#');
Query OK, 1 row affected (0.13 sec)
Display all records from the table using a select statement. The query is as follows
mysql> select *from selectDistinctDemo;
The following is the output
+--------------+-----------+------------------+
| InstructorId | StudentId | TechnicalSubject |
+--------------+-----------+------------------+
| 1            | 121       | Java             |
| 2            | 121       | MongoDB          |
| 3            | 121       | MySQL            |
| 4            | 298       | Python           |
| 5            | 298       | SQL Server       |
| 6            | 397       | C#               |
+--------------+-----------+------------------+
6 rows in set (0.00 sec)
Here is the query to use select statement DISTINCT for multiple columns
mysql> select InstructorId,StudentId,TechnicalSubject from selectDistinctDemo
-> where InstructorId IN
   -> (
   -> select max(InstructorId) from selectDistinctDemo
   -> group by StudentId
   -> )
-> order by InstructorId desc;
The following is the output
+--------------+-----------+------------------+
| InstructorId | StudentId | TechnicalSubject |
+--------------+-----------+------------------+
| 6            | 397       | C#               |
| 5            | 298       | SQL Server       |
| 3            | 121       | MySQL            |
+--------------+-----------+------------------+
3 rows in set (0.10 sec)
How to get Source Code of any website ? - GeeksforGeeks

11 Sep, 2021
A Website is defined as a collection of web pages. A website can be designed using HTML, CSS, Bootstrap, etc. HTML language decides what will appear on the webpage and CSS language depicts how it will appear. In other words, HTML place elements on the webpage, and CSS styles it. Bootstrap is pre-compiled CSS. Suppose we see a website eg. geeksforgeeks.org, and we want its source code then there are two ways to get it:
Using Inspect Element (Ctrl + Shift + I )
Using View Page Source ( Ctrl + U )
Let’s understand both methods one by one.
1. Using Inspect Element 
Below is the step-by-step implementation.
 
Step 1: Visit your desired website eg geeksforgeeks.org.
Step 2: Click on Inspect.
Step 3: You will get code on right-hand side.
Short Cut Key: 
(Ctrl + Shift + I )
 
2. Using Page Source:
Step 1: Visit your desired website eg geeksforgeeks.org.
Step 2: Right click on website and click on “View Page Source”.
Step 3: You will get source code as following. 
Shortcut Key
CTRL + U
Blogathon-2021
Blogathon
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Import JSON Data into SQL Server?
How to Create a Table With Multiple Foreign Keys in SQL?
How to Install Tkinter in Windows?
SQL Query to Convert Datetime to Date
SQL Query to Create Table With a Primary Key
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Get unique values from a list in Python

A list in python is a number of items placed with in [] which may or may not have same data types. It can also contain duplicates. In this article we will see how to extract only the unique values from a list.
In this approach we will first create a new empty list and then keep appending elements to this new list only if it is not already present in this new list. A for loop is used along with not in condition. It checks for the existence of the incoming element and it is appended only if it is not already present.
 Live Demo
def catch_unique(list_in):
   # intilize an empty list
   unq_list = []

   # Check for elements
   for x in list_in:
      # check if exists in unq_list
      if x not in unq_list:
         unq_list.append(x)
         # print list
   for x in unq_list:
      print(x)

Alist = ['Mon', 'Tue', 'Mon', 'wed', 40, 40]
print("Unique values from the list is")
catch_unique(Alist)
Running the above code gives us the following result −
Unique values from the list is
Mon
Tue
wed
40
A set only contains unique values. In this approach we convert the list to a set and then convert the set back to a list which holds all the unique elements.
 Live Demo
Alist = ['Mon', 'Tue', 'Mon', 'wed', 40, 40]
A_set = set(Alist)
New_List=list(A_set)
print("Unique values from the list is")
print(New_List)
Running the above code gives us the following result −
Unique values from the list is
[40, 'Tue', 'wed', 'Mon']
The numpy library has a function named unique which does the straight job of taking the list as input and giving the unique elements as a new list.
 Live Demo
import numpy as np

Alist = ['Mon', 'Tue', 'Mon', 'wed', 40, 40]
print("The unique values from list is: ")
print(np.unique(Alist))
Running the above code gives us the following result −
The unique values from list is:
['40' 'Mon' 'Tue' 'wed']
How to raise an error within MySQL?

MySQL has introduced signals similar to an exception in other languages. Let us first see the syntax of signal.
SIGNAL SQLSTATE ' PredefinedValueforSignalError' 
SET MESSAGE_TEXT = 'AnyMessageInformation';

Above, we have set our own error message text as well.
We will apply the above query to get an error message with the help of signals.
mysql > SIGNAL SQLSTATE '42927' SET MESSAGE_TEXT = 'Error Generated';
The following is the output of the above query.
ERROR 1644 (42927): Error Generated

In the above output, ‘42927’ is a SQLSTATE and ‘Error Generated’ is an error message, which we added.
How to write and render LaTeX math formulas on Medium | by Shuyi Yang | Towards Data Science

Every day, many practitioners share technical tutorials and findings by creating contents on Medium. However, posting articles with math formulas (eg. equations written in LaTeX) is a struggle since it is not supported on Medium. The most common solution to this limitation is transforming your formulas in images and add them to the article. You can take a screenshot to a rendered PDF file or use an online LaTeX editor like CodeCogs.
The image containing the formula attached to this article will be visualized as:
This is the most simple strategy to add math formulas when posting on Medium, but it is not flexible and it doesn’t work for inline equations.
A similar approach consists in creating Jupyter Notebook Markdown with math formulas and upload the notebook to GitHub Gist.
Then, just copy the Share link on Medium and the result is:
This is a math formula rendered in Jupyter Notebook:
Honestly, it is not very fancy.
Another way to add LaTeX formulas on Medium is using TeX to Unicode Chrome Addon to convert LaTeX code to Unicode. Once installed the addon, just select the LaTeX code you want to convert, for example
\alpha : \mathbb{R} \to \mathbb{R}
press Alt+W (you can change the shortcut in configuration) and you should get the unicode version of the equation:
α : R → R
This method doesn’t rely on images or embedded objects, it can work inline but it is also limited in characters and layout conversion. For example, the instance above
(\cos x + \sin x)^2 =    \underbrace{\cos^2 x + \sin^2 x}_{1} +    \overbrace{2 \sin x \cos x}^{\sin 2x}
is converted in
(\cos x + \sin x)2 =    \underbrace{\cos2 x + \sin2 x}1 +    \overbrace{2 \sin x \cos x}^{\sin 2x}
Not very useful when the formula is a little complex.
The last method to render mathematics formulas on Medium requires the installation of a Chome addon both on creator’s and reader’s browser. The addon is called Math Anywhere and it should render every MathML/LaTeX formulas on any page, also outside Medium. During the editing, you just need to put your formulas in appropriate delimiters like dollar symbols (the addon should be turned off) and during the reading, once activated the addon, the equations will be converted.
The formula
should be rendered correctly:
(cosx+sinx)2=cos2x+sin2x+2sinxcosx(cos⁡x+sin⁡x)2=cos2⁡x+sin2⁡x+2sin⁡xcos⁡x(\cos x + \sin x)^2=\cos^2 x + \sin^2 x+2 \sin x \cos x
and also inline formulas like α:R→Rα:R→R\alpha: \mathbb{R} \to \mathbb{R} should work. The drawback of this approach is that the reader is required to install the addon (only the first time). Of course, we can insert a kind reminder at the beginning of the post like this:
This post contains LaTeX formulas. To render them correctly, install Math Anywhere addon and activate it.
Do you know any other method to add math formulas on Medium? Let me know in comments!
How to write mathematics on MediumHow to use math formula on Medium posting
Contacts: LinkedIn | Twitter
Async and Await in Dart Programming

Async and Await keywords are used to provide a declarative way to define the asynchronous function and use their results.
The async keyword is used when we want to declare a function as asynchronous and the await keyword is used only on asynchronous functions.
void main() async { .. }
If the function has a declared return type, then update the type of the Future<T> to the return type.
Future<void> main() async { .. }
And finally, we make use of await keyword when we want to wait for the asynchronous function to finish.
await someAsynchronousFunction()
Let's consider an example where we are declaring the main function with the help of the async keyword and then wait for an asynchronous result using the await keyword.
Future<void> printDelayedMessage() {
   return Future.delayed(Duration(seconds: 4), () => print('Delayed Output.'));
}
void main() async {
await printDelayedMessage(); // will block the output until the asynchronous result
print('First output ...');
}
Delayed Output.
First output ...
Let's consider one more complete example where we make use of both the async and await keyword.
Consider the example shown below −
void main() async {
   var userEmailFuture = getUserEmail();
   // register callback
   await userEmailFuture.then((userEmail) => print(userEmail));
   print('Hello');
}
// method which computes a future
Future<String> getUserEmail() {
   // simulate a long network call
   return Future.delayed(Duration(seconds: 4), () => "mukul@tutorialspoint.com");
}
mukul@tutorialspoint.com
Hello
Python - Filter tuple with all same elements - GeeksforGeeks

07 Oct, 2021
Given List of tuples, filter tuples that have same values.
Input : test_list = [(5, 6, 5, 5), (6, 6, 6), (9, 10)] Output : [(6, 6, 6)] Explanation : 1 tuple with same elements.
Input : test_list = [(5, 6, 5, 5), (6, 5, 6), (9, 10)] Output : [] Explanation : No tuple with same elements. 
Method #1 : Using list comprehension + set() + len()
In this, we check for length of set converted tuple to be 1, if that checks out, tuple is added to result, else, omitted.
Python3
# Python3 code to demonstrate working of# Filter similar elements Tuples# Using list comprehension + set() + len() # initializing listtest_list = [(5, 6, 5, 5), (6, 6, 6), (1, 1), (9, 10)] # printing original listprint("The original list is : " + str(test_list)) # length is computed using len()res = [sub for sub in test_list if len(set(sub)) == 1]         # printing resultsprint("Filtered Tuples : " + str(res))
The original list is : [(5, 6, 5, 5), (6, 6, 6), (1, 1), (9, 10)]
Filtered Tuples : [(6, 6, 6), (1, 1)]
Method #2 : Using filter() + lambda + set() + len()
In this, we perform task of filtering using filter(), and single element logic is checked in lambda function using set() and len().
Python3
# Python3 code to demonstrate working of# Filter similar elements Tuples# Using filter() + lambda + set() + len() # initializing listtest_list = [(5, 6, 5, 5), (6, 6, 6), (1, 1), (9, 10)] # printing original listprint("The original list is : " + str(test_list)) # end result converted to list object# filter extracts req. tuplesres = list(filter(lambda sub : len(set(sub)) == 1, test_list))         # printing resultsprint("Filtered Tuples : " + str(res))
The original list is : [(5, 6, 5, 5), (6, 6, 6), (1, 1), (9, 10)]
Filtered Tuples : [(6, 6, 6), (1, 1)]
abhishek0719kadiyan
Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Python Dictionary
Enumerate() in Python
Read a file line by line in Python
Defaultdict in Python
Different ways to create Pandas Dataframe
Defaultdict in Python
Python program to convert a list to string
Python | Get dictionary keys as a list
Python | Split string into list of characters
Python | Convert a list to dictionary
Animate border-color property with CSS

To implement animation on the border-color property with CSS, you can try to run the following code
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <style>
         div {
            width: 500px;
            height: 300px;
            background: yellow;
            border: 10px solid gray;
            animation: myanim 3s infinite;
            background-position: bottom left;
            background-size: 50px;
         }
         @keyframes myanim {
            20% {
               border-color: red;
            }
         }
      </style>
   </head>
   <body>
      <h2>Performing Animation for color of border</h2>
      <div></div>
   </body>
</html>
AbstractList remove() Method in Java with Examples - GeeksforGeeks

26 Nov, 2018
The remove(int index) method of java.util.AbstractList class is used to remove an element from an abstract list from a specific position or index.
Syntax:
AbstractList.remove(int index)
Parameters: The parameter index is of integer data type and specifies the position of the element to be removed from the AbstractList.
Return Value: This method returns the element that has just been removed from the list.
Below programs illustrate the AbstractList.remove(int index) method:
Program 1:
// Java code to illustrate remove() method  import java.util.*;import java.util.LinkedList;  public class AbstractListDemo {    public static void main(String args[])    {          // Creating an empty AbstractList        AbstractList<String>            list = new LinkedList<String>();          // Using add() method to add elements in the list        list.add("Geeks");        list.add("for");        list.add("Geeks");        list.add("10");        list.add("20");          // Output the list        System.out.println("AbstractList: " + list);          // Remove the head using remove()        list.remove(3);          // Print the final list        System.out.println("Final AbstractList: " + list);    }}
AbstractList: [Geeks, for, Geeks, 10, 20]
Final AbstractList: [Geeks, for, Geeks, 20]

Program 2:
// Java code to illustrate remove() when position of// element is passed as parameter  import java.util.*;import java.util.LinkedList;  public class AbstractListDemo {    public static void main(String args[])    {          // Creating an empty AbstractList        AbstractList<String> list = new LinkedList<String>();          // Use add() method to add elements in the list        list.add("Geeks");        list.add("for");        list.add("Geeks");        list.add("10");        list.add("20");          // Output the list        System.out.println("AbstractList:" + list);          // Remove the head using remove()        list.remove(0);          // Print the final list        System.out.println("Final AbstractList:" + list);    }}
AbstractList:[Geeks, for, Geeks, 10, 20]
Final AbstractList:[for, Geeks, 10, 20]

Java - util package
Java-AbstractList
Java-Collections
Java-Functions
Java
Java
Java-Collections
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Arrays in Java
Split() String method in Java with examples
For-each loop in Java
Reverse a string in Java
Arrays.sort() in Java with examples
Object Oriented Programming (OOPs) Concept in Java
HashMap in Java with Examples
How to iterate any Map in Java
Interfaces in Java
Initialize an ArrayList in Java
How to define the breaks for a histogram using ggplot2 in R?

To manually define the breaks for a histogram using ggplot2, we can use breaks argument in the geom_histogram function. While creating the number of breaks we must be careful about the starting point and the difference between values for breaks. This will define the number of bars for histogram so it should be taken seriously and should be according to the distribution of the data.
Consider the below data frame −
 Live Demo
x<-rnorm(5000,525,30.24)
df<-data.frame(x)
head(df,20)
    x
1  524.0964
2  490.5952
3  518.6243
4  544.0018
5  480.8306
6  461.2975
7  464.0870
8  516.5240
9  517.3936
10 506.0277
11 480.3274
12 505.6415
13 440.9464
14 532.0064
15 482.7700
16 517.3608
17 536.5500
18 518.7121
19 598.5776
20 506.3834
Loading ggplot2 package and creating a histogram of x −
library(ggplot2)
ggplot(df,aes(x))+geom_histogram(bins=30)
Creating histogram of x with manually defined breaks −
ggplot(df,aes(x))+geom_histogram(bins=30,breaks=c(400,420,440,460,480,500,520,540,560))
MATLAB - GNU Octave Tutorial

GNU Octave is a high-level programming language like MATLAB and it is mostly compatible with MATLAB. It is also used for numerical computations.
Octave has the following common features with MATLAB −
matrices are fundamental data type
it has built-in support for complex numbers
it has built-in math functions and libraries
it supports user-defined functions
GNU Octave is also freely redistributable software. You may redistribute it and/or modify it under the terms of the GNU General Public License (GPL) as published by the Free Software Foundation.
Most MATLAB programs run in Octave, but some of the Octave programs may not run in MATLAB because, Octave allows some syntax that MATLAB does not.
For example, MATLAB supports single quotes only, but Octave supports both single and double quotes for defining strings. If you are looking for a tutorial on Octave, then  kindly go through this tutorial from beginning which covers both MATLAB as well as Octave.
Almost all the examples covered in this tutorial are compatible with MATLAB as well as Octave. Let's try following example in MATLAB and Octave which produces same result without any syntax changes −
This example creates a 3D surface map for the function g = xe-(x2 + y2). Create a script file and type the following code −
[x,y] = meshgrid(-2:.2:2);
g = x .* exp(-x.^2 - y.^2);
surf(x, y, g)
print -deps graph.eps
When you run the file, MATLAB displays the following 3-D map −
Though all the core functionality of MATLAB is available in Octave, there are some functionality for example, Differential & Integration Calculus, which does not match exactly in both the languages. This tutorial has tried to give both type of examples where they differed in their syntax.
Consider following example where MATLAB and Octave make use of different functions to get the area of a curve: f(x) = x2 cos(x) for −4 ≤ x ≤ 9. Following is MATLAB version of the code −
f = x^2*cos(x);
ezplot(f, [-4,9])
a = int(f, -4, 9)
disp('Area: '), disp(double(a));
When you run the file, MATLAB plots the graph −
The following result is displayed
a =
8*cos(4) + 18*cos(9) + 14*sin(4) + 79*sin(9)
 
Area: 
   0.3326

But to give area of the same curve in Octave, you will have to make use of symbolic package as follows −
pkg load symbolic
symbols

x = sym("x");
f = inline("x^2*cos(x)");

ezplot(f, [-4,9])
print -deps graph.eps

[a, ierror, nfneval] = quad(f, -4, 9);
display('Area: '), disp(double(a));

    30 Lectures 
     4 hours 

 Nouman Azam

    127 Lectures 
     12 hours 

 Nouman Azam

    17 Lectures 
     3 hours 

 Sanjeev

    37 Lectures 
     5 hours 

 TELCOMA Global

    22 Lectures 
     4 hours 

 TELCOMA Global

    18 Lectures 
     3 hours 

 Phinite Academy
 Print
 Add Notes
 Bookmark this page
HTML canvas strokeRect() Method

The strokeRect() method of the HTML canvas is used to create a rectangle on a web page. The <canvas> element allows you to draw graphics on a web page using JavaScript. Every canvas has two elements that describes the height and width of the canvas i.e. height and width respectively.
Following is the syntax −
context.strokeRect(p,q,width,height);
Above,
p − The x-coordinate of the upper-left corner of the rectangle
q − The y-coordinate of the upper-left corner of the rectangle
width − Width of the rectangle
height − Height of the rectangle
Let us now see an example to implement the strokeStyle property of canvas −
 Live Demo
<!DOCTYPE html>
<html>
<body>
<canvas id="newCanvas" width="550" height="400" style="border −2px solid orange;"></canvas>
<script>
   var c = document.getElementById("newCanvas");
   var ctx = c.getContext("2d");
   ctx.strokeRect(120, 120, 220, 120);
</script>
</body>
</html>
How to write Java program to add two matrices

To add two matrices −
Create an empty matrix
At each position in the new matrix, assign the sum of the values in the same position from the given two matrices i.e. if A[i][j] and B[i][j] are the two given matrices then, the value of c[i][j] should be A[i][j] + B[i][j]
Live Demo
public class AddingTwoMatrices{
   public static void main(String args[]){
      int a[][]={{1,2,3},{4,5,6},{7,8,9}};
      int b[][]={{1,1,1},{1,1,1},{1,1,1}};
      int c[][]=new int[3][3];

      for(int i = 0;i<3;i++){
         for(int j = 0;j<3;j++){
            c[i][j] = a[i][j]+b[i][j];
            System.out.print(c[i][j]+" ");
         }
         System.out.println();
      }
   }
}
2 3 4
5 6 7
8 9 10
How to implement the Fibonacci series using lambda expression in Java?

The Fibonacci is a sequence of numbers in which every number after the first two numbers is the sum of the two preceding numbers like 0, 1, 1, 2, 3, 5, 8, 13, 21 and so on. The sequence of Fibonacci numbers defined by using "F(n)=F(n-1)+F(n-2)".
In the below example, we can implement the Fibonacci series with the help of Stream API and lambda expression. The Stream.iterate() method returns an infinite sequential ordered stream produced by iterative application of a function to an initial element seed, producing a stream consisting of seed, f(seed), f(f(seed)), etc.
import java.util.List;
import java.util.stream.*;

public class FibonacciTest {
   public static void main(String args[]) {
      System.out.println(FibonacciTest.generate(10));
   }
   public static List generate(int series) {
      return Stream.iterate(new int[]{0, 1}, s -> new int[]{s[1], s[0] + s[1]}) // lambda expression
                  .limit(series)
     .map(n -> n[0])
     .collect(Collectors.toList());
   }
}
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
Google Charts - Stacked Column Chart

Following is an example of a stacked column chart. We've already seen the configuration used to draw this chart in Google Charts Configuration Syntax chapter. So, let's see the complete example.
We've used isStacked configuration to show stacked chart.
// Set chart options
var options = {
   isStacked: true
};
googlecharts_column_stacked.htm
<html>
   <head>
      <title>Google Charts Tutorial</title>
      <script type = "text/javascript" src = "https://www.gstatic.com/charts/loader.js">
      </script>
      <script type = "text/javascript">
         google.charts.load('current', {packages: ['corechart']});     
      </script>
   </head>
   
   <body>
      <div id = "container" style = "width: 550px; height: 400px; margin: 0 auto">
      </div>
      <script language = "JavaScript">
         function drawChart() {
            // Define the chart to be drawn.
            var data = google.visualization.arrayToDataTable([
               ['Year', 'Asia', 'Europe'],
               ['2012',  900,      390],
               ['2013',  1000,      400],
               ['2014',  1170,      440],
               ['2015',  1250,       480],
               ['2016',  1530,      540]
            ]);

            var options = {title: 'Population (in millions)', isStacked:true};  

            // Instantiate and draw the chart.
            var chart = new google.visualization.ColumnChart(document.getElementById('container'));
            chart.draw(data, options);
         }
         google.charts.setOnLoadCallback(drawChart);
      </script>
   </body>
</html>
Verify the result.
 Print
 Add Notes
 Bookmark this page
How Region of Interest (ROI) works in OpenCV using C++?

To separate a particular portion from the image, we have to locate the area first. Then we
have to copy that area from the main image to another matrix. This is how the ROI in
OpenCV works.
In this example, two matrices have been declared at the beginning. After that, an image named 'image_name.jpg' has been loaded into the 'image1' matrix. The next line 'image2=image1 (Rect(100, 100, 120, 120));' requires special attention. This line is cropping out the defined region of the image and storing it in the 'image2' matrix.
The figure shows what we have done here with the 'Rect(100,100,120,120)' code. The
basic form of this line of code is 'Rect(x, y,x1,y1)'. Here x and y defines the rectangle's starting point and x1 and y1represents the endpoint of the rectangle. By changing these values, we can change the size of the rectangle.
The following program demonstrates the working of Region of Interest in OpenCV:
#include
#include
#include
using namespace std;
using namespace cv;
int main() {
   Mat image1; //Declaring a matrix named 'image1'//
   Mat image2; //Declaring a matrix named 'image2'//
   image1 = imread("RGB.png"); //Loading an image name 'image_name.png into image1 matrix//
   image2 = image1(Rect(100, 100, 120, 120)); //imposing a rectangle on
   image1//
   namedWindow("Image_Window1"); //Declaring an window to show actual image//
   namedWindow("Image_Window2"); //Declaring an window to show ROI//
   imshow("Image_Window1", image1); //Showing actual image//
   imshow("Image_Window2", image2);
   waitKey(0);
   return 0;
}