code-rag-bench/online-tutorials huggingface dataset:
C program to find the length of a string?

The string is actually a one-dimensional array of characters which is terminated by a null character '\0'. Thus a null-terminated string contains the characters that comprise the string followed by a null.
To find the length of a string we need to loop and count all words in the loop until the ‘\0’ character is matched.
Input −naman 
Output − string length is 5
Explanation − we need to iterate over each index of the string until reach the end of string means ‘\0’ which is the null character. 
#include <stdio.h>
#include<string.h>
int main() {
   char string1[]={"naman"};
   int i=0, length;
   while(string1[i] !='\0') {
      i++;
   }
   length=i;
   printf(" string length is %d",length);
   return 0;
}
string length is 5
Powershell - Delete Folder

Remove-Item cmdlet is used to delete a directory by passing the path of the directory to be deleted.
In this example, we'll delete a folder D:\Temp\Test Folder1
Type the following command in PowerShell ISE Console
Remove-Item 'D:\temp\Test Folder1'
You can see the Test Folder1 in Windows Explorer is deleted now.
In this example, we'll remove the folder D:\Temp\Test Folder1 recursively. In first example, PowerShell confirms if directory is not empty. In this case, it will simply delete the item.
Type the following command in PowerShell ISE Console
Remove-Item 'D:\temp\Test Folder' -Recurse
You can see the content of temp folder in Windows Explorer where its folders are now removed.

    15 Lectures 
     3.5 hours 

 Fabrice Chrzanowski

    35 Lectures 
     2.5 hours 

 Vijay Saini

    145 Lectures 
     12.5 hours 

 Fettah Ben
 Print
 Add Notes
 Bookmark this page
Bubble sort in Java.

Following is the required program.
Live Demo
public class Tester {
   static void bubbleSort(int[] arr) {  
      int n = arr.length;  
      int temp = 0;  
      for(int i = 0; i < n; i++){  
         for(int j = 1; j < (n-i); j++){  
            if(arr[j-1] > arr[j]){  
               //swap elements  
               temp = arr[j-1];  
               arr[j-1] = arr[j];  
               arr[j] = temp;  
            }          
         }  
      }
   }  
   public static void main(String[] args) {  
      int arr[] = {21,60,32,01,41,34,5};
      System.out.println("Before Bubble Sort");  
      for(int i = 0; i < arr.length; i++){  
         System.out.print(arr[i] + " ");  
      }  
      System.out.println();  
      bubbleSort(arr);
      System.out.println("After Bubble Sort");  
      for(int i = 0; i < arr.length; i++){  
         System.out.print(arr[i] + " ");  
      }  
   }
}
Before Bubble Sort
21 60 32 1 41 34 5
After Bubble Sort
1 5 21 32 34 41 60
GATE | GATE-CS-2017 (Set 2) | Question 62 - GeeksforGeeks

28 Jun, 2021
If a random variable X has a Poisson distribution with mean 5, then the expression E[(X + 2)2] equals _____.
Note: This question appeared as Numerical Answer Type.(A) 54(B) 55(C) 56(D) 57Answer: (A)Explanation:
Using Linearity of Expectation, we can write, 
E[(X+2)2] = E[X2] + E[4X] + E[4]

In Poisson distribution, mean and variance are same.
Mean is given as 5. So variance should also be 5.
Also, variance = E[X2] – (E[X])2
5 =  E[X2] – 25
E[X2] = 30

Thus E[(X+2)2] = 30 + 4*5 + 4 = 54. 
Quiz of this Question
GATE-CS-2017 (Set 2)
GATE-GATE-CS-2017 (Set 2)
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | Gate IT 2007 | Question 25
GATE | GATE-CS-2001 | Question 39
GATE | GATE-CS-2000 | Question 41
GATE | GATE-CS-2005 | Question 6
GATE | GATE MOCK 2017 | Question 21
GATE | GATE MOCK 2017 | Question 24
GATE | GATE-CS-2006 | Question 47
GATE | Gate IT 2008 | Question 43
GATE | GATE-CS-2009 | Question 38
GATE | GATE-CS-2003 | Question 90
How to use aplay and spd-say command in Linux? - GeeksforGeeks

03 Aug, 2021
We can send the text to the terminal to play that as an audio clip. These are basically command-line audio player and works using Linux Sound Architecture. To send audio to the terminal to play, you can use aplay and spd-say command as shown below. 
1. aplay: This command in linux is used to play the audio file. 
Syntax:  
aplay filename
Example: 
 
