code-rag-bench/online-tutorials huggingface dataset:
How to open a new window by the user pressing a button in a tkinter GUI?

Tkinter creates a default window (i.e., master or root window) for every application. In tkinter, we can create a Popup window or a child window by defining a Toplevel(master) constructor. This will allow the tkinter application to create another window which can be resized dynamically by defining its size property.
In this example, we have created a button widget that will open the new window with a text label.
#Import tkinter library
from tkinter import *
from tkinter import ttk
#Create an instance of tkinter frame or window
win= Tk()
#Set the geometry of tkinter frame
win.geometry("750x250")
#Define a new function to open the window
def open_win():
   new= Toplevel(win)
   new.geometry("750x250")
   new.title("New Window")
   #Create a Label in New window
   Label(new, text="Hey, Howdy?", font=('Helvetica 17 bold')).pack(pady=30)
#Create a label
Label(win, text= "Click the below button to Open a New Window", font= ('Helvetica 17 bold')).pack(pady=30)
#Create a button to open a New Window
ttk.Button(win, text="Open", command=open_win).pack()
win.mainloop()
Running the above code will display a window that contains a button widget. When we click the button, it will open a new Window.
Now, click the "Open" button to open a new Window.
How to take user input for two dimensional (2D) array in PHP ?

23 Dec, 2021
There are two methods to take user input in PHP in two dimensional (2D) array.Approach 1: 
Use HTML forms through PHP GET & POST method to take user input in two dimensional (2D) array.
First, input data to HTML forms.
Then use GET or POST method of PHP to get or post those input data into a variables.
Finally, use those variable which holds input data and process using for loop.
Though it is form two dimensional array so, you need two indices/variables for processing in for loop.
Enter input one below another to state as two variables.
Example 1: Below example illustrate how to input user data for 2D-array using Form POST method.
php
<?php echo "Enter n for nxn : <br>";echo "<form method='POST'>    Row:<input type='number' min='2'            max='5' name='1d' value='1'/>    Column:<input type='number' min='2'            max='5' name='2d' value='1'/>    <input type='submit' name='submit'            value='Submit'/></form>"; // Submit user input data for 2D arrayif (isset($_POST['submit'])) {         // POST submitted data    $dimention1 = $_POST["1d"];         // POST submitted data    $dimention2 = $_POST["2d"];         echo "Entered 2d nxn: " . $dimention1            . "x" . $dimention2 . " <br>";    $d = [];    $k = 0;         for($row = 0; $row < $dimention1; $row++) {        for ($col = 0; $col < $dimention2; $col++) {            $d[$row][$col]= $k++;        }    }         for ($row = 0; $row < $dimention1; $row++) {        for ($col = 0; $col < $dimention2; $col++) {            echo $d[$row][$col]." ";        }        echo "<br>";    }}?>
Output: 
Approach 2: 
To take user input in php for two dimensional (2D) by using fopen() function which helps to get user input either at runtime or by external input file.
First, assign those input data to variables.
Finally, use those variable which holds input data and process using for loop.
Though it is form two dimensional array so, you need two indices/variables for processing in for loop.
Example: Below example illustrate how to input user data for 2D array using fopen() function. 
php
<?php // fopen() using standard input$stdin = fopen('php://stdin', 'r');?><?phperror_reporting(0);echo "\n\n\nEnter row and column: \n"; // Right trim fgets(user input)$dimention1 = rtrim(fgets($stdin)); // Right trim fgets(user input)$dimention2 = rtrim(fgets($stdin)); echo "Entered row and column: " .    $dimention1 . "x" . $dimention1 . " \n"; $d = [];$k = 0; for ($row = 0; $row < $dimention1; $row++) {    for ($col = 0; $col < $dimention2; $col++) {        $d[$row][$col]= $k++;    }} for ($row = 0; $row < $dimention1; $row++) {    for ($col = 0; $col < $dimention2; $col++) {        echo $d[$row][$col]." ";    }    echo "\n";} ?>
Output: 
Reference: https://www.geeksforgeeks.org/php-fopen-function-open-file-or-url/ 
khushboogoyal499
abhishek0719kadiyan
PHP-Misc
Picked
PHP
Web Technologies
Web technologies Questions
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Create and Call a Stored Procedure in SQL?

25 Oct, 2021
With this article, we will learn how to Create and Call a Stored Procedure in SQL. For this article, we are going to use MSSQL as our database server.
A stored procedure is a pre-written SQL query that can be called multiple times and will run as the same. Like we can create a Stored procedure for Insert, select, update in SQL database. We can also pass parameters to the Stored procedures. So, we will create a database first:
Step 1: Creating Database
Query:
CREATE DATABASE GFG
Step 2: Using Database
Query:
USE GFG
Step 3: Create a table
Query:
CREATE TABLE gfgTutorial(
id integer,
Name varchar(20)
)
Step 4: Describe the table
Query:
sp_help 'dbo.gfgTutorial'
Output:
Created Table schema
Step 5: Insert some data into the table
Query:
INSERT INTO [dbo].[gfgTutorial]
           ([id]
           ,[Name])
     VALUES
           (1, 'Devesh')
GO

INSERT INTO [dbo].[gfgTutorial]
           ([id]
           ,[Name])
     VALUES
           (2, 'Geeks')
GO

