code-rag-bench/online-tutorials huggingface dataset:
How to customize how a JTabbedPane looks in Java?

To customize how a JTabbedPane looks, change its font style, font face, font size and the background and foreground colors.
Let’s say the following is the JTabbedPane −
JTabbedPane tabbedPane = new JTabbedPane();
Now, let us customize the above created JTabbedPane −
tabbedPane.setBackground(Color.orange);
tabbedPane.setForeground(Color.white);
Font font = new Font("Verdana", Font.CENTER_BASELINE, 18);
tabbedPane.setFont(font);
The following is an example to customize JTabbedPane −
package my;
import javax.swing.*;
import java.awt.*;
public class SwingDemo {
   public static void main(String args[]) {
      JFrame frame = new JFrame("Technologies");
      JTabbedPane tabbedPane = new JTabbedPane();
      JPanel panel1, panel2, panel3, panel4, panel5;
      panel1 = new JPanel();
      panel2 = new JPanel();
      panel3 = new JPanel();
      panel4 = new JPanel();
      panel5 = new JPanel();
      tabbedPane.addTab("Data Science", panel1);
      tabbedPane.addTab("Blockchain ", panel2);
      tabbedPane.addTab("PHP", panel3);
      tabbedPane.addTab("Matlab ", panel4);
      tabbedPane.addTab("Servlet", panel5);
      tabbedPane.setBackground(Color.orange);
      tabbedPane.setForeground(Color.white);
      Font font = new Font("Verdana", Font.CENTER_BASELINE, 18);
      tabbedPane.setFont(font);
      frame.add(tabbedPane);
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.setSize(660,350);
      frame.setVisible(true);
   }
}
Pointer to C++ Classes

A pointer to a C++ class is done exactly the same way as a pointer to a structure and to access members of a pointer to a class you use the member access operator -> operator, just as you do with pointers to structures. Also as with all pointers, you must initialize the pointer before using it.
Let us try the following example to understand the concept of pointer to a class −
#include <iostream>
 
using namespace std;

class Box {
   public:
      // Constructor definition
      Box(double l = 2.0, double b = 2.0, double h = 2.0) {
         cout <<"Constructor called." << endl;
         length = l;
         breadth = b;
         height = h;
      }
      double Volume() {
         return length * breadth * height;
      }
      
   private:
      double length;     // Length of a box
      double breadth;    // Breadth of a box
      double height;     // Height of a box
};

int main(void) {
   Box Box1(3.3, 1.2, 1.5);    // Declare box1
   Box Box2(8.5, 6.0, 2.0);    // Declare box2
   Box *ptrBox;                // Declare pointer to a class.

   // Save the address of first object
   ptrBox = &Box1;

   // Now try to access a member using member access operator
   cout << "Volume of Box1: " << ptrBox->Volume() << endl;

   // Save the address of second object
   ptrBox = &Box2;

   // Now try to access a member using member access operator
   cout << "Volume of Box2: " << ptrBox->Volume() << endl;
  
   return 0;
}
When the above code is compiled and executed, it produces the following result −
Constructor called.
Constructor called.
Volume of Box1: 5.94
Volume of Box2: 102


    154 Lectures 
     11.5 hours 

 Arnab Chakraborty

    14 Lectures 
     57 mins

 Kaushik Roy Chowdhury

    30 Lectures 
     12.5 hours 

 Frahaan Hussain

    54 Lectures 
     3.5 hours 

 Frahaan Hussain

    77 Lectures 
     5.5 hours 

 Frahaan Hussain

    12 Lectures 
     3.5 hours 

 Frahaan Hussain
 Print
 Add Notes
 Bookmark this page
Convert string to char array in C++

This is a C++ program to Convert string to char array in C++. This can be done in many ways:
Begin
   Assign value to string m.
   For i = 0 to sizeof(m)
      Print the char array.
End
 Live Demo
#include<iostream>
#include<string.h>
using namespace std;
int main() {
   char m[] = "Tutorialspoint";
   string str;
   int i;
   for(i=0;i<sizeof(m);i++) {
      str[i] = m[i];
      cout<<str[i];
   }
   return 0;
}
We can simply call strcpy() function to copy the string to char array.
Begin
   Assign value to string s.
   Copying the contents of the string to char array using strcpy().
End
 Live Demo
#include <iostream>
#include <string>
#include <cstring>
using namespace std;
int main() {
   string str = "Tutorialspoint";
   char c[str.size() + 1];
   strcpy(c, str.c_str());
   cout << c << '\n';
   return 0;
}
Tutorialspoint
We can avoid using strcpy() which is basically used in c by
std::string::copy instead.
Begin
   Assign value to string s.
   copying the contents of the string to char array using copy().
End
 Live Demo
#include <iostream>
#include <string>
using namespace std;
int main() {
   string str = "Tutorialspoint";
   char c[str.size() + 1];
   str.copy(c, str.size() + 1);
   c[str.size()] = '\0';
   cout << c << '\n';
   return 0;
}
Tutorialspoint
How to use Global Variable in Postman Request?