Here, the maybe-next-time.wav is the audio file that we are playing. This command is especially for the Advanced Linux Sound Architecture) sound card drivers. 
2. spd-say This command in linux is used to play the given text as the sound. Basically, this works as text to speech converter. 
Syntax:  
spd-say "Your text"
Example: 
 
 
sagar0719kumar
linux-command
Picked
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
ZIP command in Linux with examples
TCP Server-Client implementation in C
SORT command in Linux/Unix with examples
tar command in Linux with examples
curl command in Linux with Examples
Conditional Statements | Shell Script
diff command in Linux with examples
Tail command in Linux with examples
UDP Server-Client implementation in C
scp command in Linux with Examples
Kolmogorov-Smirnov Test (KS Test) - GeeksforGeeks

10 Jun, 2020
Kolmogorov–Smirnov test a very efficient way to determine if two samples are significantly different from each other. It is usually used to check the uniformity of random numbers. Uniformity is one of the most important properties of any random number generator and Kolmogorov–Smirnov test can be used to test it.
The Kolmogorov–Smirnov test may also be used to test whether two underlying one-dimensional probability distributions differ. It is a very efficient way to determine if two samples are significantly different from each other.
The Kolmogorov–Smirnov statistic quantifies a distance between the empirical distribution function of the sample and the cumulative distribution function of the reference distribution, or between the empirical distribution functions of two samples.
To use the test for checking the uniformity of random numbers, we use the CDF (cumulative distribution function) of U[0, 1].
F(x)= x for 0<=x<=1
Empirical CDF, Sn(x)= (number of R1, R2...Rn < x)/N array of random numbers, the random numbers must be in the range of [0, 1].
H0(Null Hypothesis): Null hypothesis assumes that the numbers are uniformly distributed between 0-1. If we are able to reject the Null Hypothesis, this means that the numbers are not uniformly distributed between 0-1. Failure to reject the Null Hypothesis although does not necessarily mean that the numbers follow the uniform distribution.
Algorithm:
-> Rank the N random numbers in ascending order.
-> Calculate D+ as max(i/N-Ri) for all i in(1, N)
-> Calculate D- as max(Ri-((i-1)/N)) for all i in(1, N)
-> Calculate D as max(sqrt(N) * D+, sqrt(N) * D-)
-> If D>D(alpha) 
    Rejects Uniformity
   else
    It fails to reject the Null Hypothesis.
Below is the Python implementation of above algorithm :
import random  N = int(input("Enter the size of random numbers to be produced : "))D_plus =[]D_minus =[]_random =[]  # Rank the N random numbersfor i in range(0, N):    _random.append(random.random())    _random.sort()  # Calculate max(i/N-Ri)for i in range(1, N + 1):    x = i / N - _random[i-1]    D_plus.append(x)  # Calculate max(Ri-((i-1)/N))for i in range(1, N + 1):    y =(i-1)/N    y =_random[i-1]-y    D_minus.append(y)  # Calculate max(D+, D-)ans = max(sqrt(N) * D_plus, sqrt(N) * D_minus)print("Value of D is :")print(ans)
Reference – https://dl.acm.org/doi/pdf/10.1145/355719.355724
ardadrl
Machine Learning
Python
Machine Learning
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
ML | Linear Regression
Reinforcement learning
Decision Tree
Activation functions in Neural Networks
Introduction to Recurrent Neural Network
Read JSON file using Python
Adding new column to existing DataFrame in Pandas
Python map() function
How to get column names in Pandas dataframe
GATE | GATE-IT-2004 | Question 13 - GeeksforGeeks

28 Jun, 2021
Let P be a singly linked list. Let Q be the pointer to an intermediate node x in the list. What is the worst-case time complexity of the best known algorithm to delete the node x from the list?(A) O(n)(B) O(log2 n)(C) O(logn)(D) O(1)Answer: (D)Explanation: A simple solution is to traverse the linked list until you find the node you want to delete. But this solution requires pointer to the head node which contradicts the problem statement.
Fast solution is to copy the data from the next node to the node to be deleted and delete the next node. Something like following.
    // Find next node using next pointer
    struct node *temp  = node_ptr->next;

    // Copy data of next node to this node
    node_ptr->data  = temp->data;

    // Unlink next node
    node_ptr->next  = temp->next;

    // Delete next node
    free(temp);

Time complexity of this approach is O(1)
Refer this for implementation.
Note that this approach doesn’t work when node to deleted is last node. Since the question says intermediate node, we can use this approach.Quiz of this Question
GATE IT 2004
GATE-GATE IT 2004
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | Gate IT 2007 | Question 25
GATE | GATE-CS-2001 | Question 39
GATE | GATE-CS-2000 | Question 41
GATE | GATE-CS-2005 | Question 6
GATE | GATE MOCK 2017 | Question 21
GATE | GATE MOCK 2017 | Question 24
GATE | GATE-CS-2006 | Question 47
GATE | Gate IT 2008 | Question 43
GATE | GATE-CS-2009 | Question 38
GATE | GATE-CS-2003 | Question 90
Golang | Searching an element of int type in slice of ints - GeeksforGeeks