INSERT INTO [dbo].[gfgTutorial]
           ([id]
           ,[Name])
     VALUES
           (3, 'For')
GO

INSERT INTO [dbo].[gfgTutorial]
           ([id]
           ,[Name])
     VALUES
           (4, 'Geeks')
GO

INSERT INTO [dbo].[gfgTutorial]E
           ([id]
           ,[Name])
     VALUES
           (5, 'GFG')
GO
Step 6: Create a Stored procedure for Select all the rows from a table
Query:
CREATE PROCEDURE select_all_data
AS
SELECT * FROM gfgTutorial
GO;
Output:
Successfully created the stored procedure
Execute Stored procedure select_all_data 
Query:
EXEC select_all_data
Output:
Executing stored procedure to select all data
Now we have seen how to create a basic stored procedure now let’s see how to create the parameterized stored procedure
Step 1: Create a parameterized stored procedure to insert data in the table
Query:
CREATE PROCEDURE insertData
@Name varchar(30), @id varchar(30)
AS
INSERT INTO gfgTutorial VALUES(@id, @Name)
GO
Step 2: Execute stored procedure
Query:
EXEC insertData @Name = 'Inserted Name', @id = 6
Data insertion successful
Check the data is inserted or not.
Data is inserted by the stored procedure.
Picked
SQL-Server
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Update Multiple Columns in Single Update Statement in SQL?
Window functions in SQL
What is Temporary Table in SQL?
SQL | Sub queries in From Clause
SQL using Python
RANK() Function in SQL Server
SQL Query to Find the Name of a Person Whose Name Starts with Specific Letter
SQL Query to Convert VARCHAR to INT
SQL Query to Compare Two Dates
How to Write a SQL Query For a Specific Date Range and Date Time?
Tensorflow.js tf.browser.fromPixels() Function

21 May, 2021
Tensorflow.js is an open-source library developed by Google for running machine learning models and deep learning neural networks in the browser or node environment.
The tf.browser.fromPixels() function is used to creates a Tensor of pixels values of an specified image. 
Syntax:
tf.browser.fromPixels (pixels, numChannels)
Parameters: This function accepts two parameters which are illustrated below:
pixels: It is the pixels of the input image from which the Tensor is going to be constructed. The supported image types are all 4-channel.
numchannels: It is the number of channels of the output Tensor. It’s default value is 3 and the upper limit is up to 4.
Return Value: This function returns the created Tensor of pixels values of the specified image. 
Example 1:
Javascript
// Importing the tensorflow.js libraryimport * as tf from "@tensorflow/tfjs"  // Creating a image from some specified// pixel valuesconst image = new ImageData(2, 2);image.data[0] = 5;image.data[1] = 10;image.data[2] = 15;image.data[3] = 20;  // Calling the .fromPixels() function // over the above image as its parameter// without using numChannels value,so// it prints only 3 pixels value as// the default value of numchannels // parameter is 3tf.browser.fromPixels(image).print();
Output:
Tensor
   [[[5, 10, 15],
     [0, 0 , 0 ]],

    [[0, 0 , 0 ],
     [0, 0 , 0 ]]]
Example 2:
Javascript
// Importing the tensorflow.js libraryimport * as tf from "@tensorflow/tfjs"  // Creating a image from some specified// pixels valuesconst image = new ImageData(1, 1);image.data[0] = 5;image.data[1] = 10;image.data[2] = 15;image.data[3] = 20;  // Calling the .fromPixels() function // over the above image as its parameter// along with 4 value for numChannels parametertf.browser.fromPixels(image, 4).print();
Output:
Tensor
    [ [[5, 10, 15, 20],]]
Reference:https://js.tensorflow.org/api/1.0.0/#browser.fromPixels
Picked
Tensorflow
Tensorflow.js
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
Hide or show elements in HTML using display property
How to append HTML code to a div using JavaScript ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Installation of Node.js on Linux
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
numpy.minimum() in Python

28 Nov, 2018
numpy.minimum() function is used to find the element-wise minimum of array elements.
It compare two arrays and returns a new array containing the element-wise minima. If one of the elements being compared is a NaN, then that element is returned. If both elements are NaNs then the first is returned.
Syntax : numpy.minimum(arr1, arr2, /, out=None, *, where=True, casting=’same_kind’, order=’K’, dtype=None, ufunc ‘minimum’)
Parameters :arr1 : [array_like] Input array.arr2 : [array_like] Input array.out : [ndarray, optional] A location into which the result is stored.  -> If provided, it must have a shape that the inputs broadcast to.  -> If not provided or None, a freshly-allocated array is returned.**kwargs : allows you to pass keyword variable length of argument to a function. It is used when we want to handle named argument in a function.where : [array_like, optional]True value means to calculate the universal functions(ufunc) at that position, False value means to leave the value in the output alone.
Return : [ndarray or scalar] Result.The minimum of arr1 and arr2, element-wise. This is a scalar if both arr1 and arr2 are scalars.
Code #1 : Working
# Python program explaining# minimum() function  import numpy as geekin_num1 = 10in_num2 = 21  print ("Input  number1 : ", in_num1)print ("Input  number2 : ", in_num2)     out_num = geek.minimum(in_num1, in_num2) print ("minimum of 10 and 21 : ", out_num) 
Output :
Input  number1 :  10
Input  number2 :  21
minimum of 10 and 21 :  10

 Code #2 :
