code-rag-bench/online-tutorials huggingface dataset:
C# Properties (Get and Set)

Before we start to explain properties, you should have a basic understanding of "Encapsulation".
The meaning of Encapsulation, is to make sure that "sensitive" data is hidden 
from users. To achieve this, you must:

declare fields/variables as private
provide public get 
and set methods, through properties, to access and update the value of a private 
field
You learned from the previous chapter that private variables can only be 
accessed within the same class (an outside class has no access to it). However, 
sometimes we need to access them - and it can be done with properties.
A property is like a combination of a variable and a method, and it has two methods: a get and a set method:
class Person
{
  private string name; // field

  public string Name   // property
  {
    get { return name; }   // get method
    set { name = value; }  // set method
  }
} 
 
 

The Name property is associated with the name field. It is a good practice to use the same name for both the property and the private field, but with an uppercase first letter.
The get method returns the value of the variable name.
The set method assigns a value to the
name variable. The value keyword represents the value we assign to the property.
If you don't fully understand it, take a look at the example below.
Now we can use the Name property to access and update the private field of the Person class:
class Person
{
  private string name; // field
  public string Name   // property
  {
    get { return name; }
    set { name = value; }
  }
}

class Program
{
  static void Main(string[] args)
  {
    Person myObj = new Person();
    myObj.Name = "Liam";
    Console.WriteLine(myObj.Name);
  }
}
 
 
 
 
 

The output will be:

Try it Yourself »

C# also provides a way to use short-hand / automatic properties, where you do 
not have to define the field for the property, and you only have to write get; 
and set; inside the property.
The following example will produce the same result as the example above. The only difference is that there is less code:
Using automatic properties:
class Person
{
  public string Name  // property
  { get; set; }
}

class Program
{
  static void Main(string[] args)
  {
    Person myObj = new Person();
    myObj.Name = "Liam";
    Console.WriteLine(myObj.Name);
  }
}
 
 

The output will be:

Try it Yourself »

Better control of class members (reduce the possibility of yourself (or others) to mess up the code)
Fields can be made read-only (if you only use the get method), or write-only (if you only use the set method)
Flexible: the programmer can change one part of the code without affecting other parts
Increased security of data
We just launchedW3Schools videos
Get certifiedby completinga course today!
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com
Your message has been sent to W3Schools.
HTML | <button> name Attribute

18 May, 2019
The <button> name attribute is used to specify the name attribute of <button> element. It is used to reference the form-data after submitting the form or to reference the element in a JavaScript.
Syntax:
<button name="name">
Attribute Values: It contains a single value name which describes the name of the <button> element.
Example:
<!DOCTYPE html> <html>     <head>         <title>            HTML button name Attribute        </title>     </head>           <body>        <h1>GeeksforGeeks</h1>                  <h3>HTML button name Attribute</h3>                   <form action="#" method="get">            Username: <input type="text" name="uname">                          <br><br>                          Password: <input type="password" name="pwd">                          <br><br>                          <button type="submit" value="submit">                Submit            </button>        </form>    </body> </html>                    
Output:
Supported Browsers: The browser supported by HTML <button> name attribute are listed below:
Google Chrome
Internet Explorer
Firefox
Safari
Opera
HTML-Attributes
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to update Node.js and NPM to next version ?
REST API (Introduction)
Types of CSS (Cascading Style Sheet)
HTTP headers | Content-Type
Design a Tribute Page using HTML & CSS
Installation of Node.js on Linux
Difference between var, let and const keywords in JavaScript
How to fetch data from an API in ReactJS ?
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
How to pass an Array to a Function in Golang?

25 Mar, 2021
Arrays in Golang or Go programming language is much similar to other programming languages. In the program, sometimes we need to store a collection of data of the same type, like a list of student marks. Such type of collection is stored in a program using an Array. An array is a fixed-length sequence which is used to store homogeneous elements in the memory. In Go language, you are allowed to pass an array as an argument in the function. For passing an array as an argument in the function you have to first create a formal parameter using the following syntax: 
Syntax:  
// For sized array
func function_name(variable_name [size]type){
// Code
}
Using this syntax you can pass 1 or multiple dimensional arrays to the function. Let us discuss this concept with the help of an example:
Example: 
Go
// Go program to illustrate how to pass an// array as an argument in the functionpackage main import "fmt" // This function accept// an array as an argumentfunc myfun(a [6]int, size int) int {    var k, val, r int     for k = 0; k < size; k++ {        val += a[k]    }     r = val / size    return r} // Main functionfunc main() {     // Creating and initializing an array    var arr = [6]int{67, 59, 29, 35, 4, 34}    var res int     // Passing an array as an argument    res = myfun(arr, 6)    fmt.Printf("Final result is: %d ", res)}
Output: 
Final result is: 38 
Explanation: In the above example, we have a function named as myfun() which accept an array as an argument. In the main function, we passed arr[6] of int type to the function with the size of the array and the function return the average of the array. 
ravikumarvallabhu
arorakashish0911
Go-Functions
Golang
Golang-Arrays
Go Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Different ways to concatenate two strings in Golang
time.Sleep() Function in Golang With Examples
strings.Contains Function in Golang with Examples
strings.Replace() Function in Golang With Examples
fmt.Sprintf() Function in Golang With Examples
Golang Maps
Time Formatting in Golang
Interfaces in Golang
Different Ways to Find the Type of Variable in Golang
How to convert a string in lower case in Golang?
How to use cURL to Get JSON Data and Decode JSON Data in PHP ?