28 Aug, 2019
In Go language slice is more powerful, flexible, convenient than an array, and is a lightweight data structure. The slice is a variable-length sequence which stores elements of a similar type, you are not allowed to store different type of elements in the same slice.In the Go slice, you can search an element of int type in the given slice of ints with the help of SearchInts() function. This function searches for the given element in a sorted slice of ints and returns the index of that element if present in the given slice. And if the given element is not available in the slice(it could be len(s_slice)), then it returns the index to insert the element in the slice. The specified slice must be sorted in ascending order. It is defined under the sort package so, you have to import sort package in your program for accessing SearchInts function.
Syntax:
func SearchInts(s_slice []int, i int) int
Example 1:
// Go program to illustrate how to search// an int type element in the slice of intspackage main  import (    "fmt"    "sort")  // Main functionfunc main() {      // Creating and searching an element     // in the given slice of ints    // Using SearchInts function    res1 := sort.SearchInts([]int{1, 2, 3,                        4, 5, 6, 7, 8}, 5)          res2 := sort.SearchInts([]int{200, 300,                  400, 500, 600, 700}, 400)      // Displaying the results    fmt.Println("Result 1: ", res1)    fmt.Println("Result 2: ", res2)  }
Output:
Result 1:  4
Result 2:  2

Example 2:
// Go program to illustrate how to search an // element of int type in the slice of intspackage main  import (    "fmt"    "sort")  // Main functionfunc main() {      // Creating and initializing    // slice of ints using the     // shorthand declaration    slice_1 := []int{34, 67, 78, 10, 43, 67, 8}    slice_2 := []int{100, 500, 300, 600, 900, 1000}      var f1, f2, f3 int    f1 = 67    f2 = 300    f3 = 100      // Sorting the given slice of ints    sort.Ints(slice_1)    sort.Ints(slice_2)      // Displaying the slices    fmt.Println("Slice 1: ", slice_1)    fmt.Println("Slice 2: ", slice_2)      // Searching a int type element     // in the given slice using     // the SearchInts function    res1 := sort.SearchInts(slice_1, f1)    res2 := sort.SearchInts(slice_2, f2)    res3 := sort.SearchInts(slice_2, f3)      // Displaying the results    fmt.Println("Result 1: ", res1)    fmt.Println("Result 2: ", res2)    fmt.Println("Result 3: ", res3)  }
Output:
Slice 1:  [8 10 34 43 67 67 78]
Slice 2:  [100 300 500 600 900 1000]
Result 1:  4
Result 2:  1
Result 3:  0

Golang
Golang-Slices
Go Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
6 Best Books to Learn Go Programming Language
How to Parse JSON in Golang?
Strings in Golang
Time Durations in Golang
Structures in Golang
How to iterate over an Array using for loop in Golang?
Rune in Golang
Loops in Go Language
Defer Keyword in Golang
Class and Object in Golang
find_element_by_name() driver method - Selenium Python - GeeksforGeeks

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

To set image contrast in CSS, use filter contrast(%). Remember, the value 0 makes the image black, 100% is for original image and default. Rest, you can set any value of your choice, but values above 100% would make the image with more contrast.
Let us now see an example to adjust image contrast with CSS3 −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<style>
img.demo {
   filter: brightness(120%);
   filter: contrast(120%);
}
</style>
</head>
<body>
<h1>Learn MySQL</h1>
<img src="https://www.tutorialspoint.com/mysql/images/mysql-mini-logo.jpg" alt="MySQL" width="160" height="150">
<h1>Learn MySQL</h1>
<p>Below image is brighter and has more contrast than the original image above.</p>
<img class="demo" src="https://www.tutorialspoint.com/mysql/images/mysql-mini-logo.jpg" alt="MySQL" width="160" height="150">
</body>
</html>
Tryit Editor v3.7

Tryit: bigger HTML heading
Python - Check if a list is contained in another list

Given two different python lists we need to find if the first list is a part of the second list.
We can first apply the map function to get the elements of the list and then apply the join function to cerate a comma separated list of values. Next we use the in operator to find out if the first list is part of the second list.
 Live Demo
listA = ['x', 'y', 't']
listB = ['t', 'z','a','x', 'y', 't']
print("Given listA elemnts: ")
print(', '.join(map(str, listA)))
print("Given listB elemnts:")
print(', '.join(map(str, listB)))

res = ', '.join(map(str, listA)) in ', '.join(map(str, listB))
if res:
   print("List A is part of list B")
else:
   print("List A is not a part of list B")
Running the above code gives us the following result −
Given listA elemnts:
x, y, t
Given listB elemnts:
t, z, a, x, y, t
List A is part of list B
We can design a for loop to check the presence of elements form one list in another using the range function and the len function.
 Live Demo
