code-rag-bench/online-tutorials huggingface dataset:
Python 3 - String capitalize() Method

It returns a copy of the string with only its first character capitalized.
Following is the syntax for capitalize() method −
str.capitalize()

NA
string
#!/usr/bin/python3

str = "this is string example....wow!!!"
print ("str.capitalize() : ", str.capitalize())
When we run above program, it produces the following result −
str.capitalize() :  This is string example....wow!!!


    187 Lectures 
     17.5 hours 

 Malhar Lathkar

    55 Lectures 
     8 hours 

 Arnab Chakraborty

    136 Lectures 
     11 hours 

 In28Minutes Official

    75 Lectures 
     13 hours 

 Eduonix Learning Solutions

    70 Lectures 
     8.5 hours 

 Lets Kode It

    63 Lectures 
     6 hours 

 Abhilash Nelson
 Print
 Add Notes
 Bookmark this page
PostgreSQL - FETCH clause - GeeksforGeeks

28 Aug, 2020
The PostgreSQL FETCH clause has a functionality similar to the PostgreSQL LIMIT clause. It is used to retrieve a portion of rows returned by a query. As the LIMIT clause is not a standard SQL-command, PostgreSQL provides a standard way of fetching a subset of results from a query.
Syntax:OFFSET start { ROW | ROWS }FETCH { FIRST | NEXT } [ row_count ] { ROW | ROWS } ONLY
Let’s analyze the above syntax:
ROW and FIRST are synonymous with ROWS and NEXT respectively.
The start is an integer value that is either zero or positive. By default, it is zero.
The row_count is either one or higher. By default, it is one.
As the order of rows stored in the table is unpredictable, one should always use the FETCH clause with the ORDER BY clause to make the result set consistent.
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 query the first 10 rows of the film sorted by “title” from the film table of our sample database.
SELECT
    film_id,
    title
FROM
    film
ORDER BY
    title 
FETCH FIRST 10 ROW ONLY;
Output:
Example 2:Here we will query the first 10 rows of the film after the first five films, sorted by “title” from the film table of our sample database.
SELECT
    film_id,
    title
FROM
    film
ORDER BY
    title 
OFFSET 5 ROWS 
FETCH FIRST 10 ROW ONLY;
Output:
postgreSQL-clauses
PostgreSQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
PostgreSQL - Change Column Type
PostgreSQL - Psql commands
PostgreSQL - For Loops
PostgreSQL - Function Returning A Table
PostgreSQL - Create Auto-increment Column using SERIAL
PostgreSQL - ARRAY_AGG() Function
PostgreSQL - DROP INDEX
PostgreSQL - Copy Table
PostgreSQL - Interval Data Type
How to use PostgreSQL Database in Django?
Scala Collections - Filter Method

filter() method is method used by List to select all elements which satisfies a given predicate.
The following is the syntax of filter method.
def filter(p: (A) => Boolean): List[A]

Here, p: (A) => Boolean is a predicate or condition to be applied on each element of the list. This method returns the all the elements of list which satisfiles the given condition.
Below is an example program of showing how to use filter method −
object Demo {
   def main(args: Array[String]) = {
      val list = List(3, 6, 9, 4, 2)
      // print list
      println(list)
      //apply operation
      val result = list.filter(x=>{x % 3 == 0})
      //print result
      println(result)      
   }
}
Save the above program in Demo.scala. The following commands are used to compile and execute this program.
\>scalac Demo.scala
\>scala Demo

List(3, 6, 9, 4, 2)
List(3, 6, 9)


    82 Lectures 
     7 hours 

 Arnab Chakraborty

    23 Lectures 
     1.5 hours 

 Mukund Kumar Mishra

    52 Lectures 
     1.5 hours 

 Bigdata Engineer

    76 Lectures 
     5.5 hours 

 Bigdata Engineer

    69 Lectures 
     7.5 hours 

 Bigdata Engineer

    46 Lectures 
     4.5 hours 

 Stone River ELearning
 Print
 Add Notes
 Bookmark this page
LocalTime isAfter() method in Java with Examples - GeeksforGeeks

03 Dec, 2018
The isAfter() method of a LocalTime class is used to check if this LocalTime timeline position is after the LocalTime passed as parameter or not. If this LocalTime timeline position is after the LocalTime passed as a parameter then the method will return true else false. The comparison is based on the time-line position of the instants.
Syntax:
public boolean isAfter(LocalTime other)

Parameters: This method accepts a single parameter other which is the other LocalTime object to compare to. It should not be null.
Return value: This method returns true if this time is after the specified time, else false.
Below programs illustrate the isAfter() method:
Program 1:
// Java program to demonstrate// LocalTime.isAfter() method  import java.time.*;  public class GFG {    public static void main(String[] args)    {          // create a LocalTime object        LocalTime time1            = LocalTime.parse("19:34:50.63");          // create other LocalTime        LocalTime time2            = LocalTime.parse("23:14:00.63");          // print instances        System.out.println("LocalTime 1: " + time1);        System.out.println("LocalTime 2: " + time2);          // check if LocalTime is after LocalTime        // using isAfter()        boolean value = time1.isAfter(time2);          // print result        System.out.println("Is LocalTime1 after LocalTime2: "                           + value);    }}
LocalTime 1: 19:34:50.630
LocalTime 2: 23:14:00.630
Is LocalTime1 after LocalTime2: false