01 Apr, 2022
In this article, we are going to see how to use cURL to Get JSON data and Decode JSON data in PHP.
cURL: 
It stands for Client URL.
It is a command line tool for sending and getting files using URL syntax.
cURL allows communicating with other servers using HTTP, FTP, Telnet, and more.
Approach:
We are going to fetch JSON data from one of free website, which gives JSON data for testing i.e. reqres.in
First, we initialize curl using curl_init() method.
Sending GET request to reqres.in server using curl_setopt() method with CURLOPT_URL to get json data.
After that, we have to tell curl to store json data in a variable instead of dumping on screen. This is done by using CURLOPT_RETURNTRANSFER parameter in curl_setopt() function.
Execute curl using curl_exec() method.
At last, close the curl using curl_close() method.
Example:
PHP
<?php // Initializing curl$curl = curl_init();   // Sending GET request to reqres.in// server to get JSON datacurl_setopt($curl, CURLOPT_URL,    "https://reqres.in/api/users?page=2");   // Telling curl to store JSON// data in a variable instead// of dumping on screencurl_setopt($curl,    CURLOPT_RETURNTRANSFER, true);   // Executing curl$response = curl_exec($curl); // Checking if any error occurs// during request or notif($e = curl_error($curl)) {    echo $e;} else {         // Decoding JSON data    $decodedData =        json_decode($response, true);             // Outputting JSON data in    // Decoded form    var_dump($decodedData);} // Closing curlcurl_close($curl);?>
Output:
GET Request using cURL
simmytarika5
JSON
PHP-cURL
PHP-function
PHP-Questions
Picked
PHP
Web Technologies
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to execute PHP code using command line ?
PHP in_array() Function
How to delete an array element based on key in PHP?
How to Insert Form Data into Database using PHP ?
How to convert array to string in PHP ?
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
Python OpenCV – cv2.transpose() method

08 Jul, 2020
OpenCV is a library of programming functions mainly aimed at real-time computer vision. cv2.transpose() method is used to transpose a 2D array. The function cv::transpose rotate the image 90 degrees Counter clockwise.
Syntax: cv2.cv.transpose( src[, dst] )
Parameters:src: It is the image whose matrix is to be transposed.dst: It is the output image of the same size and depth as src image. It is an optional parameter.
Return Value: It returns an image.
Image used for all the below examples:
Example:
# Python program to explain cv2.transpose() method  # importing cv2import cv2  # pathpath = r'C:\Users\user\Desktop\geeks14.png'  # Reading an image in default modesrc = cv2.imread(path)  # Window name in which image is displayedwindow_name = 'Image'  # Using cv2.transpose() methodimage = cv2.transpose(src)  # Displaying the imagecv2.imshow(window_name, image)cv2.waitKey(0)
Output:
Python-OpenCV
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Solidity – Break and Continue Statements

11 May, 2022
In any programming language, Control statements are used to change the execution of the program. Solidity allows us to handle loops and switch statements. These statements are usually used when we have to terminate the loop without reaching the bottom or we have to skip some part of the block of code and start the new iteration. Solidity provides the following control statements to handle the program execution.
This statement is used when we have to terminate the loop or switch statements or some block of code in which it is present. After the break statement, the control is passed to the statements present after the break. In nested loops, break statement terminates only those loops which has break statement.
Example: In the below example, the contract Types is defined consisting of a dynamic array, an unsigned integer variable, and a function containing the while loop to demonstrate the working of the break statement.
Solidity
// Solidity program to demonstrate// use of Break statementpragma solidity ^0.5.0;    // Creating a contractcontract Types {           // Declaring a dynamic array       uint[] data;         // Declaring the state variable    uint8 j = 0;      // Defining the function to     // demonstrate use of Break     // statement    function loop(    ) public returns(uint[] memory){    while(j < 5) {        j++;        if(j==3){            break;        }        data.push(j);     }      return data;    }}
Output : 
This statement is used when we have to skip the remaining block of code and start the next iteration of the loop immediately. After executing the continue statement, the control is transferred to the loop check condition, and if the condition is true the next iteration starts.
Example: In the below example, contract Types is defined consisting of a dynamic array, an unsigned integer variable, and a function containing the while loop to demonstrate the working of the continue statement.
Solidity
// Solidity program to demonstrate// use of Continue statementpragma solidity ^0.5.0;    // Creating a contractcontract Types {           // Declaring a dynamic array    uint[] data;         // Declaring a state variable    uint8 j = 0;      // Defining a function to      // demonstrate the use of     // Continue statement    function loop(    ) public returns(uint[] memory){    while(j < 5) {        j++;        if(j==3){            continue;        }        data.push(j);     }      return data;    }}
Output : 
Solidity Control-Flow
Blockchain
Solidity
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Solidity - Arrays
How to Become a Blockchain Developer?
Solidity - Mappings
Storage vs Memory in Solidity
How to connect ReactJS with MetaMask ?
Solidity - Arrays
Solidity - Mappings
Storage vs Memory in Solidity
Solidity - Enums and Structs
Solidity - Fall Back Function
How to use labels in Java code?