We can use a Global variable in Postman Request. . We can set, get and clear a Global variable at runtime using the scripts. This is achieved by the pm.* function. The script to use a Global variable can be included either in the Tests or Pre-Request Script tab
To set a Global variable, the script should be −
pm.globals.set('<name of Global variable>', '<value of variable>')
To get the value of a Global variable, the script should be −
pm.globals.get('<name of Global variable>')
To get the value of the Global variable in the Postman console, the script should be −
console.log(pm.globals.get('<name of Global variable>')
To delete a Global variable, the script is −
pm.globals.unset('<name of Global variable>')
Let us try to work with a Global variable g.
Step1 − Add the below script to set the value value1 for the Global variable g.
pm.globals.set('g', 'value1')
Step2 − Add the below script to get the value of Global variable g and print it in console.
console.log(pm.globals.get('g'))
Step3 − Add the below script to delete the value of Global variable g and verify it.
pm.globals.unset('g'))
console.log(pm.globals.get('g'))
Step4 − Click on Send to execute a request.
Step5 − After the Response is received, open the Postman Console. It first displays value1 which is the value set for the Global variable g. Next, it displays undefined since the value of the Global variable g has been deleted in the Step3.
Redis - List Rpush Command

Redis RPUSH command inserts all the specified values at the tail of the list stored at the key. If the key does not exist, it is created as an empty list before performing the push operation. When the key holds a value that is not a list, an error is returned.
Integer reply, the length of the list after the push operation.
Following is the basic syntax of Redis RPUSH command.
redis 127.0.0.1:6379> RPUSH KEY_NAME VALUE1..VALUEN 

redis 127.0.0.1:6379> RPUSH mylist "hello" 
(integer) 1 
redis 127.0.0.1:6379> RPUSH mylist "foo" 
(integer) 2 
redis 127.0.0.1:6379> RPUSH mylist "bar" 
(integer) 3 
redis 127.0.0.1:6379> LRANGE mylist 0 -1 
1) "hello"
2) "foo" 
3) "bar"


    22 Lectures 
     40 mins

 Skillbakerystudios
 Print
 Add Notes
 Bookmark this page
Find Perimeter of a triangle in C++

In this problem, we will see the perimeter of a triangle, formula for the
perimeter of different types of triangle and program to find them.
Perimeter is defined as the total distance about the figure. Basically, it is the sum of all sides of the given figure.
Perimeter of a triangle
The perimeter of a triangle is the sum of all its three sides (triangle is a three
sides figure).
Formula,
Perimeter = sum of all sides
Perimeter = x + y + z
Program to find the perimeter of a triangle,
 Live Demo
#include <iostream>
using namespace std;
int calcPerimeter(int x, int y, int z ){
   int perimeter = x + y + z;
   return perimeter;
}
int main(){
   int x = 5, y = 7, z = 8;
   cout<<"The side of the triangle are \n";
   cout<<"X = "<<x<<"\tY = "<<y<<"\tZ = "<<z<<endl;
   cout<<"The perimeter of the triangle is "<<calcPerimeter(x, y, z);
   return 0;
}
The side of the triangle are
X = 5 Y = 7 Z = 8
The perimeter of the triangle is 20
Perimeter of different type of triangles,
In mathematics, there are different types of triangle with some special properties. Though the basic formula of the perimeter remains the same, there are specific formulas of all types of triangle. Let’s see each of them.
It is a special type of triangle in which all sides and angles are equal.
Perimeter = 3*a
Program to find the area of equilateral triangle,
 Live Demo
#include <iostream>
using namespace std;
int calcPerimeter(int a){
   int perimeter = 3*a;
   return perimeter;
}
int main(){
   int a = 5;
   cout<<"The side of the equilateral triangle are \n";
   cout<<"a = "<<a<<endl;
   cout<<"The perimeter of the triangle is "<<calcPerimeter(a);
   return 0;
}
The side of the equilateral triangle are
a = 5
The perimeter of the triangle is 15
It is a special type of triangle in which two sides are equal and the third one
has different length.
Perimeter = 2*X + Y
Program to find the perimeter of isosceles triangle,
 Live Demo
#include <iostream>
using namespace std;
int calcPerimeter(int x, int y){
   int perimeter = 2*x + y;
   return perimeter;
}
int main(){
   int x = 5, y = 8;
   cout<<"The side of the Isosceles triangle are \n";
   cout<<"X = "<<x<<"\tY = "<<y<<endl;
   cout<<"The perimeter of the triangle is "<<calcPerimeter(x, y);
   return 0;
}
The side of the Isosceles triangle are
X = 5 Y = 8
The perimeter of the triangle is 18
It is a triangle whose all three sides are different.
Perimeter = x + y + z
Standard Chartered Interview Experience - GeeksforGeeks

30 Oct, 2019
I attended an interview with Standard Chartered on 20th Oct 2019. I hold about 9 years of exp in java.
There is only one round that was the written round.
Find the exact pair of the numbers in an array whose sum of values is equal to targets. Assume that there is only such a pair. This implementation needs to be done in O(n).Find the prime factors of the given number and the output should be as 15-> 5, 3 and 9->3*3Given the array of numbers with positive and negative values. Arrange them so that all negative values appear first and positive next without changing the relative order.input: [-15, -17, -2, 19, -34, 5, 19, 0]
output: [-15, -17, -2, -34, 19, 5, 19, 0]
Find the exact pair of the numbers in an array whose sum of values is equal to targets. Assume that there is only such a pair. This implementation needs to be done in O(n).
Find the prime factors of the given number and the output should be as 15-> 5, 3 and 9->3*3
Given the array of numbers with positive and negative values. Arrange them so that all negative values appear first and positive next without changing the relative order.input: [-15, -17, -2, 19, -34, 5, 19, 0]
output: [-15, -17, -2, -34, 19, 5, 19, 0]
input: [-15, -17, -2, 19, -34, 5, 19, 0]
output: [-15, -17, -2, -34, 19, 5, 19, 0]
Marketing
Standard Chartered
Interview Experiences
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Amazon Interview Experience for SDE-1 (Off-Campus)
Amazon AWS Interview Experience for SDE-1
Amazon Interview Experience for SDE-1 (Off-Campus) 2022
Amazon Interview Experience
Amazon Interview Experience for SDE-1
Amazon Interview Experience (Off-Campus) 2022
Freshworks/Freshdesk Interview Experience for Software Developer (On-Campus)
Amazon Interview Experience for SDE-1 (On-Campus)
JPMorgan Chase & Co. Code for Good Internship Interview Experience 2021
EPAM Interview Experience (Off-Campus)
HTML | DOM IFrame contentDocument Property - GeeksforGeeks