Program 2:
// Java program to demonstrate// LocalTime.isAfter() method  import java.time.*;  public class GFG {    public static void main(String[] args)    {          // create a LocalTime object        LocalTime time1            = LocalTime.parse("23:59:11.98");          // create other LocalTime        LocalTime time2            = LocalTime.parse("10:24:53.21");          // print instances        System.out.println("LocalTime 1: " + time1);        System.out.println("LocalTime 2: " + time2);          // check if LocalTime is after LocalTime        // using isAfter()        boolean value = time1.isAfter(time2);          // print result        System.out.println("Is LocalTime1 after LocalTime2: "                           + value);    }}
LocalTime 1: 23:59:11.980
LocalTime 2: 10:24:53.210
Is LocalTime1 after LocalTime2: true

Reference: https://docs.oracle.com/javase/10/docs/api/java/time/LocalTime.html#isAfter(java.time.LocalTime)
Java-Functions
Java-LocalTime
Java-time package
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Initialize an ArrayList in Java
HashMap in Java with Examples
Interfaces in Java
ArrayList in Java
Multidimensional Arrays in Java
Stack Class in Java
Stream In Java
Singleton Class in Java
Set in Java
Overriding in Java
Error Handling in C

Error handling is not supported by C language. There are some other ways by which error handling can be done in C language. The header file “error.h” is used to print the errors using return statement function.
It returns -1 or NULL in case of any error and errno variable is set with the error code. Whenever a function is called in C language, errno variable is associated with it. errno is a global variable and is used to find the type of error in the execution.
The following table displays some errors −
There are some methods to handle errors in C language −
perror() − This function is used to print the error and it returns the string along with the textual representation of current errno value.
perror() − This function is used to print the error and it returns the string along with the textual representation of current errno value.
strerror() − This function is declared in “string.h” header file and it returns the pointer to the string of current errno value.
strerror() − This function is declared in “string.h” header file and it returns the pointer to the string of current errno value.
Exit status − There are two constants EXIT_SUCCESS and EXIT_FAILURE which can be used in function exit() to inform the calling function about the error.
Exit status − There are two constants EXIT_SUCCESS and EXIT_FAILURE which can be used in function exit() to inform the calling function about the error.
Divided by zero − This is a situation in which nothing can be done to handle this error in C language. Avoid this error and you can check the divisor value by using ‘if’ condition in the program.
Divided by zero − This is a situation in which nothing can be done to handle this error in C language. Avoid this error and you can check the divisor value by using ‘if’ condition in the program.
Here is an example of error handling in C language,
 Live Demo
#include <stdio.h>
#include <stdlib.h>

main() {
   int x = 28;
   int y = 8;
   int z;

   if( y == 0) {
      fprintf(stderr, "Division by zero!\n");
      exit(EXIT_FAILURE);
   }
   z = x / y;
   fprintf(stderr, "Value of z : %d\n", z );
   exit(EXIT_SUCCESS);
}
Here is the output
Value of z : 3
How to select a specific subdocument in MongoDB?

To select a specific subdocument in MongoDB, use find(). Let us create a collection with documents −
> db.demo37.insertOne({"Details":[{"Name":"Chris","Age":21},{"Name":"David","Age":23}]});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e176635cfb11e5c34d898d7")
}
> db.demo37.insertOne({"Details":[{"Name":"Sam","Age":23},{"Name":"Robert","Age":25}]});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e17664acfb11e5c34d898d8")
}
Display all documents from a collection with the help of find() method −
> db.demo37.find();
This will produce the following output −
{ "_id" : ObjectId("5e176635cfb11e5c34d898d7"), "Details" : [ { "Name" : "Chris", "Age" : 21 }, { "Name" : "David", "Age" : 23 } ] }
{ "_id" : ObjectId("5e17664acfb11e5c34d898d8"), "Details" : [ { "Name" : "Sam", "Age" : 23 }, { "Name" : "Robert", "Age" : 25 } ] }
Following is the query to select subdocument −
> db.demo37.find({'Details.Name' : 'Sam'},{_id: 0, 'Details.$.Name': 1});
This will produce the following output −
{ "Details" : [ { "Name" : "Sam", "Age" : 23 } ] }
Remove duplicated elements of associative array in PHP

The ‘array_map’ function sends the value of every element in the array to a user-defined function. It then returns an array with new values, because of calling the user-defined function on the array.
array_map ( user-defined function, array_1, array_2, array_3...)
The user-defined function and the array_1 are compulsory arguments, but array_2 and array_3 are optional.
 Live Demo
$result = array(
   0=>array('a'=>1,'b'=>'Hello'),
   1=>array('a'=>1,'b'=>'duplicate_val'),
   2=>array('a'=>1,'b'=>'duplicate_val')
);
$unique = array_map("unserialize", array_unique(array_map("serialize", $result)));
print_r($unique);
This will produce the following output −
Array ( [0] => Array ( [a] => 1 [b] => Hello ) [1] => Array ( [a] => 1 [b] => duplicate_val ) )
In the above code, an array is defined with 3 elements and this is assigned to a variable named ‘result’. The array_map function is called and the ‘result’ value is passed as a parameter.
The resultant output would be the contents in the ‘result’ variable along with mention about the duplicate value in the array.
DAX - FILTER function