# Python program explaining# minimum() function  import numpy as geek  in_arr1 = [2, 8, 125]in_arr2 = [3, 3, 15]   print ("Input array1 : ", in_arr1) print ("Input array2 : ", in_arr2)    out_arr = geek.minimum(in_arr1, in_arr2) print ("Output array after selecting minimum: ", out_arr) 
Output :
Input array1 :  [2, 8, 125]
Input array2 :  [3, 3, 15]
Output array after selecting minimum:  [ 2  3 15]

 Code #3 :
# Python program explaining# minimum() function  import numpy as geek  in_arr1 = [geek.nan, 0, geek.nan]in_arr2 = [geek.nan, geek.nan, 0]   print ("Input array1 : ", in_arr1) print ("Input array2 : ", in_arr2)    out_arr = geek.minimum(in_arr1, in_arr2) print ("Output array after selecting minimum: ", out_arr) 
Output :
Input array1 :  [nan, 0, nan]
Input array2 :  [nan, nan, 0]
Output array after selecting minimum:  [ nan  nan  nan]

Python numpy-Mathematical Function
Python-numpy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Convert integer to string in Python
Python OOPs Concepts
Introduction To PYTHON
Python | os.path.join() method
Python | Insert a number in string

25 Jun, 2019
Sometimes, while dealing with strings, we may encounter a problem in which we might have a numeric variable whose value keeps changing and we need to print the string including that number. Strings and numbers being different data types have to be solved in different ways. Let’s discuss certain ways in which this problem can be solved.
Method #1 : Using Type conversionThe simplest way in which this task can be performed is by converting the integer explicitly into string datatype using the basic type conversion and adding it to appropriate position.
# Python3 code to demonstrate working of# Inserting a number in string # Using type conversion  # initializing string test_str = "Geeks"  # initializing numbertest_int = 4   # printing original string print("The original string is : " + test_str)  # printing numberprint("The original number : " + str(test_int))  # using type conversion# Inserting number in string res = test_str + str(test_int) + test_str  # printing result print("The string after adding number is  : " + str(res))
The original string is : Geeks
The original number : 4
The string after adding number is  : Geeks4Geeks

 
Method #2 : Using %d operatorThis operator can be used to format the string to add the integer. The “d” represents that the datatype to be inserted to string is an integer. This can be changed according to the requirements.
# Python3 code to demonstrate working of# Inserting a number in string # Using % d operator  # initializing string test_str = "Geeks"  # initializing numbertest_int = 4   # printing original string print("The original string is : " + test_str)  # printing numberprint("The original number : " + str(test_int))  # using % d operator# Inserting number in string res = (test_str + "% d" + test_str) % test_int  # printing result print("The string after adding number is  : " + str(res))
The original string is : Geeks
The original number : 4
The string after adding number is  : Geeks4Geeks

Python string-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Java program to check if string is pangram

A pangram is a string that contains all the letters of the English alphabet. An example of a pangram is "The quick brown fox jumps over the lazy dog".
A program that checks if a string is pangram or not is given as follows.
 Live Demo
public class Example {
   public static void main(String[] args) {
      String str = "The quick brown fox jumps over the lazy dog";
      boolean[] alphaList = new boolean[26];
      int index = 0;
      int flag = 1;
      for (int i = 0; i < str.length(); i++) {
         if ( str.charAt(i) >= 'A' && str.charAt(i) <= 'Z') {
            index = str.charAt(i) - 'A';
         }else if( str.charAt(i) >= 'a' && str.charAt(i) <= 'z') {
            index = str.charAt(i) - 'a';
      }
      alphaList[index] = true;
   }
   for (int i = 0; i <= 25; i++) {
      if (alphaList[i] == false)
      flag = 0;
   }
   System.out.print("String: " + str);
   if (flag == 1)
      System.out.print("\nThe above string is a pangram.");
   else
      System.out.print("\nThe above string is not a pangram.");
   }
}
String: The quick brown fox jumps over the lazy dog
The above string is a pangram.
Now let us understand the above program.
The string str is traversed using a for loop and for every alphabet, the corresponding index in aplhaList is set to true. The code snippet that demonstrates this is given as follows −
for (int i = 0; i < str.length(); i++) {
   if ( str.charAt(i) >= 'A' && str.charAt(i) <= 'Z') {
      index = str.charAt(i) - 'A';
   }else if( str.charAt(i) >= 'a' && str.charAt(i) <= 'z') {
      index = str.charAt(i) - 'a';
   }
   alphaList[index] = true;
}
After this, the array alphaList is traversed. If all the values are true, then string is a pangram and value of flag remains 1. However, if even 1 value is false, then string is not a pangram and the value of flag is set to 0. Then it is displayed if string is pangram or not. The code snippet that demonstrates this is given as follows.
for (int i = 0; i <= 25; i++) {
   if (alphaList[i] == false)
      flag = 0;
   }
   System.out.print("String: " + str);
   if (flag == 1)
      System.out.print("\nThe above string is a pangram.");
   else
      System.out.print("\nThe above string is not a pangram.");
}
How to compare two ArrayList for equality in Java?

You can compare two array lists using the equals() method of the ArrayList class, this method accepts a list object as a parameter, compares it with the current object, in case of the match it returns true and if not it returns false.
 Live Demo