Java provides two types of branching/control statements namely, break and continue.
This statement terminates the loop or switch statement and transfers execution to the statement immediately following the loop or switch.
Following is the example of the break statement. Here we are trying to print elements up to 10 and, using break statement we are terminating the loop when the value in the loop reaches 8.
Live Demo
public class BreakExample {
   public static void main(String args[]){
      for(int i=0; i<10; i++){
         if (i==8){
            break;
         }
         System.out.println("......."+i);
      }
   }
}
.......0
.......1
.......2
.......3
.......4
.......5
.......6
.......7
 This statement causes the loop to skip the remainder of its body and immediately retest its condition prior to reiterating.
Following is the example of the continue statement. Here we are trying to print elements up to 10 and, using break continue we are skipping the loop when the value in the loop reaches 8.
Live Demo
public class ContinueExample {
   public static void main(String args[]){
      for(int i=0; i<10; i++){
         if (i==8){
            continue;
         }
         System.out.println("......."+i);
      }
   }
}
.......0
.......1
.......2
.......3
.......4
.......5
.......6
.......7
.......9
Java provides two types of branching statements namely, labelled and unlabelled.
We can also use the above-mentioned branching statements with labels.
You can assign a label to the break/continue statement and can use that label with the break/continue statement as −
Task:
for(int i=0; i<10; i++){
   if (i==8){
      continue Task;
      (or)
      break Task;
   }
}
The labeled break statement terminates the outer most loop whereas the normal break statement terminates the innermost loop.
Live Demo
public class LabeledBreakExample {
   public static void main(String args[]){
      Task:
      for(int i=0; i<10; i++){
         if (i==8){
            break Task;
          }
          System.out.println("......."+i );
      }
   }
}
.......0
.......1
.......2
.......3
.......4
.......5
.......6
.......7
.......9
The labelled continue statement skips the current iteration of the outer most loop whereas the normal continue skips the current iteration of the innermost loop.
Live Demo
public class LabeledContinueExample {
   public static void main(String args[]){
      Task:
      for(int i=0; i<10; i++){
          if (i==8){
             continue Task;
          }
          System.out.println("......."+i );
       }  
   }  
}
.......0
.......1
.......2
.......3
.......4
.......5
.......6
.......7
.......9
Python | Pandas Series.pct_change()

21 Jul, 2021
Pandas pct_change() method is applied on series with numeric data to calculate Percentage change after n number of elements. By default, it calculates percentage change of current element from the previous element. (Current-Previous/Previous) * 100.First, n(n=period) values are always NaN, since there is no previous value to calculate change. 
Syntax: Series.pct_change(periods=1, fill_method=’pad’, limit=None)Parameters: periods: Defines gap between current and previous value. Default is 1 fill_method: Defines method used to handle null values limit: Number of consecutive NaN values to fill before stopping.Return type: Numeric series with percentage change  
Example #1: In this method, a Series is created from Python list using Pandas Series(). The series doesn’t contain any null value and hence pct_change() method is called directly with default value of period parameter, that is 1.  
Python3
# importing pandas moduleimport pandas as pd   # importing numpy moduleimport numpy as np   # creating listlist = [10, 14, 20, 25, 12.5, 13, 0, 50] # creating seriesseries = pd.Series(list) # calling methodresult = series.pct_change() # displayresult
Output:  
0         NaN
1    0.400000
2    0.428571
3    0.250000
4   -0.500000
5    0.040000
6   -1.000000
7         inf
dtype: float64
As shown in output, first n values are always equal to NaN. Rest of the values are equal to the percentage change in Old values and are stored at the same position as caller series. Note: Since second last value was 0, the Percentage change is inf. inf stands for infinite. Using the formula, pct_change= x-0/0 = Infinite  Example #2: Handling Null valuesIn this example, some null values are also created using Numpy’s np.nan method and passed to the list. ‘bfill‘ is passed to fill_method. bfill stands for Back fill and will fill Null values with values at their very next position. 
Python3
# importing pandas moduleimport pandas as pd   # importing numpy moduleimport numpy as np   # creating listlist =[10, np.nan, 14, 20, 25, 12.5, 13, 0, 50] # creating seriesseries = pd.Series(list) # calling methodresult = series.pct_change(fill_method ='bfill') # displayresult
Output:  
0         NaN
1    0.400000
2    0.000000
3    0.428571
4    0.250000
5   -0.500000
6    0.040000
7   -1.000000
8         inf
dtype: float64
As it can be seen in output, value at position 1 is 40 because NaN was replaced by 14. Hence, (14-10/10) *100 = 40. The very next value is 0 because percentage change in 14 and 14 is 0. 
sweetyty
Python pandas-series
Python pandas-series-methods
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Convert integer to string in Python
Python | os.path.join() method
Create a Pandas DataFrame from Lists
Introduction To PYTHON
Fix "Execution Failed for task :app:compileDebugJavaWithJavac" in Android Studio - GeeksforGeeks

