code-rag-bench/online-tutorials huggingface dataset:
How to display R-squared value on scatterplot with regression model line in R?

The R-squared value is the coefficient of determination, it gives us the percentage or proportion of variation in dependent variable explained by the independent variable. To display this value on the scatterplot with regression model line without taking help from any package, we can use plot function with abline and legend functions.
Consider the below data frame −
 Live Demo
set.seed(1234)
x<-rnorm(20,1,0.096)
y<-rnorm(20,2,0.06)
df<-data.frame(x,y)
df
         x          y
1    0.8841217    2.008045
2    1.0266332    1.970559
3    1.1041064    1.973567
4    0.7748130    2.027575
5    1.0411960    1.958377
6    1.0485814    1.913108
7    0.9448250    2.034485
8    0.9475233    1.938581
9    0.9458126    1.999092
10    0.9145564    1.943843
11    0.9541895    2.066138
12    0.9041549    1.971464
13    0.9254796    1.957434
14    1.0061880    1.969925
15    1.0921114    1.902254
16    0.9894126    1.929943
17    0.9509431    1.869198
18    0.9125252    1.919540
19    0.9196315    1.982342
20    1.2319202    1.972046
Creating the regression model to predict y from x −
Model<-lm(y~x,data=df)
summary(Model)
Call −
lm(formula = y ~ x, data = df)
Residuals:
Min 1Q Median 3Q Max
-0.09955 -0.03138 0.00522 0.02981 0.09783
Coefficients −
Estimate Std. Error t value Pr(>|t|)
(Intercept) 2.0971 0.1084 19.349 1.7e-13 ***
x -0.1350 0.1105 -1.221 0.238 ---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.04689 on 18 degrees of freedom
Multiple R-squared: 0.07649, Adjusted R-squared: 0.02519
F-statistic: 1.491 on 1 and 18 DF, p-value: 0.2378
Creating the scatterplot with R-squared value on the plot −
plot(x,y)
abline(Model) legend("topleft",legend=paste("R2 is", format(summary(Model)$r.squared,digits=3)))
Long.parse method in C#

To convert a string to a long, use the Long.parse method in C# −
Firstly, set a string −
string str = "7864646475767";
Now, convert it to long −
long.Parse(str);
Here is the complete code −
 Live Demo
using System;
using System.Linq;
class Demo {
   static void Main() {
      string str = "7864646475767";
      long res = long.Parse(str);
      Console.WriteLine(res);
   }
}
7864646475767
Bootstrap 4 .flex-*-column-reverse class

Use the flex-*-column-reverse class to display flex items vertically and reversed on different screen sizes.
Here’s the example of reversing flex items on medium device using “flex-md-column-reverse” class −
<div class="d-flex flex-md-column-reverse mb-3">
  <div class="p-2 bg-warning">One</div>
  <div class="p-2 bg-danger">Two</div>
  <div class="p-2 bg-secondary">Three</div>
</div>
In the same way, set for large devices using “flex-lg-column-reverse” class −
<div class="d-flex flex-lg-column-reverse mb-3">
  <div class="p-2 bg-warning">One</div>
  <div class="p-2 bg-danger">Two</div>
  <div class="p-2 bg-secondary">Three</div>
</div>
Implementing the .flex-*-column-reverse class −
Live Demo
<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Bootstrap Example</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
  </head>

<body>
  <div class="container mt-3">
    <h2>Example</h2>
    <p>Change the browser size to see the effect:<p>
    <p>Default </p>
    <div class="d-flex flex-column">
      <div class="p-2 bg-primary">One</div>
      <div class="p-2 bg-secondary">Two</div>
      <div class="p-2 bg-info">Three</div>
    </div>
    <p>Flex on differet screen size (Medium-Reverse)</p>
    <div class="d-flex flex-md-column-reverse mb-3">
      <div class="p-2 bg-warning">One</div>
      <div class="p-2 bg-danger">Two</div>
      <div class="p-2 bg-secondary">Three</div>
    </div>
    <p>Flex on different screen size (Large-Reverse)</p>
    <div class="d-flex flex-lg-column-reverse mb-3">
      <div class="p-2 bg-warning">One</div>
      <div class="p-2 bg-danger">Two</div>
      <div class="p-2 bg-secondary">Three</div>
    </div>
 </div>

</body>
</html>
Python | Boolean list initialization

01 Feb, 2022
Many times in programming, we require to initialize a list with some initial values. In Dynamic programming, this is used more often and mostly the requirement is to initialize with a boolean 0 or 1. Let’s discuss certain ways in which this can be achieved.
Method #1: Using list comprehension This can easily be done with the naive method, hence, can also be converted into a compact version using list comprehension. This is the most basic way to perform this task.
Python3
# Python3 code to demonstrate# to perform boolean list initializing# using list comprehension # using list comprehension# to perform boolean list initializingres =  [True for i in range(6)] # printing resultprint ("The True initialized list is : " +  str(res))
The True initialized list is : [True, True, True, True, True, True]
 
  Method #2: Using * operator This can be done using the * operator in a comparatively more readable and compact way. We multiply the single list N no. of times to get the desired result.
