code-rag-bench/online-tutorials huggingface dataset:
How to find the column and row indices of values in a matrix using which function in R?

To find the row and column indices of values in a matrix, we cannot simply use which function because it returns the index based on sequence of the numbers in the matrix. For example, if we have a matrix M as below −
1 2 3
4 1 6
7 8 1
Now if we try to find the index using which(M==1) then it will return 1 5 9
Because 1 is placed at 1, 5 and 9.
Hence, we need to use arr.ind = TRUE so that the matrix can be read as an array by which function.
Consider the below matrix −
 Live Demo
> M<-matrix(sample(1:10,100,replace=TRUE),nrow=10)
> M
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,] 9 5 4 5 2 7 6 7 1 1
[2,] 2 6 5 4 2 4 6 4 4 8
[3,] 10 4 9 10 8 4 4 4 5 5
[4,] 8 2 5 10 4 1 3 10 5 8
[5,] 10 1 8 9 10 10 3 8 6 10
[6,] 4 3 4 8 8 4 9 1 9 7
[7,] 5 8 1 5 5 9 9 10 8 7
[8,] 9 9 9 5 5 9 7 2 5 2
[9,] 5 6 5 6 8 9 9 10 1 9
[10,] 7 1 1 6 8 9 5 1 2 4
Finding the index for 1 to 10 values in the matrix M −
> which(M==1,arr.ind=TRUE)
row col
[1,] 5 2
[2,] 10 2
[3,] 7 3
[4,] 10 3
[5,] 4 6
[6,] 6 8
[7,] 10 8
[8,] 1 9
[9,] 9 9
[10,] 1 10
> which(M==2,arr.ind=TRUE)
row col
[1,] 2 1
[2,] 4 2
[3,] 1 5
[4,] 2 5
[5,] 8 8
[6,] 10 9
[7,] 8 10
> which(M==3,arr.ind=TRUE)
row col
[1,] 6 2
[2,] 4 7
[3,] 5 7
> which(M==4,arr.ind=TRUE)
row col
[1,] 6 1
[2,] 3 2
[3,] 1 3
[4,] 6 3
[5,] 2 4
[6,] 4 5
[7,] 2 6
[8,] 3 6
[9,] 6 6
[10,] 3 7
[11,] 2 8
[12,] 3 8
[13,] 2 9
[14,] 10 10
> which(M==5,arr.ind=TRUE)
row col
[1,] 7 1
[2,] 9 1
[3,] 1 2
[4,] 2 3
[5,] 4 3
[6,] 9 3
[7,] 1 4
[8,] 7 4
[9,] 8 4
[10,] 7 5
[11,] 8 5
[12,] 10 7
[13,] 3 9
[14,] 4 9
[15,] 8 9
[16,] 3 10
> which(M==6,arr.ind=TRUE)
row col
[1,] 2 2
[2,] 9 2
[3,] 9 4
[4,] 10 4
[5,] 1 7
[6,] 2 7
[7,] 5 9
> which(M==7,arr.ind=TRUE)
row col
[1,] 10 1
[2,] 1 6
[3,] 8 7
[4,] 1 8
[5,] 6 10
[6,] 7 10
> which(M==8,arr.ind=TRUE)
row col
[1,] 4 1
[2,] 7 2
[3,] 5 3
[4,] 6 4
[5,] 3 5
[6,] 6 5
[7,] 9 5
[8,] 10 5
[9,] 5 8
[10,] 7 9
[11,] 2 10
[12,] 4 10
> which(M==9,arr.ind=TRUE)
row col
[1,] 1 1
[2,] 8 1
[3,] 8 2
[4,] 3 3
[5,] 8 3
[6,] 5 4
[7,] 7 6
[8,] 8 6
[9,] 9 6
[10,] 10 6
[11,] 6 7
[12,] 7 7
[13,] 9 7
[14,] 6 9
[15,] 9 10
> which(M==10,arr.ind=TRUE)
row col
[1,] 3 1
[2,] 5 1
[3,] 3 4
[4,] 4 4
[5,] 5 5
[6,] 5 6
[7,] 4 8
[8,] 7 8
[9,] 9 8
[10,] 5 10
Difference between vi Editor and cat Command - GeeksforGeeks

22 Sep, 2020
Both vi editor and cat command are used to input contents in a file.
1. vi Editor :vi editor stands for the visual editor which is an intelligent editing tool in UNIX Operating System used for reading, creating files, editing them, and more. It is the default editing tool in UNIX.
Command to open a particular file :
vi filename
It has three modes :
Command Mode : The vi editor always opens in this mode. It is where all the commands are accepted.Insert/Input Mode : The file is opened in the input mode and the contents of the file are written or edited here.Execution Mode : The execution mode is invoked by the ‘:’ command from the command mode. Then the commands are read into the command mode.
Command Mode : The vi editor always opens in this mode. It is where all the commands are accepted.
Insert/Input Mode : The file is opened in the input mode and the contents of the file are written or edited here.
Execution Mode : The execution mode is invoked by the ‘:’ command from the command mode. Then the commands are read into the command mode.
The way to access each mode from one another has been explained in the image below.
Way to access each mode from one another
2. cat Command :The cat command stands for concatenate. It is also used to create new files, read and update already existing files. They are also used for joining multiple files together or copying a file’s content to another one.
Examples of cat Command :
To create and add some content to a file.cat > newfile
This is a new file that is not empty.
cat > newfile
This is a new file that is not empty.
To read or display the contents of an existing file.cat newfile
cat newfile
To merge two files into a new one.cat file1 file2 >> file3There are a lot of other commands using cat. However, there are certain limitations to both of their usage.
cat file1 file2 >> file3
There are a lot of other commands using cat. However, there are certain limitations to both of their usage.
Difference between vi Editor and cat Command :
Difference Between
Linux-Unix
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
Difference Between Method Overloading and Method Overriding in Java
Difference between Internal and External fragmentation
Difference between Prim's and Kruskal's algorithm for MST
Differences and Applications of List, Tuple, Set and Dictionary in Python
Sed Command in Linux/Unix with examples
AWK command in Unix/Linux with examples
grep command in Unix/Linux
cut command in Linux with examples
TCP Server-Client implementation in C
HTML <dl> Tag