30 Sep, 2019
The IFrame contentDocument property in HTML DOM is used to return the document object generated by a frame or iframe element. It can be used in the host window to access the document object that belongs to a frame or iframe element.
Syntax:
iframeObject.contentDocument 
Return Value: It returns the reference of the document object. If there is no object available then it returns null.
Example:
<!DOCTYPE html> <html>   <head>     <title>         HTML DOM iframe contentDocument Property     </title> </head>   <body style="text-align:center;">       <h1>GeeksforGeeks</h1>       <h2>         HTML DOM iframe contentDocument Property     </h2>       <iframe src="https://ide.geeksforgeeks.org/index.php"                id="GFG" height="200" width="400">     </iframe>           <br><br>           <button onclick="Geeks()">        Submit    </button>       <script>         function Geeks() {             var iframeID = document.getElementById("GFG");                           var iframeCW = (iframeID.contentWindow                    || iframeID.contentDocument);                          if (iframeCW.document)iframeCW = iframeCW.document;                iframeCW.body.style.border = "5px solid black";        }     </script> </body>   </html>
Before Clicking on the Button:
After Clicking on the Button:
Supported Browsers: The browsers supported by HTML DOM IFrame contentDocument property are listed below:
Google Chrome
Internet Explorer
Firefox
Safari
Opera
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
HTML-DOM
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
REST API (Introduction)
How to Insert Form Data into Database using PHP ?
Types of CSS (Cascading Style Sheet)
How to position a div at the bottom of its container using CSS?
HTML | <img> align Attribute
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
Perl | rename() Function - GeeksforGeeks

25 Jun, 2019
rename() function in Perl renames the old name of a file to a new name as given by the user.
Syntax: rename(old_file_path, new_file_path)
Parameters:old_file_path: path of the old file along with its namenew_file_path: path of the new file along with its name
Returns0 on failure and 1 on success
Example:
#!/usr/bin/perl -w  # Calling the rename() function # with required parametersrename("D:/GeeksforGeeks/GFG File.txt",       "D:/GeeksforGeeks/GFG File 2.txt") ||       die ( "Error in renaming" );
Output:
Original File: 
Running the Command: 
Updated File:  Steps to Run the above code:Step1: Create a file anywhere in your System and copy the File Path.Step 2: Provide the path of your File in the code above and save it as .pl extension.Step 3: Run the above code in Command line as perl Filename.pl.Step 4: Name of the File is now changed with the new name provided.
Perl-File-Functions
Perl-function
Perl
Perl
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Perl Tutorial - Learn Perl With Examples
Perl | Basic Syntax of a Perl Program
Perl | Inheritance in OOPs
Perl | Opening and Reading a File
Perl | Multidimensional Hashes
Perl | Scope of Variables
Perl | ne operator
Perl | Hashes
Perl | Data Types
Perl | defined() Function
How to set delay in android?

In some cases, after some time we need to update on UI to solve this problem, In this example demonstrate how to set a delay in android.
Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.
Step 2− Add the following code to res/layout/activity_main.xml.
<?xml version = "1.0" encoding = "utf-8"?>
<LinearLayout xmlns:android = "http://schemas.android.com/apk/res/android"
   android:id = "@+id/parent"
   xmlns:tools = "http://schemas.android.com/tools"
   android:layout_width = "match_parent"
   android:layout_height = "match_parent"
   tools:context = ".MainActivity"
   android:gravity = "center"
   android:orientation = "vertical">
   <TextView
      android:id = "@+id/textChanger"
      android:layout_margin = "20dp"
      android:textAlignment = "center"
      android:text = "Initial text"
      android:layout_width = "match_parent"
      android:layout_height = "wrap_content" />
</LinearLayout>
In the above code, we have taken text view, primary it shows "initial text" after some delay it will update with new text.
Step 3 − Add the following code to src/MainActivity.java
package com.example.andy.myapplication;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.RequiresApi;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
   int view = R.layout.activity_main;
   TextView textChanger;
   @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(view);
      textChanger = findViewById(R.id.textChanger);
      Handler handler = new Handler();
      handler.postDelayed(new Runnable() {
         @Override
         public void run() {
            textChanger.setText("After some delay, it changed to new text");
         }
      }, 5000);
   }
}
In the above code, we have used the handler to maintain delay as shown below -
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
   @Override
   public void run() {
      textChanger.setText("After some delay, it changed to new text");
   }
}, 5000);
In the above code after 5000ms it is updating text. Let's try to run your application. I assume you have connected your actual Android Mobile device with your computer. To run the app from android studio, open one of your project's activity files and click Run   icon from the toolbar. Select your mobile device as an option and then check your mobile device which will display your default screen −
Initially, it will show text as shown above. after some time, it will update text as shown below -
Click here to download the project code
Python break statement