19 Jun, 2021
Working on some important java project with Java code involved, and just when you hit that Build hammer icon, you get this:
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
Figure 1: The Error
Well, let’s fix this error and get you up and working in no time, just follow the below methods chronologically and it will be a breeze!
GeekTip: Please download the buildTools for this version with SDKManager as a hint if you haven’t already.
and then just change these in your build.gradle file
compileSdkVersion 23
buildToolsVersion "23.0.1"
then sync the Gradle file and rebuild!
Sometimes, it might be the slightest error in your $JAVA_HOME configuration which is tabbing this error, just fix it like this:
export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home"
GeekTip: Make Change this in the .bash profile
Double-check the build of your app. gradle. It adds an extra.jar file as a dependency that didn’t exist in your project. As a result, remove that and you’re back on track!
If you happen to be running the latest version of Android Studio or the Canary Flavor of the IDE then maybe the issue is there with the certain sdkVersions of your project. Change it this way:
Navigate to File > Project Structure
then
change the compileSdkVersion to any value (like 24) which works with your project like
compileSdkVersion 24
If you’re using the retrolambda build script then you may change its configuration in the build.gradle and your error might be resolved
retrolambda {
    jdk System.getenv("JAVA_HOME")
    oldJdk System.getenv("JAVA7_HOME")
    javaVersion JavaVersion.VERSION_1_8
}
GeekTip: You can also establish a new environment variable named JAVA8 HOME that points to the correct JDK location.
That’s it if you followed the methods given in this article you would’ve resolved this issue and would be back on the track with that project building perfectly as intended!
Android-Studio
Picked
Android
Android
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Flutter - Custom Bottom Navigation Bar
How to Read Data from SQLite Database in Android?
Android Listview in Java with Example
How to Post Data to API using Retrofit in Android?
Retrofit with Kotlin Coroutine in Android
How to Add Image to Drawable Folder in Android Studio?
How to Retrieve Data from the Firebase Realtime Database in Android?
How to Change the Background Color After Clicking the Button in Android?
GridView in Android with Example
ImageView in Android with Example
How to validate XML response in Rest Assured?

We can validate XML response in Rest Assured. For obtaining an XML response, we have to pass the parameter ContentType.XML to the accept method. We shall first send a GET request via Postman on a mock API URL.
Using Rest Assured, we shall validate its XML Response containing the name of the subjects Rest Assured, Postman, and their prices 10 and 6 respectively.
In the above XML Response, we shall obtain the values of the name and price tags by traversing the paths - courses.subject.name and courses.subject.price respectively.
We shall perform the assertion with the help of the Hamcrest framework which uses the Matcher class for assertion. To work with Hamcrest we have to add the Hamcrest Core dependency in the pom.xml in our Maven project. The link to this dependency is available in the below link −
https://mvnrepository.com/artifact/org.hamcrest/hamcrest-core
Code Implementation
import org.hamcrest.Matchers;
import org.testng.annotations.Test;
import static io.restassured.RestAssured.*;
import io.restassured.RestAssured;
import io.restassured.http.ContentType;
public class NewTest {
   @Test
   void validateXMLResponse() {

      //base URI with Rest Assured class
      RestAssured.baseURI = "https://run.mocky.io/v3";

      //accept XML CONTENT
      given().accept(ContentType.XML)

      //GET request .when().get("/55889581-
      da52-4383-840e-bdf6dde19252")

      //validate XML body
      .then().assertThat()

      //validate subject lists
      .body("courses.subject.name", Matchers.hasItems
      ("Rest Assured", "Postman"))
      .and().assertThat()

      //validate price lists
      .body("courses.subject.price", Matchers.hasItems("10", "6"));
   }
}
Selenium - Exception Handling

When we are developing tests, we should ensure that the scripts can continue their execution even if the test fails. An unexpected exception would be thrown if the worst case scenarios are not handled properly.
If an exception occurs due to an element not found or if the expected result doesn't match with actuals, we should catch that exception and end the test in a logical way rather than terminating the script abruptly.
The actual code should be placed in the try block and the action after exception should be placed in the catch block. Note that the 'finally' block executes regardless of whether the script had thrown an exception or NOT.
try {
   //Perform Action
} catch(ExceptionType1 exp1) {
   //Catch block 1
}  catch(ExceptionType2 exp2) {
   //Catch block 2
} catch(ExceptionType3 exp3) {
   //Catch block 3 
} finally {
   //The finally block always executes.
}
If an element is not found (due to some reason), we should step out of the function smoothly. So we always need to have a try-catch block if we want to exit smoothly from a function.
public static WebElement lnk_percent_calc(WebDriver driver)throws Exception {
   try {
      element = driver.findElement(By.xpath(".//*[@id='menu']/div[4]/div[3]/a")); 
      return element;
   } catch (Exception e1) {
      // Add a message to your Log File to capture the error
      Logger.error("Link is not found.");
      
      // Take a screenshot which will be helpful for analysis.
      File screenshot = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
      FileUtils.copyFile(screenshot, new File("D:\\framework\\screenshots.jpg"));
      throw(e1);
   }
}

    46 Lectures 
     5.5 hours 

 Aditya Dua

    296 Lectures 
     146 hours 

 Arun Motoori

    411 Lectures 
     38.5 hours 

 In28Minutes Official

    22 Lectures 
     7 hours 

 Arun Motoori

    118 Lectures 
     17 hours 

 Arun Motoori

    278 Lectures 
     38.5 hours 

 Lets Kode It
 Print
 Add Notes
 Bookmark this page
numpy.select() function | Python