import java.util.ArrayList;

public class ComparingList {
   public static void main(String[] args) {
      ArrayList<String> list1 = new ArrayList<String>();
      list1.add("JavaFx");
      list1.add("Java");
      list1.add("WebGL");
      list1.add("OpenCV");
      ArrayList<String> list2 = new ArrayList<String>();
      list2.add("JavaFx");
      list2.add("Java");
      list2.add("WebGL");
      list2.add("OpenCV");
      System.out.println(list2);
      System.out.println(list1.equals(list2));
   }
}
How can we use MySQL ALTER TABLE command for adding comments on columns?

We can use ‘COMMENT’ keyword with ALTER TABLE command while modifying the column to add comments on columns. For example if we want to add comment in column ‘id’ of table ‘testing’ then following query will do it −
mysql> ALTER TABLE testing MODIFY id INT COMMENT 'id of employees';
Query OK, 0 rows affected (0.07 sec)
Records: 0 Duplicates: 0 Warnings: 0
With following query it can be checked in the comment field of a column.
mysql> Show full columns from testing\G
*************************** 1. row ***************************
     Field: id
      Type: int(11)
 Collation: NULL
      Null: NO
       Key: PRI
   Default: 0
     Extra:
Privileges: select,insert,update,references
   Comment: id of employees
*************************** 2. row ***************************
     Field: Name
      Type: varchar(20)
 Collation: latin1_swedish_ci
      Null: YES
       Key:
   Default: NULL
     Extra:
Privileges: select,insert,update,references
   Comment:
2 rows in set (0.05 sec)
Java Program to remove all white spaces from a String.

The replaceAll() method of the String class replaces each substring of this string that matches the given regular expression with the given replacement. You can remove white spaces from a string by replacing " " with "".
 Live Demo
public class DuplicateCharacters {
   public static void main(String[] args){
      String str = "Hello how are you";
      str = str.replaceAll(" ", "");
      System.out.println(str);
   }
}
Hellohowareyou
How to put text outside Python plots?

To put text outside a plot, we can change the text position by changing the value of text_pos_x and text_pos_y
Create data points for x and y.
Initialize the text position of x and y.
To plot x and y, use plot() method with color='red'.
Use text() method to add text to figure.
To display the figure, use show() method.
import numpy as np
from matplotlib import pyplot as plt
plt.rcParams["figure.figsize"] = [7.00, 3.50]
plt.rcParams["figure.autolayout"] = True
x = np.linspace(1, 5, 100)
y = np.exp(x)
text_pos_x = 0.60
text_pos_y = 0.50
plt.plot(x, y, c='red')
plt.text(text_pos_x, text_pos_y, "$\mathit{y}=e^{x}$", fontsize=14,
transform=plt.gcf().transFigure, color='green')
plt.show()
Tau - A Mathematical Constant - GeeksforGeeks

22 Jul, 2021
What is Tau?The constant is numerically equal to 2*pi (2 times pi), and with value approximately 6.28. The ratio equates to 2*C/D. Where C is circumference and D is diameter of circle.Applications of Tau  
There are many expressions that actually require “2*pi” calculation, having tau being equal to that simplifies them to great extent, for e.g Circumference of circle = 2*pi*r = tau*r.
Concept of tau can be useful in angular measurements like angles in radians, representing as a complete “one-turn” and cos,sine functions in trigonometry have period of tau.
These concepts can be useful for teaching geometry as would reduce the confusion of using “pi” and “2*pi” at many applications and would help get rid of factor of 2.
Tau simplifies euler’s identity by eradicating the factor of 2.
It is useful at many places where “2*pi” are used such as fourier transforms, cauchy integral formula’s etc.
Criticism against Tau  
Since it contradicts with the symbols of torque, shear stress and time, this symbol has been a lot of criticism.
We already had a ratio of “C/D” equal to pi, having another circle ratio with factor of two will create confusion in choice.
There exist formulas which look more elegant as expression of “pi” rather than tau, for example, area of circle = pi*r*r = (tau*r*r)/2, introducing an extra factor of “1/2”.
Coding Prospects Since Programming has always been trying to match up with mathematical advancements, symbol of tau has been introduced as a constant in recent python 3.6 under the math module. Below is the illustration of it.  
Python3
# Python code to demonstrate the working# of tau import math # Printing the value of tau using 2*piprint ("The value of tau (using 2*pi) is : ",end="")print (math.pi*2) # Printing the value of tau using in-built tau functionprint ("The value of tau (using in-built tau) is : ",end="")print (math.tau);
Output:  
The value of tau (using 2*pi) is : 6.283185307179586
The value of tau (using in-built tau) is : 6.283185307179586
Note: This code won’t work on Geeksforgeeks IDE as Python 3.6 is not supported. Reference : http://math.wikia.com/wiki/Tau_(constant)This article is contributed by Manjeet Singh. If you like GeeksforGeeks and would like to contribute, you can also write an article using write.geeksforgeeks.org or mail your article to review-team@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above. 
adnanirshad158
Mathematical
Mathematical
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Merge two sorted arrays
Modulo Operator (%) in C/C++ with Examples
Prime Numbers
Program to find GCD or HCF of two numbers
Program for Decimal to Binary Conversion
Program to find sum of elements in a given array
Sieve of Eratosthenes
The Knight's tour problem | Backtracking-1
Program for factorial of a number
Find all factors of a natural number | Set 1
sciPy stats.tstd() function | Python - GeeksforGeeks