Returns a table that represents a subset of another table or expression.
FILTER (<table>, <filter>) 

table
The table to be filtered. The table can also be an expression that results in a table.
filter
A Boolean expression that is to be evaluated for each row of the table.
A table containing only the filtered rows.
You can use DAX FILTER function to reduce the number of rows in the table that you are working with, and use only specific data in calculations.
DAX FILTER function is not used independently, but as a function that is embedded in other functions that require a table as an argument.
Medal Count Summer Sports:= COUNTAX ( 
   FILTER (Results, Results[Season] = "Summer"), Results[Medal]
) 

    53 Lectures 
     5.5 hours 

 Abhay Gadiya

    24 Lectures 
     2 hours 

 Randy Minder

    26 Lectures 
     4.5 hours 

 Randy Minder
 Print
 Add Notes
 Bookmark this page
Disconnecting Database in Python

To disconnect Database connection, use close() method.
db.close()
If the connection to a database is closed by the user with the close() method, any outstanding transactions are rolled back by the DB. However, instead of depending on any of DB lower level implementation details, your application would be better off calling commit or rollback explicitly.
Find the most frequent value in a NumPy array - GeeksforGeeks

29 Aug, 2020
In this article, let’s discuss how to find the most frequent value in the NumPy array. 
Steps to find the most frequency value in a NumPy array:
Create a NumPy array.
Apply bincount() method of NumPy to get the count of occurrences of each element in the array.
The n, apply argmax() method to get the value having a maximum number of occurrences(frequency).
Example 1:
Python3
import numpy as np    # create arrayx = np.array([1,2,3,4,5,1,2,1,1,1])print("Original array:")print(x)  print("Most frequent value in the above array:")print(np.bincount(x).argmax())
Output:
1
This code will generate a single output only, it will not work fine if the array contains more than one element having the maximum number of frequency.
Example 2: If the array has more than one element having maximum frequency
Python3
import numpy as np    x = np.array([1, 1, 1, 2, 3, 4, 2, 4, 3, 3, ])print("Original array:")print(x)  print("Most frequent value in above array")y = np.bincount(x)maximum = max(y)  for i in range(len(y)):    if y[i] == maximum:        print(i, end=" ")
Output:
1 3
Python numpy-arrayManipulation
Python-numpy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Install PIP on Windows ?
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | Pandas dataframe.groupby()
Defaultdict in Python
Python | Get unique values from a list
Python Classes and Objects
Python | os.path.join() method
Create a directory in Python
Write a C program to print "Geeks for Geeks" without using a semicolon - GeeksforGeeks

02 Jun, 2017
First of all we have to understand how printf() function works.Prototype of printf() function is:
int printf( const char *format , ...)

Parameter
format: This is a string that contains a text to be written to stdout.
Additional arguments: ... (Three dots are called ellipses) which indicates the variable number of arguments depending upon the format string.
printf() returns the total number of characters written to stdout. Therefore it can be used as a condition check in an if condition, while condition, switch case and Macros.
Let’s see each of these conditions one by one.
Using if condition:#include<stdio.h>int main(){      if (printf("Geeks for Geeks") )      {    }}   Using while condition:#include<stdio.h>int main(){    while (!printf( "Geeks for Geeks" ))    {   }}Using switch case:#include<stdio.h>int main(){    switch (printf("Geeks for Geeks" ))    {   }}Using Macros:#include<stdio.h>#define PRINT printf("Geeks for Geeks")int main(){    if (PRINT)    {    }}
Using if condition:#include<stdio.h>int main(){      if (printf("Geeks for Geeks") )      {    }}   
#include<stdio.h>int main(){      if (printf("Geeks for Geeks") )      {    }}   
Using while condition:#include<stdio.h>int main(){    while (!printf( "Geeks for Geeks" ))    {   }}
#include<stdio.h>int main(){    while (!printf( "Geeks for Geeks" ))    {   }}
Using switch case:#include<stdio.h>int main(){    switch (printf("Geeks for Geeks" ))    {   }}
#include<stdio.h>int main(){    switch (printf("Geeks for Geeks" ))    {   }}
Using Macros:#include<stdio.h>#define PRINT printf("Geeks for Geeks")int main(){    if (PRINT)    {    }}
#include<stdio.h>#define PRINT printf("Geeks for Geeks")int main(){    if (PRINT)    {    }}
Output: Geeks for Geeks

One trivial extension of the above problem: Write a C program to print “;” without using a semicolon
#include<stdio.h>int main(){      // ASCII value of ; is 59   if (printf("%c", 59))   {   }}
Output: ;

This blog is contributed by Shubham Bansal. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
c-puzzle
C Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Multidimensional Arrays in C / C++
rand() and srand() in C/C++
Left Shift and Right Shift Operators in C/C++
Different methods to reverse a string in C/C++
Core Dump (Segmentation fault) in C/C++
Command line arguments in C/C++
fork() in C
TCP Server-Client implementation in C
Function Pointer in C
Enumeration (or enum) in C
Java | Constructors | Question 3 - GeeksforGeeks

28 Jun, 2021
Which of the following is/are true about constructors in Java?

1) Constructor name should be same as class name.
2) If you don't define a constructor for a class, 
    a default parameterless constructor is automatically
    created by the compiler. 
3) The default constructor calls super() and initializes all 
   instance variables to default value like 0, null.