listA = ['x', 'y', 't']
listB = ['t', 'z','a','x', 'y', 't']
print("Given listA elemnts: \n",listA)
print("Given listB elemnts:\n",listB)

n = len(listA)
res = any(listA == listB[i:i + n] for i in range(len(listB) - n + 1))

if res:
   print("List A is part of list B")
else:
   print("List A is not a part of list B")
Running the above code gives us the following result −
Given listA elemnts:
['x', 'y', 't']
Given listB elemnts:
['t', 'z', 'a', 'x', 'y', 't']
List A is part of list B
Git GitHub Getting Started

Go to GitHub and sign up for an account:
Note: Remember to use the same e-mail address you used in the Git config.
Now that you have made a GitHub account, sign in, and create a new Repo:
And fill in the relevant details:
We will go over the different options and what they mean later. But for 
now, choose Public (if you want the repo to be viewable for anyone) or Private 
(if you want to choose who should be able to view the repo). Either way, you 
will be able to choose who can contribute to the repo.
Then click "Create repository".
Since we have already set up a local Git repo, we are going to 
push that to GitHub:
Copy the URL, or click the clipboard marked in the image above.
Now paste it the following command:
git remote add origin https://github.com/w3schools-test/hello-world.git
git remote add origin URL specifies that you are adding a remote repository, with the specified URL,   as an origin to your local Git repo.
Now we are going to push our master branch to the origin url, and set it as the default remote branch:
git push --set-upstream origin master
Enumerating objects: 22, done.
Counting objects: 100% (22/22), done.
Delta compression using up to 16 threads
Compressing objects: 100% (22/22), done.
Writing objects: 100% (22/22), 92.96 KiB | 23.24 MiB/s, done.
Total 22 (delta 11), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (11/11), done.
To https://github.com/w3schools-test/hello-world.git
 * [new branch]      master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.
Note: Since this is the first time you are connecting to 
  GitHub, you will get some kind of notification you to authenticate this connection.
Now, go back into GitHub and see that the repository has been updated:
Add a remote repository as an origin:
git    https://abc.com/x/y.git


Start the Exercise
We just launchedW3Schools videos
Get certifiedby completinga course today!
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com
Your message has been sent to W3Schools.
Differences between org.simple.json and org.json libraries in Java?

The org.json.simple library allows us to read and write JSON data in Java. In other words, we can encode and decode the JSON object. The org.json.simple package contains important classes like JSONValue, JSONObject, JSONArray, JsonString and JsonNumber. We need to install the json-simple.jar file to execute a JSON program whereas org.json library has classes to parse JSON for Java. It also converts between JSON and XML, HTTP header, Cookies, and CDF. The org.json package contains important classes like JSONObject, JSONTokener, JSONWriter, JSONArray, CDL, Cookie and CookieList. We need to install the json.jar file to execute a JSON program.
import org.json.simple.JSONObject;
public class SimpleJsonTest {
   public static void main(String[] args) {
      JSONObject jsonObj = new JSONObject();
      jsonObj.put("empName", "Raja");
      jsonObj.put("employeeId", "115");
      jsonObj.put("age","30");
      System.out.println(jsonObj.toJSONString());
   }
}
{"empName":"Raja","employeeId":"115","age":"30"}
import org.json.*;
public class JSONTest {
   public static void main(String args[]) throws JSONException {
      String json = "{" + "Name : Jai," + "Age : 25, " + "Salary: 25000.00 " + "}";
      JSONObject jsonObj = new JSONObject(json);
      System.out.println(jsonObj.toString());
   }
}
{"Salary":25000,"Age":25,"Name":"Jai"}
PostgreSQL – IN operator

28 Aug, 2020
The PostgreSQL IN operator is used with the WHERE clause to check against a list of values.
The syntax for using IN operator with the WHERE clause to check against a list of values which returns a boolean value depending upon the match is as below:
Syntax: value IN (value1, value2, ...)
The syntax for using IN operator to return the matching values in contrast with the SELECT statement is as below:
Syntax: value IN (SELECT value FROM tbl_name);
For the sake of this article we will be using the sample DVD rental database, which is explained here and can be downloaded by clicking on this link.
Now, let’s look into a few examples.Example 1:Here we will make a query for the rental information of customer id 10 and 12, using the WHERE clause and IN operator.
SELECT
 customer_id,
    rental_id,
    return_date
FROM
    rental
WHERE
    customer_id IN (10, 12)
ORDER BY
    return_date DESC;
Output:
Example 2:Here we will make a query for a list of customer id of customers that has rental’s return date on 2005-05-27.
SELECT
    first_name,
    last_name
FROM
    customer
WHERE
    customer_id IN (
        SELECT
            customer_id
        FROM
            rental
        WHERE
            CAST (return_date AS DATE) = '2005-05-27'
    );