Python3
# Python3 code to demonstrate# to perform boolean list initializing# using * operator # using * operator# to perform boolean list initializingres =  [True] * 6 # printing resultprint ("The True initialized list is : " +  str(res))
The True initialized list is : [True, True, True, True, True, True]
 
  Method #3 : Using bytearray() This method can be used to perform the list initialization, but this argument can only be extended to False value initializations. It doesn’t work when we require to initialize with the True values.
Python3
# Python3 code to demonstrate# to perform boolean list initializing# using bytearray() # using bytearray()# to perform boolean list initializingres = list(bytearray(6)) # printing resultprint ("The False initialized list is : " +  str(res))
The False initialized list is : [0, 0, 0, 0, 0, 0]
 
chhabradhanvi
Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Enumerate() in Python
Different ways to create Pandas Dataframe
Read a file line by line in Python
How to Install PIP on Windows ?
Python String | replace()
Python program to convert a list to string
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python Program for Fibonacci numbers
verbose_name – Django Built-in Field Validation

13 Feb, 2020
Built-in Field Validations in Django models are the validations that come predefined to all Django fields. Every field comes in with built-in validations from Django validators. One can also add more built-in field validations for applying or removing certain constraints on a particular field. verbose_name is a human-readable name for the field. If the verbose name isn’t given, Django will automatically create it using the field’s attribute name, converting underscores to spaces. This attribute in general changes the field name in admin interface.
Syntax –
field_name = models.Field(verbose_name = "name")
Illustration of verbose_name using an Example. Consider a project named geeksforgeeks having an app named geeks.
Refer to the following articles to check how to create a project and an app in Django.
How to Create a Basic Project using MVT in Django?
How to Create an App in Django ?
Enter the following code into models.py file of geeks app. We will be using CharField for experimenting for all field options.
from django.db import modelsfrom django.db.models import Model# Create your models here.  class GeeksModel(Model):    geeks_field = models.CharField(                    max_length = 200,                      )
After running makemigrations and migrate on Django and rendering the above model, let us check the display name for geeks_field.
Now let us modify this using verbose_name attribute. change models.py to
from django.db import modelsfrom django.db.models import Model# Create your models here.  class GeeksModel(Model):    geeks_field = models.CharField(                    max_length = 200,                      verbose_name = "Geeksforgeeks"                    )
Since models.py is modified run makemigrations and migrate again on the project. Open admin interface and check the name of that field again, it is changes to “Geeksforgeeks”.You can see the modified image. Therefore, verbose_name modifies the field name.
NaveenArora
Django-models
Python Django
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
HTML | <input> pattern Attribute - GeeksforGeeks

28 Jun, 2019
The HTML <input> pattern attribute is used to specify the regular expression on which the input elements value is checked against. This attribute works with the following input types: text, password, date, search, email, etc. Use the Global title attribute to describe the pattern for helping the user.
Syntax:
<input pattern = "regular_exp">
Example: This example illustrates the use of pattern attribute in <input> element.
<!DOCTYPE html> <html>     <head>         <title>            HTML input pattern attribute        </title>                   <style>             body {                 text-align:center;             }             h1 {                 color:green;             }         </style>     </head>           <body>         <h1>GeeksforGeeks</h1>                   <h2>HTML <input>pattern attribute</h2>                   <form action="#">             Password: <input type="text" name="Password"                          pattern="[A-Za-z]{3}" title="Three letter Password">                           <input type="submit">         </form>     </body> </html>
Output:
Supported Browsers: The browser supported by HTML <input> pattern attribute are listed below:
Google Chrome 5.0
Internet Explorer 10.0
Firefox 4.0
Safari 10.1
Opera 9.6
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
HTML-Attributes
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to update Node.js and NPM to next version ?
Types of CSS (Cascading Style Sheet)
How to Insert Form Data into Database using PHP ?
CSS to put icon inside an input element in a form
REST API (Introduction)
Top 10 Front End Developer Skills That You Need in 2022
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Difference between var, let and const keywords in JavaScript
Convert a string to an integer in JavaScript
MySQL GROUP BY and CONCAT() to display distinct first and last name