10 Feb, 2019
scipy.stats.tstd(array, limits=None, inclusive=(True, True)) calculates the trimmed standard deviation of the array elements along the specified axis of the array.
It’s formula –
Parameters :array: Input array or object having the elements to calculate the trimmed standard deviation.axis: Axis along which the trimmed standard deviation is to be computed. By default axis = 0.limits: Lower and upper bound of the array to consider, values less than the lower limit or greater than the upper limit will be ignored. If limits is None [default], then all values are used.
Returns : Trimmed standard deviation of the array elements based on the set parameters.
Code #1:
# Trimmed Standard Deviation    from scipy import statsimport numpy as np    # array elements ranging from 0 to 19x = np.arange(20)    print("Trimmed Standard Deviation :", stats.tstd(x))       print("\nTrimmed Standard Deviation by setting limit : ",       stats.tstd(x, (2, 10)))
Trimmed Standard Deviation : 5.9160797831

Trimmed Standard Deviation by setting limit :  2.73861278753

 Code #2: With multi-dimensional data, axis() working
# Trimmed Standard Deviation    from scipy import statsimport numpy as np   arr1 = [[1, 3, 27],         [5, 3, 18],         [17, 16, 333],         [3, 6, 82]]      # using axis = 0print("Trimmed Standard Deviation is with default axis = 0 : \n",       stats.tstd(arr1, axis = 1))
Trimmed Standard Deviation is with default axis = 0 : 
 94.0423824505

Python scipy-stats-functions
Python-scipy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Python | Get unique values from a list
Python | os.path.join() method
Defaultdict in Python
Create a directory in Python
Python | Pandas dataframe.groupby()
AngularJS Forms ngSubmit() Method - GeeksforGeeks

14 Jun, 2021
In this article, we are going to see what is ngSubmit method in Angular 10 and how to use it.
The ngSubmit() method is called when the ‘submit’ event is triggered on the ngForm.
Syntax:
<form (ngSubmit)='method($event)'></form>
Parameters:
$event: the “submit” event object
 
Approach: 
Create an Angular app that to be used.
In app.component.ts, make an array that takes the value from the form.
In app.component.html, make a form and send the value using (ngSubmit) method.
Serve the angular app using ng serve to see the output.
Example:
app.component.ts
import { Component, Inject } from '@angular/core';import { FormGroup, FormControl, FormArray, NgForm } from '@angular/forms'@Component({    selector: 'app-root',    templateUrl: './app.component.html',    styleUrls: [ './app.component.css' ]})export class AppComponent  {    submit(form: NgForm) {        console.log(form.value);       }}
app.component.html
<form #form="ngForm" (ngSubmit)="submit(form)" novalidate>    <input name="first" ngModel required #first="ngModel">    <input name="last" ngModel>    <button>Submit</button></form>
Output:
Reference: https://angular.io/api/forms/NgForm#onsubmit
Angular10
AngularJS-API
AngularJS-Function
AngularJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Angular PrimeNG Dropdown Component
Angular PrimeNG Calendar Component
Angular 10 (blur) Event
Angular PrimeNG Messages Component
How to make a Bootstrap Modal Popup in Angular 9/8 ?
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
Output of C++ Program | Set 5 - GeeksforGeeks

05 Jan, 2022
Difficulty Level: RookiePredict the output of below C++ programs.Question 1  
C++
#include<iostream>using namespace std; class Test {    int value;public:    Test(int v);}; Test::Test(int v) {    value = v;} int main() {    Test t[100];    return 0;}
Output:  
Compiler error
The class Test has one user defined constructor “Test(int v)” that expects one argument. It doesn’t have a constructor without any argument as the compiler doesn’t create the default constructor if user defines a constructor (See this). Following modified program works without any error. 
C++
#include<iostream>using namespace std; class Test {    int value;public:    Test(int v = 0);}; Test::Test(int v) {    value = v;} int main() {    Test t[100];    return 0;}
Question 2  
C++
#include<iostream>using namespace std;int &fun() {  static int a = 10;  return a;} int main() {  int &y = fun();  y = y +30;  cout<<fun();  return 0;}
Output:  
40
The program works fine because ‘a’ is static. Since ‘a’ is static, memory location of it remains valid even after fun() returns. So a reference to static variable can be returned.Question 3  
C++
#include<iostream>using namespace std; class Test{public:  Test();}; Test::Test()  {    cout<<"Constructor Called \n";} int main(){    cout<<"Start \n";    Test t1();    cout<<"End \n";    return 0;}
Output:  
Start
End
Note that the line “Test t1();” is not a constructor call. Compiler considers this line as declaration of function t1 that doesn’t receive any parameter and returns object of type Test.Please write comments if you find any of the answers/explanations incorrect, or you want to share more information about the topics discussed above 
kalrap615
healer
CPP-Output
Program Output
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Output of Java program | Set 18 (Overriding)
Output of Java Program | Set 11
Output of Java programs | Set 13 (Collections)
Output of C++ programs | Set 34 (File Handling)
Different ways to copy a string in C/C++
Output of Java Program | Set 3
Runtime Errors
Output of Java program | Set 28
Output of Java program | Set 5
Output of Java Programs | Set 12
Mathematics | Walks, Trails, Paths, Cycles and Circuits in Graph - GeeksforGeeks