The dl element in HTML is used to define description list. In HTML5, the <dl> is used to define a description list, whereas the <dl> in HTML4 defined definition list.
Let us now see an example to implement the <dl> tag −
 Live Demo
<!DOCTYPE html>
<html>
<body>
<h2>Sports</h2>
<dl>
   <dt>Football</dt>
      <dd>It is played by 250 million players in over 200 countries.</dd>
   <dt>Cricket</dt>
      <dd>It is a bat-and-ball game played between two teams of eleven players on a field.</dd>
   <dt>Hockey</dt>
      <dd>There are many types of hockey such as bandy, field hockey, and ice hockey.</dd>
   <dt>Golf</dt>
      <dd>It is a club-and-ball sport in which players use various clubs to hit balls into a series of holes on a course in as few strokes as possible.</dd>
</dl>
</body>
</html>
In the above example, we have set the <dl> to set the description list −
<dl>
   <dt>Football</dt>
      <dd>It is played by 250 million players in over 200 countries.</dd>
   <dt>Cricket</dt>
      <dd>It is a bat-and-ball game played between two teams of eleven players on a field.</dd>
   <dt>Hockey</dt>
      <dd>There are many types of hockey such as bandy, field hockey, and ice hockey.</dd>
   <dt>Golf</dt>
      <dd>It is a club-and-ball sport in which players use various clubs to hit balls into a series of holes on a course in as few strokes as possible.</dd>
</dl>
The <dt> element above defines a term in the definition list, whereas the <dd> also defines a term, but you can add links, images, line breaks inside the <dd>.
SAP Web Dynpro - URL of an Application

In a Web Dynpro application, the URL is automatically generated. You can find the URL of an application in the Properties tab. The URL structure can be of two types −
SAP namespace −
SAP namespace −
<schema>://<host>.<domain>.<extension>:<port>/sap/bc/webdynpro/<namespace>/<application name>

Custom namespace −
<schema>://<host>.<domain>.<extension>:<port>/abc/klm/xyz/<namespace>/webdynpro/<application name>
<schema>://<host>.<domain>.<extension>:<port>/namespace>/webdynpro/<application name>

where,
<schema> − Defines the protocol to access application http/https
<host> − Defines the name of the application server
<domain><extension> − Defines several hosts under a common name
<port> − It can be omitted if the standard port 80 (http) or 443 (https) is used
You should specify Fully Qualified Domain Name (FQDN) in Web Dynpro application URL.
Application 1 http://xyz.sap.corp:1080/sap/bc/webdynpro/sap/myFirstApp/
Application 2 http://xyz.sap.corp:1080/sap/bc/webdynpro/sap/ mySecondApp/
To check fully qualified domain name, go to Web Dynpro explorer in the ABAP development environment use T-code − SE80 and select the Web Dynpro application from the navigation tree for your Web Dynpro component/interface and check the URL in the administration data. You also need to check the path details in the field URL. It should contain the full domain and host name.
Full Domain name should be used for the following reasons −
You need a domain to set cookies.
You should use FQDN for certificate and SSL protocol in https mode.
For portal integration, domain relation code is used.

    25 Lectures 
     6 hours 

 Sanjo Thomas

    26 Lectures 
     2 hours 

 Neha Gupta

    30 Lectures 
     2.5 hours 

 Sumit Agarwal

    30 Lectures 
     4 hours 

 Sumit Agarwal

    14 Lectures 
     1.5 hours 

 Neha Malik

    13 Lectures 
     1.5 hours 

 Neha Malik
 Print
 Add Notes
 Bookmark this page
CICS - STARTBR

STARTBR is known as start browse. The STARTBR command gets the process started. It tells the CICS from where to start reading the file.
The FILE and RIDFLD parameters are the same as in a READ command.
The FILE and RIDFLD parameters are the same as in a READ command.
The options allowed are GTEQ and EQUAL.
The options allowed are GTEQ and EQUAL.
UPDATE is not allowed and file browsing is strictly a read-only operation.
UPDATE is not allowed and file browsing is strictly a read-only operation.
Following is the syntax of STARTBR command −
EXEC CICS STARTBR
   FILE ('name')
   RIDFLD (data-value)
   KEYLENGTH(data-value)
   GTEQ/EQUAL/GENERIC
END-EXEC.

 Print
 Add Notes
 Bookmark this page
HTML5 - email

It accepts only email value. This type is used for input fields that should contain an e-mail address. If you try to submit a simple text, it forces to enter only email address in email@example.com format.
<!DOCTYPE HTML>

<html>
   <body>

      <form action = "/cgi-bin/html5.cgi" method = "get">
         Enter email : <input type = "email" name = "newinput" />
         <input type = "submit" value = "submit" />
      </form>

   </body>
</html>

    19 Lectures 
     2 hours 

 Anadi Sharma

    16 Lectures 
     1.5 hours 

 Anadi Sharma

    18 Lectures 
     1.5 hours 

 Frahaan Hussain

    57 Lectures 
     5.5 hours 

 DigiFisk (Programming Is Fun)

    54 Lectures 
     6 hours 

 DigiFisk (Programming Is Fun)

    45 Lectures 
     5.5 hours 

 DigiFisk (Programming Is Fun)
 Print
 Add Notes
 Bookmark this page