4) If we want to parent class constructor, it must be called in 
   first line of constructor.
(A) 1(B) 1, 2(C) 1, 2 and 3(D) 1, 2, 3 and 4Answer: (D)Explanation:Quiz of this Question
Constructors
Java-Constructors
Java Quiz
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Java | Functions | Question 1
Java | Exception Handling | Question 2
Java | Class and Object | Question 1
Java | final keyword | Question 1
Java | Abstract Class and Interface | Question 2
Java | Exception Handling | Question 3
Java | Exception Handling | Question 4
Java | Exception Handling | Question 7
Java | Exception Handling | Question 8
Java | Inheritance | Question 8
How to Find the Difference Between Two Rows in Pandas? - GeeksforGeeks

19 Dec, 2021
In this article, we are going to see how to find the difference between two rows in Pandas. 
Pandas DataFrame is a two-dimensional data structure in tabular form with labeled axes. During data analysis, one might need to compute the difference between two rows for comparison purposes. This can be done using pandas.DataFrame.diff() function. This function calculates the difference between two consecutive DataFrame elements. 
Syntax: pandas.DataFrame.diff(periods=1, axis=0)
Parameters:
periods: Represents periods to shift for computing difference, Integer type value. Default value is 1
axis: Represents difference to be taken over rown or columns. Can take two values {0: rows, 1: columns}. Default value is 0
Returns: Returns DataFrame
Example 1: To test this function we created a dummy DataFrame with 3 columns and 6 rows. Now, this diff function will find the difference of each row with its previous row as periods by default is 1. Hence the reason why values in the 0th indexed row are NaN.
Python3
# Importing Pandas Libraryimport pandas as pd   # Creating dummy DataFrame for testingdf = pd.DataFrame({ 'a': [1, 2, 3, 4, 5, 6],                    'b': [8, 18, 27, 20, 33, 49],                    'c': [2, 24, 6, 16, 20, 52]})# Printing DataFrame before applying diff functionprint(df)  # Printing DataFrame after applying diff functionprint("Difference: ")print(df.diff())
Output:
   a   b   c
0  1   8   2
1  2  18  24
2  3  27   6
3  4  20  16
4  5  33  20
5  6  49  52
Difference: 
     a     b     c
0  NaN   NaN   NaN
1  1.0  10.0  22.0
2  1.0   9.0 -18.0
3  1.0  -7.0  10.0
4  1.0  13.0   4.0
5  1.0  16.0  32.0
Example 2:
Python3
# Importing Pandas Libraryimport pandas as pd   # Creating dummy DataFrame for testingdf = pd.DataFrame({ 'a': [1, 2, 3, 4, 5, 6],                    'b': [8, 18, 27, 20, 33, 49],                    'c': [2, 24, 6, 16, 20, 52]})# Printing DataFrame before applying diff functionprint(df)  # Printing DataFrame after applying diff functionprint("Difference: ")print(df.diff(periods=2))
Output:
   a   b   c
0  1   8   2
1  2  18  24
2  3  27   6
3  4  20  16
4  5  33  20
5  6  49  52
Difference: 
     a     b     c
0  NaN   NaN   NaN
1  NaN   NaN   NaN
2  2.0  19.0   4.0
3  2.0   2.0  -8.0
4  2.0   6.0  14.0
5  2.0  29.0  36.0
pandas-dataframe-program
Picked
Python pandas-dataFrame
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Python | Get unique values from a list
Python | os.path.join() method
Defaultdict in Python
Create a directory in Python
Python | Pandas dataframe.groupby()
How to italicize text in CSS ? - GeeksforGeeks

04 Jul, 2021
In this article, we will see how to make a text italic using CSS. To italicize text in any webpage the CSS font-style property is used. We have a variety of options to set it to italic text.
normal: It is the normal font-style. It is the same as 400, the default numeric value for boldness.
bold: It is the bold font-style. It is the same as 700.
italic: It is the cursive font-style.
Approach: The font-style property in CSS has three values that are normal, italic, and bold. The CSS value italic is used to italicize the text.
Syntax:
font-style: italic;
Example:
HTML
<!DOCTYPE html><html lang="en">  <head>    <meta charset="UTF-8" />    <meta http-equiv="X-UA-Compatible" content="IE=edge" />      <meta name="viewport" content=        "width=device-width, initial-scale=1.0" />      <!--Style CSS-->    <style>        .gfg {            font-style: italic;            font-size: 24px;            margin: 10px;            padding: 2px;            color: black;        }    </style></head>  <body>    <h2>        GeeksForGeeks | A Computer Science         Portal for Geeks    </h2>      <p class="gfg">        This platform has been designed for         every geek wishing to expand their        knowledge, share their knowledge and         is ready to grab their dream job. We        have millions of articles, live as         well as online courses, thousands of        tutorials and much more just for the         geek inside you.    </p>      <p class="geeks">        Thank You for choosing and supporting us!    </p></body>  </html>
Note: When you will be using an external CSS file always use some default CSS for your webpage this default CSS written in * { } selector. This will remove default CSS from your webpage. 
Output: Now, as you can see in the output, we have created an italicized text in our webpage using CSS, which will attract readers to read the contents on the webpage.
CSS-Properties
CSS-Questions
Picked
CSS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to set space between the flexbox ?
Design a web page using HTML and CSS
Form validation using jQuery
How to style a checkbox using CSS?
Search Bar using HTML, CSS and JavaScript
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
Difference between var, let and const keywords in JavaScript
Class toString() method in Java with Examples - GeeksforGeeks