Output:
postgreSQL-operators
PostgreSQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
PostgreSQL - Psql commands
PostgreSQL - Change Column Type
PostgreSQL - For Loops
PostgreSQL - Function Returning A Table
PostgreSQL - LIMIT with OFFSET clause
PostgreSQL - ARRAY_AGG() Function
PostgreSQL - DROP INDEX
PostgreSQL - Create Auto-increment Column using SERIAL
PostgreSQL - Copy Table
How to use PostgreSQL Database in Django?
Lodash | _.remove() Method

23 Jan, 2022
The _.remove() method is used to remove all elements from the array that predicate returns True and returns the removed elements.
Syntax: 
_.remove(array, function)
Parameters: This method accept two parameters as mentioned above and described below:  
array: This parameter holds the array that need to be modify.
function: This parameter holds the function that invoked per iteration.
Return Value: It returns an array of removed elements.
Example: Here all the elements returning true are even elements. The function is invoked on all the elements (n) of the array. 
Javascript
let x = [1, 2, 3, 4, 5]; let even = _.remove(x, function(n) {    return n % 2 == 0;}); console.log('Original Array ', x);console.log('Removed element array ', even);
Here, const _ = require(‘lodash’) is used to import the lodash library into the file.
Output: 
Original Array  [ 1, 3, 5 ]
Removed element array  [ 2, 4 ]
Example 2: This example removes all the vowels from an array containing alphabets and store them in a new array.  
Javascript
const _ = require('lodash');   let x = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'];   let vowelArray = _.remove(x, function(n) {       let vowels = ['a', 'e', 'i', 'o', 'u'];       for (let i = 0; i < 5; i++)    {        if (n === vowels[i])        {            return true;        }    }});
Output: 
Original Array  [ 'b', 'c', 'd', 'f', 'g', 'h' ]
Removed element array  [ 'a', 'e', 'i' ]
Example 3: This example removes all the integers from a given array containing floats, characters, and integers. 
Javascript
let x = ['a', 'b', 1, 5.6, 'e', -7, 'g', 4, 10.8];   let intsArray = _.remove(x, function(n) {       return Number.isInteger(n);});   console.log('Original Array ', x);console.log('Removed element array ', intsArray);
Output: 
Original Array  [ 'a', 'b', 5.6, 'e', 'g', 10.8 ]
Removed element array  [ 1, -7, 4 ]
Note: This will not work in normal JavaScript because it requires the library lodash to be installed.Reference: https://lodash.com/docs/4.17.15#remove 
gulshankumarar231
sagar0719kumar
JavaScript-Lodash
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
Difference Between PUT and PATCH Request
How to append HTML code to a div using JavaScript ?
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
Jython - Loops

In general, statements in a program are executed sequentially: The first statement in a function is executed first, followed by the second, and so on. There may be a situation when you need to execute a block of code several number of times. Statements that provide such repetition capability are called looping statements.
In Jython, a loop can be formed by two statements, which are −
The while statement and
The while statement and
The for statement
The for statement
A while loop statement in Jython is similar to that in Java. It repeatedly executes a block of statements as long as a given condition is true. The following flowchart describes the behavior of a while loop.
The general syntax of the while statement is given below.
while expression:
   statement(s)

The following Jython code uses the while loop to repeatedly increment and print value of a variable until it is less than zero.
count = 0
while count<10:
   count = count+1
   print "count = ",count
print "Good Bye!"
Output − The output would be as follows.
count =  1
count =  2
count =  3
count =  4
count =  5
count =  6
count =  7
count =  8
count =  9
count =  10
Good Bye!

The FOR loop in Jython is not a counted loop as in Java. Instead, it has the ability to traverse elements in a sequence data type such as string, list or tuple. The general syntax of the FOR statement in Jython is as shown below −
for iterating_var in sequence:
   statements(s)

We can display each character in a string, as well as each item in a List or Tuple by using the FOR statement as shown below −
#each letter in string
for letter in 'Python':
   print 'Current Letter :', letter
Output − The output would be as follows.
Current Letter : P
Current Letter : y
Current Letter : t
Current Letter : h
Current Letter : o
Current Letter : n

Let us consider another instance as follows.
#each item in list
libs = [‘PyQt’, 'WxPython',  'Tkinter']
for lib in libs:        # Second Example
   print 'Current library :', lib
Output − The output will be as follows.
Current library : PyQt
Current library : WxPython
Current library : Tkinter

Here is another instance to consider.
#each item in tuple
libs = (‘PyQt’, 'WxPython',  'Tkinter')
for lib in libs:        # Second Example
   print 'Current library :', lib
Output − The output of the above program is as follows.
Current library : PyQt
Current library : WxPython
Current library : Tkinter