22 Apr, 2020
numpy.select()() function return an array drawn from elements in choicelist, depending on conditions.
Syntax : numpy.select(condlist, choicelist, default = 0)Parameters :condlist : [list of bool ndarrays] It determine from which array in choicelist the output elements are taken. When multiple conditions are satisfied, the first one encountered in condlist is used.choicelist : [list of ndarrays] The list of arrays from which the output elements are taken. It has to be of the same length as condlist.default : [scalar, optional] The element inserted in output when all conditions evaluate to False.Return : [ndarray] An array drawn from elements in choicelist, depending on conditions.
Code #1 :
# Python program explaining# numpy.select() function  # importing numpy as geek import numpy as geek  arr = geek.arange(8)  condlist = [arr<3, arr>4]choicelist = [arr, arr**3]  gfg = geek.select(condlist, choicelist)  print (gfg)
Output :
[  0, 1, 2, 0, 0, 125, 216, 343]

 Code #2 :
# Python program explaining# numpy.select() function  # importing numpy as geek import numpy as geek  arr = geek.arange(8)  condlist = [arr<4, arr>6]choicelist = [arr, arr**2]  gfg = geek.select(condlist, choicelist)  print (gfg)
Output :
[ 0, 1, 2, 3, 0, 0, 0, 49]

Python numpy-arrayManipulation
Python-numpy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Enumerate() in Python
Read a file line by line in Python
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Iterate over a list in Python
Python OOPs Concepts
Introduction To PYTHON
Convert integer to string in Python
Fill an array with specific values in Julia | Array fill() method

27 Jan, 2022
The fill() is an inbuilt function in julia which is used to return an array of specified dimensions filled with a specific value passed to it as parameter. 
Syntax: fill(Value, Dimension)Parameters:  
Value: To be filled in the array
Dimension: Required size of the array
Returns: It returns an array of nXn dimension with each element as the specified value.  
Example:  
Python
# Julia program to illustrate# the use of Array fill() method # Creating a 1D array of size 4# with each element filled with value 5A = fill(5, 4)println(A) # Creating a 2D array of size 2X3# with each element filled with value 5B = fill(5, (2, 3))println(B) # Creating a 3D array of size 2X2X2# with each element filled with value 5C = fill(5, (2, 2, 2))println(C)
Output:  
 
fill!() method works exactly like fill() method i.e. it fills an array with a specific value passed to it as argument, but the only difference is that, fill!() method takes an existing array as argument and fills it with a new specified value. While the fill() method takes array dimensions and creates a new array of its own.  
Syntax: fill!(Array, Value)Parameters:  
Array: It is the array of specified dimension.
Value: It is the value to be filled in the array.
Returns: It returns the array passed to it as argument with the specified value filled at each index.  
Example: Below code is using one dimension array of 3 elements.  
Python
# Julia program to illustrate# the use of Array fill() method # Creating a 1D array of size 5Array1 = [1, 2, 3, 4, 5] # Filling array with fill!()Array1 = fill!(Array1, 10)println(Array1) # Creating a 2D array of size 2X2Array2 = [1 2; 3 4]Array2 = fill!(Array2, 10)println(Array2) # Creating a 3D array of size 2X2X2Array3 = cat([1 2; 3 4], [5, 6; 7 8], dims=3)Array3 = fill!(Array3, 10)println(Array3)
Output:  
 
clintra
julia-array
Julia
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Vectors in Julia
Getting rounded value of a number in Julia - round() Method
Manipulating matrices in Julia
Reshaping array dimensions in Julia | Array reshape() Method
Storing Output on a File in Julia
Exception handling in Julia
Formatting of Strings in Julia
Creating array with repeated elements in Julia - repeat() Method
Get array dimensions and size of a dimension in Julia - size() Method
Get number of elements of array in Julia - length() Method
Compute Variance and Standard Deviation of a value in R Programming – var() and sd() Function

26 May, 2020
var() function in R Language computes the sample variance of a vector. It is the measure of how much value is away from the mean value.
Syntax: var(x)
Parameters:x : numeric vector
Example 1: Computing variance of a vector
# R program to illustrate# variance of vector  # Create example vectorx <- c(1, 2, 3, 4, 5, 6, 7)     # Apply var function in R var(x)                         print(x)
Output:
 4.667
Here in the above code, we took an example vector “x1” and calculated its variance.
sd() function is used to compute the standard deviation of given values in R. It is the square root of its variance.
Syntax: sd(x)

Parameters:
x: numeric vector

Example 1: Computing standard deviation of a vector
# R program to illustrate# standard deviation of vector  # Create example vectorx2 <- c(1, 2, 3, 4, 5, 6, 7)   # Compare with sd functionsd(x2)                            print(x2)
Output: 2.200
Here in the above code, we took an example vector “x2” and calculated its standard deviation.
R-Functions
Programming Language
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Communication between two process using signals in C