Let us first create a table −
mysql> create table DemoTable
(
   FirstName varchar(100),
   LastName varchar(100)
);
Query OK, 0 rows affected (0.92 sec)
mysql> alter table DemoTable add index(FirstName,LastName);
Query OK, 0 rows affected (1.00 sec)
Records: 0 Duplicates: 0 Warnings: 0
Insert some records in the table using insert command −
mysql> insert into DemoTable values('Adam','Smith');
Query OK, 1 row affected (0.73 sec)
mysql> insert into DemoTable values('Adam','Smith');
Query OK, 1 row affected (1.17 sec)
mysql> insert into DemoTable values('John','Doe');
Query OK, 1 row affected (0.19 sec)
mysql> insert into DemoTable values('Carol','Taylor');
Query OK, 1 row affected (0.25 sec)
mysql> insert into DemoTable values('John','Doe');
Query OK, 1 row affected (0.66 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+-----------+----------+
| FirstName | LastName |
+-----------+----------+
| Adam      | Smith    |
| Adam      | Smith    |
| Carol     | Taylor   |
| John      | Doe      |
| John      | Doe      |
+-----------+----------+
5 rows in set (0.00 sec)
Following is the query to combine distinct First and Last Name −
mysql> select concat(FirstName,' ',LastName) as combinedName from DemoTable
group by LastName,FirstName;
This will produce the following output −
+--------------+
| combinedName |
+--------------+
| Adam Smith   |
| Carol Taylor |
| John Doe     |
+--------------+
3 rows in set (0.00 sec)
base64.decodebytes(s) in Python - GeeksforGeeks

22 Apr, 2020
With the help of base64.decodebytes(s) method, we can decode the binary string with the help of base64 data into normal form.
Syntax : base64.decodebytes(b_string)
Return : Return the decoded string.
Example #1 :In this example we can see that by using base64.decodebytes(s) method, we are able to get the decoded string which can be in binary form by using this method.
# import base64from base64 import encodebytesfrom base64 import decodebytes  s = b'GeeksForGeeks's = encodebytes(s)# Using base64.decodebytes(s) methodgfg = decodebytes(s)  print(gfg)
Output :
b’GeeksForGeeks’
Example #2 :
# import base64from base64 import encodebytesfrom base64 import decodebytes  s = b'Hello World's = encodebytes(s)# Using base64.decodebytes(s) methodgfg = decodebytes(s)  print(gfg)
Output :
b’Hello World’
Python base64-module
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 | os.path.join() method
Create a directory in Python
Defaultdict in Python
Python | Get unique values from a list
Python | Pandas dataframe.groupby()
Python os.chdir() Method

Python method chdir() changes the current working directory to the given path.It returns None in all the cases.
Following is the syntax for chdir() method −
os.chdir(path)

path − This is complete path of the directory to be changed to a new location.
path − This is complete path of the directory to be changed to a new location.
This method does not return any value.
The following example shows the usage of chdir() method.
#!/usr/bin/python
import os

path = "/usr/tmp"

# Check current working directory.
retval = os.getcwd()
print "Current working directory %s" % retval

# Now change the directory
os.chdir( path )

# Check current working directory.
retval = os.getcwd()

print "Directory changed successfully %s" % retval
When we run above program, it produces following result −
Current working directory /usr
Directory changed successfully /usr/tmp


    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
C# | How to get Third Element of the Tuple? - GeeksforGeeks

30 Apr, 2019
Tuple is a data structure which gives you the easiest way to represent a data set which has multiple values that may/may not be related to each other. Item3 Property is used to get the third element of the given tuple. It is not applicable on 1-Tuple, 2-Tuple but applicable on all other remaining tuples.
Syntax:
public T3 Item3 { get; }
Here, T3 is the value of the current Tuple<> object’s third component. This Tuple<> can be 3-tuple, or 4-tuple, or 5-tuple, or 6-tuple, or 7-tuple, or 8-tuple.
Example: In the below code, you can see that we are accessing the third element of each tuple.
// C# program to illustrate how to get // the third element of the tupleusing System;  class GFG {      // Main method    static public void Main()    {          // Taking 3-tuple        var st3 = Tuple.Create("Soniya", 30, "CSE");        Console.WriteLine("Student-3 Branch: " + st3.Item3);          // Taking 4-tuple        var st4 = Tuple.Create("Rohan", 29, "EC", 2015);        Console.WriteLine("Student-4 Branch: " + st4.Item3);          // Taking 5-tuple        var st5 = Tuple.Create("Siya", 22, "EEE", 2017,                                           "20-Mar-1993");          Console.WriteLine("Student-5 Branch: " + st5.Item3);          // Taking 6-tuple        var st6 = Tuple.Create("Riya", 24, "ME", 2015,                               "30-May-2015", 230134832);          Console.WriteLine("Student-6 Branch: " + st6.Item3);          // Taking 7-tuple        var st7 = Tuple.Create("Rohit", 21, "IT", 2017,                         "21-Apr-1998", 384749829, 20000);          Console.WriteLine("Student-7 Branch: " + st7.Item3);          // Taking 8-tuple        var st8 = Tuple.Create("Manita", 24, "CSE", 2016,                    "03-Aug-1991", 235678909, 34000, "C#");          Console.WriteLine("Student-8 Branch: " + st8.Item3);    }}
Student-3 Branch: CSE
Student-4 Branch: EC
Student-5 Branch: EEE
Student-6 Branch: ME
Student-7 Branch: IT
Student-8 Branch: CSE

CSharp-Tuple
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Destructors in C#
Extension Method in C#
HashSet in C# with Examples
Top 50 C# Interview Questions & Answers
C# | How to insert an element in an Array?
Partial Classes in C#
C# | Inheritance
C# | List Class
Difference between Hashtable and Dictionary in C#
Lambda Expressions in C#
String Handling in Java

Strings, which are widely used in Java programming, are a sequence of characters. In Java programming language, strings are treated as objects.
The Java platform provides the String class to create and manipulate strings.
The most direct way to create a string is to write −
String greeting = "Hello world!";
Whenever it encounters a string literal in your code, the compiler creates a String object with its value in this case, "Hello world!'.
Live Demo
public class StringDemo {
   public static void main(String args[]) {
      char[] helloArray = { 'h', 'e', 'l', 'l', 'o', '.' };
      String helloString = new String(helloArray);
      System.out.println( helloString );
   }
}
hello.
Python String lower() Method

Python string  method lower() returns a copy of the string in which all case-based characters have been lowercased.
Following is the syntax for lower() method −
str.lower()

NA
NA
This method returns a copy of the string in which all case-based characters have been lowercased.
The following example shows the usage of lower() method.
#!/usr/bin/python

str = "THIS IS STRING EXAMPLE....WOW!!!";
print str.lower()
When we run above program, it produces following result −
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
Perl rename Function

This function renames the file with OLDNAME to NEWNAME. Uses the system function rename( ), and so it will not rename files across file systems or volumes. If you want to copy or move a file, use the copy or move command supplied in the File::Copy module.
Following is the simple syntax for this function −
rename OLDNAME, NEWNAME
This function returns 0 on failure and 1 on success.
First create test file in /tmp directory and then use following code to change file name.
#!/usr/bin/perl -w

rename("/tmp/test", "/tmp/test2") || die ( "Error in renaming" );
When above code is executed, it produces the following result −
the file gets renamed


    46 Lectures 
     4.5 hours 

 Devi Killada

    11 Lectures 
     1.5 hours 

 Harshit Srivastava

    30 Lectures 
     6 hours 

 TELCOMA Global

    24 Lectures 
     2 hours 

 Mohammad Nauman

    68 Lectures 
     7 hours 

 Stone River ELearning

    58 Lectures 
     6.5 hours 

 Stone River ELearning
 Print
 Add Notes
 Bookmark this page
RxJava - PublishSubject

PublishSubject emits items to currently subscribed Observers and terminal events to current or late Observers.
Following is the declaration for io.reactivex.subjects.PublishSubject<T> class −
public final class PublishSubject<T>
extends Subject<T>

Create the following Java program using any editor of your choice in, say, C:\> RxJava.
import io.reactivex.subjects.PublishSubject;
public class ObservableTester  {
   public static void main(String[] args) {   
      final StringBuilder result1 = new StringBuilder();
      final StringBuilder result2 = new StringBuilder();         

      PublishSubject<String> subject = PublishSubject.create(); 
      subject.subscribe(value -> result1.append(value) ); 
      subject.onNext("a"); 
      subject.onNext("b"); 
      subject.onNext("c"); 
      subject.subscribe(value -> result2.append(value)); 
      subject.onNext("d"); 
      subject.onComplete();

      //Output will be abcd 
      System.out.println(result1);
      //Output will be d only
      //as subscribed after c item emitted.
      System.out.println(result2);
   }
}
Compile the class using javac compiler as follows −
C:\RxJava>javac ObservableTester.java

Now run the ObservableTester as follows −
C:\RxJava>java ObservableTester

It should produce the following output −
abcd
d

 Print
 Add Notes
 Bookmark this page
Laravel - Localization

Localization feature of Laravel supports different language to be used in application. You need to store all the strings of different language in a file and these files are stored at resources/views directory. You should create a separate directory for each supported language. All the language files should return an array of keyed strings as shown below.
<?php
return [
   'welcome' => 'Welcome to the application'
];
Step 1 − Create 3 files for languages − English, French, and German. Save English file at resources/lang/en/lang.php
<?php
   return [
      'msg' => 'Laravel Internationalization example.'
   ];
?>
Step 2 − Save French file at resources/lang/fr/lang.php.
<?php
   return [
      'msg' => 'Exemple Laravel internationalisation.'
   ];
?>
Step 3 − Save German file at resources/lang/de/lang.php.
<?php
   return [
      'msg' => 'Laravel Internationalisierung Beispiel.' 
   ];
?>
Step 4 − Create a controller called LocalizationController by executing the following command.
php artisan make:controller LocalizationController --plain

Step 5 − After successful execution, you will receive the following output −
Step 6 − Copy the following code to file
app/Http/Controllers/LocalizationController.php
app/Http/Controllers/LocalizationController.php
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;

class LocalizationController extends Controller {
   public function index(Request $request,$locale) {
      //set’s application’s locale
      app()->setLocale($locale);
      
      //Gets the translated message and displays it
      echo trans('lang.msg');
   }
}
Step 7 − Add a route for LocalizationController in app/Http/routes.php file. Notice that we are passing {locale} argument after localization/ which we will use to see output in different language.
app/Http/routes.php
Route::get('localization/{locale}','LocalizationController@index');

Step 8 − Now, let us visit the different URLs to see all different languages. Execute the below URL to see output in English language.
http://localhost:8000/localization/en

Step 9 − The output will appear as shown in the following image.
Step 10 − Execute the below URL to see output in French language.
http://localhost:8000/localization/fr

Step 11 − The output will appear as shown in the following image.
Step 12 − Execute the below URL to see output in German language
http://localhost:8000/localization/de

Step 13 − The output will appear as shown in the following image.

    13 Lectures 
     3 hours 

 Sebastian Sulinski

    35 Lectures 
     3.5 hours 

 Antonio Papa

    7 Lectures 
     1.5 hours 

 Sebastian Sulinski

    42 Lectures 
     1 hours 

 Skillbakerystudios

    165 Lectures 
     13 hours 

 Paul Carlo Tordecilla

    116 Lectures 
     13 hours 

 Hafizullah Masoudi
 Print
 Add Notes
 Bookmark this page
Algorithms | Recursion | Question 4 - GeeksforGeeks

28 Jun, 2021
What does the following function do?
int fun(int x, int y){    if (y == 0)   return 0;    return (x + fun(x, y-1));}
(A) x + y(B) x + x*y(C) x*y(D) xyAnswer: (C)Explanation: The function adds x to itself y times which is x*y.Quiz of this Question
Algorithms-Recursion
Algorithms Quiz
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Algorithms | Dynamic Programming | Question 2
Algorithms | Dynamic Programming | Question 3
Algorithms | Analysis of Algorithms | Question 17
Algorithms | Sorting | Question 1
Algorithms | Greedy Algorithms | Question 1
Algorithms Quiz | Dynamic Programming | Question 8
Algorithms | Analysis of Algorithms | Question 8
Algorithms | Divide and Conquer | Question 6
Algorithms | Graph Traversals | Question 12
Algorithms | Sorting | Question 23
C program to trim leading white spaces from String - GeeksforGeeks

07 Aug, 2020
Given string str, the task is to write C program to remove leading space from the given string.
Examples :
Input: str = ”       geeksforgeeks”Output: geeksforgeeks
Input: str = “gfg”Output: gfg
Approach: The idea is to count the leading spaces in the given string and then from that count index copy the characters from that index to the front of the string. Below are the steps:
Initialize count = 0 to count the number of leading spaces.Iterate through given string and find the index(say idx) at which the leading space character ends.Iterate through all the characters from that index idx and copy each character from this index to the end to the front index.Finally, put ‘\0’ at the last index of the new string to terminate the string.
Initialize count = 0 to count the number of leading spaces.
Iterate through given string and find the index(say idx) at which the leading space character ends.
Iterate through all the characters from that index idx and copy each character from this index to the end to the front index.
Finally, put ‘\0’ at the last index of the new string to terminate the string.
Below is the implementation of the above approach:
C
// C program for the above approach#include <stdio.h>  // Function to remove leading// spaces from a given stringchar* removeLeadingSpaces(char* str){    static char str1[99];    int count = 0, j, k;      // Iterate String until last    // leading space character    while (str[count] == ' ') {        count++;    }      // Putting string into another    // string variable after    // removing leading white spaces    for (j = count, k = 0;         str[j] != '\0'; j++, k++) {        str1[k] = str[j];    }    str1[k] = '\0';      return str1;}  // Driver Codeint main(){    // Given string    char str[] = "         geeksforgeeks";    char* ptr;      // Function call    ptr = removeLeadingSpaces(str);      // Print string without leading space    printf("%s", ptr);    return 0;}
geeksforgeeks

Time Complexity: O(N)Auxiliary Space: O(N)
C Programs
Strings
Strings
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
C Program to read contents of Whole File
Producer Consumer Problem in C
C program to find the length of a string
Exit codes in C/C++ with Examples
Regular expressions in C
Reverse a string in Java
Write a program to reverse an array or string
Longest Common Subsequence | DP-4
Write a program to print all permutations of a given string
C++ Data Types
alsactl command in Linux with Examples - GeeksforGeeks

03 Jul, 2020
alsactl is used to control advanced settings for the ALSA(The Advanced Linux Sound Architecture) soundcard drivers. It supports multiple soundcards. It helps to get control over the card features that you can’t seem to control from a mixer application.
Syntax:
alsactl [options] [store|restore|init] 

Some of the commands require superuser privilege(sudo) to execute.
1. store: It is used to save the current driver state to the configuration file, for the selected soundcard.Syntax :
sudo alsactl store

2. restore: It loads the driver state from the configuration file,of the selected soundcard. The init action is called in case the restoring fails due to any reason.Syntax :
sudo alsactl restore

3. init: It tries to initialize all devices to a default state. It returns 99 error code if the device is not known.Syntax :
alsactl init

4. –f Option : It is used to select the configuration file which is to be used.The default configuration file is /var/lib/alsa/asound.state.Syntax :
alsactl store -f /tmp/alsa.state

5. -–help Option : It with print the flags and commands of the alsactl command.Syntax :
alsactl -help

6. –version Option : It will print the version details of the alsactl command.Syntax :
alsactl -version

linux-command
Linux-system-commands
Picked
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
scp command in Linux with Examples
SED command in Linux | Set 2
mv command in Linux with examples
Docker - COPY Instruction
chown command in Linux with Examples
nohup Command in Linux with Examples
Named Pipe or FIFO with example C program
Thread functions in C/C++
uniq Command in LINUX with examples
Basic Operators in Shell Scripting
UUID toString() Method in Java with Examples - GeeksforGeeks

27 Dec, 2018
The toString() method of UUID class in Java is generally used to get the string representation of this UUID.
Syntax:
public String toString()
Parameters: This method does not take any parameter.
Return Value: This method returns a String value which is the string representation of this UUID.
Below programs illustrate the working of toString() method:
Program 1:
// Java code to illustrate toString() method  import java.util.*;  public class UUID_Demo {    public static void main(String[] args)    {          // Creating two UUIDs        UUID UUID_1            = UUID                  .fromString(                      "58e0a7d7-eebc-11d8-9669-0800200c9a66");          // Displaying the UUID        System.out.println("UUID: "                           + UUID_1);          // Displaying the string representation        System.out.println("The string representation is: "                           + UUID_1.toString());    }}
UUID: 58e0a7d7-eebc-11d8-9669-0800200c9a66
The string representation is: 58e0a7d7-eebc-11d8-9669-0800200c9a66

Program 2:
// Java code to illustrate toString() method  import java.util.*;  public class UUID_Demo {    public static void main(String[] args)    {          // Creating two UUIDs        UUID UUID_1            = UUID                  .fromString(                      "5fc03087-d265-11e7-b8c6-83e29cd24f4c");          // Displaying the UUID        System.out.println("UUID: "                           + UUID_1);          // Displaying the toString Value        System.out.println("The string representation is: "                           + UUID_1.toString());    }}
UUID: 5fc03087-d265-11e7-b8c6-83e29cd24f4c
The string representation is: 5fc03087-d265-11e7-b8c6-83e29cd24f4c

Java - util package
Java-Functions
Java-UUID
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Stream In Java
Object Oriented Programming (OOPs) Concept in Java
HashMap in Java with Examples
Interfaces in Java
How to iterate any Map in Java
ArrayList in Java
Initialize an ArrayList in Java
Stack Class in Java
Singleton Class in Java
Set in Java
Add image on a Python Tkinter button

Tkinter, which is the GUI library for python programming has a feature to add images to the GUI buttons. This is useful for users to remember the symbols in the GUI rather than the text in the GUI. In the below Tkinter program we show how we can add an image to a GUI button. The photoimage method from the imageKT module is used. We mention the local path to the image file.
from tkinter import *
from PIL import ImageTk ,Image

base = Tk()
base.title('Start Button')

img=ImageTk.PhotoImage(Image.open ("D:\\button.jpg"))
lab=Label(image=img)
lab.pack()

button=Button(base,text='exit',command=base.quit)
button.pack()
base.mainloop()
Running the above code gives us the following result −
3 bit Synchronous Down Counter - GeeksforGeeks

19 May, 2021

Prerequisite : Counter , Synchronous counter.
3 bit Synchronous Down Counter :
In synchronous counter clock is provided to all the flip-flops simultaneously.
Circuit becomes complex as the number of states increases.
Speed is high.
Design : The steps involves in design are 
  1. Decide the number of Flip flops – 
N number of Flip flop(FF) required for N bit counter.
For 3 bit counter we require 3 FF.
Maximum count = 2n-1, where n is a number of bits.
For n= 3, Maximum count = 7.
Here T FF is used.
   2. Write excitation table of FF –
 3. Draw State diagram and circuit excitation table –      Number of states = 2n, where n is number of bits.
Here T = 1, then there is output state(next state changes from previous state) changes i.e Q changes from 0 to 1 or 1 to 0 T= 0 then, there is no state output state changes i.e Q remains same 
 4. Find simplified equation using k map –
K map for 3 bit synchronous down counter 
 5.  Create circuit diagram –The clock is provided to every Flip flop at same instant of time. The toggle(T) input is provided to every Flip flop according to the simplified equation of K map.
Timing diagram of 3 bit synchronous Down counter.
Explanation :  Here -ve edge triggered clock is used for toggling purpose.
As we see from characteristics table when T = 1, then toggling takes place and T =0 then it stores the output state.
Initially Q3 = 0, Q2= 0, Q1= 0.
In simplified equation of K map we get T1 = 1, therefore Flip flop 1 output Q1 is toggle for every negative edge(because clock is negative edge triggered). Flip-flop(FF) 2 toggle input(T2) is connected to Q’1. Therefore, Flip Flop 2 output state Q2 is toggle only when there is clock falling edge  (i.e -ve edge triggering) and Q’1 =1.
Similarly, Flip flop 3 toggle input(T) is connected to Q’2 and Q’1. Therefore, Flip flop 3 output is toggle when there is clock falling edge and Q’2=1 and Q’1 = 1 .(as you can see from timing diagram)
Therefore, we get output(as down counting Q3(MSB) Q2 Q1(LSB) after 8th -ve edge triggered clock the output of the three Flip flops again becomes Q3 = 0, Q2 = 0, Q1 =0.
We get output(state changes) after every -ve edge clock pulse.
By 3 Flip flop we get output as 23-1= 7 to 0.

Digital Electronics & Logic Design

Writing code in comment? 
                                    Please use ide.geeksforgeeks.org, 
                                    generate link and share the link here.
                                
4-bit binary Adder-Subtractor
Full Subtractor in Digital Logic
Encoder in Digital Logic
Carry Look-Ahead Adder
BCD to 7 Segment Decoder
Multiplexers in Digital Logic
Half Adder in Digital Logic
Difference between Unipolar, Polar and Bipolar Line Coding Schemes
Magnitude Comparator in Digital Logic
Encoders and Decoders in Digital Logic
Groovy - equalsIgnoreCase()

Compares this String to another String, ignoring case considerations.
Boolean equalsIgnoreCase(String str)

Str - the String to compare this String against
This method returns true if the argument is not null and the Strings are equal, ignoring case; false otherwise.
Following is an example of the usage of this method −
class Example { 
   static void main(String[] args) { 
      String a = "Hello World"; 
      String b = "HELLO World"; 
      String c = "HELLO WORLD";
		
      println(a.equalsIgnoreCase(b)); 
      println(a.equalsIgnoreCase(c)); 
      println(b.equalsIgnoreCase(c)); 
   } 
}
When we run the above program, we will get the following result −
true 
true 
true


    52 Lectures 
     8 hours 

 Krishna Sakinala

    49 Lectures 
     2.5 hours 

 Packt Publishing
 Print
 Add Notes
 Bookmark this page
How to Loop Through Column Names in R dataframes? - GeeksforGeeks

28 Nov, 2021
In this article, we will discuss how to loop through column names in dataframe in R Programming Language.
Here we are using sapply() function with some functions to get column names. This function will return column names with some results
Syntax:
sapply(dataframe,specific function)
where
dataframe is the inpiut dataframe
specific function is like mean,sum,min ,max etc
Example: R program to get column names in the dataframe by performing some operations
R
# create dataframe with 4 columnsdata = data.frame(column1=c(23, 45), column2=c(50, 39),                  column3=c(33, 45), column4=c(11, 39))  # displayprint(data)  # get mean of all columnsprint(sapply(data, mean))  # get sum of all columnsprint(sapply(data, sum))  # get minimum of all columnsprint(sapply(data, min))  # get maximum of all columnsprint(sapply(data, max))
Output:
column1 column2 column3 column4
1      23      50      33      11
2      45      39      45      39
column1 column2 column3 column4 
   34.0    44.5    39.0    25.0 
column1 column2 column3 column4 
     68      89      78      50 
column1 column2 column3 column4 
     23      39      33      11 
column1 column2 column3 column4 
     45      50      45      39 
By using this function we can get column names. We have to iterate through for loop to get all the column names.
Syntax:
for (iterator in colnames(dataframe)){
    print(iterator )
}
where
dataframe is the input dataframe
iterator is a variable is used to iterate the elements
Example:
R
# create dataframe with 4 columnsdata = data.frame(column1=c(23, 45), column2=c(50, 39),                  column3=c(33, 45), column4=c(11, 39))  # displayprint(data)  # display column namesfor (i in colnames(data)){    print(i)}
Output:
Picked
R DataFrame-Programs
R-DataFrame
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Change Color of Bars in Barchart using ggplot2 in R
Group by function in R using Dplyr
How to Split Column Into Multiple Columns in R DataFrame?
How to Change Axis Scales in R Plots?
Replace Specific Characters in String in R
How to filter R DataFrame by values in a column?
R - if statement
How to filter R dataframe by multiple conditions?
Plot mean and standard deviation using ggplot2 in R
Time Series Analysis in R
C# | CharEnumerator.GetType() Method - GeeksforGeeks

30 Apr, 2019
CharEnumerator.GetType() Method is used to get the type of the current instance. This method is inherited from the Object Class.
Syntax:
public Type GetType();
Return Value: This method returns the exact runtime type of the current instance.
Below are the programs to illustrate the use of CharEnumerator.GetType() Method:+
Example 1:
// C# program to illustrate the// use of CharEnumerator.GetType()// Methodusing System;  class GFG {      // Driver code    public static void Main()    {        // Initialize a string object        string str = "GeeksforGeeks is Awesome!";          // Instantiate a CharEnumerator object        CharEnumerator chEnum = str.GetEnumerator();          // Printing the Type of        // the CharEnumerator objects        Console.WriteLine(chEnum.GetType());    }}
System.CharEnumerator

Example 2:
// C# program to illustrate the// use of CharEnumerator.GetType()// Methodusing System;  class GFG {      // Driver code    public static void Main()    {        // Initialize a string object        string str = "GeeksforGeeks is fun";          // Instantiate a CharEnumerator object        CharEnumerator chEnum = str.GetEnumerator();          // Instantiate a clone of CharEnumerator object        CharEnumerator chEnumClone = (CharEnumerator)chEnum.Clone();          // Printing the Type of the        // CharEnumerator objects and its clone        Console.WriteLine("Type of CharEnumerator object: "                                       + chEnum.GetType());          Console.WriteLine("Type of CharEnumerator clone object: "                                         + chEnumClone.GetType());    }}
Type of CharEnumerator object: System.CharEnumerator
Type of CharEnumerator clone object: System.CharEnumerator

CSharp-CharEnumerator-Class
CSharp-method
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
C# Dictionary with examples
C# | Delegates
C# | Method Overriding
C# | Abstract Classes
Difference between Ref and Out keywords in C#
Extension Method in C#
C# | Class and Object
C# | Replace() Method
C# | Constructors
Introduction to .NET Framework
MongoDB - limit() Method - GeeksforGeeks

28 Jan, 2021
In MongoDB, the limit() method limits the number of records or documents that you want. It basically defines the max limit of records/documents that you want. Or in other words, this method uses on cursor to specify the maximum number of documents/ records the cursor will return. We can use this method after the find() method and find() will give you all the records or documents in the collection. You can also use some conditions inside find to give you the result that you want.
In this method, we only pass numeric value.
This method is undefined for values which is less than -2131 and greater than 231.
Passing 0 in this method(limit(0)) is equivalent to no limit.
Syntax :
cursor.limit()
Or
db.collectionName.find(<query>).limit(<number>)
Examples:
In the following examples, we are working with:
Database: geeksforgeeks
Collections: gfg
Document: Eight documents contains the content
Limit two documents
db.gfg.find().limit(2)
Here, we only want the first two documents in the result. So, we pass 2 in the limit method.
Limit only two documents that match the given condition
db.gfg.find({"content":/c/i}).limit(2)
Here, we only want the two documents that satisfy the given condition, i.e., {“content”:/c/i}) in the find() method. Here, content is key were we will check whether it contains ‘c’ character in the string or not. /c/ denotes that we are looking for strings that contain this ‘c’ character and in the end of  /c/i, i denotes that it is case-insensitive.
Limit only three documents that match the given condition
db.gfg.find({"content":/c/i}).limit(3)
Here, we only want the three documents that satisfy the given condition, i.e., {“content”:/c/i}) in the find() method. Here, content is key were we will check whether it contains ‘c’ character in the string or not. /c/ denotes that we are looking for strings that contain this ‘c’ character and in the end of  /c/i, i denotes that it is case-insensitive.
MongoDB-method
Picked
MongoDB
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
MongoDB - Distinct() Method
How to connect MongoDB with ReactJS ?
MongoDB - FindOne() Method
MongoDB - Regex
Export data from MongoDB
Create user and add role in MongoDB
MongoDB Cursor
MongoDB updateOne() Method - db.Collection.updateOne()
MongoDB insertMany() Method - db.Collection.insertMany()
MongoDB - sort() Method
Python - Split Numeric String into K digit integers - GeeksforGeeks