27 Nov, 2019
The toString() method of java.lang.Class class is used to convert the instance of this Class to a string representation. This method returns the formed string representation.
Syntax:
public String toString()

Parameter: This method does not accept any parameter.
Return Value: This method returns the String representation of this object.
Below programs demonstrate the toString() method.
Example 1:
// Java program to demonstrate toString() method  public class Test {    public static void main(String[] args)        throws ClassNotFoundException    {        // returns the Class object for the class        // with the specified name        Class c1 = Class.forName("java.lang.String");          System.out.print("Class represented by c1: ");          // toString method on c1        System.out.println(c1.toString());    }}
Class represented by c1: class java.lang.String

Example 2:
// Java program to demonstrate toString() method  public class Test {    public static void main(String[] args)        throws ClassNotFoundException    {        // returns the Class object for the class        // with the specified name        Class c2 = int.class;        Class c3 = void.class;          System.out.print("Class represented by c2: ");          // toString method on c2        System.out.println(c2.toString());          System.out.print("Class represented by c3: ");          // toString method on c3        System.out.println(c3.toString());    }}
Class represented by c2: int
Class represented by c3: void

Reference: https://docs.oracle.com/javase/9/docs/api/java/lang/Class.html#toString–
Java-Functions
Java-lang package
Java.lang.Class
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Stream In Java
Constructors in Java
Exceptions in Java
Functional Interfaces in Java
Different ways of Reading a text file in Java
Generics in Java
Introduction to Java
Comparator Interface in Java with Examples
Internal Working of HashMap in Java
Strings in Java
PHP | str_split() Function - GeeksforGeeks

01 Aug, 2021
The str_split() is an inbuilt function in PHP and is used to convert the given string into an array. This function basically splits the given string into smaller strings of length specified by the user and stores them in an array and returns the array.
Syntax:
array str_split($org_string, $splitting_length)
Parameters:The function accepts two parameters and are described below:
$org_string (mandatory): This refers to the original string that the user needs to split into an array.$splitting_length (optional): This refers to the length of each array element, we wish to split our string into. By default the function accepts the value as 1.
$org_string (mandatory): This refers to the original string that the user needs to split into an array.
$splitting_length (optional): This refers to the length of each array element, we wish to split our string into. By default the function accepts the value as 1.
Return Values: The function returns an array. If the length parameter exceeds the length of the original string, then the whole string is returned as a single element. If the length parameter is less than 1, then False is returned. By default length is equal to 1.
Examples:
Input: "Hello"
Output:
Array
(
    [0] => H
    [1] => e
    [2] => l
    [3] => l
    [4] => o
)

The below program will explain the working of the str_split() function.
<?php// PHP program to display the working of str_split()  $string = "Geeks";  // Since second argument is not passed,// string is split into substrings of size 1.print_r(str_split($string));  $string = "GeeksforGeeks";  // Splits string into substrings of size 4// and returns array of substrings.print_r(str_split($string, 4))?>
Output:
Array
(
    [0] => G
    [1] => e
    [2] => e
    [3] => k
    [4] => s
)
Array
(
    [0] => Geek
    [1] => sfor
    [2] => Geek
    [3] => s
)
Reference:http://php.net/manual/en/function.str-split.php
PHP is a server-side scripting language designed specifically for web development. You can learn PHP from the ground up by following this PHP Tutorial and PHP Examples.
PHP-function
PHP-string
PHP
Web Technologies
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Insert Form Data into Database using PHP ?
How to convert array to string in PHP ?
How to Upload Image into Database and Display it using PHP ?
How to check whether an array is empty using PHP?
PHP | Converting string to Date and DateTime
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Wand Drawing() function in Python - GeeksforGeeks

11 May, 2020
Another module for wand is wand.drawing. This module provides us with some very basic drawing functions. wand.drawing.Drawing object buffers instructions for drawing shapes into images, and then it can draw these shapes into zero or more images.
Syntax : with Drawing() as draw:
Note: In the above syntax “as draw” is just a nomenclature and can be any string as needed. The Drawing function in Python wand take has no parameter.
Example #1:
# Import important objects from wand libraryfrom wand.image import Imagefrom wand.drawing import Drawingfrom wand.color import Color  # Create draw object using Drawing() functionwith Drawing() as draw:    with Image(width = 200,               height = 200,               background = Color('green')) as img:        draw(img)        img.save(filename ='empty.gif')
Output Image:
Let’s draw a line
Example #2:
# Import important objects from wand libraryfrom wand.image import Imagefrom wand.drawing import Drawingfrom wand.color import Color  # Create draw object using Drawing() functionwith Drawing() as draw:    draw.stroke_color = Color('black')    draw.stroke_width = 2    draw.line((5, 5), (45, 50))    with Image(width = 200,               height = 200,               background = Color('green')) as img:        draw.draw(img)        img.save(filename ='line.gif')
Output Image:
Python-gui
Python-wand
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python Classes and Objects
How to drop one or multiple columns in Pandas Dataframe
Python | Get unique values from a list
Defaultdict in Python
Python | os.path.join() method
Create a directory in Python
Python | Pandas dataframe.groupby()
PyQt5 - nextCheckState() method for Check Box - GeeksforGeeks