31 Jan, 2019
Prerequisite : C signal handling
In this post, the communication between child and parent processes is done using kill() and signal(), fork() system call.
fork() creates the child process from the parent. The pid can be checked to decide whether it is the child (if pid == 0) or the parent (pid = child process id).
The parent can then send messages to child using the pid and kill().
The child picks up these signals with signal() and calls appropriate functions.
Example of how 2 processes can talk to each other using kill() and signal():
// C program to implement sighup(), sigint()// and sigquit() signal functions#include <signal.h>#include <stdio.h>#include <stdlib.h>#include <sys/types.h>#include <unistd.h>  // function declarationvoid sighup();void sigint();void sigquit();  // driver codevoid main(){    int pid;      /* get child process */    if ((pid = fork()) < 0) {        perror("fork");        exit(1);    }      if (pid == 0) { /* child */        signal(SIGHUP, sighup);        signal(SIGINT, sigint);        signal(SIGQUIT, sigquit);        for (;;)            ; /* loop for ever */    }      else /* parent */    { /* pid hold id of child */        printf("\nPARENT: sending SIGHUP\n\n");        kill(pid, SIGHUP);          sleep(3); /* pause for 3 secs */        printf("\nPARENT: sending SIGINT\n\n");        kill(pid, SIGINT);          sleep(3); /* pause for 3 secs */        printf("\nPARENT: sending SIGQUIT\n\n");        kill(pid, SIGQUIT);        sleep(3);    }}  // sighup() function definitionvoid sighup()  {    signal(SIGHUP, sighup); /* reset signal */    printf("CHILD: I have received a SIGHUP\n");}  // sigint() function definitionvoid sigint()  {    signal(SIGINT, sigint); /* reset signal */    printf("CHILD: I have received a SIGINT\n");}  // sigquit() function definitionvoid sigquit(){    printf("My DADDY has Killed me!!!\n");    exit(0);}
Output:
C Language
Linux-Unix
Operating Systems
Operating Systems
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
\text - Tex Command