31 Aug, 2021
Prerequisite – Graph Theory Basics – Set 1 
1. Walk – A walk is a sequence of vertices and edges of a graph i.e. if we traverse a graph then we get a walk.  Note: Vertices and Edges can be repeated.
 
Here, 1->2->3->4->2->1->3 is a walk.
Walk can be open or closed.
Open walk- A walk is said to be an open walk if the starting and ending vertices are different i.e. the origin vertex and terminal vertex are different. Closed walk- A walk is said to be a closed walk if the starting and ending vertices are identical i.e. if a walk starts and ends at the same vertex, then it is said to be a closed walk. 
In the above diagram: 1->2->3->4->5->3 is an open walk. 1->2->3->4->5->3->1 is a closed walk. 
2. Trail – Trail is an open walk in which no edge is repeated. 
Vertex can be repeated.
 
Here 1->3->8->6->3->2 is trail Also 1->3->8->6->3->2->1 will be a closed trail 
3. Circuit – Traversing a graph such that not an edge is repeated but vertex can be repeated and it is closed also i.e. it is a closed trail.  Vertex can be repeated.Edge can not be repeated. 
 
Here 1->2->4->3->6->8->3->1 is a circuit.
Circuit is a closed trail. 
These can have repeated vertices only.
4. Path – It is a trail in which neither vertices nor edges are repeated i.e. if we traverse a graph such that we do not repeat a vertex and nor we repeat an edge. As path is also a trail, thus it is also an open walk. 
Vertex not repeated Edge not repeated 
 
Here 6->8->3->1->2->4 is a Path 
5. Cycle – Traversing a graph such that we do not repeat a vertex nor we repeat a edge but the starting and ending vertex must be same i.e. we can repeat starting and ending vertex only then we get a cycle. 
Vertex not repeated Edge not repeated 
 
Here 1->2->4->3->1 is a cycle. 
Cycle is a closed path. 
These can not have repeat anything (neither edges nor vertices).
Note that for closed sequences start and end vertices are the only ones that can repeat. 
mohitg593
rwells1703
kevind28198014
amitkrraj
Discrete Mathematics
Picked
Engineering Mathematics
GATE CS
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Inequalities in LaTeX
Activation Functions
Arrow Symbols in LaTeX
Newton's Divided Difference Interpolation Formula
Set Notations in LaTeX
Layers of OSI Model
ACID Properties in DBMS
TCP/IP Model
Types of Operating Systems
Normal Forms in DBMS
How to Create Bootable USB for Arch Linux? - GeeksforGeeks

11 May, 2021
A bootable USB or live USB is a USB flash drive that contains a bootable operating system. We create these USB flash drives when we wanted to refresh or change our operating system. Let’s discuss how we can create a Bootable USB flash drive for Arch Linux. Download the Arch ISO image from the Arch download page. Here, https://archlinux.org/download/.
Arch Linux ISO
Method 1: Using dd command
Step 1: Check the available disks on the system using the following command. fdisk is a command-line utility used to get info about removable and non-removable disks. Here, -l flag means listing available disks.
sudo fdisk -l
Listing available disks
The highlighted one is my removable disk of 32gb. Run the above command and note down the path where the disk is mounted. Here, my disk is mounted at /dev/sdc.
Step 2: Write the ISO image to the removable USB. dd is an acronym for convert and copy, it is called dd because cc is already in use by the C compiler. dd is a command-line utility tool used for creating bootable USB. It converts and copies the ISO image to the USB flash drive. bs is used to set the input and output block size. 
sudo dd bs=4M if=path/to/the/archlinux.iso of=/dev/sdc
Successfully created a bootable USB
Method 2: Using imagewriter
Step 1: Open up the image writer tool using the following command :
imagewriter
Step 2: Insert a USB stick into the computer.
Step 3: Select the downloaded Arch ISO.
Step 4: Click on the write button, a popup will be promoted click the button, and you’re all done.
imagewriter
Step 5: Wait until it completes the writing ISO, then unplug the USB.
Picked
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
scp command in Linux with Examples
mv command in Linux with examples
Docker - COPY Instruction
SED command in Linux | Set 2
chown command in Linux with Examples
nohup Command in Linux with Examples
Named Pipe or FIFO with example C program
Thread functions in C/C++
uniq Command in LINUX with examples
Start/Stop/Restart Services Using Systemctl in Linux
Changing color randomly in JavaScript

We are required to write a JavaScript function, let’s say randomColor that returns a randomly generated hex color every time it is called.
Following is the code −
const randomColor = () => {
   let color = '#';
   for (let i = 0; i < 6; i++){
      const random = Math.random();
      const bit = (random * 16) | 0;
      color += (bit).toString(16);
   };
   return color;
};
console.log(randomColor());
console.log(randomColor());
console.log(randomColor());
console.log(randomColor());
console.log(randomColor());
console.log(randomColor());
console.log(randomColor());
This will produce the following output in console −
#762b46
#cfa0bf
#a20ee1
#c2f7e0
#5d5822
#380f30
#805408
How do we reset all the input fields in HTML forms?