22 Apr, 2020
We can set the state of the check box using setChecked or for tristate check box we can set its states using setCheckState method.
nextCheckState sets the next state of the check box i.e for default check box if initial check state is checked, it will set it to un-checed and vice versa. For tri-state check box if check state if un-checked it will set it to intermediate state and if initial state is intermediate, it will set it to checked and if it is checked it will set it to un-checked.
Syntax : checkbox.nextCheckState()
Argument : It takes no argument.
Action performed : It will change the state of check box according to the previous state.
Below is the implementation.
# importing librariesfrom PyQt5.QtWidgets import * from PyQt5 import QtCore, QtGuifrom PyQt5.QtGui import * from PyQt5.QtCore import * import sys    class Window(QMainWindow):      def __init__(self):        super().__init__()          # setting title        self.setWindowTitle("Python ")          # setting geometry        self.setGeometry(100, 100, 600, 400)          # calling method        self.UiComponents()          # showing all the widgets        self.show()      # method for widgets    def UiComponents(self):          # creating the check-box        checkbox = QCheckBox('Geek ?', self)          # setting geometry of check box        checkbox.setGeometry(200, 150, 100, 40)          # making it tristate check box        checkbox.setTristate(True)          # setting check box to its next state        checkbox.nextCheckState()    # create pyqt5 appApp = QApplication(sys.argv)  # create the instance of our Windowwindow = Window()  # start the appsys.exit(App.exec())
Output :
Python-gui
Python-PyQt
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Python | Get unique values from a list
Python | os.path.join() method
Defaultdict in Python
Create a directory in Python
Python | Pandas dataframe.groupby()
Types of Program Control Instructions

16 Aug, 2021
Program Control Instructions are the machine code that are used by machine or in assembly language by user to command the processor act accordingly. These instructions are of various types. These are used in assembly language by user also. But in level language, user code is translated into machine code and thus instructions are passed to instruct the processor do the task. 
Types of Program Control Instructions: There are different types of Program Control Instructions: 
1. Compare Instruction: Compare instruction is specifically provided, which is similar to a subtract instruction except the result is not stored anywhere, but flags are set according to the result.  
Example: 
CMP R1, R2 ;
2. Unconditional Branch Instruction: It causes an unconditional change of execution sequence to a new location.  
Example:
JUMP L2
Mov R3, R1 goto L2
3. Conditional Branch Instruction: A conditional branch instruction is used to examine the values stored in the condition code register to determine whether the specific condition exists and to branch if it does.  
Example:
Assembly Code : BE R1, R2, L1
Compiler allocates R1 for x and R2 for y
High Level Code: if (x==y) goto L1;
4. Subroutines: A subroutine is a program fragment that lives in user space, performs a well-defined task. It is invoked by another user program and returns control to the calling program when finished.  
Example: 
CALL and RET 
5. Halting Instructions:  
NOP Instruction – NOP is no operation. It cause no change in the processor state other than an advancement of the program counter. It can be used to synchronize timing.  
HALT – It brings the processor to an orderly halt, remaining in an idle state until restarted by interrupt, trace, reset or external action.  
6. Interrupt Instructions: Interrupt is a mechanism by which an I/O or an instruction can suspend the normal execution of processor and get itself serviced.  
RESET – It reset the processor. This may include any or all setting registers to an initial value or setting program counter to standard starting location.
TRAP – It is non-maskable edge and level triggered interrupt. TRAP has the highest priority and vectored interrupt.
INTR – It is level triggered and maskable interrupt. It has the lowest priority. It can be disabled by resetting the processor.
 
tornadomess18
microprocessor
Computer Organization & Architecture
microprocessor
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Mixtures and Alligation - GeeksforGeeks

30 Nov, 2021
Let the amount taken from S1 be 7x
And amount taken from S2 be 13y

(2x + 6y)/(5x + 7y) = 5/8
16x + 48y = 25x + 35y
9x = 13y
x/y = 13/9

Actual ratios of amounts 
               = 7x/13y
               = (7/13) * (13/9)
               = 7/9

Concentration of orange pulp in 1st vessel
Concentration of orange pulp in 2nd vessel
    40%
19%
26%
40-26=14
CP of 1 kg rice of 1st kind
CP of 1 kg rice of 2nd kind
Rs. 9
Rs.8.4
8.4 - 7 = 1.4
9 - 8.4 = 0.6
Writing code in comment? Please use ide.geeksforgeeks.org, generate link and share the link here.
Rebuilding or Repairing MySQL Tables or Indexes

