code-rag-bench/online-tutorials huggingface dataset:
Number of rows and columns in a Matrix that contain repeated values - GeeksforGeeks

17 May, 2020
Given a N x N square matrix arr[][] which contains only integers between 1 and N, the task is to compute the number of rows and the number of columns in the matrix that contain repeated values.
Examples:
Input: N = 4, arr[][] = {{1, 2, 3, 4}, {2, 1, 4, 3}, {3, 4, 1, 2}, {4, 3, 2, 1}}Output: 0 0Explanation:None of the rows or columns contain repeated values.
Input: N = 4, arr[][]= {{2, 2, 2, 2}, {2, 3, 2, 3}, {2, 2, 2, 3}, {2, 2, 2, 2}}Output: 4 4Explanation:In every column and every row of the square matrix, the values are repeated.Therefore, the total count is 4 for both rows and columns.
Approach: The idea is to use the NumPy library.
Make a NumPy array of every row and every column in the square matrix.
Find the length of the unique elements.
If the length is equal to N then, there are no repeated values present in that particular row or column.
Below is the implementation of the above approach:
# Python program to count the number of # rows and columns in a square matrix # that contain repeated values  import numpy as np  # Function to count the number of rows# and number of columns that contain # repeated values in a square matrix.def repeated_val(N, matrix):    column = 0    row = 0    for i in range (N):      # For every row, an array is formed.     # The length of the unique elements     # is calculated, which if not equal     # to 'N' then the row has repeated values.        if (len(np.unique(np.array(matrix[i])))!= N):            row += 1       # For every column, an array is formed.    # The length of the unique elements     # is calculated, which if not equal     # to N then the column has repeated values.    for j in range (N):        if (len(np.unique(np.array([m[j] for m in matrix])))!= N):            column += 1                  # Returning the count of     # rows and columns    return row, column    # Driver codeif __name__ == '__main__':            N = 3    matrix = [ [ 2, 1, 3 ], [ 1, 3, 2 ], [ 1, 2, 3 ] ]      print(repeated_val(N, matrix))  
(0, 2)

Python numpy-Matrix Function
Matrix
Matrix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Efficiently compute sums of diagonals of a matrix
Flood fill Algorithm - how to implement fill() in paint?
Check for possible path in 2D matrix
Zigzag (or diagonal) traversal of Matrix
Mathematics | L U Decomposition of a System of Linear Equations
Python program to add two Matrices
Unique paths in a Grid with Obstacles
A Boolean Matrix Question
Shortest distance between two cells in a matrix or grid
Breadth First Traversal ( BFS ) on a 2D array
Python String splitlines() Method - GeeksforGeeks

19 Aug, 2021
Python String splitlines() method is used to split the lines at line boundaries. The function returns a list of lines in the string, including the line break(optional).
Syntax: 
string.splitlines([keepends])
Parameters:
keepends (optional): When set to True line breaks are included in the resulting list. This can be a number, specifying the position of line break or, can be any Unicode characters, like “\n”, “\r”, “\r\n”, etc as boundaries for strings.
Return Value: 
Returns a list of the lines in the string, breaking at line boundaries.
splitlines() splits on the following line boundaries:
Representation
Description
Python3
# Python code to illustrate splitlines()string = "Welcome everyone to\rthe world of Geeks\nGeeksforGeeks"  # No parameters has been passedprint (string.splitlines( ))  # A specified number is passedprint (string.splitlines(0))  # True has been passed print (string.splitlines(True))
Output: 
['Welcome everyone to', 'the world of Geeks', 'GeeksforGeeks']
['Welcome everyone to', 'the world of Geeks', 'GeeksforGeeks']
['Welcome everyone to\r', 'the world of Geeks\n', 'GeeksforGeeks']
Python3
# Python code to illustrate splitlines()string = "Cat\nBat\nSat\nMat\nXat\nEat"  # No parameters has been passedprint (string.splitlines( ))  # splitlines() in one lineprint('India\nJapan\nUSA\nUK\nCanada\n'.splitlines())
Output: 
['Cat', 'Bat', 'Sat', 'Mat', 'Xat', 'Eat']
['India', 'Japan', 'USA', 'UK', 'Canada']
In this code, we will understand how to use the concept of splitlines() to calculate the length of each word in a string. 
Python3
# Python code to get length of each wordsdef Cal_len(string):          # Using splitlines() divide into a list    li = string.splitlines()    print (li)          # Calculate length of each word    l = [len(element) for element in li]    return l  # Driver Code    string = "Welcome\rto\rGeeksforGeeks"print(Cal_len(string))
Output: 
['Welcome', 'to', 'GeeksforGeeks']
[7, 2, 13]
AmiyaRanjanRout
Python-Built-in-functions
python-string
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Read JSON file using Python
Adding new column to existing DataFrame in Pandas
Python map() function
How to get column names in Pandas dataframe
Python Dictionary
Read a file line by line in Python
Taking input in Python
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
SQL UPDATE Statement