Using HTML forms, you can easily take user input. The <form> tag is used to get user input, by adding the form elements. Different types of form elements include text input, radio button input, submit button, etc.
The <input> tag helps you to take user input using the type attribute. To clear all the input in an HTML form, use the <input> tag with the type attribute as reset.
You can try to run the following code to reset input fields in HTML −
Live Demo
<!DOCTYPE html>
<html>
   <body>
      <form>
         Student Name:<br>
         <input type="text" name="sname">
         <br>
         Student Subject:<br>
         <input type="text" name="ssubject">
         <br>
         <input type="reset" value="reset">
      </form>
   </body>
</html>
How to create multi-column layout in HTML5 using tables?

Design your webpage to put your web content on multiple pages. You can keep your content in the middle column, you can use left column to use menu, and right column can be used to put an advertisement or some other stuff.
<!DOCTYPE html>
<html>
   <head>
      <title>Three Column HTML Layout</title>
   </head>
   <body>
      <table width = "100%" border = "0">
         <tr valign = "top">
            <td bgcolor = "#aaa" width = "20%">
               <b>Main Menu</b><br />
               HTML<br />
               PHP<br />
               PERL...
            </td>

            <td bgcolor = "#b5dcb3" height = "200" width = "60%">
               Technical and Managerial Tutorials
            </td>

            <td bgcolor = "#aaa" width = "20%">
               <b>Right Menu</b><br />
               HTML<br />
               PHP<br />
               PERL...
            </td>
         </tr>
      <table>
   </body>
</html>
Print all odd numbers and their sum from 1 to n in PL/SQL

In this problem, we are given a number n and we have to print all odd numbers from 1 to n and also print the sum of numbers from 1 to n in PL/SQL.
PL/SQL is a procedural language extension to SQL. The code is a sequence of instructions that are ground in a block with all related declarations and instructions.
Let’s see an example of our problem −
Input: 7
Output: odd numbers are: 1, 3, 5, 7
Sum of odd numbers is 16
To solve this problem, we will take a number and initialize it to 1 and a sum variable with initial value 0. And we will increase the number by 2 and add into the sum variable until its value is less than or equal to n.
DECLARE
   number NUMBER(3) := 1;
   sumvar NUMBER(4) := 0;

BEGIN
   dbms_output.Put_line('The odd numbers are : ');
      WHILE num <= 7 LOOP
         dbms_output.Put_line(number);
         sumvar := sumvar+num;
         num := num + 2;
      END LOOP;
dbms_output.Put_line('Sum of odd numbers is '|| sum1);
END;
The odd numbers are −
1
3
5
7
Sum of odd numbers is 16
Animate CSS flex-grow property

To implement animation on flex-grow property with CSS, you can try to run the following code
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <style>
         .mycontainer {
            display: flex;
            background-color: red;
            align-content: space-between;
         }
         .mycontainer > div {
            background-color: white;
            text-align: center;
            line-height: 40px;
            font-size: 25px;
            width: 100px;
            margin: 5px;
         }
         div {
            animation: myanim 4s infinite;
         }
         @-webkit-keyframes myanim {
            30% {
               flex-grow: 3;
            }
         }
      </style>
   </head>
   <body>
      <h1>Quiz</h1>
      <div class = "mycontainer">
         <div style = "flex-grow: 1">A1</div>
         <div style = "flex-grow: 1">A2</div>
         <div style = "flex-grow: 20">A3</div>
         <div style = "flex-grow: 1">A4</div>
         <div style = "flex-grow: 1">A5</div>
      </div>
   </body>
</html>
How to convert a string to a list of words in python?

To convert a string in a list of words, you just need to split it on whitespace. You can use split() from the string class. The default delimiter for this method is whitespace, i.e., when called on a string, it'll split that string at whitespace characters.
>>> "Please split this string".split()
['Please', 'split', 'this', 'string']
Regex can also be used to solve this problem. You can call the re.split() method using the regex '\s+' as delimiter. Note that this method is slower than the above method.
>>> import re
>>> re.split('\s+', 'Please split this string')
['Please', 'split', 'this', 'string']
Tryit Editor v3.7

Tryit: HTML input elements
How do I use Selenium with Ruby?

We can use Selenium with Ruby. First of all we have to install Ruby in the system. For installation in Windows, we have to take the help of the RubyInstaller package by navigating to the link −
https://rubyinstaller.org/
Click on Download.
The various versions of Ruby Installers links get displayed. Select the latest
version and click on it.
Click on the Save File button to download the corresponding rubyinstaller.exe file.
Once the download is completed, accept the license agreement and proceed to the next steps till installation is completed.
To have Selenium webdriver package for Ruby, run the command −
gem install selenium−webdriver
To have Rest−Client package for Ruby, run the command −
gem install rest−client
To have test−unit package for Ruby, run the command −
gem install test−unit
#set webdriver gem for Selenium
require "selenium−webdriver"
require "rubygems"
#driver object creation
driver = Selenium::WebDriver.for :chrome
#launch browser
driver.navigate.to "https://www.tutorialspoint.com/index.htm"
#close browser
driver.close
Node.js slice() function

14 Oct, 2021
The slice() function is a string function of Node.js which is used to extract sub-string from a string.
Syntax:
    
string.slice( start, end )