13 Jun, 2022
Using loops in Python automates and repeats the tasks in an efficient manner. But sometimes, there may arise a condition where you want to exit the loop completely, skip an iteration or ignore some statements of the loop before continuing further in the loop. These can be done by loop control statements called jump statements. Loop control or jump statements change execution from its normal sequence. When execution leaves a scope, all automatic objects that were created in that scope are destroyed. Python supports the following control/jump statements.
continue statement
break statement
pass statement
In this article, the main focus will be on the break statement.
Break statement
break statement in Python is used to bring the control out of the loop when some external condition is triggered. break statement is put inside the loop body (generally after if condition).  It terminates the current loop, i.e., the loop in which it appears, and resumes execution at the next statement immediately after the end of that loop. If the break statement is inside a nested loop, the break will terminate the innermost loop.
 
Syntax:
break
Example#1: 
Python3
# Python program to# demonstrate break statement s = 'geeksforgeeks'# Using for loopfor letter in s:     print(letter)    # break the loop as soon it sees 'e'    # or 's'    if letter == 'e' or letter == 's':        break print(& quot       Out of for loop & quot       )print() i = 0 # Using while loopwhile True:    print(s[i])     # break the loop as soon it sees 'e'    # or 's'    if s[i] == 'e' or s[i] == 's':        break    i += 1 print(& quot       Out of while loop & quot       )
Output:
g
e
Out of for loop

g
e
Out of while loop
In the above example, both the loops are iterating the string ‘geeksforgeeks’ and as soon as they encounter the character ‘e’ or ‘s’, the if the condition becomes true and the flow of execution is brought out of the loop.
Example#2:
Python3
num = 0for i in range(10):    num += 1    if num == 8:        break    print("The num has value:", num)print("Out of loop")
The num has value: 1
The num has value: 2
The num has value: 3
The num has value: 4
The num has value: 5
The num has value: 6
The num has value: 7
Out of loop

In the above example, after iterating till num=7, the value of num will be 8 and the break is encountered so the flow of the execution is brought out of the loop.
sheetal18june
Python-OOP
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Dart – Fat Arrow Notation

07 Sep, 2021
In Dart, we have fat arrow notation ( => ).  A fat arrow is used to define a single expression in a function. This is a cleaner way to write functions with a single statement.
Declaring Fat arrow expression in dart –
Syntax :
ReturnType FunctionName(Parameters...) => Expression;
In the above syntax:
ReturnType consists of datatypes like void,int,bool, etc..
FunctionName defines the name of the function.
Parameters are the list of parameters function requires.
Let’s see how we can write the below code in a more short way.
Dart
void main() {      perimeterOfRectangle(47, 57);   } void perimeterOfRectangle(int length, int breadth) {  var perimeter = 2 * (length + breadth);  print('The perimeter of rectangle is $perimeter');}
Output:
The perimeter of rectangle is 208
When the body of the function contains only one line, you can omit the curly braces and the return statement in favor of the “arrow syntax” as shown below:
Dart
void main() {  perimeterOfRectangle(47, 57); } // Arrow Syntaxvoid perimeterOfRectangle(int length, int breadth) =>  print('The perimeter of rectangele is ${2 * (length + breadth)}');
Output:
The perimeter of rectangele is 208
If we compare the above code we got the same output with much less code using Fat arrow notation.
Example 1:
Consider the below code:
Dart
void sum (int x, int y) {     // printing the result  print( 'sum is ${x + y}');} void main (){  sum(5,2);}
Output:
sum is 7
The given functions can be optimized with the help of a fat arrow in Dart and the same output we can get:
Dart
void main(){  sum(2,5);} // Arrow Syntaxvoid sum(int x,int y) => print('sum is ${ x + y}');
Output:
sum is 7
Fat arrow is a clean way to write function expression in a single line.
Fat arrow notation doesn’t have statements body ‘ { } ‘ .
The statement body is replaced with   ‘ => ‘ fat arrow which points to a single statement.
sweetyty
Dart Control-Flow
Dart
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python program to check if given string is pangram

05 Feb, 2019
Given a string, write a Python program to check if that string is Pangram or not. A pangram is a sentence containing every letter in the English Alphabet.
Examples:
Input : The quick brown fox jumps over the lazy dog
Output : Yes

Input : abcdefgxyz
Output : No

 
We have already discussed the naive approach of pangram checking in this article. Now, let’s discuss the Pythonic approaches to do the same.
Approach #1 : Pythonic NaiveThis method uses a loop to check if each character of the string belongs to the alphabet set or not.
# Python3 program to# Check if the string is pangramimport string  def ispangram(str):    alphabet = "abcdefghijklmnopqrstuvwxyz"    for char in alphabet:        if char not in str.lower():            return False      return True      # Driver codestring = 'the quick brown fox jumps over the lazy dog'if(ispangram(string) == True):    print("Yes")else:    print("No")
Yes

 Approach #2 : Using Python SetConvert the given string into set and then check if the alphabet set is greater than or equal to it or not. If the string set is greater or equal, print ‘Yes’ otherwise ‘No’.
# Python3 program to# Check if the string is pangramimport string  alphabet = set(string.ascii_lowercase)  def ispangram(string):    return set(string.lower()) >= alphabet      # Driver codestring = "The quick brown fox jumps over the lazy dog"if(ispangram(string) == True):    print("Yes")else:    print("No")
Yes

 Approach #3 : Alternative to set methodThis is another method that uses Python set to find if the string is Pangram or not. We make set of lowercase alphabets and the given string. If set of given string is subtracted from the set of alphabets, we get to know whether the string is pangram or not.
# Python3 program to# Check if the string is pangramimport string  alphabet = set(string.ascii_lowercase)  def ispangram(str):     return not set(alphabet) - set(str)      # Driver codestring = 'the quick brown fox jumps over the lazy dog'if(ispangram(string) == True):    print("Yes")else:    print("No")
Yes

 Approach #4 : ASCII methodCheck if each character of the string lies between the ASCII range of lowercase alphabets i.e. 96 to 122.
# Python3 program to# Check if the string is pangramimport itertoolsimport string  alphabet = set(string.ascii_lowercase)  def ispangram(str):     return sum(1 for i in set(str) if 96 < ord(i) <= 122) == 26      # Driver codestring = 'the quick brown fox jumps over the lazy dog'if(ispangram(string) == True):    print("Yes")else:    print("No")
Yes

Python string-programs
python-string
Python
Python Programs
Strings
Strings
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to use Particle.js in JavaScript project ?

18 Aug, 2020
Particles.js is a lightweight JavaScript library used for creating particles which looks likes the vertices of polygon. We can also interact by hovering over the particles and create more particles by clicking on particles.
Here is the example of particle.js
We can use this library in our portfolios which will definitely attract many users and will look good in the website.
Installation process:
1. Download the particles.js library from the following link, unzip it and copy it into your project folder. https://vincentgarreau.com/particles.js/
2. Create two files index.html and style.css.
Write the following code in index.html file.
HTML
<!DOCTYPE html><html lang="en">  <head>    <title>particles.js</title>      <!-- Import style.css from root directory -->    <link rel="stylesheet" href="./style.css" /></head>  <body>    <!-- Particles.js div -->    <div id="particles-js">        <div class="heading">            <h1>GeeksforGeeks</h1>            <h3>                A computer Science                 portal for geeks            </h3>        </div>    </div>      <!-- Import Particles.js and app.js files -->    <script src=        "particles.js-master/particles.js">    </script>    <script src=        "/particles.js-master/demo/js/app.js">    </script></body>  </html>
Filename: style.css
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 
      'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell,
      'Open Sans', 'Helvetica Neue', sans-serif;
}
.heading {
    position: absolute;
    text-align: center;
    top: 30%;
    width: 100%;
}
.heading h1 {
    color: limegreen;
    font-size: 70px;
}
.heading h3 {
    color: wheat;
    font-size: 20px;
}
#particles-js {
    background: black;
    height: 100vh;
}
3. Save the above code in respective files and run index.html file.
Note: If you are using node app, then we can simply download particles.js node module by following command.
npm install particles.js
And import particles.js and app.js files from node_modules folder and write the html code.
HTML
<!DOCTYPE html><html lang="en">  <head>    <title>particles.js</title>    <!-- Import style.css from root directory -->    <link rel="stylesheet" href="./style.css" /></head>  <body>    <!-- Particles.js div -->    <div id="particles-js">        <div class="heading">            <h1>GeeksforGeeks</h1>            <h3>A computer Science portal for geeks</h3>        </div>    </div>      <!-- Import Particles.js and app.js files -->    <script src=        "/node_modules/particles.js/particles.js">    </script>    <script src=        "/node_modules/particles.js/demo/js/app.js">    </script></body>  </html>
We can change particles properties and interactivity by modifying app.js and then see the magic.
Output:
CSS-Misc
HTML-Misc
JavaScript-Misc
CSS
HTML
JavaScript
Web Technologies
Web technologies Questions
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | Ways to split a string in different ways