The UPDATE statement is used to modify the existing records in a table.
Note: Be careful when updating records in a table! Notice the 
WHERE clause in the UPDATE statement.
The WHERE clause specifies which record(s) that should be updated. If 
you omit the WHERE clause, all records in the table will be updated!
Below is a selection from the "Customers" table in the Northwind sample 
database:
The following SQL statement updates the first customer (CustomerID = 1) with a new contact person and 
a new city.
The selection from the "Customers" table will now look like this:
It is the WHERE clause that determines how many records will be updated.
The following SQL statement will 
update the ContactName to "Juan" for all records where country is "Mexico":
The selection from the "Customers" table will now look like this:
Be careful when updating records. If you omit the 
WHERE clause, ALL records 
will be updated!
The selection from the "Customers" table will now look like this:
Update the City column of all records in the Customers table.
 Customers
 City = 'Oslo';

Start the Exercise
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 create random sample based on group columns of a data.table in R?

Random sampling helps us to reduce the biasedness in the analysis. If we have data in groups then we might want to find a random sample based on groups. For example, if we have a data frame with a group variable and each group contains ten values then we might want to create a random sample where we will have two values randomly selected from each group. This can be done by using sample function inside .SD
Consider the below data.table −
library(data.table) Group<-rep(c("A","B","C","D","E"),times=4) Percentage<-sample(1:100,20) dt1<-data.table(Group,Percentage) dt1
  Group Percentage
1:    A    97
2:    B    68
3:    C    19
4:    D    32
5:    E    98
6:    A    48
7:    B    94
8:    C    54
9:    D    7
10:   E    76
11:   A    10
12:   B    31
13:   C    59
14:   D    84
15:   E    41
16:   A    99
17:   B    1
18:   C    72
19:   D    42
20:   E    17
Creating a random sample of size 2 from each group −
dt1[,.SD[sample(.N, min(2,.N))],by=Group]
   Group Percentage
1:    A    48
2:    A    99
3:    B    94
4:    B    31
5:    C    54
6:    C    59
7:    D    42
8:    D    84
9:    E    98
10:   E    76
Let’s have a look at another example −
Class<-rep(c("First","Second","Third","Fourth"),times=10)
Experience<-sample(1:5,40,replace=TRUE)
dt2<-data.table(Class,Experience)
head(dt2,10)
   Class Experience
1: First    4
2: Second   2
3: Third    4
4: Fourth   2
5: First    4  
6: Second   5
7: Third    3
8: Fourth   5
9: First    3
10: Second  5
tail(dt2,10)
   Class Experience
1: Third    4
2: Fourth   2
3: First    5
4: Second   2
5: Third    1
6: Fourth   4
7: First    5
8: Second   2
9: Third    4
10: Fourth  4
dt2[,.SD[sample(.N, min(5,.N))],by=Class]
  Class Experience
1: First    3
2: First    3
3: First    4
4: First    5
5: First    5
6: Second   5
7: Second   2
8: Second   5
9: Second   2
10: Second  1
11: Third   3
12: Third   1
13: Third   4
14: Third   3
15: Third   4
16: Fourth  2
17: Fourth  5
18: Fourth  2
19: Fourth  4
20: Fourth  2
Tryit Editor v3.6 - Show Python

f = open("demofile2.txt", "a")
f.write("Now the file has more content!")
f.close()
​
#open and read the file after the appending:
f = open("demofile2.txt", "r")
How to install Python modules in Cygwin?

While installing cygwin, make sure you install the python/python-setuptools from the list. This will install "easy_install" package. Once you have easy_install, you can use it to install pip. Type the following command:
$ easy_install-a.b pip
You must replace a.b with your python version which can be 2.7 or 3.4 or whatever else. Now you can use pip to install the module you want. For example, To install the latest version of "SomeProject":
$ pip install 'SomeProject'
To install a specific version:
$ pip install 'SomeProject==1.4'
To install greater than or equal to one version and less than another:
$ pip install 'SomeProject>=1,<2'
pthread_equal() in C

The pthread_equal() function is used to check whether two threads are equal or not. This returns 0 or non-zero value. For equal threads, it will return non-zero, otherwise it returns 0. The syntax of this function is like below −
int pthread_equal (pthread_t th1, pthread_t th2);
Now let us see the pthread_equal() in action. In the first case, we will check the self-thread to check the result.
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <pthread.h>
pthread_t sample_thread;
void* my_thread_function(void* p) {
   if (pthread_equal(sample_thread, pthread_self())) { //pthread_self will return current thread id
      printf("Threads are equal\n");
   } else {
      printf("Threads are not equal\n");
   }
}
main() {
   pthread_t th1;
   sample_thread = th1; //assign the thread th1 to another thread object
   pthread_create(&th1, NULL, my_thread_function, NULL); //create a thread using my thread function
   pthread_join(th1, NULL); //wait for joining the thread with the main thread
}
Threads are equal
Now we will see the result, if we compare between two different threads.
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <pthread.h>
pthread_t sample_thread;
void* my_thread_function1(void* ptr) {
   sample_thread = pthread_self(); //assign the id of the thread 1
}
void* my_thread_function2(void* p) {
   if (pthread_equal(sample_thread, pthread_self())) { //pthread_self will return current thread id
      printf("Threads are equal\n");
   } else {
      printf("Threads are not equal\n");
   }
}

main() {
   pthread_t th1, th2;
   pthread_create(&th1, NULL, my_thread_function1, NULL); //create a thread using my_thread_function1
   pthread_create(&th1, NULL, my_thread_function2, NULL); //create a thread using my_thread_function2
   pthread_join(th1, NULL); //wait for joining the thread with the main thread
   pthread_join(th2, NULL);
}
Threads are not equal
VBScript - Error Handling