In Jython, the for statement is also used to iterate over a list of numbers generated by range() function. The range() function takes following form −
range[([start],stop,[step])

The start and step parameters are 0 and 1 by default. The last number generated is stop step. The FOR statement traverses the list formed by the range() function. For example −
for num in range(5):
   print num
It produces the following output −
0
1
2
3
4

 Print
 Add Notes
 Bookmark this page
How to create side by side histograms in base R?

To create side by side histograms in base R, we first need to create a histogram using hist function by defining a larger limit of X-axis with xlim argument. After that we can create another histogram that has the larger mean and smaller standard deviation so that the bars do not clash with each other and add=T argument must also be added inside the second hist function.
 Live Demo
hist(rnorm(5000,mean=5,sd=2.1),col="green",xlim=c(1,20))
hist(rnorm(5000,mean=15,sd=1.25),col="red",add=T)
Java String codePointAt() Method

❮ String Methods

Return the Unicode of the first character in a string (the Unicode value 
  of "H" is 72):
String myStr = "Hello";
int result = myStr.codePointAt(0);
System.out.println(result);

Try it Yourself »

The codePointAt() method returns the Unicode 
value of the character at the specified index in a string.
The index of the first character is 0, the second character is 1, and so on.
public int codePointAt(int index)

We just launchedW3Schools videos
Get certifiedby completinga course today!
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com
Your message has been sent to W3Schools.
How can I remove the same element in the list by Python

Just remove return statement outside for block. It will work. Also last print statement should have remove_same instead of remaove_new
def remove_same(L1, L2):
    L1_copy = L1[:]
    for e in L1_copy:
        if e in L2:
             L1.remove(e)
    return L1

L1 = [1,2,3,4]
L2 = [1,2,5,6]
print(remove_same(L1, L2))
The result:
[3, 4]
Check if both halves of the string have same set of characters in Python

We can split a long string from the middle and check if the two halves are equal or not. The input string may have an odd or even number of characters. If it has an even number of characters, we divide the two halves by taking half of the length. But if the number of characters is odd then we ignore the middlemost character and then compare the remaining two halves.
In the below program we create the two halves of the input string with above logic and then
from collections import Counter
def comparehalves(input_string):
   str_len = len(input_string)
# If number of characyes is odd
# ignore the middle character
   if (str_len % 2 != 0):
      left = input_string[0:int(str_len / 2)]
      right = input_string[(int(str_len / 2)) + 1:]
   else:
      left = input_string[0:int(str_len / 2)]
      right = input_string[int(str_len / 2):]
# Convert the halves into lists
# and sort them
   l1 = list(left)
   l1.sort()
   l2 = list(right)
   l2.sort()
   if l1 == l2:
      print ("Same character in both halves")
   else:
      print ("Both halves are different ")
in_string = input("Enter String: ")
comparehalves(in_string)
Running the above code gives us the following result −
# Run1
Enter String: Tutorials
Both halves are different
# Run2
Enter String: TutTut
Same character in both halves
What is the purpose of a self-executing function in JavaScript?

The purpose of a self-executing is that those variables declared in the self-executing function are only available inside the self-executing function.
Variables declared in the self-executing function are, by default, only available to code within the self-executing function.
It is an immediately invoked function expression (IIFE). It is a function, which executes on creation.
Here is the syntax −
(function() {
   // code
})();
As you can see above, the following pair of parentheses converts the code inside the parentheses into an expression:
function(){...}
In addition, the next pair, i.e. the second pair of parentheses continues the operation. It calls the function, which resulted from the expression above.
MySQL query to get the count of distinct records in a column

To get the count of distinct records, use DISTINCT along with COUNT(). Following is the syntax −
select count(DISTINCT yourColumnName) from yourTableName;
Let us first create a table −
mysql> create table DemoTable
-> (
-> Name varchar(20),
-> Score int
-> );
Query OK, 0 rows affected (0.67 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('John',56);
Query OK, 1 row affected (0.18 sec)

mysql> insert into DemoTable values('Sam',89);
Query OK, 1 row affected (0.20 sec)

mysql> insert into DemoTable values('John',56);
Query OK, 1 row affected (0.17 sec)

mysql> insert into DemoTable values('Carol',60);
Query OK, 1 row affected (0.20 sec)

mysql> insert into DemoTable values('Sam',89);
Query OK, 1 row affected (0.14 sec)

mysql> insert into DemoTable values('Carol',60);
Query OK, 1 row affected (0.20 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable
This will produce the following output −
+-------+-------+
| Name  | Score |
+-------+-------+
| John  | 56    |
| Sam   | 89    |
| John  | 56    |
| Carol | 60    |
| Sam   | 89    |
| Carol | 60    |
+-------+-------+
6 rows in set (0.00 sec)
Here is the query to get to get the count of distinct records in a column −
mysql> select count(DISTINCT Score) from DemoTable;
This will produce the following output −
+-----------------------+
| count(DISTINCT Score) |
+-----------------------+
| 3                     |
+-----------------------+
1 row in set (0.00 sec)
Write a C program of library management system using switch case

How to store the books-related information of library using C programming.
Step 1: Declare a structure which holds data members
Step 2: declare variables which are used for loop
Step 3: use switch case to work on each module
Step 4: case 1- for Adding book information
        Case 2- for Display book information
        Case 3- for Finding number for books in library
        Case 4- for EXIT
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<string.h>
struct library{
   char bookname[50];
   char author[50];
   int noofpages;
   float price;
};
int main(){
   struct library lib[100];
   char bookname[30];
   int i,j, keepcount;
   i=j=keepcount = 0;
   while(j!=6){
      printf("\n1. Add book information\n");
      printf("2.Display book information\n");
      printf("3. no of books in the library\n");
      printf("4. Exit");
      printf ("\n\nEnter one of the above : ");
      scanf("%d",&j);
      switch (j){
         /* Add book */
         case 1:
            printf ("Enter book name = ");
            scanf ("%s",lib[i].bookname);
            printf ("Enter author name = ");
            scanf ("%s",lib[i].author);
            printf ("Enter pages = ");
            scanf ("%d",&lib[i].noofpages);
            printf ("Enter price = ");
            scanf ("%f",&lib[i].price);
            keepcount++;
            i++;
            break;
         case 2:
            printf("you have entered the following information\n");
            for(i=0; i<keepcount; i++){
               printf ("book name = %s\n",lib[i].bookname);
               printf ("\t author name = %s\n",lib[i].author);
               printf ("\t pages = %d\n",lib[i].noofpages);
               printf ("\t price = %f\n",lib[i].price);
            }
            break;
         case 3:
            printf("\n No of books in library : %d", keepcount);
            break;
         case 4:
            exit (0);
      }
   }
   return 0;
}
1. Add book information
2.Display book information
3. no of books in the library
4. Exit

Enter one of the above : 1
Enter book name = HarryPotter
Enter author name = hp
Enter pages = 250
Enter price = 350.6

1. Add book information
2.Display book information
3. no of books in the library
4. Exit

Enter one of the above : 2
you have entered the following information
book name = HarryPotter
         author name = hp
         pages = 250
         price = 350.600006

1. Add book information
2.Display book information
3. no of books in the library
4. Exit

Enter one of the above : 3

No of books in library : 1
1. Add book information
2.Display book information
3. no of books in the library
4. Exit

Enter one of the above : 4
How to use substring () in Android textview?

This example demonstrate about How to use substring () in Android textview.
Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.
Step 2 − Add the following code to res/layout/activity_main.xml.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:app="http://schemas.android.com/apk/res-auto"
   xmlns:tools="http://schemas.android.com/tools"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:orientation="vertical"
   android:gravity="center"
   tools:context=".MainActivity">
   <EditText
      android:id="@+id/name"
      android:layout_width="match_parent"
      android:hint="Enter name"
      android:layout_height="wrap_content" />
   <Button
      android:id="@+id/click"
      android:text="Click"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content" />
   <TextView
      android:id="@+id/textview"
      android:layout_width="wrap_content"
      android:textSize="25sp"
      android:layout_height="wrap_content" />
</LinearLayout>
In the above code, we have taken name as Edit text, when user click on button it will take data and return substring value.
Step 3 − Add the following code to src/MainActivity.java
package com.example.myapplication;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {
   EditText name;
   Button button;
   TextView text;

   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      name = findViewById(R.id.name);
      button = findViewById(R.id.click);
      text = findViewById(R.id.textview);
      button.setOnClickListener(new View.OnClickListener() {
         @Override
         public void onClick(View v) {
            if (!name.getText().toString().isEmpty()) {
               if (name.getText().toString().length() >= 0) {
                  String substring = name.getText().toString().substring(0,5);
                  text.setText(String.valueOf(substring));
               }
            } else {
               name.setError("Plz enter name");
            }
         }
      });
   }
}
Let's try to run your application. I assume you have connected your actual Android Mobile device with your computer. To run the app from android studio, open one of your project's activity files and click Run  icon from the toolbar. Select your mobile device as an option and then check your mobile device which will display your default screen −
In the above result, enter the string as “sairamkrishnaprasadkrishnamm” and it returned sub string value from 0th index to 5th index as saira
Click here to download the project code
C++ Iterator Library - prev

It returns an iterator pointing to the element that it would be pointing to if advanced -n positions.
Following is the declaration for std::prev.
template <class BidirectionalIterator>
  BidirectionalIterator prev (BidirectionalIterator it,
       typename iterator_traits<BidirectionalIterator>::difference_type n = 1);

it − It is a base postion in iterator.
it − It is a base postion in iterator.
n − It indicates about number of postion.
n − It indicates about number of postion.
It returned an iterator to the element n positions before it.
If any of the arithmetical operations performed on the iterator throws.
constant for random-access iterators.
The following example shows the usage of std::prev.
#include <iostream>     
#include <iterator>     
#include <list>         
#include <algorithm>    

int main () {
   std::list<int> mylist;
   for (int i = 0; i < 10; i++) mylist.push_back (i*1);

   std::cout << "The last element is " << *std::prev(mylist.begin()) << '\n';

   return 0;
}
Let us compile and run the above program, this will produce the following result −
The last element is 10

 Print
 Add Notes
 Bookmark this page
How to set an Android App's background image repeated?

This example demonstrates about How to set an Android App's background image repeated
Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.
Step 2 − Add the following code to res/drawable/app_background.xml.
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android" android:src="@drawable/image1" android:tileMode="repeat" />
Step 2 − Add the following code to res/values/styles.xml.
<resources>
   <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
      <item name="colorPrimary">@color/colorPrimary</item>
      <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
      <item name="colorAccent">@color/colorAccent</item>
      <item name="android:windowBackground">@drawable/app_background</item>
   </style>
</resources>
Step 2 − Add the following code to res/layout/activity_main.xml.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:layout_margin="16dp" />
Step 3 − Add the following code to src/MainActivity.java
package app.com.sample;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity {
   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
   }
}
Step 4 − Add the following code to androidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="app.com.sample">
   <application
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:supportsRtl="true"
      android:theme="@style/AppTheme">
      <activity android:name=".MainActivity">
         <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
         </intent-filter>
      </activity>
   </application>
</manifest>
Let's try to run your application. I assume you have connected your actual Android Mobile device with your computer. To run the app from android studio, open one of your project's activity files and click Run  icon from the toolbar. Select your mobile device as an option and then check your mobile device which will display your default screen −
Click here to download the project code.
Array.Find() Method in C#

The Array.Find() method in C# is used to search for an element that matches the conditions defined by the specified predicate and returns the first occurrence within the entire Array.
Following is the syntax −
public static T Find<T> (T[] array, Predicate<T> match);
Above, the array is the one-dimensional, zero-based array to search, whereas match is the predicate that defines the conditions of the element to search for.
Let us now see an example to implement the Array.Find() method −
using System;
public class Demo{
   public static void Main(){
      Console.WriteLine("Array elements...");
      string[] arr = { "car", "bike", "truck", "bus"};
      for (int i = 0; i < arr.Length; i++){
         Console.Write("{0} ", arr[i]);
      }
      Console.WriteLine();
      string res = Array.Find(arr, ele => ele.StartsWith("t",
      StringComparison.Ordinal));
      Console.Write("Searched element...");
      Console.Write("{0}", res);
   }
}
This will produce the following output −
Array elements...
car bike truck bus
Searched element...truck
Sort in C++ Standard Template Library (STL) - GeeksforGeeks

11 May, 2022
Sorting is one of the most basic functions applied to data. It means arranging the data in a particular fashion, which can be increasing or decreasing. There is a builtin function in C++ STL by the name of sort(). This function internally uses IntroSort. In more details it is implemented using hybrid of QuickSort, HeapSort and InsertionSort.By default, it uses QuickSort but if QuickSort is doing unfair partitioning and taking more than N*logN time, it switches to HeapSort and when the array size becomes really small, it switches to InsertionSort. 
The prototype for sort is : 
sort(startaddress, endaddress)

startaddress: the address of the first 
              element of the array
endaddress: the address of the next 
            contiguous location of the 
            last element of the array.
So actually sort() sorts in the 
range of [startaddress,endaddress)
C++
// C++ program to sort an array#include <algorithm>#include <iostream>  using namespace std;  void show(int a[], int array_size){    for (int i = 0; i < array_size; ++i)        cout << a[i] << " ";}  // Driver codeint main(){    int a[] = { 1, 5, 8, 9, 6, 7, 3, 4, 2, 0 };        // size of the array    int asize = sizeof(a) / sizeof(a[0]);    cout << "The array before sorting is : \n";        // print the array    show(a, asize);        // sort the array    sort(a, a + asize);      cout << "\n\nThe array after sorting is :\n";        // print the array after sorting    show(a, asize);      return 0;}
The array before sorting is : 
1 5 8 9 6 7 3 4 2 0 

The array after sorting is :
0 1 2 3 4 5 6 7 8 9 
Refer std::sort() for more details.
manish095
harshitmuhal
PrashunJha
hrithikmaheshwari42
kk9826225
cpp-algorithm-library
STL
C++
STL
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Virtual Function in C++
Constructors in C++
Templates in C++ with Examples
Operator Overloading in C++
Socket Programming in C/C++
Polymorphism in C++
Copy Constructor in C++
Friend class and function in C++
C++ Data Types
Left Shift and Right Shift Operators in C/C++