22 Jun, 2022
The most common problem we have encountered in Python is splitting a string by a delimiter, But in some cases we have to split in different ways to get the answer. In this article, we will get substrings obtained by splitting string in different ways. Examples:
Input : Paras_Jain_Moengage_best Output : [‘Paras’, ‘Paras_Jain’, ‘Paras_Jain_Moengage’, ‘Paras_Jain_Moengage_best’] Input : chunky_2808_GFG_Codechef Output : [‘chunky’, ‘chunky_2808’, ‘chunky_2808_GFG’, ‘chunky_2808_GFG_Codechef’]
Below are some ways to do the task.
Method #1: Using Iteration 
Python3
# Python code to split string in substring manner # Input initialisationInput = "Geeks_for_geeks_is_best" # Split initialisesplit_string = Input.split('_') # Output list initialiseOutput = [] # Iterationfor a in range(len(split_string)):    temp = split_string[:a + 1]    temp = "_".join(temp)    Output.append(temp) # print outputprint(Output)
Method 2: Using Itertools 
Python3
# Python code to split string in substring manner # Importingfrom itertools import accumulate # Input initialisationInput = "Geeks_for_geeks_is_best" # Using accumulateOutput = [*accumulate(Input.split('_'), lambda temp1, temp2 :                                   '_'.join([temp1, temp2])), ] # Printing outputprint(Output)
Method#3 : Using re module and string slicing
Python3
# Python code to split string in substring manner# Importingimport re # Input initialisationInput = "Geeks_for_geeks_is_best" # Using re module with string slicing to generate substringans = []for i in re.finditer("(_)", Input):    temp = Input[:i.span()[0]]    ans.append(temp)     # inserting last substringans.append(Input) # Printing outputprint(ans)
Output:
['Geeks', 'Geeks_for', 'Geeks_for_geeks', 'Geeks_for_geeks_is', 'Geeks_for_geeks_is_best']
gabaa406
satyam00so
Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Matplotlib.pyplot.draw() in Python