There are three types of errors in programming: (a) Syntax Errors, (b) Runtime Errors, and (c) Logical Errors.
Syntax errors, also called parsing errors, occur at interpretation time for VBScript. For example, the following line causes a syntax error because it is missing a closing parenthesis −
<script type = "text/vbscript">

   dim x,y
   x = "Tutorialspoint"
   y = Ucase(x

</script>

Runtime errors, also called exceptions, occur during execution, after interpretation. For example, the following line causes a runtime error because here syntax is correct but at runtime it is trying to call fnmultiply, which is a non-existing function −
<script type = "text/vbscript">
   Dim x,y
   x = 10
   y = 20
   z = fnadd(x,y)
   a = fnmultiply(x,y)
   
   Function fnadd(x,y)
      fnadd = x+y
   End Function

</script>
Logic errors can be the most difficult type of errors to track down. These errors are not the result of a syntax or runtime error. Instead, they occur when you make a mistake in the logic that drives your script and you do not get the result you expected. You cannot catch those errors, because it depends on your business requirement what type of logic you want to put in your program. For example, dividing a number by zero or a script that is written which enters into infinite loop.
AAssume if we have a runtime error, then the execution stops by displaying the error message. As a developer, if we want to capture the error, then Error Object is used.
In the below example, Err.Number gives the error number and Err.Description gives error description.
<script type = "text/vbscript">
  
  Err.Raise 6     ' Raise an overflow error.
  MsgBox "Error # " & CStr(Err.Number) & " " & Err.Description
  Err.Clear       ' Clear the error.

</script>

    63 Lectures 
     4 hours 

 Frahaan Hussain
 Print
 Add Notes
 Bookmark this page
Integers have sum of squared divisors as perfect square in JavaScript

We are required to write a JavaScript function that takes in a range specified by an array of two numbers m and n.
Our function is supposed to find all integers between m and n (m and n integers such as 1 <= m <= n) such that the sum of their squared divisors is itself a square.
It should return an array of subarrays. The subarrays will have two elements: first the number the squared divisors of which is a square and then the sum of the squared divisors.
Following is the code −
 Live Demo
const range = [1, 500];
const listSquared = ([m, n]) => {
   const res = [];
   for (let i = m; i <= n; ++i) {
      let sum = getDivisors(i).reduce((sum, n) => sum + n * n, 0);
      let ok = Number.isInteger(Math.sqrt(sum));
      if (ok) {
         res.push([i, sum]);
      }
   }
   return res;
}
function getDivisors (n) {
   const divisors = [];
   for (let i = 1; i <= n / 2; ++i) {
      if (n % i) {
         continue;
      }
      divisors.push(i);
   }
   return divisors.concat([n]);
}
console.log(listSquared(range));
[ [ 1, 1 ], [ 42, 2500 ], [ 246, 84100 ], [ 287, 84100 ] ]
Dot notation vs Bracket notation in JavaScript

The dot notation and bracket notation both are used to access the object properties in JavaScript. The dot notation is used mostly as it is easier to read and comprehend and also
less verbose. The main difference between dot notation and bracket notation is that the bracket notation allows us to access object properties using variable.
Following is the code for bracket notation vs dot notation in JavaScript −
 Live Demo
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
   body {
      font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
   }
   .result {
      font-size: 20px;
      font-weight: 500;
      color: blueviolet;
   }
</style>
</head>
<body>
<h1>Dot notation vs Bracket notation in JavaScript</h1>
<div class="result"></div>
<button class="Btn">CLICK HERE</button>
<h3>Click on the above button to access the student1 object properties using dot and bracket notation</h3>
<script>
   let resEle = document.querySelector(".result");
   let BtnEle = document.querySelector(".Btn");
   function Student(name, age, standard) {
      this.name = name;
      this.age = age;
      this.standard = standard;
   }
   let student1 = new Student("Rohan", 18, 12);
   BtnEle.addEventListener("click", () => {
      let str = "name",
      str1 = "age",
      str2 = "standard";
      resEle.innerHTML ="Using dot notation <br>student1.name = " + student1.name +       "<br>";
      resEle.innerHTML += "student1.age = " + student1.age + "<br>";
      resEle.innerHTML +=
      "student1.standard = " + student1.standard + "<br><br>";
      resEle.innerHTML +=" Using bracket notation <br>student1[str] = " +
      student1[str] +"<br>";
      resEle.innerHTML += "student1[str1] = " + student1[str1] + "<br>";
      resEle.innerHTML += "student1[str2] = " + student1[str2] + "<br>";
   });
</script>
</body>
</html>
On clicking the ‘CLICK HERE’ button −
fmt.print() Function in Golang With Examples - GeeksforGeeks

05 May, 2020
In Go language, fmt package implements formatted I/O with functions analogous to C’s printf() and scanf() function. The fmt.print() function in Go language formats using the default formats for its operands and writes to standard output. Here Spaces are added between operands when any string is not used as a parameter. Moreover, this function is defined under the fmt package. Here, you need to import the “fmt” package in order to use these functions.
Syntax:
func Print(a ...interface{}) (n int, err error)

Here, “a ...interface{}” containing some strings and declared constant variables.
Return Value: It returns the number of bytes written and any write error encountered.
Example 1:
// Golang program to illustrate the usage of// fmt.print() function  // Including the main packagepackage main  // Importing fmtimport (    "fmt")  // Calling mainfunc main() {      // Declaring some const variables    const name, dept = "GeeksforGeeks", "CS"      // Calling print() function    fmt.Print(name, " is a ", dept, " portal.\n")      // It is conventional not to worry about any    // error returned by Print.  }
Output:
GeeksforGeeks is a CS portal.

Example 2:
// Golang program to illustrate the usage of// fmt.print() function  // Including the main packagepackage main  // Importing fmtimport (    "fmt")  // Calling mainfunc main() {      // Declaring some const variables    const str1, str2, str3 = "a", "b", "c"      // Calling print() function    fmt.Print(str1, str2, str3, "\n")      // It is conventional not to worry about any    // error returned by Print.  }
Output:
abc

In the above code, the constant variables used are strings hence spaces are not added in between two strings shown above in the output.
Example 3:
// Golang program to illustrate the usage of// fmt.print() function  // Including the main packagepackage main  // Importing fmtimport (    "fmt")  // Calling mainfunc main() {      // Declaring some const variables    const num1, num2, num3 = 5, 15, 15      // Calling print() function    fmt.Print(num1, num2, num3, "\n")      // It is conventional not to worry about any    // error returned by Print.  }
Output:
5 15 15

In the above code, the constant variables used are numbers hence spaces are added in between two numbers shown above in the output.
Golang-fmt
Go Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Parse JSON in Golang?
Defer Keyword in Golang
Loops in Go Language
time.Parse() Function in Golang With Examples
Anonymous function in Go Language
Time Durations in Golang
Structures in Golang
Strings in Golang
How to iterate over an Array using for loop in Golang?
Rune in Golang
How to add a JSON string to an existing JSON file in Java?

A Gson is a json library for Java and it can be used to generate a JSON. In the initial step, we can read a JSON file and parsing to a Java object then need to typecast the Java object to a JSonObject and parsing to a JsonArray. Then iterating this JSON array to print the JsonElement. We can create a JsonWriter class to write a JSON encoded value to a stream, one token at a time. Finally, a new JSON string can be written to an existing json file. 
import java.io.*;
import java.util.*;
import com.google.gson.*;
import com.google.gson.stream.*;
import com.google.gson.annotations.*;
public class JSONFilewriteTest {
   public static String nameRead;
   public static void main(String[] args) {
      try {
         JsonParser parser = new JsonParser();
         Object obj = parser.parse(new FileReader("employee1.json"));
         JsonObject jsonObject = (JsonObject) obj;
         System.out.println("The values of employee1.json file:\n" + jsonObject);
         JsonArray msg = (JsonArray)jsonObject.get("emps");
         Iterator<JsonElement> iterator = msg.iterator();
         while(iterator.hasNext()) {
            nameRead = iterator.next().toString();
            System.out.println(nameRead);
         }
         Name name = new Name();
         name.setName("Vamsi");
         Gson gson = new Gson();
         String json = gson.toJson(name);

         FileWriter file = new FileWriter("employee1.json", false);
         JsonWriter jw = new JsonWriter(file);
         iterator = msg.iterator();
         Employees emps = new Employees();
         while(iterator.hasNext()) {
            emps.addEmployee(gson.fromJson(iterator.next().toString(), Name.class));
         }
         emps.addEmployee(name);
         gson.toJson(emps, Employees.class, jw);
         file.close();
         System.out.println("data added to an existing employee1.json file successfully");
      } catch(Exception e) {
         e.printStackTrace();
      }
   }
}
// Name class
class Name {
   @Expose
   private String name;
   public String getName() {
      return name;
   }
   public void setName(String name) {
      this.name = name;
   }
}
// Employees class
class Employees {
   @Expose
   List<Name> emps = new ArrayList<>();
   public List<Name> getEmployees() {
      return emps;
   }
   public void addEmployee(Name name) {
      this.emps.add(name);
   }
}
The values of employee1.json file:
{"emps":[{"name":"Adithya"},{"name":"Jai"}]}
{"name":"Adithya"}
{"name":"Jai"}
data added to an existing employee1.json file successfully
C# Program to Check the Length of Courses is More than 2 Characters Using LINQ - GeeksforGeeks

28 Nov, 2021
Given an array that contains a list of different courses like “DSA”, “OS”, “JavaScript”, etc., now our task is to check the length of all the courses present in the given array is more than 2 characters or not with the help of LINQ. So to do our task we use the All() method of LINQ. This method returns true if all the elements present in the given sequence satisfy the specified condition. Otherwise, it will return false.
Syntax:
array_name.All(iterator => iterator.Length > 2)
Where array_name is the input array and Length is the function used to check the length of each course.
Example:
Input  : { "cse", "it", "ft", "bio-tech", "chemical" }
Output : False

Input  : { "cse", "ece", "bio-tech", "chemical" }
Output : True
C#
// C# program to find the check the length of// courses is more than 2 characters Using LINQusing System;using System.Linq;  class GFG{  static void Main(string[] args){          // Create 5 courses    string[] course1 = { "cse", "ece", "bio-tech", "chemical", "civil" };    string[] course2 = { "DSA", "JS", "Kotlin", "C", "React" };          // Checking the length of all courses     // is greater than 2 or not    bool result1 = course1.All(display => display.Length > 2);    bool result2 = course2.All(display => display.Length > 2);          Console.WriteLine("Is the length of the courses " +                      "is greater than 2 in course1?: " + result1);                            Console.WriteLine("Is the length of the courses " +                      "is greater than 2 in course2?: " + result2);}}
Output:
Is the length of the courses is greater than 2 in course1?: True
Is the length of the courses is greater than 2 in course2?: False
Picked
C#
C# Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Destructors in C#
Extension Method in C#
HashSet in C# with Examples
Top 50 C# Interview Questions & Answers
C# | How to insert an element in an Array?
Convert String to Character Array in C#
Socket Programming in C#
Program to Print a New Line in C#
Getting a Month Name Using Month Number in C#
Program to find absolute value of a given number
Node.js – Chalk Module

The chalk module is a third-party library that can be used for styling of texts. It allows the users to create their own themes in a Node.js project.
This module helps the users to customize the response messages with
different colors as per the preferences.
This module helps the users to customize the response messages with
different colors as per the preferences.
It also improves the readability by providing colors and makes it easier
to detect warnings and errors.
It also improves the readability by providing colors and makes it easier
to detect warnings and errors.
npm install chalk
Create a file with the name "chalk.js" and copy the following code. After creating the file, use the command "node chalk.js" to run this code as shown in the example below −
// Importing the chalk module
const chalk=require("chalk");

// Coloring different text messages
console.log(chalk.green("Welcome to Tutorials Point"))
console.log(chalk.red.underline("Welcome to Tutorials Point"))
console.log(chalk.red.underline.bold("Welcome to Tutorials Point"))
Let's take another example
// Importing the chalk module
const chalk=require("chalk");

// Coloring different text messages
const welcome=chalk.green;
const warning=chalk.red;

console.log(welcome("Welcome to Tutorials Point"))
console.log(welcome("Success !!!"))
console.log(warning("Error - An unknown error occurred !"))
console.log(warning("Warning - Exception occurred !"))
Python | Get match indices - GeeksforGeeks

19 Mar, 2019
Sometimes, while working with lists we need to handle two lists and search for the matches, and return just the indices of the match. Querying the whole list for this process is not feasible when the size of master list is very large, hence having just the match indices helps in this cause. Let’s discuss certain ways in which this can be achieved.
Method #1 : Using list comprehension + index()This problem can potentially be solved using the index function of python to get the wanted indices and list comprehension can be used to extend this to the whole string.
# Python3 code to demonstrate# Get match indices# using list comprehension and index()  # initializing liststest_list1 = [5, 4, 1, 3, 2]test_list2 = [1, 2]  # printing original listsprint("The original list 1 : " + str(test_list1))print("The original list 2 : " + str(test_list2))  # using list comprehension and index()# Get match indicesres = [test_list1.index(i) for i in test_list2]  # print resultprint("The Match indices list is : " + str(res))
The original list 1 : [5, 4, 1, 3, 2]
The original list 2 : [1, 2]
The Match indices list is : [2, 4]

 
Method #2 : Using enumerate() + list comprehensionThe enumerate function can be used to produce the key value pair for the list being it’s index and value and we can store them using list comprehension.
# Python3 code to demonstrate# Get match indices# using list comprehension and enumerate()  # initializing liststest_list1 = [5, 4, 1, 3, 2]test_list2 = [1, 2]  # printing original listsprint("The original list 1 : " + str(test_list1))print("The original list 2 : " + str(test_list2))  # using list comprehension and enumerate()# Get match indicesres = [key for key, val in enumerate(test_list1)                      if val in set(test_list2)]  # print resultprint("The Match indices list is : " + str(res))
The original list 1 : [5, 4, 1, 3, 2]
The original list 2 : [1, 2]
The Match indices list is : [2, 4]

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
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Iterate over a list in Python
Python program to convert a list to string
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Split string into list of characters
Python | Convert a list to dictionary
How to debug lambda expressions in Java?

The lambda expression composed of two parts, one is an argument and another one is code or expression. These two parts have separated by an arrow operator "->". We can use different IDE's like Netbeans, IntelliJ, and Eclipse to debug the lambda expressions in Java. It is always possible to create multi-line lambda expressions and use print statements to display the values of a variable. The debugger can also provide additional information about the state of a java program. It allows some variables to be modified while the debugger is executing.
(parameters) -> expression
  or
(parameters) -> { statements; }
import java.util.*;

public class LambdaDebugTest {
   public static void main(String args[]) {
      List<Strng> list = Arrays.asList("jai", "adithya", "raja");
      list.stream()
          .map(s -> s + " - " + s.toUpperCase())  // Convert to upper case using lambda
          .forEach(s -> System.out.println(s));   // To print 's' using lambda
   }
}
jai - JAI
adithya - ADITHYA
raja - RAJA
Apply Glowing Effect to the Image using HTML and CSS - GeeksforGeeks

16 Feb, 2021
While surfing most of the websites you have seen some special effects which can be seen on various images while putting your cursor over them. So, in this article we are going to implement the same. We can use such images as a card for our website. 
In this article, you’re going to learn how to apply glowing effect to a particular image, when you put cursor over it you will see that effect. We will implement it  by using HTML and CSS.  A sample video is provided to understand more clearly what you are going to develop in this article.
HTML
<!-- Give a suitable heading using h1 tag--><h1 style="color: green; text-align: center;">  GeeksForGeeks Glowling Card</h1><div class="container">  <!-- Set a image a background named gfg.jpg present in images folder -->  <img class="GFG" src="images/gfg.jpg"       alt="GeeksForGeeks" /></div>
Now, we will apply some CSS properties to decorate the image and also fix it’s position on webpage. The key is to use the box-shadow property of CSS to glow the image when user put cursor on image. Here is the internal CSS code given to you for help. 
HTML
<style>  .GFG{      width:200px ;    height:250px;    margin-left: 550px;    border-radius: 10%;}.GFG:hover{    color: #111;     background: greenyellow;     box-shadow: 0 0 100px greenyellow; }</style>
 This example uses box-shadow property to apply glowing effect to the image. You can change the background glowing color according to you.
HTML
<!DOCTYPE html><html>  <head>      <style>        .GFG {            width: 200px;            height: 250px;            margin-left: 550px;            border-radius: 10%;        }                  .GFG:hover {            color: #111;            background: greenyellow;            box-shadow: 0 0 100px greenyellow;        }    </style></head>  <body>      <!-- Give a suitable heading using h1 tag-->    <h1 style="color: green; text-align: center;">        GeeksForGeeks Glowling Card    </h1>    <div class="container">        <!-- Set a image a background named         gfg.jpg present in images folder -->        <img class="GFG" src="images/gfg.jpg"             alt="GeeksForGeeks" />    </div>  </body>  </html>
that’s all for this article. Here is the output video of above code.
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
CSS-Questions
HTML-Questions
Technical Scripter 2020
CSS
HTML
Technical Scripter
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to set space between the flexbox ?
Design a web page using HTML and CSS
Form validation using jQuery
How to style a checkbox using CSS?
Search Bar using HTML, CSS and JavaScript
How to set the default value for an HTML <select> element ?
Hide or show elements in HTML using display property
How to set input type date in dd-mm-yyyy format using HTML ?
REST API (Introduction)
How to Insert Form Data into Database using PHP ?
How to create a triangle using Python for loop?

There are multiple variations of generating triangle using numbers in Python. Let's look at the 2 simplest forms:
for i in range(5):
   for j in range(i + 1):
      print(j + 1, end="")
   print("")
This will give the output:
1
12
123
1234
12345
You can also print numbers continuously using:
start = 1
for i in range(5):
   for j in range(i + 1):
      print(start, end=" ")
      start += 1
   print("")
This will give the output:
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
You can also print these numbers in reverse using:
start = 15
for i in range(5):
   for j in range(i + 1):
      print(start, end=" ")
      start -= 1
   print("")
This will give the output:
15
14 13
12 11 10
9 8 7 6
5 4 3 2 1
How do you check if a widget has a focus in Tkinter?

Let us assume that we want to check if a particular widget has a focused set or not. The only way to check the widget focus is to use the utility method focus_get(). It returns the object containing the widget’s information which is currently focused on, during the program’s execution. We will use the focus_get() method to find the active widget during our program’s execution.
In this example, we have created an Entry widget that will get its focus when we press the <Enter> key. The focus_get() method will return the current widget’s information which is active.
#Import the Tkinter library
from tkinter import *
#Create an instance of Tkinter frame
win= Tk()
#Define the geometry
win.geometry("750x250")
#Define Event handlers for different Operations
def event_show(event):
   label.config(text="Hello World")
   e.focus_set()
   print("focus is:" ,e.focus_get)
#Create a Label
label= Label(win, text="Press Enter",font=('Helvetica 15 underline'))
label.pack()
#Create an entry widget
e= Entry(win, width= 25)
e.pack(pady=20)
#Bind the function
win.bind('<Return>',lambda event:event_show(event))
win.mainloop()
Running the above code will display a window that contains a button. When we press the <Enter> key, it will print the output containing the widget’s information which is currently focused on the window pane.
Now, when we press <Enter>, it will show the output in the shell as,
focus is : <bound method Misc.focus_get of <tkinter.Entry object .!entry >>
Cucumber - Scenarios

Scenario is one of the core Gherkin structures. Every scenario starts with the keyword “Scenario:” (or localized one) and is followed by an optional scenario title. Each feature can have one or more scenarios and every scenario consists of one or more steps. A very simple example of scenario can be −
Scenario − Verify Help Functionality.
Given user navigates to Facebook.
When the user clicks on Help, then the Help page opens.
Consider a case, where we need to execute a test scenario more than once. Suppose, we need to make sure that the login functionality is working for all types of subscription holders. That requires execution of login functionality scenario multiple times. Copy paste the same steps in order to just re-execute the code, does not seem to be a smart idea. For this, Gherkin provides one more structure, which is scenario outline.
Scenario outline is similar to scenario structure; the only difference is the provision of multiple inputs. As you can see in the following example, the test case remains the same and non-repeatable. At the bottom we have provided multiple input values for the variables “Username” and “Password”. While running the actual test, Cucumber will replace the variable with input values provided and it will execute the test. Once pass-1 has been executed, the test will rerun for second iteration with another input value. Such variable or placeholders can be represented with ”<>” while mentioning with gherkin statements.
Scenario Outline − Login functionality for a social networking site. The given user navigates to Facebook.
When the user logs in using the Username as "<username>" and the Password as "<password>", then login should be successful.
| username | password  | 
| user1    | password1 | 
| user2    | password2 |

There are a few tips and tricks to smartly define the Cucumber scenarios.
Each step should be clearly defined, so that it does not create any confusion for the reader.
Each step should be clearly defined, so that it does not create any confusion for the reader.
Do not repeat the test scenario, if needed use scenario outline to implement repetition.
Do not repeat the test scenario, if needed use scenario outline to implement repetition.
Develop a test step in a way that, it can be used within multiple scenarios and scenario outlines.
Develop a test step in a way that, it can be used within multiple scenarios and scenario outlines.
As far as possible, keep each step completely independent. For example: “Given the user is logged in”. This can be divided into two steps

Given the user enters the user name.
Clicks on login.

As far as possible, keep each step completely independent. For example: “Given the user is logged in”. This can be divided into two steps
Given the user enters the user name.
Clicks on login.
 Print
 Add Notes
 Bookmark this page
XSLT <value-of>

<xsl:value-of> tag puts the value of the selected node as per XPath expression, as text.
Following is the syntax declaration of <xsl:value-of> element.
<xsl:value-of
   select = Expression
   disable-output-escaping = "yes" | "no" >
</xsl:value-of>

Select
XPath Expression to be evaluated in current context.
disable-outputescaping
Default-"no". If "yes", output text will not escape xml characters from text.
Parent elements
xsl:attribute, xsl:comment, xsl:copy, xsl:element, xsl:fallback, xsl:for-each, xsl:if, xsl:message, xsl:otherwise, xsl:param, xsl:processing instruction, xsl:template, xsl:variable, xsl:when, xsl:with-param, output elements
Child elements
None
This example creates a table of <student> element with its attribute rollno and its child <firstname>, <lastname>, <nickname>, and <marks>.
students.xml
<?xml version = "1.0"?> 
<?xml-stylesheet type = "text/xsl" href = "students.xsl"?> 
<class> 
   <student rollno = "393"> 
      <firstname>Dinkar</firstname> 
      <lastname>Kad</lastname> 
      <nickname>Dinkar</nickname> 
      <marks>85</marks> 
   </student> 
   <student rollno = "493"> 
      <firstname>Vaneet</firstname> 
      <lastname>Gupta</lastname> 
      <nickname>Vinni</nickname> 
      <marks>95</marks> 
   </student> 
   <student rollno = "593"> 
      <firstname>Jasvir</firstname> 
      <lastname>Singh</lastname> 
      <nickname>Jazz</nickname> 
      <marks>90</marks> 
   </student> 
</class>
students.xsl
<?xml version = "1.0" encoding = "UTF-8"?> 
   <xsl:stylesheet version = "1.0" 
      xmlns:xsl = "http://www.w3.org/1999/XSL/Transform">
		
   <xsl:template match = "/"> 
      <html> 
         <body> 
            <h2>Students</h2> 
            <table border = "1"> 
               <tr bgcolor = "#9acd32"> 
                  <th>Roll No</th> 
                  <th>First Name</th> 
                  <th>Last Name</th> 
                  <th>Nick Name</th> 
                  <th>Marks</th> 
               </tr> 
					
               <xsl:for-each select = "class/student"> 
                  <tr> 
                     <td><xsl:value-of select = "@rollno"/></td> 
                     <td><xsl:value-of select = "firstname"/></td> 
                     <td><xsl:value-of select = "lastname"/></td> 
                     <td><xsl:value-of select = "nickname"/></td> 
                     <td><xsl:value-of select = "marks"/></td> 
                  </tr> 
               </xsl:for-each> 
					
            </table> 
         </body> 
      </html> 
   </xsl:template>  
</xsl:stylesheet>
 Print
 Add Notes
 Bookmark this page
C library function - abs()

The C library function int abs(int x) returns the absolute value of int x.
Following is the declaration for abs() function.
int abs(int x)
x − This is the integral value.
x − This is the integral value.
This function returns the absolute value of x.
The following example shows the usage of abs() function.
#include <stdio.h>
#include <stdlib.h>

int main () {
   int a, b;

   a = abs(5);
   printf("value of a = %d\n", a);

   b = abs(-10);
   printf("value of b = %d\n", b);
   
   return(0);
}
Let us compile and run the above program, this will produce the following result −
value of a = 5
value of b = 10


    12 Lectures 
     2 hours 

 Nishant Malik

    12 Lectures 
     2.5 hours 

 Nishant Malik

    48 Lectures 
     6.5 hours 

 Asif Hussain

    12 Lectures 
     2 hours 

 Richa Maheshwari

    20 Lectures 
     3.5 hours 

 Vandana Annavaram

    44 Lectures 
     1 hours 

 Amit Diwan
 Print
 Add Notes
 Bookmark this page
Generating random number list in Python

There is a need to generate random numbers when studying a model or behavior of a program for different range of values. Python can generate such random numbers by using the random module. In the below examples we will first see how to generate a single random number and then extend it to generate a list of random numbers.
The random() method in random module generates a float number between 0 and 1.
import random
n = random.random()
print(n)
Running the above code gives us the following result −
0.2112200
The randint() method generates a integer between a given range of numbers.
import random
n = random.randint(0,22)
print(n)
Running the above code gives us the following result −
2
We can use the above randint() method along with a for loop to generate a list of numbers. We first create an empty list and then append the random numbers generated to the empty list one by one.
import random
randomlist = []
for i in range(0,5):
n = random.randint(1,30)
randomlist.append(n)
print(randomlist)
Running the above code gives us the following result −
[10, 5, 21, 1, 17]
We can also use the sample() method available in random module to directly generate a list of random numbers.Here we specify a range and give how many random numbers we need to generate.
import random
#Generate 5 random numbers between 10 and 30
randomlist = random.sample(range(10, 30), 5)
print(randomlist)
Running the above code gives us the following result −
[16, 19, 13, 18, 15]
Spring Boot - Actuator

Spring Boot Actuator provides secured endpoints for monitoring and managing your Spring Boot application. By default, all actuator endpoints are secured. In this chapter, you will learn in detail about how to enable Spring Boot actuator to your application.
To enable Spring Boot actuator endpoints to your Spring Boot application, we need to add the Spring Boot Starter actuator dependency in our build configuration file.
Maven users can add the below dependency in your pom.xml file.
<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
Gradle users can add the below dependency in your build.gradle file.
compile group: 'org.springframework.boot', name: 'spring-boot-starter-actuator'

In the application.properties file, we need to disable the security for actuator endpoints.
management.security.enabled = false

YAML file users can add the following property in your application.yml file.
management:
   security:
      enabled: false
If you want to use the separate port number for accessing the Spring boot actutator endpoints add the management port number in application.properties file.
management.port = 9000

YAML file users can add the following property in your application.yml file.
management:
   port: 9000

Now, you can create an executable JAR file, and run the Spring Boot application by using the following Maven or Gradle commands.
For Maven, you can use the following command −
mvn clean install

After “BUILD SUCCESS”, you can find the JAR file under the target directory.
For Gradle, you can use the following command −
gradle clean build

After “BUILD SUCCESSFUL”, you can find the JAR file under the build/libs directory.
Now, you can run the JAR file by using the following command −
java –jar <JARFILE> 

Now, the application has started on the Tomcat port 8080. Note that if you specified the management port number, then same application is running on two different port numbers.
Some important Spring Boot Actuator endpoints are given below. You can enter them in your web browser and monitor your application behavior.

    102 Lectures 
     8 hours 

 Karthikeya T

    39 Lectures 
     5 hours 

 Chaand Sheikh

    73 Lectures 
     5.5 hours 

 Senol Atac

    62 Lectures 
     4.5 hours 

 Senol Atac

    67 Lectures 
     4.5 hours 

 Senol Atac

    69 Lectures 
     5 hours 

 Senol Atac
 Print
 Add Notes
 Bookmark this page
How to validate whether a string is a number in C#?

A string having number can be validated using int.TryParse or int.Parse.
Int.Parse throws an exception if it cannot parse the string to an integer, whereas Int.TryParse returns a bool indicating whether it succeeded. Also, Int.TryParse has an out parameter which has the value of the parsed string.
 Live Demo
using System;
namespace DemoApplication {
   class Program {
      static void Main(string[] args) {
         string numberString = "123";
         int number = 0;
         if(int.TryParse(numberString, out number)) {
            Console.WriteLine($"Try Parse Interger Number: {number}");
         }
         Console.WriteLine($"Parse Interger Number: {int.Parse(numberString)}");
         Console.ReadLine();
      }
   }
}
The output of the code is
Try Parse Interger Number: 123
Parse Interger Number: 123
In the above example since int.Tryparse returns a boolean value along with the parsed string in the out parameter, the if condition returns true. Also, int.Parse return the integer value as the string contains a proper number.
 Live Demo
using System;
namespace DemoApplication {
   class Program {
      static void Main(string[] args) {
         string numberString = "A123";
         int number = 0;
         if(int.TryParse(numberString, out number)) {
            Console.WriteLine($"Try Parse Interger Number: {number}");
         }
         elsem{
            Console.WriteLine($"String doesnot have a proper number");
         }
         Console.ReadLine();
      }
   }
}
The output of the above code is
String doesnot have a proper number
As the string does not have a proper number, the int.Tryparse will return false and the else part of the code is executed. In the same case, int.Parse will throw exception like below.
using System;
namespace DemoApplication {
   class Program {
      static void Main(string[] args) {
         string numberString = "A123";
         Console.WriteLine($"Parse Interger Number: {int.Parse(numberString)}");
         //Exception: Input string was not in correct format.
      }
   }
}
Python 3 - Tuple max() Method

The max() method returns the elements from the tuple with maximum value.
Following is the syntax for max() method −
max(tuple)

tuple − This is a tuple from which max valued element to be returned.
This method returns the elements from the tuple with maximum value.
The following example shows the usage of max() method.
#!/usr/bin/python3

tuple1, tuple2 = ('maths', 'che', 'phy', 'bio'), (456, 700, 200)
print ("Max value element : ", max(tuple1))
print ("Max value element : ", max(tuple2))
When we run above program, it produces the following result −
Max value element :  phy
Max value element :  700


    187 Lectures 
     17.5 hours 

 Malhar Lathkar

    55 Lectures 
     8 hours 

 Arnab Chakraborty

    136 Lectures 
     11 hours 

 In28Minutes Official

    75 Lectures 
     13 hours 

 Eduonix Learning Solutions

    70 Lectures 
     8.5 hours 

 Lets Kode It

    63 Lectures 
     6 hours 

 Abhilash Nelson
 Print
 Add Notes
 Bookmark this page