\text - Used to produce text-mode material within a mathematical expression.
{ \text #1}
\text command is used to produce text-mode material (in a given font) within a mathematical expression.

|x| = x \text{ for all \(x \ge 0\)}

|x|=x for all x≥0


\text{\alpha in text mode }\alpha

\alpha in text mode α



|x| = x \text{ for all \(x \ge 0\)}

|x|=x for all x≥0


|x| = x \text{ for all \(x \ge 0\)}
\text{\alpha in text mode }\alpha

\alpha in text mode α


\text{\alpha in text mode }\alpha

    14 Lectures 
     52 mins

 Ashraf Said

    11 Lectures 
     1 hours 

 Ashraf Said

    9 Lectures 
     1 hours 

 Emenwa Global, Ejike IfeanyiChukwu

    29 Lectures 
     2.5 hours 

 Mohammad Nauman

    14 Lectures 
     1 hours 

 Daniel Stern

    15 Lectures 
     47 mins

 Nishant Kumar
 Print
 Add Notes
 Bookmark this page
Convert an image into Blur using HTML/CSS - GeeksforGeeks

16 Feb, 2019
Given an image and the task is to convert the image into blur image using CSS property. In CSS, filter property is used to convert an image into blur image. Filter property is mainly used to set the visual effect of an image.
Syntax:
filter: blur()

Example 1: This example use blur filter to convert the image into blur image.
Original Image:
<!DOCTYPE html> <html>     <head>         <title>Convert into blur image</title>         <style>             img {                 -webkit-filter: blur(4px);                 filter: blur(4px);             }             h1 {                 color:green;             }         </style>     </head>     <body>         <center>         <h1>GeeksforGeeks</h1>         <h2>Blur Image</h2>         <img src= "https://media.geeksforgeeks.org/wp-content/uploads/interview-preparation-2.png"        width="500px" height="250px" alt="filter applied" />         </center>     </body> </html> 
Output:
Example 2: This example use blur filter to create background blur image.Original Image:
<!DOCTYPE html> <html>     <head>         <title>            Convert into blur image        </title>                   <style>             img {                 -webkit-filter: blur(4px);                 filter: blur(4px);             }             h1 {                 color:green;             }             .backgr-text {                position: absolute;                top: 20%;                left: 50%;                transform: translate(-50%, -50%);                text-align: center;            }        </style>     </head>           <body>         <center>             <img src= "https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-logo.png"            width="500px" height="250px" alt="filter applied" />                       <div class="backgr-text">                <h1>GeeksforGeeks</h1>                <h2>Blurred Background Image</h2>            </div>        </center>     </body> </html>                    
Output:
CSS-Misc
CSS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
How to create footer to stay at the bottom of a Web page?
How to update Node.js and NPM to next version ?
CSS to put icon inside an input element in a form
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Convert a string to an integer in JavaScript
How to style an hr element with CSS?

To style an hr element with CSS, the code is as follows −
 Live Demo
<!DOCTYPE html>
<html>
<meta name="viewport" content="width=device-width, initial-scale=1">
<head>
<style>
   body{
      font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
      margin: 20px;
   }
   hr{
      margin-bottom: 20px;
   }
   .solid {
      border-top: 5px solid rgb(16, 2, 141);
   }
   .dashed {
      border-top: 5px dashed rgb(190, 13, 146);
   }
   .double {
      border-top: 5px double rgb(22, 145, 11);
   }
   .dotted {
      border: 5px dotted rgb(200, 255, 0);
   }
   .round {
      border: 5px solid rgb(35, 196, 142);
      border-radius: 5px;
   }
</style>
</head>
<body>
<h1 style="text-align: center;">HR styling example</h1>
<hr class="solid">
<hr class="dashed">
<hr class="double">
<hr class="dotted">
<hr class="round">
</body>
</html>
The above code will produce the following output −
How to import a single function from a Python module?

You can use the "from module import function" statement to import a specific function from a Python module. For example, if you want to import the sin function from the math library without importing any other function, you can do it as follows:
>>> from math import sin
>>> sin(0)
0.0
Note that you don't have to prefix sin with "math." as only sin has been imported and not math. Also you can alias imported functions. For example,
>>> from math import cos as cosine
>>> cosine(0)
1.0
Tryit Editor v3.7

Tryit: The flex-basis property
How to set different opacity of edgecolor and facecolor of a patch in Matplotlib?

To set different opacity of edge and face color, we can use a color tuple and the 4th index of the tuple could set the opacity value of the colors.
Set the figure size and adjust the padding between and around the subplots.
Create a figure and a set of subplots using subplots() method.
Set different values for edge and face color opacity.
Add a rectangel patch using add_patch() method.
To display the figure, use show() method.
from matplotlib import pyplot as plt, patches

plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True

figure, ax = plt.subplots()
edge_color_opacity = 1 # 0<val<1
face_color_opacity = 0.75 # 0<val<1

ax.add_patch(patches.Rectangle((.25, .25), .50, .50,
                              edgecolor=(1, 0, 0, edge_color_opacity),
                              facecolor=(0, 1, 0, face_color_opacity),
                              linewidth=2))

plt.show()
C++ Program to implement Linear Extrapolation

In this tutorial, we will be discussing a program to implement Linear Extrapolation.
Extrapolation is defined as a process in which the required value for a certain function is beyond the lower or the upper limits of the function definition.
In the case of Linear Extrapolation, the value beyond the scope is found using the tangent made on the graph of the function to determine the required value. Linear Extrapolation gives quite accurate results when applied.
#include <bits/stdc++.h>
using namespace std;
//structuring the values of x and y
struct Data {
   double x, y;
};
//calculating the linear extrapolation
double calc_extrapolate(Data d[], double x){
   double y;
   y = d[0].y
      + (x - d[0].x)
      / (d[1].x - d[0].x)
         * (d[1].y - d[0].y);
   return y;
}
int main(){
   Data d[] = { { 1.2, 2.7 }, { 1.4, 3.1 } };
   double x = 2.1;
   cout << "Value of y (x = 2.1) : " << calc_extrapolate(d, x) << endl;
   return 0;
}
Value of y (x = 2.1) : 4.5
Loops in MySQL - GeeksforGeeks

17 Jan, 2022
The MySQL LOOP statement could be used to run a block of code or set of statements, again and again, depends on the condition.
Syntax :
[labelname:] LOOP
   statements
END LOOP [labelname]
Parameters –
labelname : It is an optional label at the start and end.
statements : They could have one or multiple statements, each ended by a semicolon (;) and executed by LOOP.
Syntax of the LOOP statement with LEAVE statement :
[labelname]: LOOP
     -- terminate the loop
   IF condition THEN
       LEAVE [labelname];
   END IF;
END LOOP;
Example-1 :
DROP PROCEDURE IF EXISTS GeekLoop();
DELIMITER $$ 
CREATE PROCEDURE GeekLoop()
 BEGIN
DECLARE no INT;
  SET no = 0;
  loop: LOOP
    SET no = no +1;
    select no ;
    IF no =5 THEN
     LEAVE loop;
    END IF;
 END LOOP loop;
SELECT no;
END $$
DELIMITER ;

Statement to check the output :
CALL GeekLoop();
Output –
0, 1, 2, 3, 4, 5
Example-2 :
DELIMITER $$
CREATE FUNCTION Geekdemo (value1 INT)
RETURNS INT
BEGIN
 DECLARE value2 INT;
 SET value2 = 0;
 label: LOOP
  SET income = value2 + value1 ;
  IF value2 < 4000 THEN
    ITERATE label;
  END IF;
  LEAVE label;
 END LOOP label;
 RETURN value2 ;
END $$
DELIMITER ;

Queries to check the output :
CALL Geekdemo();
Input –
value1: 3500
Output –
value2: 3500
Example-3 :
CREATE TABLE Geektable (value VARCHAR(50) NULL DEFAULT NULL);
DELIMITER $$ 
CREATE PROCEDURE ADD()
 BEGIN
  DECLARE a INT Default 1 ;
  simple_loop: LOOP     
    insert into table1 values(a);
    SET a=a+1;
    IF a=11 THEN
      LEAVE simple_loop;
    END IF;
 END LOOP simple_loop;
END $$

Queries to check the output –
CALL ADD();
Select value 
from Geektable;
Output –
1
2
3
4
5
6
7
8
9
10 
kk9826225
mysql
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
SQL Interview Questions
CTE in SQL
How to Update Multiple Columns in Single Update Statement in SQL?
Difference between SQL and NoSQL
Difference between DELETE, DROP and TRUNCATE
MySQL | Group_CONCAT() Function
Difference between DELETE and TRUNCATE
SQL - ORDER BY
SQL | Subquery
How to Create a Table With Multiple Foreign Keys in SQL?
How to pass an argument to the event handler in Tkinter?

In most situations, the callback functions can refer to as an Instance Method. An instance method accesses all its members and performs operations with them without specifying any arguments.
Let's consider a case where more than one component is defined and we want to handle some events with those components. To run multiple events, we prefer to pass multiple arguments in event handlers.
In this example, we have created multiple button widgets in a frame, and we will handle various events by passing the name of the widget as arguments. Once a Button will be clicked, it will update the Label widget and so on.
#Import the Tkinter library
from tkinter import *
from tkinter import ttk
from tkinter import filedialog
#Create an instance of Tkinter frame
win= Tk()
#Define the geometry
win.geometry("750x250")
#Define Event handlers for different Operations
def event_low(button1):
   label.config(text="This is Lower Value")
def event_mid(button2):
   label.config(text="This is Medium Value")
def event_high(button3):
   label.config(text="This is Highest value")
#Create a Label
label= Label(win, text="",font=('Helvetica 15 underline'))
label.pack()
#Create a frame
frame= Frame(win)
#Create Buttons in the frame
button1= ttk.Button(frame, text="Low", command=lambda:event_low(button1))
button1.pack(pady=10)
button2= ttk.Button(frame, text="Medium",command= lambda:event_mid(button2))
button2.pack(pady=10)
button3= ttk.Button(frame, text="High",command= lambda:event_high(button3))
button3.pack(pady=10)
frame.pack()
win.mainloop()
Running the above code will display a window that contains Buttons Low, Medium, and High. When we click a button, it will show some label text on the window.
\bf - Tex Command

\bf - Used to turn on boldface; affects uppercase and lowercase letters, and digits.
{ \bf ... }
\bf command is used to turn on boldface; affects uppercase and lowercase letters, and digits.

\bf AaBb\alpha\beta123 

AaBbαβ123


{\bf A B} A B 

ABAB


\bf AB \rm CD 

ABCD


\bf{AB}CD 

ABCD



\bf AaBb\alpha\beta123 

AaBbαβ123


\bf AaBb\alpha\beta123 
{\bf A B} A B 

ABAB


{\bf A B} A B 
\bf AB \rm CD 

ABCD


\bf AB \rm CD 
\bf{AB}CD 

ABCD


\bf{AB}CD 

    14 Lectures 
     52 mins

 Ashraf Said

    11 Lectures 
     1 hours 

 Ashraf Said

    9 Lectures 
     1 hours 

 Emenwa Global, Ejike IfeanyiChukwu

    29 Lectures 
     2.5 hours 

 Mohammad Nauman

    14 Lectures 
     1 hours 

 Daniel Stern

    15 Lectures 
     47 mins

 Nishant Kumar
 Print
 Add Notes
 Bookmark this page
Displaying distinct values in a column filtered on other column in SAP BO report

There are multiple ways to do this. First is by creating a variable like this:
Terms Count =Count([Terms Code]) in ([Sales #])
You have to add this variable to your report. It will display 1 for all Sales # 1000 and 2 for all Sales # 1001. You can apply a filter on Count > 1.
You can also do this using PREVIOUS() function as below:
Previous([Payment Terms Code]; ([Sales #];[Line #]))
Batch Script - NET STOP/START

This command is used to stop and start a particular service.
Net stop/start [servicename]

NET STOP Spooler
The above command is used to stop the printer spooler service. Following is the output of the above command.
The Print Spooler service is stopping.
The Print Spooler service was stopped successfully.
NET START Spooler

The above command is used to start the printer spooler service. Following is the output of the above command.
The Print Spooler service is starting.
The Print Spooler service was started successfully.

 Print
 Add Notes
 Bookmark this page
Python - Merge DataFrames of different length

To merge dataframes of different length, we need to use the merge() method. Let’s say the following is our 1st DataFrame with length 4 −
dataFrame1 = pd.DataFrame(
   {
      "Car": ['BMW', 'Lexus', 'Audi', 'Jaguar']
   }
)

print("DataFrame1 ...\n",dataFrame1)
print("DataFrame1 length = ", len(dataFrame1))
Following is our 2nd DataFrame with length 6 −
dataFrame2 = pd.DataFrame(
   {
      "Car": ['BMW', 'Lexus', 'Audi', 'Mercedes', 'Jaguar', 'Bentley']
   }
)

print("\nDataFrame2 ...\n",dataFrame2) print("DataFrame2 length = ", len(dataFrame2))
Now, merge DataFrames using the merge() −
mergedRes = dataFrame2.merge(dataFrame1, how='left')
Following is the code −
import pandas as pd
# Create DataFrame1
dataFrame1 = pd.DataFrame(
   {
      "Car": ['BMW', 'Lexus', 'Audi', 'Jaguar']
   }
)
print("DataFrame1 ...\n",dataFrame1)
# Find length of DataFrame1
print("DataFrame1 length = ", len(dataFrame1))
# Create DataFrame2
dataFrame2 = pd.DataFrame(
   {
      "Car": ['BMW', 'Lexus', 'Audi', 'Mercedes', 'Jaguar', 'Bentley']
   }
)
print("\nDataFrame2 ...\n",dataFrame2)
# Find length of DataFrame2
print("DataFrame2 length = ", len(dataFrame2))
# merge DataFrames
mergedRes = dataFrame2.merge(dataFrame1, how='left')
print("\nMerged data frame...\n", mergedRes)
This will produce the following output −
DataFrame1 ...
      Car
0     BMW
1   Lexus
2    Audi
3  Jaguar
DataFrame1 length = 4

DataFrame2 ...
        Car
0       BMW
1     Lexus
2      Audi
3  Mercedes
4    Jaguar
5   Bentley
DataFrame2 length = 6

Merged data frame...
        Car
0       BMW
1     Lexus
2      Audi
3  Mercedes
4    Jaguar
5   Bentley