Assembly - SCAS Instruction

The SCAS instruction is used for searching a particular character or set of characters in a string. The data item to be searched should be in AL (for SCASB), AX (for SCASW) or EAX (for SCASD) registers. The string to be searched should be in memory and pointed by the ES:DI (or EDI) register.
Look at the following program to understand the concept −
section .text
   global _start        ;must be declared for using gcc
	
_start:	                ;tell linker entry point

   mov ecx,len
   mov edi,my_string
   mov al , 'e'
   cld
   repne scasb
   je found ; when found
   ; If not not then the following code
	
   mov eax,4
   mov ebx,1
   mov ecx,msg_notfound
   mov edx,len_notfound
   int 80h
   jmp exit
	
found:
   mov eax,4
   mov ebx,1
   mov ecx,msg_found
   mov edx,len_found
   int 80h
	
exit:
   mov eax,1
   mov ebx,0
   int 80h
	
section .data
my_string db 'hello world', 0
len equ $-my_string  

msg_found db 'found!', 0xa
len_found equ $-msg_found

msg_notfound db 'not found!'
len_notfound equ $-msg_notfound   
When the above code is compiled and executed, it produces the following result −
found!


    46 Lectures 
     2 hours 

 Frahaan Hussain

    23 Lectures 
     12 hours 

 Uplatz
 Print
 Add Notes
 Bookmark this page
Write a program to print message without using println() method in java?

The println() method of the System class accepts aStringas parameter an prints the given String on the console.
public class PrintData {
   public static void main(String args[]) {
      System.out.println("Hello how are you");
   }
}
Hello how are you
In addition to this you can print data on the console in several other ways, some of them are −
Using output stream classes, you can write dat on the specified destination. You can print data on the screen/console by passing the standard output Stream object System.out as source to them.
import java.io.IOException;
import java.io.OutputStreamWriter;
public class PrintData {
   public static void main(String args[]) throws IOException {
      //Creating a OutputStreamWriter object
      OutputStreamWriter streamWriter = new OutputStreamWriter(System.out);
      streamWriter.write("Hello welcome to Tutorialspoint . . . . .");
      streamWriter.flush();
   }
}
Hello welcome to Tutorialspoint . . . . .
The PrintStream class of Java provides two more methods to print data on the console (in addition to the println() method).
The print() − This method accepts a single value of any of the primitive or reference data types as a parameter and prints the given value on the console.
(double value or, a float value or, an int value or, a long value or, a char value, a boolean value or, a char array, a String or, an array or, an object)
The printf() − This method accepts a local variable, a String value representing the required format, objects of variable number representing the arguments and, prints data as instructed.
public class PrintData {
   public static void main(String args[]) {
      System.out.print("Hello how are you");
      System.out.printf(" "+"welcome to Tutorialspoint");
   }
}
Hello how are you Welcome to Tutorialspoint
The Logger class of the log4j library provides methods to print data on the console.
<dependencies>
   <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-api</artifactId>
      <version>2.4</version>
   </dependency>
   <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-core</artifactId>
      <version>2.4</version>
   </dependency>
</dependencies>
import java.util.logging.Logger;
public class PrintData{
   static Logger log = Logger.getLogger(PrintData.class.getName());
   public static void main(String[] args){
      log.info("Hello how are you Welcome to Tutorialspoint");
   }
}
Jun 28, 2019 2:49:25 PM Mypackage.PrintData main
INFO: Hello how are you Welcome to Tutorialspoint
What is the AddRange method in C# lists?

AddRange method in lists adds an entire collection of elements. Let us see an example −
Firstly, set a list in C# and add elements −
List<int> list = new List<int>();
list.Add(100);
list.Add(200);
list.Add(300);
list.Add(400);
Now set an array of elements to be added to the list −
// array of 4 elements
int[] arr = new int[4];
arr[0] = 500;
arr[1] = 600;
arr[2] = 700;
arr[3] = 800;
Use the AddRange() method add the entire collection of elements in the list −
list.AddRange(arr);
Now let us see the complete code and display the list −
using System;
using System.Collections.Generic;

class Demo {
   static void Main() {
      List<int> list = new List<int>();
      list.Add(100);
      list.Add(200);
      list.Add(300);
      list.Add(400);

      // array of 4 elements
      int[] arr = new int[4];
      arr[0] = 500;
      arr[1] = 600;
      arr[2] = 700;
      arr[3] = 800;
   
      list.AddRange(arr);

      foreach (int val in list) {
         Console.WriteLine(val);
      }
   }
}
List Data Type in Python

Lists are the most versatile of Python's compound data types. A list contains items separated by commas and enclosed within square brackets ([]). To some extent, lists are similar to arrays in C. One difference between them is that all the items belonging to a list can be of different data type.
The values stored in a list can be accessed using the slice operator ([ ] and [:]) with indexes starting at 0 in the beginning of the list and working their way to end -1. The plus (+) sign is the list concatenation operator, and the asterisk (*) is the repetition operator. For example −
#!/usr/bin/python
list = [ 'abcd', 786 , 2.23, 'john', 70.2 ]
tinylist = [123, 'john']
print list # Prints complete list
print list[0] # Prints first element of the list
print list[1:3] # Prints elements starting from 2nd till 3rd
print list[2:] # Prints elements starting from 3rd element
print tinylist * 2 # Prints list two times
print list + tinylist # Prints concatenated lists
This produce the following result −
['abcd', 786, 2.23, 'john', 70.2]
abcd
[786, 2.23]
[2.23, 'john', 70.2]
[123, 'john', 123, 'john']
['abcd', 786, 2.23, 'john', 70.2, 123, 'john']
JCL Online Quiz