Parameters: This function uses thress parameters as mentioned above and described below:
string: It holds the string content. The substring is extracted from this string.
start: This parameter holds the starting index of sub-string.
end: This parameter holds the ending index od sub-string.
Return type: The function returns the substring.
The program below demonstrates the working of the function:
Program 1:
function findsubstr(str) {          var index = str.slice(12, 25);          console.log(index);}  var str = "Welcome to GeeksforGeeks";  findsubstr(str);
Output:
GeeksforGeeks
Program 2:
function findsubstr(str, start, end) {          var index = str.slice(start, end);          console.log(index);}  var str = "Welcome to GeeksforGeeks";  var start = 0;var end = 6;  findsubstr(str, start, end);
Output:
Welcome
NodeJS-function
Node.js
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Node.js fs.writeFile() Method
Difference between promise and async await in Node.js
Mongoose | findByIdAndUpdate() Function
Installation of Node.js on Windows
JWT Authentication with Node.js
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
Differences between Functional Components and Class Components in React
Python Bitwise Operators Example

There are following Bitwise operators supported by Python language.
#!/usr/bin/python

a = 60            # 60 = 0011 1100 
b = 13            # 13 = 0000 1101 
c = 0

c = a & b;        # 12 = 0000 1100
print "Line 1 - Value of c is ", c

c = a | b;        # 61 = 0011 1101 
print "Line 2 - Value of c is ", c

c = a ^ b;        # 49 = 0011 0001
print "Line 3 - Value of c is ", c

c = ~a;           # -61 = 1100 0011
print "Line 4 - Value of c is ", c

c = a << 2;       # 240 = 1111 0000
print "Line 5 - Value of c is ", c

c = a >> 2;       # 15 = 0000 1111
print "Line 6 - Value of c is ", c
When you execute the above program it produces the following result −
Line 1 - Value of c is 12
Line 2 - Value of c is 61
Line 3 - Value of c is 49
Line 4 - Value of c is -61
Line 5 - Value of c is 240
Line 6 - Value of c is 15
How to add NOT NULL constraint to an already created MySQL column?

Achieve this using ALTER TABLE. Let us first create a table −
mysql> create table DemoTable
   -> (
   -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   -> StudentName varchar(100)
   -> );
Query OK, 0 rows affected (0.86 sec)
Let us check the description of the table −
mysql> desc DemoTable;
This will produce the following output −
+-------------+--------------+------+-----+---------+----------------+
| Field       | Type         | Null | Key | Default | Extra          |
+-------------+--------------+------+-----+---------+----------------+
| StudentId   | int(11)      | NO   | PRI | NULL    | auto_increment |
| StudentName | varchar(100) | YES  |     | NULL    |                |
+-------------+--------------+------+-----+---------+----------------+
2 rows in set (0.01 sec)
Here is the query to add a NOT NULL constraint to the other column “StudentName”, which wasn’t set NOT NULL initially −
mysql> alter table DemoTable modify StudentName varchar(100) NOT NULL;
Query OK, 0 rows affected (1.57 sec)
Records: 0 Duplicates: 0 Warnings: 0
Let us check the description of the table once again −
mysql> desc DemoTable;
This will produce the following output −
+-------------+--------------+------+-----+---------+----------------+
| Field       | Type         | Null | Key | Default | Extra          |
+-------------+--------------+------+-----+---------+----------------+
| StudentId   | int(11)      | NO   | PRI | NULL    | auto_increment |
| StudentName | varchar(100) | NO   |     | NULL    |                |
+-------------+--------------+------+-----+---------+----------------+
2 rows in set (0.00 sec)
Download City Scapes Dataset with script | by Cem Sazara | Towards Data Science

City Scapes dataset is a very popular dataset that consists of labeled street images (from video sequence). There are 5000 high-quality labeled frames and 20000 weakly annotated frames. The website for this dataset is www.cityscapes-dataset.com
When I was working with this dataset, I quickly realized the dataset can only be downloaded from the website after logging in. So, there is no direct download link. This means when you need to deploy a deep learning model to a cloud machine or to another linux machine, you need to get the data from another source: Dropbox etc. Some of the data files are really large: 44GB, 11GB, 6.6GB !!! . A solution to this problem is to login and download the data without a browser.
First, you need to create an account in the web page. You will use your username and password in the first line of the script to login to the page.
Here is the two line script:
wget --keep-session-cookies --save-cookies=cookies.txt --post-data 'username=myusername&password=mypassword&submit=Login' https://www.cityscapes-dataset.com/login/wget --load-cookies cookies.txt --content-disposition https://www.cityscapes-dataset.com/file-handling/?packageID=1
In the first line, put your username and password. This will login with your credentials and keep the associated cookies.
In the second line, you need to provide the packageID paramater and it downloads the file.
packageIDs map like this in the website:
1 -> gtFine_trainvaltest.zip (241MB)  2 -> gtCoarse.zip (1.3GB)  3 -> leftImg8bit_trainvaltest.zip (11GB)  4 -> leftImg8bit_trainextra.zip (44GB)  8 -> camera_trainvaltest.zip (2MB)  9 -> camera_trainextra.zip (8MB)  10 -> vehicle_trainvaltest.zip (2MB)  11 -> vehicle_trainextra.zip (7MB)  12 -> leftImg8bit_demoVideo.zip (6.6GB)  28 -> gtBbox_cityPersons_trainval.zip (2.2MB)
A screenshot from the download page:
You can see the GitHub repository for this script here.