21 Apr, 2020
Matplotlib is a library in Python and it is numerical – mathematical extension for NumPy library. Pyplot is a state-based interface to a Matplotlib module which provides a MATLAB-like interface.
The draw() function in pyplot module of matplotlib library is used to redraw the current figure.
Syntax: matplotlib.pyplot.draw()
Below examples illustrate the matplotlib.pyplot.draw() function in matplotlib.pyplot:
Example #1:
# Implementation of matplotlib functionimport numpy as npimport matplotlib.pyplot as plt    def tellme(s):    plt.title(s, fontsize = 16)    plt.draw()plt.clf()plt.setp(plt.gca(), autoscale_on = False)  tellme('matplotlib.pyplot.draw() function Example')plt.show()
Output:
Example #2:
# Implementation of matplotlib functionfrom mpl_toolkits.mplot3d import axes3dimport matplotlib.pyplot as plt  fig = plt.figure()ax = fig.add_subplot(111, projection ='3d')  X, Y, Z = axes3d.get_test_data(0.1)ax.plot_wireframe(X, Y, Z, rstride = 5,                   cstride = 5)  for angle in range(0, 360):    ax.view_init(30, angle)    plt.draw()    plt.pause(.001)    ax.set_title('matplotlib.pyplot.draw()\    function Example', fontweight ="bold")
Output:
Python-matplotlib
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python | os.path.join() method
Python OOPs Concepts
Introduction To PYTHON
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 | Get unique values from a list
Python | datetime.timedelta() function
HTML | <input> align Attribute

18 Feb, 2022
The HTML <input> align attribute is used with <input type=”image”> to set the horizontal alignment of image. It is not supported by HTML 5.
Syntax:
<input align="left|right|middle|top|bottom">
Attribute Values:
left: It sets the alignment of image to the left. it is a default value.
right: It sets the alignment of image to the right.
middle: It sets the alignment of image to the middle.
top: It sets the alignment of image to the top.
bottom: It sets the alignment of image to the bottom.
Example 1:
<!DOCTYPE html><html>  <head>    <title>        HTML input align Attribute    </title></head>  <body>    <h1 style="color:green;">GeeksforGeeks</h1>      <h3>HTML input align Attribute</h3>       <input type="image" src= "https://media.geeksforgeeks.org/wp-content/uploads/20190506164011/logo3.png"        alt="GeeksforGeeks logo" align="right"> </body>   </html>
Output:
Example 2:
<!DOCTYPE html><html>  <head>    <title>        HTML input align Attribute    </title></head>  <body>    <center>        <h1 style="color:green;">GeeksforGeeks</h1>          <h3>HTML input align Attribute</h3>    </center>    <div>        Email_id:        <!--Here type="text" align will not work-->        <input type="text" alt="mail_id" align="right">        <input type="image" src="https://media.geeksforgeeks.org/wp-content/uploads/20190506164011/logo3.png"                      alt="GeeksforGeeks" align="right">    </div></body>  </html>
Output:Note: Since <input type=”image”> is not supported by the HTML5 so you can use CSS there instead of this attribute. Syntax for CSS <input type=”image” style=”float:right”>.Supported Browsers:
Google Chrome
Internet Explorer
Firefox
Safari
Opera
chhabradhanvi
HTML-Attributes
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Plot a Horizontal line in Matplotlib

12 Nov, 2020
Matplotlib is a popular python library used for plotting, It provides an object-oriented API to render GUI plots
Plotting a horizontal line is fairly simple, Using axhline()
The axhline() function in pyplot module of matplotlib library is used to add a horizontal line across the axis.
Syntax: matplotlib.pyplot.axhline(y, color, xmin, xmax, linestyle)
Parameters:
y: Position on Y axis to plot  the line, It accepts integers.
xmin and xmax: scalar, optional, default: 0/1.  It plots the line in the given range
color: color for the line, It accepts  a string. eg ‘r’ or ‘b’ .
linestyle: Specifies the type of line, It accepts a string. eg ‘-‘, ‘–‘, ‘-.’, ‘:’, ‘None’, ‘ ‘, ”, ‘solid’, ‘dashed’, ‘dashdot’, ‘dotted’
Python3
# importing libraryimport matplotlib.pyplot as plt  # specifying horizontal line typeplt.axhline(y = 0.5, color = 'r', linestyle = '-')  # rendering the plotplt.show()
Output:
To plot multiple horizontal lines, use the axhline() method multiple times.
Python
# importing the moduleimport matplotlib.pyplot as plt  # plotting line within the given rangeplt.axhline(y = .5, xmin = 0.25, xmax = 0.9)  # line colour is blueplt.axhline(y = 3, color = 'b', linestyle = ':')  # line colour is whiteplt.axhline(y = 1, color = 'w', linestyle = '--')  # line colour is redplt.axhline(y = 2, color = 'r', linestyle = 'dashed')        # adding axis labels    plt.xlabel('x - axis')plt.ylabel('y - axis')  # displaying the plotplt.show()
Output:
The legend can be added using the legend() function.
Python3
# importing the moduleimport matplotlib.pyplot as plt  # plotting line within the given rangeplt.axhline(y = .5, xmin = 0.25, xmax = 0.9)  # line colour is blueplt.axhline(y = 3, color = 'b', linestyle = ':', label = "blue line")  # line colour is whiteplt.axhline(y = 1, color = 'w', linestyle = '--', label = "white line")  # line colour is redplt.axhline(y = 2, color = 'r', linestyle = 'dashed', label = "red line")        # adding axis labels    plt.xlabel('x - axis')plt.ylabel('y - axis')  # plotting the legendplt.legend(bbox_to_anchor = (1.0, 1), loc = 'upper center')  # displaying the plotplt.show()
Output:
Python-matplotlib
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
std::gcd | C++ inbuilt function for finding GCD