Following quiz provides Multiple Choice Questions (MCQs) related to JCL Framework. You will have to read all the given answers and click over the correct answer. If you are not sure about the answer then you can check the answer using Show Answer button. You can use Next Quiz button to check new set of questions in the quiz.
Q 1 - What does JCL stands for?
A - Job Cobol Language
B - Job Communication Language
C - Job Control Language
D - None of these
JCL stands for Job Control Language which provides the specifications necessary to process a job.
Q 2 - What operation is performed by JOB statement?
A - Job Identification
B - Execution of program
C - Includes name of the dataset to operate
D - None of these
Specifies the information required for SPOOLing of the job such as job id, priority of execution, user-id to be notified upon completion of the job.
Q 3 - What will happen to Step2 if Step1 executes with RC=0?
//TXXXXXX JOB (XXXXX), ’XXXX’
//STEP1 EXEC PGM = PR1
//STEP2 EXEC PGM = PR2, COND = (0, EQ, STEP1)
A - Step2 will be bypassed 
B - Step2 will be executed
C - None of these
It will read the condition on step2 as 0 EQUAL 0, which is true, so step will be bypassed. If condition is true then the step will be bypassed.
Q 4 - If COND parameter is coded on both JOB and EXEC statement, then the condition on JOB is checked before checking the condition on EXEC statement. State whether true or false?
A - True
B - False
This statement is correct.
Q 5 - How you will define a temporary dataset in JCL?
A - DSN = &&TEMP with DSN parameters
B - DSN = temp-file-name with DSN parameters
C - DSN = temp-file-name with out DSN parameters
D - DSN = &&TEMP with out DSN parameters
A temporary dataset is the one that is created and deleted within a job and is declared as DSN=&&TEMP. Do not mention the DSN parameters with this.
Q 6 - Which utility is used to update PDS?
A - IEBGENER
B - IEBCOPY
C - IEBCOMPR
D - IEBUPDTE
IEBUPDTE is used to update PDS
Q 7 - A CHKPT is the parameter coded for multi-volume QSAM datasets in a DD statement. When a CHKPT is coded as CHKPT=EOV, a checkpoint is written to the dataset specified in the SYSCKEOV statement at the end of each volume of the input/output multi-volume dataset. State whether true or false?
A - False
B - True
This is self explanatory.
Q 8 - In-stream procedure is coded as a separate member of a PDS. State whether true or false?
A - True
B - False
In-stream procedure is coded inside the JCL itself. So this statement is incorrect.
Q 9 - If we have created a (+1) generation dataset in the first step of a job then how we can reference it in later steps of the same job for input?
A - As (+2) generation
B - As (+0) generation
C - As (+1) generation
D - As (-2) generation
As we have created it in the same JCL, then we use (+1) as its reference.
Q 10 - What units are used for allocation of output dataset?
A - KB
B - Bytes
C - Cylinders, Tracks & Blocks
D - MB
In mainframes, we use cylinders, tracks and blocks for allocation of datasets.

    12 Lectures 
     2 hours 

 Nishant Malik

    73 Lectures 
     4.5 hours 

 Topictrick Education
 Print
 Add Notes
 Bookmark this page
How to use a StringVar object in an Entry widget in Tkinter?

A StringVar object in Tkinter can help manage the value of a widget such as an Entry widget or a Label widget. You can assign a StringVar object to the textvariable of a widget. For example,
data = ['Car', 'Bus', 'Truck', 'Bike', 'Airplane']

var = StringVar(win)

my_spinbox = Spinbox(win, values=data, textvariable=var)
Here, we created a list of strings followed by a StringVar object "var". Next, we assigned var to the textvariable of a Spinbox widget. To get the current value of the Spinbox, you can use var.get().
The following example demonstrates how you can use a StringVar object in an Entry widget.
from tkinter import *

top = Tk()
top.geometry("700x300")
top.title("StringVar Object in Entry Widget")

var = StringVar(top)

def submit():
   Label2.config(text="Your User ID is: " +var.get(), font=("Calibri,15,Bold"))

Label1 = Label(top, text='Your User ID:')
Label1.grid(column=0, row=0, padx=(20,20), pady=(20,20))

myEntry = Entry(top, textvariable=var)
myEntry.grid(column=1, row=0, padx=(20,20), pady=(20,20))

myButton = Button(top, text="Submit", command=submit)
myButton.grid(column=2, row=0)

Label2 = Label(top, font="Calibri,10")
Label2.grid(column=0, row=1, columnspan=3)

top.mainloop()
It will produce the following output −
How to add the tag of Azure VM using PowerShell?

To add the tag to the Azure VM we need to use the Update-AZTag command. This command will merge the new tag to the existing tag(s) of the VM. If you are planning to add the entirely new VM tag, you can use the New-AZTag command. Once you use the New-AZTag command, other tags will be deleted for that particular VM and the New tag will be created so pls be careful with that command.
We have the VM called TestMachine2k12 on Azure and there are few existing tags applied to the VM as shown below.
Get-AzVM -Name TestMachine2k12 | Select -ExpandProperty Tags
We need to add the new tag called Patching_Day and its value should be Sunday. We will first create a tag that is a Hashtable with its name and associated value as shown below.
$tag = @{'Patching_Day' = 'Monday'}
Once the tag is created, we can use the Update-AZTag command. This command uses the resource ID. So we need VM resource ID to apply the tag.
PS C:\> $vm = Get-AzVM -Name TestMachine2k12
PS C:\> Update-AzTag -Tag $tag -ResourceId $vm.Id -Operation Merge -Verbose
Here, we are retrieving the VM information first to get the resource ID of it and you might have noticed that we are using Merge operation here. When you check the applied tag, it should show.
If you have multiple tags for the single VM then, you can add the additional tag to the TAG hashtable by a semicolon as shown below.
$tag = @{'Patching_Day' = 'Sunday'; 'App_Owner'='James Clean'}
You can use the Update-AZTag command to update the tag. When you have more than one VM to apply the same tag then you can use the foreach loop for it and if you have different tags for the different VMs then we can use the CSV file which has VM and associated tags and then foreach loop to apply the tag.
How to Set Border of Tkinter Label Widget? - GeeksforGeeks