02 Sep, 2020
Given a String, convert it to K digit integers
Input : test_str = ‘457336’, K = 2Output : [45, 73, 36]Explanation : Divided in 2 digit integers.
Input : test_str = ‘457336’, K = 3Output : [457, 336]Explanation : Divided in 3 digit integers.
Method #1 : Using int() + slice + loop
In this, we iterate for string and perform slicing till K digits and then perform task of conversion to integer using int().
Python3
# Python3 code to demonstrate working of # Split Numeric String into K digit integers# Using int() + slice + loop  # initializing stringtest_str = '457336842'  # printing original stringprint("The original string is : " + str(test_str))  # initializing substringK = 3  res = []for idx in range(0, len(test_str), K):          # converting to int, after slicing    res.append(int(test_str[idx : idx + K]))  # printing result print("Converted number list : " + str(res)) 
The original string is : 457336842
Converted number list : [457, 336, 842]

Method #2 : Using list comprehension + int() + slicing
Similar method to above, just a shorthand to solve this problem.
Python3
# Python3 code to demonstrate working of # Split Numeric String into K digit integers# Using list comprehension + int() + slicing  # initializing stringtest_str = '457336842'  # printing original stringprint("The original string is : " + str(test_str))  # initializing substringK = 3  # one liner to solve problemres = [int(test_str[idx : idx + K]) for idx in range(0, len(test_str), K)]  # printing result print("Converted number list : " + str(res)) 
The original string is : 457336842
Converted number list : [457, 336, 842]