24 Jun, 2022
In many competitive programming problems, we need to find greatest common divisor also known as gcd. Euclids algorithm to find gcd has been discussed here.C++ has the built-in function for calculating GCD. This function is present in header file. Syntax for C++14 :
 Library: 'algorithm'
 __gcd(m, n) 
Parameter :  m, n
Return Value :  0 if both m and n are zero, 
else gcd of m and n.
Syntax for C++17 :
Library: 'numeric'
gcd(m, n)
Parameter :  m, n
Return Value :  0 if both m and n are zero,
else gcd of m and n.
CPP
// CPP program to illustrate// gcd function of C++ STL#include <iostream>#include <algorithm>// #include<numeric> for C++17 using namespace std; int main(){    cout << "gcd(6, 20) = " << __gcd(6, 20) << endl; // gcd(2.0,8) for C++17}
gcd(6, 20) = 2
Time Complexity: O(logn)
Auxiliary Space: O(1)
Note: If either M or N is not an integer type, or if either is (possibly cv-qualified) bool, the program is ill-formed. Also, If either |m| or |n| is not representable as a value of type std::common_type_t, the behavior is undefined.  
CPP
// CPP program to illustrate// undefined behavior of// gcd function of C++ STL#include <iostream>#include <algorithm>// #include<numeric> for C++17 using namespace std; int main(){    cout << "gcd(6, 20) = " << __gcd(2.0, 8) << endl; // gcd(2.0,8) for C++17}
Output: Error, As the data type float is not supported by std::gcd.This article is contributed by Pratik Chhajer. If you like GeeksforGeeks and would like to contribute, you can also write an article using write.geeksforgeeks.org or mail your article to review-team@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above. 
utkarshanand221
gauravguptaco20b366
CPP-Library
cpp-numerics-library
STL
C++
STL
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to define preformatted text using HTML ? - GeeksforGeeks

24 Jun, 2020
In this article, we define a preformatted text in HTML by using the <pre> tag in the document. It is used to define the block of preformatted text that preserves the text spaces, line breaks, tabs, and other formatting characters which are ignored by web browsers. Text in the pre tag is displayed in a fixed-width font, but it can be changed using CSS. The pre tag requires a starting and ending tag.
Syntax:
<pre> Contents... </pre>
Example 1:
<html>     <head>         <title>HTML5: How to define preformatted text?</title> <style>    h2    {        Text-align:center;    }</style>    </head>     <body>     <h2>GeeKsForGeeks</h2>    <h2>HTML5: How to define preformatted text</h2>        <pre>             GeeksforGeeks             A Computer Science Portal For Geeks         </pre>     </body> </html>                     
Output:
Example 2:
<html>     <head>         <title>HTML5: How to define preformatted text?</title> <style>    h2    {        Text-align:center;    }</style>    </head>     <body>     <h2>GeeKsForGeeks</h2>    <h2>HTML5: How to define preformatted text</h2>        <pre>this  is  a   pre        formatted                     text</pre>    </body> </html>                     
Output:
Supported Browsers are listed below:
Google Chrome
Internet Explorer
Firefox
Opera
Safari
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
HTML-Misc
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to update Node.js and NPM to next version ?
How to Insert Form Data into Database using PHP ?
REST API (Introduction)
CSS to put icon inside an input element in a form
Form validation using HTML and JavaScript
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Convert a string to an integer in JavaScript
Difference between var, let and const keywords in JavaScript
Count number of Distinct Substring in a String in C++

According to the problem we are given a string str, we must count all the substrings in the given string. Substring is a string which is a part of an already existing string whose size may be smaller than or equal to the existing string.
Let's understand the problem and its solution with the help of examples.
Input − str = "wxyz";
Output − count of distinct substring is: 10
Explanation − Distinct substrings counted are −
wxyz, wxy, wx, w, xyz, xy, x, yz, y, z so their count is 10
Input − str = "zzzz"
Output − count of distinct substring is: 4
Explanation − Distinct substrings counted are −
zzzz, zzz, zz, z
Take a string str as an input.
Take a string str as an input.
Declare an empty unordered_set "myset".
Declare an empty unordered_set "myset".
Loop i from 0 move 1 step till i is less than the size of the string.Declare a new string space "" (empty).Loop j starting from i move 1 step at the time till j is less than the size of the string.Concatenate the value of space on each step with str[j]Insert space in myset.
Loop i from 0 move 1 step till i is less than the size of the string.
Declare a new string space "" (empty).
Declare a new string space "" (empty).
Loop j starting from i move 1 step at the time till j is less than the size of the string.
Loop j starting from i move 1 step at the time till j is less than the size of the string.
Concatenate the value of space on each step with str[j]
Concatenate the value of space on each step with str[j]
Insert space in myset.
Insert space in myset.
Print the size of the str as an answer.
Print the size of the str as an answer.
 Live Demo
#include<iostream>
#include<unordered_set>
using namespace std;
int main(){
   string str = "aaaa";
   unordered_set<string> myset;
   int i, j;
   for (i = 0; i < str.size(); ++i){
      string space = "";
      for (j = i; j < str.size(); ++j){
         space = space + str[j];
         myset.insert(space);
       }
   }
   cout <<"count of distinct substring is: " <<str.size();
   return 0;
}
If we run the above code we will get the following output −
count of distinct substring is: 4
DAX Logical - AND function