11 Dec, 2020
The task here is to draft a python program using Tkinter module to set borders of a label widget. A Tkinter label Widget is an Area that displays text or images. We can update this text at any point in time. 
Import module
Create a window
Set a label widget with required attributes for border
Place this widget on the window created
Syntax: Label ( master, option, ... )
Parameters:
Master: This represents the parent window.
Option: There are so many options for labels like bg, fg, font, bd, etc
Now to set the border of the label we need to add two options to the label property: 
borderwidth: It will represent the size of the border around the label. By default, borderwidth is 2 pixels. “bd” can also be used as a shorthand for borderwidth.
relief: It will Specify the look of a decorative border around the label. By default, it is FLAT. Other than Flat there are many more acceptable values like raised, ridge, solid, etc.
Given below is the implementation to set border and edit it as required.
Program 1: To set a border 
Python3
# import tkinterfrom tkinter import *  # Create Tk objectwindow = Tk()  # Set the window titlewindow.title('With_Border')  # set the window sizewindow.geometry('300x100')  # take one Label widgetlabel = Label(window, text="WELCOME TO GFG", borderwidth=1, relief="solid")  # place that label to windowlabel.grid(column=0, row=1, padx=100, pady=10)window.mainloop()
Output:
Program 2: to set the border and edit it as required.
Python3
# import tkinterfrom tkinter import *  # Create Tk objectwindow = Tk()  # Set the window titlewindow.title('GFG')  # take Label widgetsA = Label(window, text="flat", width=10,          height=2, borderwidth=3, relief="flat")B = Label(window, text="solid", width=10,          height=2, borderwidth=3, relief="solid")C = Label(window, text="raised", width=10,          height=2, borderwidth=3, relief="raised")D = Label(window, text="sunken", width=10,          height=2, borderwidth=3, relief="sunken")E = Label(window, text="ridge", width=10,          height=2, borderwidth=3, relief="ridge")F = Label(window, text="groove", width=10,          height=2, borderwidth=3, relief="groove")  # place that labels to windowA.grid(column=0, row=1, padx=100, pady=10)B.grid(column=0, row=2, padx=100, pady=10)C.grid(column=0, row=3, padx=100, pady=10)D.grid(column=0, row=4, padx=100, pady=10)E.grid(column=0, row=5, padx=100, pady=10)F.grid(column=0, row=6, padx=100, pady=10)  window.mainloop()
Output:
Python-tkinter
Technical Scripter 2020
Python
Technical Scripter
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Read a file line by line in Python
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Iterate over a list in Python
Python String | replace()
Reading and Writing to text files in Python
*args and **kwargs in Python
Create a Pandas DataFrame from Lists
Is it possible to rename _id field after MongoDB group aggregation?