Changes to tables and indexes refers to how MySQL handles data types and character sets. The necessary table repairs or upgrades are reported by CHECK TABLE, mysqlcheck, or mysql_upgrade.
There are many methods to rebuild a table. Some of them have been listed below −
Dump and Reload Method
Dump and Reload Method
ALTER TABLE Method
ALTER TABLE Method
REPAIR TABLE Method
REPAIR TABLE Method
Let us understand each of them in brief −
If the tables are being rebuilt due to the fact that different versions of MySQL version can’t handle the tables after a binary (in-place) upgrade or download, then this dump and reload method needs to be used.
A table can be rebuilt by dumping and reloading it. This can be done by using the ‘mysqldump’ and creating a dump file and allowing mysql to reload the file. This can be done using the below commands −
mysqldump db_name t1 > dump.sql
mysql db_name < dump.sql
If all the tables have to be rebuilt in a single database, the name of the database can be specified without using any table name. It can be done using the below command −
mysqldump db_name > dump.sql
mysql db_name < dump.sql
If all the tables in all the databases have to be rebuilt, then the ‘− − all databases’ option has to be used. It can be done using the below command −
mysqldump --all-databases > dump.sql
mysql < dump.sql
If a table needs to be rebuilt using the ALTER TABLE method, then a “null” alteration can be used. An ALTER TABLE statement can be used which changes the table so that it can use the storage engine. Let us take an example: Suppose TblName is an InnoDB table, the below statement can be used to rebuild the table −
ALTER TABLE TblName ENGINE = InnoDB;
The REPAIR TABLE method is only applicable to MyISAM, ARCHIVE, and CSV tables. The statement REPAIR TABLE can be used if the table checking operation suggests that the file has been corrupted or an upgrade is required. Let us take an example: In order to repair a MyISAM table, the below statement can be executed −
REPAIR TABLE TblName;
mysqlcheck −−repair provides command−line access to the REPAIR TABLE statement. This can be a more convenient means of repairing tables because you can use the −−databases to repair a specific table in a database or −−all−databases option to repair all tables in all databases. It can be done using the below commands −
mysqlcheck −−repair −−databases db_name ...
mysqlcheck −−repair −−all−databases
jQuery Effects - Fading

With jQuery you can fade elements in and out of visibility.
Click to fade in/out panel
Because time is valuable, we deliver quick and easy learning.
At W3Schools, you can study everything you need to learn, in an accessible and handy format.
jQuery fadeIn()
Demonstrates the jQuery fadeIn() method.
jQuery fadeOut()
Demonstrates the jQuery fadeOut() method.
jQuery 
fadeToggle()
Demonstrates the jQuery fadeToggle() method.
jQuery fadeTo()
Demonstrates the jQuery fadeTo() method.
With jQuery you can fade an element in and out of visibility.
jQuery has the following fade methods:
fadeIn()
fadeOut()
fadeToggle()
fadeTo()
The jQuery fadeIn() method is used to fade in a hidden element.
Syntax:
The optional speed parameter specifies the duration of the effect. It can take the following values: "slow", "fast", or 
milliseconds.
The optional callback parameter is a function to be executed after the 
fading completes.
The following example demonstrates the fadeIn() method with different 
parameters:
The jQuery fadeOut() method is used to fade out a visible element.
Syntax:
The optional speed parameter specifies the duration of the effect. It can take the following values: "slow", "fast", or 
milliseconds.
The optional callback parameter is a function to be executed after the 
fading completes.
The following example demonstrates the fadeOut() method with different 
parameters:
The jQuery fadeToggle() method toggles between the fadeIn() and fadeOut() 
methods.
If the elements are faded out, fadeToggle() will fade them in.
If the elements are faded in, fadeToggle() will fade them out. 
Syntax:
The optional speed parameter specifies the duration of the effect. It can take the following values: "slow", "fast", or 
milliseconds.
The optional callback parameter is a function to be executed after the 
fading completes.
The following example demonstrates the fadeToggle() method with different 
parameters:
The jQuery fadeTo() method allows fading to a given opacity (value between 0 and 1).
Syntax:
The required speed parameter specifies the duration of the effect. It can take the following values: "slow", "fast", or 
milliseconds.
The required opacity parameter in the fadeTo() method specifies fading to a given opacity (value between 0 and 1).
The optional callback parameter is a function to be executed after the function completes.
The following example demonstrates the fadeTo() method with different 
parameters:
Use a jQuery method to fade out a <div> element.
$("div").();

Start the Exercise
For a complete overview of all jQuery effects, please go to our 
jQuery Effect Reference.
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.
Compute value of Log Normal Quantile Function in R Programming - qlnorm() Function - GeeksforGeeks

25 Jun, 2020
qlnorm() function in R Language is used to compute the value of log normal quantile function. It also creates a plot of the quantile function of log normal distribution.
Syntax: qlnorm(vec)
Parameters:vec: x-values for normal density
Example 1:
# R program to compute value of# log normal quantile function  # Creating x-values for densityx <- seq(0, 1, by = 0.2)  # Calling qlnorm() functiony <- qlnorm(x)y
Output:
[1] 0.0000000 0.4310112 0.7761984 1.2883304 2.3201254       Inf

Example 2:
# R program to compute value of# log normal quantile function  # Creating x-values for densityx <- seq(0, 1, by = 0.02)  # Calling qlnorm() functiony <- qlnorm(x)  # Plot a graphplot(y)
Output:
R-Statistics
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Change Color of Bars in Barchart using ggplot2 in R
How to Change Axis Scales in R Plots?
Group by function in R using Dplyr
How to Split Column Into Multiple Columns in R DataFrame?
Replace Specific Characters in String in R
How to filter R DataFrame by values in a column?
How to filter R dataframe by multiple conditions?
R - if statement
How to import an Excel File into R ?
Time Series Analysis in R
Get JFrame window size information in Java