Checks the two arguments if they are TRUE or FALSE, and returns TRUE only when both are TRUE. Otherwise, returns FALSE.
AND (<logical1>, <logical2>) 

TRUE, if both the arguments are TRUE.
FALSE, otherwise.
AND function takes only two arguments. If you have more than two arguments, either nest the AND functions or use the DAX logical operator &&.
= AND([Country] = "USA",[Medal] = "Gold") 
This DAX formula returns a calculated column with TRUE for Country – USA and Medal – Gold values, and FALSE otherwise.
USA Gold Medal Count:= SUMX(
   Results,IF(AND([Country] = "USA",[Medal] = "Gold") = TRUE(),1,0)
) 
This DAX formula returns a calculated field with total number of Gold Medals for USA.

    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
Passing a vector to constructor in C++ - GeeksforGeeks

31 Jan, 2022
When class member is a vector object (not a reference).We can simply assign in constructor.  
CPP
// Passing vector object to a constructor.#include <iostream>#include <vector>using namespace std; class MyClass {    vector<int> vec; public:    MyClass(vector<int> v)    {       vec = v;    }    void print()    {        /// print the value of vector        for (int i = 0; i < vec.size(); i++)            cout << vec[i] << " ";    }}; int main(){    vector<int> vec;    for (int i = 1; i <= 5; i++)        vec.push_back(i);    MyClass obj(vec);    obj.print();    return 0;}
1 2 3 4 5
 
We can also initialize using the initializer list. 
CPP
// Initializing vector object using initializer// list.#include <iostream>#include <vector>using namespace std; class MyClass {    vector<int> vec; public:    MyClass(vector<int> v) : vec(v)    {    }    void print()    {        /// print the value of vector        for (int i = 0; i < vec.size(); i++)            cout << vec[i] << " ";    }}; int main(){    vector<int> vec;    for (int i = 1; i <= 5; i++)        vec.push_back(i);    MyClass obj(vec);    obj.print();    return 0;}
1 2 3 4 5
 
When class member is a vector a reference. In C++, references must be initialized using initializer list. 
CPP
// CPP program to initialize a vector reference.#include <iostream>#include <vector>using namespace std; class MyClass {    vector<int>& vec; public:    // this is the right way to assign    // the reference of stl container    MyClass(vector<int>& arr)        : vec(arr)    {    }    void print()    {        /// print the value of vector        for (int i = 0; i < vec.size(); i++)            cout << vec[i] << " ";    }}; int main(){    vector<int> vec;    for (int i = 1; i <= 5; i++)        vec.push_back(i);    MyClass obj(vec);    obj.print();    return 0;}
1 2 3 4 5
 
chhabradhanvi
cpp-references
cpp-vector
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Operator Overloading in C++
Sorting a vector in C++
Polymorphism in C++
Friend class and function in C++
List in C++ Standard Template Library (STL)
Convert string to char array in C++
new and delete operators in C++ for dynamic memory
Destructors in C++
Pair in C++ Standard Template Library (STL)
Inline Functions in C++
Groovy - compareTo()

The compareTo method is to use compare one number against another. This is useful if you want to compare the value of numbers.
public int compareTo( NumberSubClass referenceName ) 

referenceName - This could be a Byte, Double, Integer, Float, Long or Short.
If the Integer is equal to the argument then 0 is returned.
If the Integer is less than the argument then -1 is returned.
If the Integer is greater than the argument then 1 is returned.
Following is an example of the usage of this method −
class Example { 
   static void main(String[] args) { 
      Integer x = 5;
		
      //Comparison against a Integer of lower value 
      System.out.println(x.compareTo(3));
		
      //Comparison against a Integer of equal value 
      System.out.println(x.compareTo(5)); 
		
      //Comparison against a Integer of higher value 
      System.out.println(x.compareTo(8)); 
   } 
} 
When we run the above program, we will get the following result −
1 
0 
-1 


    52 Lectures 
     8 hours 

 Krishna Sakinala

    49 Lectures 
     2.5 hours 

 Packt Publishing
 Print
 Add Notes
 Bookmark this page
What is the difference between findElement and findElements in Selenium Webdriver?

There are differences between findElement and findElements in the Selenium webdriver. Both of them can be used to locate elements on a webpage. The findElement points to a single element, while the findElements method
returns a list of matching elements.
The return type of findElements is a list but the return type of findElement is a WebElement. If there is no matching element, a NoSuchElementException is thrown by the findElement, however, an empty list is returned by the findElements method.
Good usage of the findElements method usage is counting the total number of images or accessing each of images by iterating with a loop.
Syntax −
WebElement i = driver.findElement(By.id("img-loc"));
List<WebElement> s =
driver.findElements(By.tagName("img"));
Code Implementation
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import java.util.concurrent.TimeUnit;
import java.util.List;
public class FindElementFindElementMthds{
   public static void main(String[] args) {
      System.setProperty("webdriver.chrome.driver", "C:\\Users\\ghs6kor\\Desktop\\Java\\chromedriver.exe");
      WebDriver driver = new ChromeDriver();

      //implicit wait
      driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);

      //URL launch
      driver.get("https://www.tutorialspoint.com/upsc_ias_exams.htm");

      //identify single element
      WebElement elm = driver.findElement(By.tagName("h2"));
      String s = elm.getText();
      System.out.println("Get text on element: " + s);

      //identify all elements with tagname
      List<WebElement> i = driver.findElements(By.tagName("img"));

      //count
      int c = i.size();
      System.out.println("Number of images: " + c);

      //browser close
      driver.close();
   }
}