Yes, it is possible to rename using aggregation. Let us first create a collection with documents
> db.renameIdDemo.insertOne({"StudentName":"Chris"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5c9a1760353decbc2fc927c5")
}
> db.renameIdDemo.insertOne({"StudentName":"Robert"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5c9a1765353decbc2fc927c6")
}
> db.renameIdDemo.insertOne({"StudentName":"David"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5c9a176b353decbc2fc927c7")
}
Following is the query to display all documents from a collection with the help of find() method
> db.renameIdDemo.find();
This will produce the following output
{ "_id" : ObjectId("5c9a1760353decbc2fc927c5"), "StudentName" : "Chris" }
{ "_id" : ObjectId("5c9a1765353decbc2fc927c6"), "StudentName" : "Robert" }
{ "_id" : ObjectId("5c9a176b353decbc2fc927c7"), "StudentName" : "David" }
Following is the query to rename _id field:
> db.renameIdDemo.aggregate({ $project: {
...    _id: 0,
...    mainId: "$_id",
...    count: 1,
...    sum: 1
... }
... }
... );
This will produce the following output. We have renamed _id to mainId;
{ "mainId" : ObjectId("5c9a1760353decbc2fc927c5") }
{ "mainId" : ObjectId("5c9a1765353decbc2fc927c6") }
{ "mainId" : ObjectId("5c9a176b353decbc2fc927c7") }
find_element_by_id() driver method - Selenium Python - GeeksforGeeks

07 Dec, 2021
Selenium’s Python Module is built to perform automated testing with Python. Selenium Python bindings provides a simple API to write functional/acceptance tests using Selenium WebDriver. After you have installed selenium and checked out – Navigating links using get method, you might want to play more with Selenium Python. After one has opened a page using selenium such as geeksforgeeks, one might want to click some buttons automatically or fill a form automatically or any such automated task. This article revolves around how to grab or locate elements in a webpage using locating strategies of Selenium Web Driver. More specifically, find_element_by_id() is discussed in this article. With this strategy, the first element with the id attribute value matching the location will be returned. If no element has a matching id attribute, a NoSuchElementException will be raised.Syntax –  
driver.find_element_by_id("id_of_element")
Example – For instance, consider this page source:  
html
<html> <body>  <form id="loginForm">   <input name="username" type="text" />   <input name="password" type="password" />   <input name="continue" type="submit" value="Login" />  </form> </body><html>
Now after you have created a driver, you can grab an element using –  
login_form = driver.find_element_by_id('loginForm')
 
Let’s try to practically implement this method and get a element instance for “https://www.geeksforgeeks.org/”. Let’s try to grab search form input using its id “gsc-i-id2”. Create a file called run.py to demonstrate find_element_by_id method –  
Python3
# Python program to demonstrate# selenium # import webdriverfrom selenium import webdriver # create webdriver objectdriver = webdriver.Firefox() # enter keyword to searchkeyword = "geeksforgeeks" # get geeksforgeeks.orgdriver.get("https://www.geeksforgeeks.org/") # get elementelement = driver.find_element_by_id("gsc-i-id2") # print complete elementprint(element)
Now run using –  
Python run.py
First, it will open firefox window with geeksforgeeks, and then select the element and print it on terminal as show below. Browser Output –  
Terminal Output –  
 
 
.math-table { border-collapse: collapse; width: 100%; } .math-table td { border: 1px solid #5fb962; text-align: left !important; padding: 8px; } .math-table th { border: 1px solid #5fb962; padding: 8px; } .math-table tr>th{ background-color: #c6ebd9; vertical-align: middle; } .math-table tr:nth-child(odd) { background-color: #ffffff; } 
 
 
NaveenArora
simmytarika5
Python-selenium
selenium
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Read a file line by line in Python
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Iterate over a list in Python
Python String | replace()
Reading and Writing to text files in Python
*args and **kwargs in Python
Create a Pandas DataFrame from Lists
Python | Numpy matrix.tobytes() - GeeksforGeeks

29 May, 2019
With the help of Numpy matrix.tobytes() method, we can find the byte code for the matrix by using the matrix.tobytes() method.
Syntax : matrix.tobytes()Return : Return byte code for matrix
Example #1 :In this example we can see that by using matrix.tobytes() method we are able to find the byte code for the given matrix.
# import the important module in pythonimport numpy as np              # make matrix with numpygfg = np.matrix('[4, 1; 12, 3]')              # applying matrix.tobytes() methodgeek = gfg.tobytes()    print(geek)
b’\x04\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x0c\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00′
Example #2 :
# import the important module in pythonimport numpy as np              # make matrix with numpygfg = np.matrix('[4, 1, 9; 12, 3, 1; 4, 5, 6]')              # applying matrix.tobytes() methodgeek = gfg.tobytes()    print(geek)
b’\x04\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\t\x00\x00\x00\x00\x00\x00\x00\x0c\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x06\x00\x00\x00\x00\x00\x00\x00′
Python numpy-Matrix Function
Python-numpy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Read a file line by line in Python
How to Install PIP on Windows ?
Different ways to create Pandas Dataframe
Python String | replace()
*args and **kwargs in Python
Reading and Writing to text files in Python
Create a Pandas DataFrame from Lists
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
C++ Algorithm Library - copy() Function

The C++ function std::algorithm::copy() copies a range of elements to a new location.
Following is the declaration for std::algorithm::copy() function form std::algorithm header.
template <class InputIterator, class OutputIterator>
OutputIterator copy (InputIterator first, InputIterator last, OutputIterator result);

first − Input iterators to the initial positions in a sequence.
first − Input iterators to the initial positions in a sequence.
last − Input iterators to the final positions in a sequence.
last − Input iterators to the final positions in a sequence.
result − Output iterator to the initial position in the new sequence.
result − Output iterator to the initial position in the new sequence.
Returns an iterator to the end of the destination range where elements have been copied.
Throws an exception if either element assignment or an operation on an iterator throws exception.
Please note that invalid parameters cause undefined behavior.
Linear in the distance between first to last.
The following example shows the usage of std::algorithm::copy() function.
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {
   vector<int> v1 = {1, 2, 3, 4, 5};
   vector<int> v2(5);

   copy(v1.begin(), v1.end(), v2.begin());

   cout << "Vector v2 contains following elements" << endl;

   for (auto it = v2.begin(); it != v2.end(); ++it)
      cout << *it << endl;

   return 0;
}
Let us compile and run the above program, this will produce the following result −
Vector v2 contains following elements
1
2
3
4
5

 Print
 Add Notes
 Bookmark this page
My Java Setup in Visual Studio Code | by Ryan Gleason | Towards Data Science

Launch a simple Java application after setting up a local development environment.
We are going to keep this as short and as simple as possible. You will be able to get Java code up and running in your VSCode environment in less than five minutes.
These are the tools we will be installing:
Visual Studio Code
Java Development Kit (JDK)
Java Extensions to enhance our environment
Let’s get started!
Download the stable build from Visual Studio Code.
This is a very easy download. Microsoft has done a good job of simplifying the installation process for this application.
This process has been automated like you wouldn’t believe.
We are going to navigate to this site: https://code.visualstudio.com/docs/languages/java and then scroll down to where you see “Download Visual Studio Code Java Pack Installer”
This installer is going to take care of all Java-related packages that are required for you to get started with Java development.
Hit the “Install” button and it will take a couple of seconds to complete.
Once we have the JDK installed, we can install the Extension Pack. These are tools that will enhance our project. It adds things like autocomplete, a dependency viewer, Maven support, a debugger, test runner, etc.
On the VSCode site we were just on, scroll down until you see this:
Click the Install the Java Extension Pack button.
Once this Extension Pack has been successfully installed you will be brought to a screen that looks like this:
We are going to follow the directions and create a new file. Inside this file we are going to put the following code:
class HelloWorld {  public static void main(String[] args) {    System.out.println("Hello, World.");  }}
When you click the “Run” button (or hit F5) you should see this output in the console:
Note: If you have a space anywhere in your path. For example, if this was my path: C:\Users\Ryan Gleason\Documents\...
A quick solution is to switch your default terminal to Powershell.
Type Ctrl + Shift + P to open up your command palette, enter Terminal: Select Default Shell and choose the Powershell option.
And that’s it. You are now ready to build something amazing using Java in VSCode!
Program to calculate Area Of Octagon

21 Jun, 2022
A regular octagon is a closed figure with sides of the same length and internal angles of the same size. It has eight lines of reflective symmetry and rotational symmetry of order 8. The internal angle at each vertex of a regular octagon is 135°. The central angle is 45°.Properties :  
Convex polygon, Equilateral polygon, Isogonal figure, Isotoxal figure, Cyclic.
 
Formula :  
Area : 2 × (side length)2 × (1+sqrt(2))
Examples :  
Input : side = 3
Output : Area of Regular Octagon = 43.4558

Input : side = 4
Output : Area of Regular Octagon = 77.2548
 
 
C++
Java
Python3
C#
PHP
Javascript
// CPP program to find area of octagon#include <bits/stdc++.h>using namespace std; // Utility functiondouble areaOctagon(double side){    return (float)(2 * (1 + sqrt(2)) *                   side * side);} // Driver Codeint main(){    double side = 4;    cout << "Area of Regular Octagon = "         << areaOctagon(side) << endl;    return 0;}
// Java Program to find// area of Octagon.import java.io.*; class GFG{      // utility function    static double areaOctagon(double side)    {    return (float)(2 * (1 + Math.sqrt(2))                          * side * side);    }         // driver code    public static void main(String arg[])    {        double side = 4;        System.out.print("Area of Regular Octagon = "                           + areaOctagon(side));    }} // This code is contributed by Anant Agarwal.
# Python3 program to# find area of octagon import math # Utility functiondef areaOctagon(side):    return (2 * (1 + (math.sqrt(2))) * side * side) # Driver functionside = 4print("Area of Regular Octagon =",       round(areaOctagon(side), 4)) # This code is contributed# by Azkia Anam.
// C# Program to find// area of Octagon.using System; class GFG{    // utility function    static double areaOctagon(double side)    {    return (float)(2 * (1 + Math.Sqrt(2))                        * side * side);    }         // Driver code    public static void Main()    {        double side = 4;        Console.WriteLine("Area of Regular Octagon = "                          + areaOctagon(side));    }} // This code is contributed by vt_m.
<?php// PHP program to find area of octagon // Utility functionfunction areaOctagon( $side){    return (2 * (1 + sqrt(2)) *            $side * $side);} // Driver Code $side = 4;echo("Area of Regular Octagon = ");echo(areaOctagon($side)); // This code is contributed by vt_m.?>
<script> // Javascript program to find area of octagon // Utility functionfunction areaOctagon(side){    return (2 * (1 + Math.sqrt(2)) *                side * side);} // Driver Code    let side = 4;    document.write("Area of Regular Octagon = "        + areaOctagon(side) + "<br>"); // This code is contributed by Mayank Tyagi</script>
Output :  
Area of Regular Octagon = 77.25
Time complexity : O(1) Auxiliary Space : O(1)
vt_m
mayanktyagi1709
krishnav4
area-volume-programs
Geometric
Mathematical
School Programming
Mathematical
Geometric
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
The implementation of import in Python (importlib)

The importlib package provides the implementation of the import statement in Python source code portable to any Python interpreter. This also provides an implementation which is easier to comprehend than one implemented in a programming language other than Python.
This package also exposes components to implement import, making it easier for users to create their own custom objects (known as an importer) to participate in the import process.
The importlib package has an important function named as import_module()
This function imports a module programmatically. Name of module is first parameter to the function. Optional second parameter specifies package name if any.
This function invalidates the internal caches of finders. This function should be called if any modules are created/installed while your program is running to guarantee all finders will notice the new module’s existence.
This function reloads a previously imported module. This is useful if you have edited the module source file using an external editor and want to try out the new version without leaving the Python interpreter.
Example:
Create two Python scripts named module1.py and module2.py having same code as below:
#module1
def main():
   print ('module imported', __name__)
   return
if __name__=='__main__':
   main()
We now import these modules dynamically using importlib package.
>>> import importlib
>>> mod=importlib.import_module('module1')
>>> mod.__name__
'module1'
>>> mod=importlib.import_module('module2')
>>> mod.__name__
'module2'
>>> mod.main()
module imported module2
>>>
The importlib package contains following submodules:
This module contains all of the core abstract base classes used by import. Some subclasses of the core abstract base classes are also provided to help in implementing the core ABCs
This module leverages Python’s import system to provide access to resources within packages.
This module contains the various objects that help import find and load modules.
This module has utility code for importers. It contains the various objects that help in the construction of an importer. Following important functions are defined in it.
This function find the specifications for a module, relative to the specified package name. If name is for a submodule (contains a dot), the parent module is automatically imported. Name and package work the same as for import_module().
Create a new module based on spec and spec.loader.create_module.
import importlib.util
def check_module(mod):
   spec = importlib.util.find_spec(mod)
   if spec is None:
      print('Module: {} not found'.format(mod))
      return None
   else:
      print('Module: {} can be imported!'.format(mod))
      return spec
   def import_module(spec):
      mod = importlib.util.module_from_spec(spec)
      spec.loader.exec_module(mod)
      return mod
if __name__ == '__main__':
   spec = check_module('notamodule')
   spec = check_module('module1')
   if spec:
      mod = import_module(spec)
      mod.main()
Module: notamodule not found
Module: module1 can be imported!
module imported module1
How to Remove Duplicate Values from Slice in Golang? - GeeksforGeeks

05 Aug, 2021
An array is a data structure. Similarly, in Golang we have slice which is more flexible, powerful, lightweight and convenient than array. As slice is more flexible than array therefore, its flexibility is determined in terms of its size. Just like an array, it has indexing value and length but its size is not fixed. When we declare a slice we do not specify the size of it. Syntax: 
[]mySlice;
 OR
[]mySlice{};
OR
[]mySlice{input1, input2, .........input n}
Moreover, a slice and an array are connected with each other, in a slice, there is a referencing to an underlying array. And in a slice, we can store duplicate elements.Example: Here, we will see how to remove the duplicate elements from slice. We have defined a function where we are passing the slice values and using the map function we are checking the duplicates and removing them. 
C
// Golang program to remove duplicate// values from Slicepackage main import (    "fmt") func removeDuplicateValues(intSlice []int) []int {    keys := make(map[int]bool)    list := []int{}     // If the key(values of the slice) is not equal    // to the already present value in new slice (list)    // then we append it. else we jump on another element.    for _, entry := range intSlice {        if _, value := keys[entry]; !value {            keys[entry] = true            list = append(list, entry)        }    }    return list} func main() {     // Assigning values to the slice    intSliceValues := []int{1,2,3,4,5,2,3,5,7,9,6,7}     // Printing original value of slice    fmt.Println(intSliceValues)     // Calling function where we    // are removing the duplicates    removeDuplicateValuesSlice := removeDuplicateValues(intSliceValues)     // Printing the filtered slice    // without duplicates    fmt.Println(removeDuplicateValuesSlice)}
Output: 
[1 2 3 4 5 2 3 5 7 9 6 7]
[1 2 3 4 5 7 9 6]
Explanation: 
From the main function, we have declared a slice. Also we have print the original value of the slice.
We have defined a function where we are passing the slice original values and checking the duplicates.
Logic for duplicate check : For this we have defined another slice and assigning the first values by checking if the value already exists in the new slice or not. It returns the slice without duplicates.
We are calling removeDuplicateValues function from main function where the return slice from the function is printed.
 
Golang-Slices
Picked
Go Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
strings.Replace() Function in Golang With Examples
How to Split a String in Golang?
Arrays in Go
Golang Maps
Slices in Golang
How to compare times in Golang?
How to Trim a String in Golang?
Inheritance in GoLang
How to Parse JSON in Golang?
Different Ways to Find the Type of Variable in Golang
How can we set Mnemonic Key Radio Button in Java?

Mnemonic key is set so that a user can use Keyboard keys to select a Radio Button. For example, a key can be set with ALT −
radio2.setMnemonic(KeyEvent.VK_R);
Above, we have set key ALT+R for radio2.
The following is an example to set Mnemonic key radio button −
package my;
import java.awt.FlowLayout;
import java.awt.event.KeyEvent;
import javax.swing.ButtonGroup;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JRadioButton;
public class SwingDemo {
   public static void main(String[] args) {
      JRadioButton radio1 = new JRadioButton("Male");
      JRadioButton radio2 = new JRadioButton("Female");
      radio2.setMnemonic(KeyEvent.VK_R);
      ButtonGroup group = new ButtonGroup();
      group.add(radio1);
      group.add(radio2);
      radio1.setSelected(true);
      JFrame frame = new JFrame();
      frame.setLayout(new FlowLayout());
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.add(new JLabel("Select Gender:"));
      frame.add(radio1);
      frame.add(radio2);
      frame.pack();
      frame.setVisible(true);
   }
}
The output is as follows. When you will press Alt+R, you will be able to select the radio buttons.
C++ Program to Implement Sparse Array

A sparse matrix is a matrix in which majority of the elements are 0. An example for this is given as follows.
The matrix given below contains 5 zeroes. Since the number of zeroes is more than half the elements of the matrix, it is a sparse matrix.
0 0 9
5 0 8
7 0 0
Begin
   Declare a 2D array a[10][10] to the integer datatype.
      Initialize some values of array.
   Declare i, j, count to the integer datatype.
      Initialize count = 0.
   Declare row, col to the integer datatype.
      Initialize row = 3, col = 3.
   for (i = 0; i < row; ++i) {
      for (j = 0; j < col; ++j)
         if (a[i][j] == 0)
            count++.
         Print “The matrix is:” .
      for (i = 0; i < row; ++i)
         for (j = 0; j < col; ++j)
            Print the values of array.
      Print “The number of zeros in the matrix are”.
   if (count > ((row * col)/ 2)) then
      Print "This is a sparse matrix".
   else
   Print "This is not a sparse matrix".
End.
 Live Demo
#include<iostream>
using namespace std;
int main () {
   int a[10][10] = { {0, 0, 9} , {5, 0, 8} , {7, 0, 0} };
   int i, j, count = 0;
   int row = 3, col = 3;
   for (i = 0; i < row; ++i) {
      for (j = 0; j < col; ++j) {
         if (a[i][j] == 0)
            count++;
      }
   }
   cout<<"The matrix is:"<<endl;
   for (i = 0; i < row; ++i) {
      for (j = 0; j < col; ++j) {
         cout<<a[i][j]<<" ";
      }
      cout<<endl;
   }
   cout<<"The number of zeros in the matrix are "<< count <<endl;
   if (count > ((row * col)/ 2))
      cout<<"This is a sparse matrix"<<endl;
   else
      cout<<"This is not a sparse matrix"<<endl;
   return 0;
}
The matrix is:
0 0 9
5 0 8
7 0 0
The number of zeros in the matrix are 5
This is a sparse matrix