Python list-programs
Python string-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Python Dictionary
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Create a Pandas DataFrame from Lists
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python program to check whether a number is Prime or not
How to print without newline in Python?
How to plot a Bar Chart with multiple labels in Matplotlib?

To plot a bar chart with multiple labels in Matplotlib, we can take the following steps −
Make some data set for men_means, men_std, women_means, and women_std.
Make some data set for men_means, men_std, women_means, and women_std.
Make index data points using numpy.
Make index data points using numpy.
Initialize the width of the bars.
Initialize the width of the bars.
Use subplots() method to create a figure and a set of subplots.
Use subplots() method to create a figure and a set of subplots.
Create rects1 and rects2 bars rectangle using bar() method.
Create rects1 and rects2 bars rectangle using bar() method.
Use set_ylabel(),
set_title(), set_xticks() and set_xticklabels() methods.
Use set_ylabel(),
set_title(), set_xticks() and set_xticklabels() methods.
Place a legend on the plot.
Place a legend on the plot.
Add multiple labels for bar chart using autolabel() method.
Add multiple labels for bar chart using autolabel() method.
To display the figure, use show() method.
To display the figure, use show() method.
import matplotlib.pyplot as plt
import numpy as np

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

men_means, men_std = (20, 35, 30, 35, 27), (2, 3, 4, 1, 2)
women_means, women_std = (25, 32, 34, 20, 25), (3, 5, 2, 3, 3)

ind = np.arange(len(men_means)) # the x locations for the groups
width = 0.35 # the width of the bars

fig, ax = plt.subplots()
rects1 = ax.bar(ind - width/2, men_means, width, yerr=men_std, label='Men')
rects2 = ax.bar(ind + width/2, women_means, width, yerr=women_std, label='Women')

ax.set_ylabel('Scores')
ax.set_title('Scores by group and gender')
ax.set_xticks(ind)
ax.set_xticklabels(('G1', 'G2', 'G3', 'G4', 'G5'))
ax.legend()

def autolabel(rects, xpos='center'):
   ha = {'center': 'center', 'right': 'left', 'left': 'right'}
   offset = {'center': 0, 'right': 1, 'left': -1}
   for rect in rects:
      height = rect.get_height()
      ax.annotate('{}'.format(height),
         xy=(rect.get_x() + rect.get_width() / 2, height),
         xytext=(offset[xpos]*3, 3), # use 3 points offset
         textcoords="offset points", # in both directions
         ha=ha[xpos], va='bottom')

autolabel(rects1, "left")
autolabel(rects2, "right")
plt.show()