To get JFrame window size information, you can use the following −
environment.getMaximumWindowBounds();
For Screen Size −
config.getBounds()
For Frame Size −
frame.getSize());
The following is an example to get JFrame window size information −
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Rectangle;
import javax.swing.JFrame;
public class SwingDemo {
   public static void main(String[] args) {
      GraphicsEnvironment environment = GraphicsEnvironment.getLocalGraphicsEnvironment();
      Rectangle bounds = environment.getMaximumWindowBounds();
      System.out.println("Screen Bounds = " + bounds);
      GraphicsDevice device = environment.getDefaultScreenDevice();
      GraphicsConfiguration config = device.getDefaultConfiguration();
      System.out.println("Screen Size = " + config.getBounds());
      JFrame frame = new JFrame("Frame Info");
      frame.setSize(500, 300); frame.setVisible(true);
      System.out.println("Frame Size = " + frame.getSize());
   }
}
Screen Bounds = java.awt.Rectangle[x=0,y=0,width=1366,height=728]
Screen Size = java.awt.Rectangle[x=0,y=0,width=1366,height=768]
Frame Size = java.awt.Dimension[width=500,height=300]
Pycharm - Understanding Basics

This chapter will discuss the basics of PyCharm and make you feel comfortable to begin working in PyCharm editor.
When you launch PyCharm for the first time, you can see a welcome screen with entry points to IDE such as −
Creating or opening the project
Checking out the project from version control
Viewing the documentation
Configuring the IDE
Recall that in the last chapter, we created a project named demo1 and we will be referring
to the same project throughout this tutorial. Now we will start creating new files in the same project to understand the basics of PyCharm Editor.
The above snapshot describes the project overview of demo1 and the options to create a new file. Let us create a new file called main.py.
The code included in main.py is as follows −
y = 3

def print_stuff():
   print ("Calling print_stuff")
   print (y)
   z = 4
   print (z)
   print("exiting print_stuff")
	
print_stuff() # we call print_stuff and the program execution goes to (***)
print(y) # works fine
print (z) # NameError!!!
The code created in the file main.py using PyCharm Editor is displayed as shown below −
This code can be run within IDE environment. The basic demonstration of running a program is discussed below −
Note that we have included some errors within the specified code such that console can execute the code and display output as the way it is intended to.

    19 Lectures 
     59 mins

 Mustafa Mahmoud

    19 Lectures 
     49 mins

 Pedro Planas
 Print
 Add Notes
 Bookmark this page
Arduino - Comparison Operators

Assume variable A holds 10 and variable B holds 20 then −
void loop () { 
   int a = 9,b = 4
   bool c = false;
   if(a == b)
      c = true;
   else
      c = false;

   if(a != b)
      c = true;
   else
      c = false;
   
   if(a < b)
      c = true;
   else
      c = false;
   
   if(a > b)
      c = true;
   else
      c = false;
   
   if(a <= b)
      c = true;
   else
      c = false;
   
   if(a >= b)
      c = true;
   else
      c = false;
}
c = false
c = true
c = false
c = true
c = false
c = false


    65 Lectures 
     6.5 hours 

 Amit Rana

    43 Lectures 
     3 hours 

 Amit Rana

    20 Lectures 
     2 hours 

 Ashraf Said

    19 Lectures 
     1.5 hours 

 Ashraf Said

    11 Lectures 
     47 mins

 Ashraf Said

    9 Lectures 
     41 mins

 Ashraf Said
 Print
 Add Notes
 Bookmark this page
p5.js | select() Function - GeeksforGeeks

29 Jan, 2020
The select() function is used to search an element in the page with the given id, class or tag name and return it as a p5.element. It has a syntax similar to the CSS selector. An optional parameter is available that can be used to search within a given element. This method only returns the first element if multiple elements exist on the page that matches the selector.
Note: The DOM node of the element can be accessed using the .elt property.
Syntax:
select(name, [container])
Parameters: This function accept two parameters as mentioned above and described below:
name: It is a string which denotes the id, class or tag name of the element that has to be searched.
container: It is an optional parameter which denotes an element to search.
Return Value: When the given element is successfully found, it returns a p5.element that contains the node. Otherwise, it returns null.
Below examples illustrates the select() function in p5.js:
Example 1:
function setup() {  createCanvas(650, 50);  textSize(20);  text("Click the mouse to select the paragraph" +       " element and change its position.", 0, 20);     para1 = createP("This is paragraph 1");  para2 = createP("This is paragraph 2");  para3 = createP("This is paragraph 3");}   function mouseClicked() {    // Select the first  // paragraph element  selectedP = select("p");     // Change position to 200, 20  selectedP.position(200, 20);}
Output:
Example 2:
function setup() {  createCanvas(650, 300);  textSize(20);  text("Click the mouse once to select the"+       " canvas and change its color.", 0, 20);   }   function mouseClicked() {    // Select the first  // canvas element  selectedCanvas = select("canvas");     // Get the DOM node using .elt and  // change background color to green  selectedCanvas.elt.style.backgroundColor        = "green";}
Output:
Online editor: https://editor.p5js.org/
Environment Setup: https://www.geeksforgeeks.org/p5-js-soundfile-object-installation-and-methods/
Reference: https://p5js.org/reference/#/p5/select
JavaScript-p5.js
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Remove elements from a JavaScript Array
Convert a string to an integer in JavaScript
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
How to calculate the number of days between two dates in javascript?
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?