code-rag-bench/online-tutorials huggingface dataset:
PyQt5 – How to change the text of existing push button ?

22 Apr, 2020
In this article we will see how to change the text of existing push button. We know when we create a button, we set the text to it but sometimes, conditions occur in which re-usability of push button occur i.e button should do its normal operation just change the text of it, so it look different.
In order to do this we use setText method. This method will over-write the existing text of push button.
Syntax : button.setText(new_text)
Argument : It takes string as argument.
Action performed : It over-write the text of button.
Code :
# importing librariesfrom PyQt5.QtWidgets import * from PyQt5.QtGui import * from PyQt5.QtCore import * import sys    class Window(QMainWindow):    def __init__(self):        super().__init__()          # setting title        self.setWindowTitle("Python ")          # setting geometry        self.setGeometry(100, 100, 600, 400)          # calling method        self.UiComponents()          # showing all the widgets        self.show()      # method for widgets    def UiComponents(self):          # creating a push button        button = QPushButton("CLICK", self)          # setting geometry of button        button.setGeometry(200, 150, 100, 30)          # adding action to a button        button.clicked.connect(self.clickme)          # changing the text of button        button.setText("Over-write")        # action method    def clickme(self):          # printing pressed        print("pressed")  # create pyqt5 appApp = QApplication(sys.argv)  # create the instance of our Windowwindow = Window()  # start the appsys.exit(App.exec())
Output :
Python-gui
Python-PyQt
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python | os.path.join() method
Introduction To PYTHON
Python OOPs Concepts
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
Create a directory in Python
Sitadel – Web Application Security Scanner in Kali Linux

23 Aug, 2021
Sitadel is an open-source web application vulnerability scanner. The tool uses the technique of black-box to find various vulnerabilities. Sitadel provides a command-line interface that you can run on the Kali Linux terminal in order to scan hosts and domains. The interactive console provides a number of helpful features, such as command completion and contextual help. Sitadel provides a powerful environment in which open source web-based reconnaissance can be conducted and you can gather all information about the target. This tool is written in python language you must have python language installed in your kali linux operating system.
Sitadel can be used for content delivery network detection.
By using sitadel security researchers to define risk levels to allow for scans.
Sitadel can be used for Plugin system detection.
Step 1: Use the following command to install the tool in your kali Linux operating system. Use the second command given below to move into the directory of the tool.
git clone https://github.com/shenril/Sitadel.git
cd Sitadel
Step 2: Use the following command to run the tool.
python3 sitadel.py --help
The tool is running successfully. Now we will see examples to use the tool.
Example 1: Use the sitadel tool to find missing security headers of the domain.
python3 sitadel.py https://secnhack.in
Example 2: Use the sitadel tool to find risk levels.
python3 sitadel.py <domain>--risk 2
Kali-Linux
Linux-Tools
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
TCP Server-Client implementation in C
tar command in Linux with examples
Compiling with g++
'crontab' in Linux with Examples
UDP Server-Client implementation in C
touch command in Linux with Examples
nohup Command in Linux with Examples
echo command in Linux with Examples
Cat command in Linux with examples
Conditional Statements | Shell Script
GATE | GATE-CS-2000 | Question 23

28 Jun, 2021
Given the relations
employee (name, salary, deptno) and
department (deptno, deptname, address)
Which of the following queries cannot be expressed using the basic relational algebra operations (U, -, x, ,  , p)?(A) Department address of every employee(B) Employees whose name is the same as their department name(C) The sum of all employees’ salaries(D) All employees of a given departmentAnswer: (C)Explanation: See question 1 of https://www.geeksforgeeks.org/database-management-system-set-1/Quiz of this Question
GATE-CS-2000
GATE-GATE-CS-2000
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Perl | chop() Function

07 May, 2019
The chop() function in Perl is used to remove the last character from the input string.
Syntax: chop(String)
Parameters:String : It is the input string whose last characters are removed.
Returns: the last removed character.
Example 1:
#!/usr/bin/perl  # Initialising a string$string = "GfG is a computer science portal";  # Calling the chop() function$A  = chop($string);  # Printing the chopped string and # removed characterprint " Chopped String is : $string\n";print " Removed character is : $A\n";
Output:
Chopped String is : GfG is a computer science porta
Removed character is : l

Example 2:
#!/usr/bin/perl  # Initialising a string$string = "[1, 2, 3]";  # Calling the chop() function$A  = chop($string);  # Printing the chopped string and # removed characterprint " Chopped String is : $string\n";print " Removed character is : $A\n";
Output :
Chopped String is : [1, 2, 3
Removed character is : ]

Perl-function
Perl-String-Functions
Perl
Perl
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Perl | Arrays
Perl Tutorial - Learn Perl With Examples
Perl | Boolean Values
Perl | length() Function
Perl | Subroutines or Functions
Use of print() and say() in Perl
Hello World Program in Perl
Perl | Basic Syntax of a Perl Program
Perl | ne operator
Perl | eq operator
Trim a string in Java to remove leading and trailing spaces

To remove leading and trailing spaces in Java, use the trim() method. This method returns a copy of this string with leading and trailing white space removed, or this string if it has no leading or trailing white space.
Let’s say the following is our string with leading and trailing spaces −
String str = new String(" Jack Sparrow ");
Now, let us trim the string −
str.trim()
Following is an example to remove the leading and trailing spaces in Java −
import java.io.*;
public class Main {
   public static void main(String args[]) {
      String str = new String(" Jack Sparrow ");
      System.out.println("String: "+str);
      System.out.print("Result after removing leading and trailing spaces:" );
      System.out.println(str.trim() );
   }
}
String: Jack Sparrow
Result after removing leading and trailing spaces:Jack Sparrow
Perl do...while Loop

Unlike for and while loops, which test the loop condition at the top of the loop, the do...while loop checks its condition at the bottom of the loop.
A do...while loop is similar to a while loop, except that a do...while loop is guaranteed to execute at least one time.
The syntax of a do...while loop in Perl is −
do {
   statement(s);
}while( condition );

It should be noted that the conditional expression appears at the end of the loop, so the statement(s) in the loop executes once before the condition is tested. If the condition is true, the flow of control jumps back up to do, and the statement(s) in the loop executes again. This process repeats until the given condition becomes false.
The number 0, the strings '0' and "" , the empty list () , and undef are all false in a boolean context and all other values are true. Negation of a true value by ! or not returns a special false value.
#!/usr/local/bin/perl
 
$a = 10;

# do...while loop execution
do{
   printf "Value of a: $a\n";
   $a = $a + 1;
}while( $a < 20 );
When the above code is executed, it produces the following result −
Value of a: 10
Value of a: 11
Value of a: 12
Value of a: 13
Value of a: 14
Value of a: 15
Value of a: 16
Value of a: 17
Value of a: 18
Value of a: 19


    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
C Program for nth Catalan Number

Given an interger n; the task is to find the Catalan Number on that nth position. So, before doing the program we must know what is a Catalan Number?
Catlan numbers are the sequence of natural numbers, which occurs in the form of various counting number problems.
Catalan numbers C0, C1, C2,... Cn are driven by formula −
cn=1n+1(2nn)=2n!(n+1)!n!
The few Catalan numbers for every n = 0, 1, 2, 3, ... are 1, 1, 2, 5, 14, 42, 132, 429, 1430, 4862, ...
So if we entered n =3 we should get 5 as an output from the program
Some of few applications of Catalan numbers −
Counting the number of possible binary search trees with n keys.
Finding the number of expressions containing n pair of parenthesis which are correctly matched. Like for n = 3 the possible parenthesis expression would be ((())), ()(()), ()()(), (())(), (()()).
Finding number of ways to connect point on circle disjoint chords, and many more.
Input: n = 6
Output: 132
Input: n = 8
Output: 1430
Approach we will be using to solve the given problem −
Taking and input n.
Check If n <= 1 then, Return 1
Loop from i=0 to i<n and i++
For every i Set result = result + (catalan(i)*catalan(n-i-1))
Return and print the result.
Start
   Step 1 -> In function unsigned long int catalan(unsigned int n)
      If n <= 1 then,
         Return 1
      End if
      Declare an unsigned long variable res = 0
      Loop For i=0 and i<n and i++
         Set res = res + (catalan(i)*catalan(n-i-1))
      End Loop
      Return res
   Step 2 -> int main()
   Declare an input n = 6
   Print "catalan is : then call function catalan(n)
Stop
#include <stdio.h>
// using recursive approach to find the catalan number
unsigned long int catalan(unsigned int n) {
   // Base case
   if (n <= 1) return 1;
   // catalan(n) is sum of catalan(i)*catalan(n-i-1)
   unsigned long int res = 0;
   for (int i=0; i<n; i++)
      res += catalan(i)*catalan(n-i-1);
   return res;
}
//Main function
int main() {
   int n = 6;
   printf("catalan is :%ld\n", catalan(n));
   return 0;
}
catalan is :132
C# Program to Generate Random Even Numbers Using LINQ Parallel Query - GeeksforGeeks

28 Nov, 2021
LINQ is known as Language Integrated Query and was introduced in .NET 3.5. It gives power to .NET languages to generate or create queries to retrieve data from the data source. In this article, we will generate random even numbers in parallel using LINQ. So, we will use ParallelQuery{TSource} to generate a sequence of integral numbers in parallel within the given range. Along with it, we have to use the where and select clause to get the even numbers. Remember that it will throw an ArgumentOutOfRangeException if the stop is less than 0 or start +stop-1 is greater than the MaxValue.
Syntax:
IEnumerable<int> variable = ((ParallelQuery<int>)ParallelEnumerable.Range(start,
                            stop)).Where(x => x % 2 == 0).Select(i => i);
Where the start is the first integer value in the sequence and the stop is the number of sequential integers to generate.
Example:
Input  : Range(start, stop) = Range(1, 20)
Output :
2
6
12
16
4
8
14
18
10
20

Input  : Range(start, stop) = Range(10, 20)
Output :
10
12
14
16
18
20
22
24
26
28
Approach:
To print even numbers in parallel follow the following steps:
Implement a parallelQuery{TSource} and mention the range.Use where clause to check the modulus of y by 2 is equal to zero.Now Select is used to check if the value of the j variable is greater than or equal to the value of the variable(i.e., j).Iterate the even numbers using the foreach loop
Implement a parallelQuery{TSource} and mention the range.
Use where clause to check the modulus of y by 2 is equal to zero.
Now Select is used to check if the value of the j variable is greater than or equal to the value of the variable(i.e., j).
Iterate the even numbers using the foreach loop
Example:
C#
// C# program to generate random even numbers// using LINQ Parallel Queryusing System;using System.Collections.Generic;using System.Linq;  class GFG{  static void Main(string[] args){          // Creating data    IEnumerable<int> data = ((ParallelQuery<int>)ParallelEnumerable.Range(                                                          // Condition for generating even numbers                            10, 20)).Where(i => i % 2 == 0).Select(                                       value => value);      // Display even numbers    foreach(int even in data)    {        Console.WriteLine(even);    }}}
Output:
12
14
16
18
20
22
24
26
28
10
Picked
C#
C# Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Extension Method in C#
HashSet in C# with Examples
Top 50 C# Interview Questions & Answers
C# | How to insert an element in an Array?
C# | Inheritance
Convert String to Character Array in C#
Socket Programming in C#
Getting a Month Name Using Month Number in C#
Program to Print a New Line in C#
Program to find absolute value of a given number
unordered_set find() function in C++ STL - GeeksforGeeks

28 Sep, 2018
The unordered_set::find() function is a built-in function in C++ STL which is used to search for an element in the container. It returns an iterator to the element, if found else, it returns an iterator pointing to unordered_set::end().
Syntax :
unordered_set_name.find(key)
Parameter: This function accepts a mandatory parameter key which specifies the element to be searched for.
Return Value: It returns an iterator to the element if found, else returns an iterator pointing to the end of unordered_set.
Below programs illustrate the unordered_set::find() function:
Program 1:
// C++ program to illustrate the// unordered_set::find() function  #include <iostream>#include <string>#include <unordered_set>  using namespace std;  int main(){      unordered_set<string> sampleSet = { "geeks1", "for", "geeks2" };      // use of find() function    if (sampleSet.find("geeks1") != sampleSet.end()) {        cout << "element found." << endl;    }    else {        cout << "element not found" << endl;    }      return 0;}
element found.

Program 2:
// CPP program to illustrate the// unordered_set::find() function  #include <iostream>#include <string>#include <unordered_set>  using namespace std;  int main(){      unordered_set<string> sampleSet = { "geeks1", "for", "geeks2" };      // use of find() function    if (sampleSet.find("geeksforgeeks") != sampleSet.end()) {        cout << "found" << endl;    }    else {        cout << "Not found" << endl;    }      return 0;}
Not found

CPP-Functions
cpp-unordered_set
cpp-unordered_set-functions
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Operator Overloading in C++
Polymorphism in C++
Sorting a vector in C++
Friend class and function in C++
std::string class in C++
Pair in C++ Standard Template Library (STL)
Queue in C++ Standard Template Library (STL)
Inline Functions in C++
Array of Strings in C++ (5 Different Ways to Create)
Convert string to char array in C++
p5.js | setInput() Function - GeeksforGeeks

17 Jan, 2020
The setInput() function is an inbuilt function in p5.js library. This function is used to connects to the p5sound instance that is the master output by default. By using this function you can also pass in a specific source.
Syntax:
setInput(snd, smoothing)
Note: All the sound-related functions only work when the sound library is included in the head section of the index.html file.
Parameter: This function accepts two parameters as mentioned above and described below:
snd: This parameter is use to set the sound source and it is optional.
smoothing: This parameter is use to set the smooth amplitude reading and the range is between 0.0 to 1.0, this parameter is also optional.
Below example illustrate the p5.setInput() function in JavaScript:
function preload(){  sound1 = loadSound('song.mp3');  sound2 = loadSound('pfivesound.mp3');}function setup(){  amplitude = new p5.Amplitude();  sound1.play();  sound2.play();  amplitude.setInput(sound2);}function draw() {  background(255);  fill(200);  let gfg = amplitude.getLevel();  let size = map(gfg, 0, 1, 0, 400);  ellipse(width/1, height/1, size*2, size*2);}function mousePressed(){  sound2.pause();}  function mouseReleased(){  sound2.play();}
Online editor: https://editor.p5js.org/Environment Setup: https://www.geeksforgeeks.org/p5-js-soundfile-object-installation-and-methods/
Supported Browsers: The browsers supported by p5.js setInput() function are listed below:
Google Chrome
Internet Explorer
Firefox
Safari
Opera
JavaScript-p5.js
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Remove elements from a JavaScript Array
Difference between var, let and const keywords in JavaScript
Difference Between PUT and PATCH Request
JavaScript | Promises
How to get character array from string in JavaScript?
Remove elements from a JavaScript Array
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
Difference between var, let and const keywords in JavaScript
Python string | ascii_lowercase - GeeksforGeeks

16 Oct, 2018
In Python3, ascii_lowercase is a pre-initialized string used as string constant. In Python, string ascii_lowercase will give the lowercase letters ‘abcdefghijklmnopqrstuvwxyz’.
Syntax : string.ascii_lowercase
Parameters : Doesn’t take any parameter, since it’s not a function.
Returns : Return all lowercase letters.
Note : Make sure to import string library function inorder to use ascii_lowercase.
Code #1 :
# import string library function import string     # Storing the value in variable result result = string.ascii_lowercase    # Printing the value print(result) 
Output :
abcdefghijklmnopqrstuvwxyz
 Code #2 : Given code checks if the string input has only lower ASCII characters.
# importing string library function import string      # Function checks if input string # has lower only ascii letters or not def check(value):     for letter in value:                      # If anything other than lower ascii         # letter is present, then return         # False, else return True         if letter not in string.ascii_lowercase:             return False    return True     # Driver Code input1 = "GeeksForGeeks"print(input1, "--> ",  check(input1))      input2 = "geeks for geeks"print(input2, "--> ", check(input2))      input3 = "geeksforgeeks"print(input3, "--> ", check(input3)) 
Output:
GeeksForGeeks -->  False
geeks for geeks -->  False
geeksforgeeks -->  True
Applications :The string constant ascii_lowercase can be used in many practical applications. Let’s see a code explaining how to use ascii_lowercase to generate strong random passwords of given size.
# Importing random to generate # random string sequence import random     # Importing string library function import string     def rand_pass(size):             # Takes random choices from     # ascii_letters and digits     generate_pass = ''.join([random.choice(                         string.ascii_lowercase + string.digits)                         for n in range(size)])                                 return generate_pass     # Driver Code  password = rand_pass(10) print(password)       
Output:
52v3bdyk63
python-string
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Python String | replace()
*args and **kwargs in Python
Reading and Writing to text files in Python
Create a Pandas DataFrame from Lists
Convert integer to string in Python
Check if element exists in list in Python
Express.js res.send() Function - GeeksforGeeks

19 Aug, 2021
The res.send() function basically sends the HTTP response. The body parameter can be a String or a Buffer object or an object or an Array.
Syntax: 
res.send( [body] )
Parameter: This function accepts a single parameter body that describe the body which is to be sent in the response.
Returns: It returns an Object.
Installation of express module:  
1. You can visit the link to Install express module. You can install this package by using this command. 
npm install express
2. After installing the express module, you can check your express version in command prompt using the command. 
npm version express
3. After that, you can just create a folder and add a file for example, index.js. To run this file you need to run the following command. 
node index.js
Example 1: Filename: index.js 
Javascript
var express = require('express');var app = express();var PORT = 3000; // Without middlewareapp.get('/', function(req, res){    res.send({ title: 'GeeksforGeeks' });}); app.listen(PORT, function(err){    if (err) console.log(err);    console.log("Server listening on PORT", PORT);});
Steps to run the program: 
1. The project structure will look like this: 
2. Make sure you have installed express module using the following command: 
npm install express
3. Run index.js file using below command: 
node index.js
Output: 
Server listening on PORT 3000
4. Now open browser and go to http://localhost:3000/, now check your browser and you will see the following output: 
{"title":"GeeksforGeeks"}
Example 2: Filename: index.js 
Javascript
var express = require('express');const path = require('path');var app = express();var PORT = 3000; // With middlewareapp.use('/', function(req, res, next){   res.send({"name":"GeeksforGeeks"});   next();}); app.get('/', function(req, res){    console.log("Body Sent")}); app.listen(PORT, function(err){    if (err) console.log(err);    console.log("Server listening on PORT", PORT);});
Run index.js file using below command: 
node index.js
Now open the browser and go to http://localhost:3000/, now check your console and you will see the following output: 
Server listening on PORT 3000
Body Sent
And you will see the following output on your browser screen:  
{"name":"GeeksforGeeks"}
Reference: https://expressjs.com/en/5x/api.html#res.send 
kalrap615
Express.js
Node.js
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Node.js fs.writeFile() Method
Node.js fs.readFile() Method
How to install the previous version of node.js and npm ?
Difference between promise and async await in Node.js
How to use an ES6 import in Node.js?
Remove elements from a JavaScript Array
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
Difference between var, let and const keywords in JavaScript
PHP | Spreadsheet_Excel_Writer | Close() Function - GeeksforGeeks

04 Oct, 2021
The close() function is an inbuilt function in PHP | Spreadsheet_Excel_Writer which is used to finalize the spreadsheet after which all the operations are done. This method should always be the last one to be called on every workbook.
Syntax: 
mixed Workbook::close()
Parameters: This function does not accept any parameter.Return Value: This function returns TRUE on success and PEAR_ERROR on failure.
Example 1:  
PHP
<?php require_once 'Spreadsheet/Excel/Writer.php'; // Add Workbook$workbook = new Spreadsheet_Excel_Writer(); // Add Format to spreadsheet$format_bold =& $workbook->addFormat(); // Set Bold Format$format_bold->setBold(); // Add Worksheet to Spreadsheet$worksheet =& $workbook->addWorksheet(); $format_bold->setBorder(2); // Write to Worksheet$worksheet->write(0, 0, "Details of GeeksforGeeks                   Contributors", $format_bold);$worksheet->write(1, 0, "Author", $format_bold);$worksheet->write(1, 1, "User Handle", $format_bold);$worksheet->write(2, 0, "Sarthak");$worksheet->write(2, 1, "sarthak_ishu11"); // Send .xlsx file to header$workbook->send('test.xls'); // Close Workbook Object$workbook->close();?>
Output: 
Example 2:  
PHP
<?php require_once 'Spreadsheet/Excel/Writer.php'; // Add Workbook$workbook = new Spreadsheet_Excel_Writer(); // Add Format to spreadsheet$format_border =& $workbook->addFormat(); // Add Worksheet to Spreadsheet$worksheet =& $workbook->addWorksheet(); // Set and Add Border Width$format_border->setBorder(2); // Set and Add Color to Border$format_border->setBorderColor('red'); // Write to Worksheet$worksheet->write(0, 0, "Details of GeeksforGeeks                     Contributors", $format_bold);$worksheet->write(1, 0, "Author", $format_border);$worksheet->write(1, 1, "User Handle", $format_border);$worksheet->write(2, 0, "Sarthak");$worksheet->write(2, 1, "sarthak_ishu11"); // Send .xlsx file to header$workbook->send('test.xls'); // Close Workbook Object$workbook->close();?>
Output: 
Reference: https://pear.php.net/manual/en/package.fileformats.spreadsheet-excel-writer.spreadsheet-excel-writer-workbook.close.php 
sooda367
PHP-function
PHP-Spreadsheet
PHP
Web Technologies
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to fetch data from localserver database and display on HTML table using PHP ?
How to create admin login page using PHP?
PHP str_replace() Function
How to pass form variables from one page to other page in PHP ?
Different ways for passing data to view in Laravel
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Split Vector into Chunks in R - GeeksforGeeks

23 Sep, 2021
In this article, we will discuss how to split vectors into chunks in R programming language.
In this scenario, a chuck length is specified, so that we can divide the vector using the split() function.
Syntax:
split(vector,   ceiling(seq_along(vector) / chunk_length))
where,
vector is the input vector
split() function is used to split the vector
ceiling() is the function that takes two parameters one parameter that is vector with sequence along to divide the vector sequentially and second is chunklength, which represents the length of chunk to be divided
Example: R program to divide the vector into chunks with length
R
# create a vector with 10 elementsvector=c(1,2,3,4,5,6,7,8,9,10)  # specify the chunk length as 2chunklength=2  # split the vector by lengthprint(split(vector,ceiling(seq_along(vector) / chunklength)))
Output:
Example: R program to divide the vector into chunks with length
R
# create a vector with 10 elementsvector=c(1,2,3,4,5,6,7,8,9,10)  # specify the chunk length as 5chunklength=5  # split the vector by lengthprint(split(vector,ceiling(seq_along(vector) / chunklength)))
Output:
In this scenario, the number of chunks is to be provided, so that we can divide the vector using the split() function.
Syntax:
split(vector,  cut(seq_along(vector), chunk_number, labels = FALSE)
where,
vector is the input vector
split() function is used to split the vector
cut() is the function that takes three parameters one parameter that is a vector with sequence along to divide the vector sequentially, second is the chunk number that is for number of chunks to be divided and the last is for labels to specify the chunks range
Note:
If the label is FALSE, it will not display the chunk size.
If labels are not specified, it will display labels
Example: R program to divide the vector into chunks using chunk number
R
# create a vector with 10 elementsvector=c(1,2,3,4,5,6,7,8,9,10)  # specify the chunk number as 5chunk_no=5  # split the vector by chunk number by specifying # labels as FALSEprint(split(vector, cut(seq_along(vector),chunk_no,labels = FALSE)))
Output:
Example: R program to divide the vector into chunks using chunk number
R
# create a vector with 10 elementsvector=c(1,2,3,4,5,6,7,8,9,10)  # specify the chunk number as 2chunkno=2  # split the vector by chunk number by # unspecifying labels print(split(vector, cut(seq_along(vector),chunkno)))
Output:
Picked
R Vector-Programs
R-Vectors
R Language
R Programs
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 Change Axis Scales in R Plots?
How to Split Column Into Multiple Columns in R DataFrame?
Replace Specific Characters in String in R
How to Split Column Into Multiple Columns in R DataFrame?
Replace Specific Characters in String in R
How to filter R DataFrame by values in a column?
How to filter R dataframe by multiple conditions?
Convert Matrix to Dataframe in R
JavaTuples getLabel() method - GeeksforGeeks

27 Aug, 2018
The getLabel() method in org.javatuples is used to fetch the label from the TupleClassObject from the LabelValue Class. This method can be used with only LabelValue class object of javatuples library. It returns a Label which is the element present at the index 0 of the LabelValueClassObject. The returned Label is ensures the type-safety.
Method Declaration:
public A getLabel()
Syntax:
LabelValue LabelValueClassObject = LabelValue.with(A a, B b);
A val = LabelValueClassObject.getLabel()
Return Value: This method returns a Label which is the element present at the index 0 of the LabelValueClassObject.
Below programs illustrate the various ways to use getLabel() method:
Example 1:
// Below is a Java program to get// a LabelValue value  import java.util.*;import org.javatuples.LabelValue;  class GfG {    public static void main(String[] args)    {        // Creating a LabelValue object        LabelValue<Integer, String> lv            = LabelValue.with(Integer.valueOf(1), "GeeksforGeeks");          // Using getLabel() method        int label = lv.getLabel();          // Printing the Label        System.out.println(label);    }}
Output:
1

Example 2:
// Below is a Java program to get// a LabelValue value  import java.util.*;import org.javatuples.LabelValue;  class GfG {    public static void main(String[] args)    {        // Creating a LabelValue object        LabelValue<String, String> lv            = LabelValue.with("GeeksforGeeks",                              "A Computer Science Portal for Geeks");          // Using getLabel() method        String label = lv.getLabel();          // Printing the Label        System.out.println(label);    }}
Output:
GeeksforGeeks

Java-Functions
JavaTuples
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Constructors in Java
Exceptions in Java
Stream In Java
Functional Interfaces in Java
Different ways of Reading a text file in Java
Internal Working of HashMap in Java
Iterators in Java
Java Programming Examples
Strings in Java
Comparator Interface in Java with Examples
C library function - system()

The C library function int system(const char *command) passes the command name or program name specified by command to the host environment to be executed by the command processor and returns after the command has been completed.
Following is the declaration for system() function.
int system(const char *command)
command − This is the C string containing the name of the requested variable.
command − This is the C string containing the name of the requested variable.
The value returned is -1 on error, and the return status of the command otherwise.
The following example shows the usage of system() function to list down all the files and directories in the current directory under unix machine.
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main () {
   char command[50];

   strcpy( command, "ls -l" );
   system(command);

   return(0);
} 
Let us compile and run the above program that will produce the following result on my unix machine −
drwxr-xr-x 2 apache apache 4096 Aug 22 07:25 hsperfdata_apache
drwxr-xr-x 2 railo railo 4096 Aug 21 18:48 hsperfdata_railo
rw------ 1 apache apache 8 Aug 21 18:48 mod_mono_dashboard_XXGLOBAL_1
rw------ 1 apache apache 8 Aug 21 18:48 mod_mono_dashboard_asp_2
srwx---- 1 apache apache 0 Aug 22 05:28 mod_mono_server_asp
rw------ 1 apache apache 0 Aug 22 05:28 mod_mono_server_asp_1280495620
srwx---- 1 apache apache 0 Aug 21 18:48 mod_mono_server_global

The following example shows the usage of system() function to list down all the files and directories in the current directory under windows machine.
#include <stdio.h>
#include <string.h>

int main () {
   char command[50];

   strcpy( command, "dir" );
   system(command);

   return(0);
} 
Let us compile and run the above program that will produce the following result on my windows machine −
a.txt
amit.doc
sachin
saurav
file.c


    12 Lectures 
     2 hours 

 Nishant Malik

    12 Lectures 
     2.5 hours 

 Nishant Malik

    48 Lectures 
     6.5 hours 

 Asif Hussain

    12 Lectures 
     2 hours 

 Richa Maheshwari

    20 Lectures 
     3.5 hours 

 Vandana Annavaram

    44 Lectures 
     1 hours 

 Amit Diwan
 Print
 Add Notes
 Bookmark this page
Convert Decimal to Int64 (long) in C#

Use the Convert.ToInt64() method to convert Decimal to Int64 (long) in C#.
Let’s say we have a decimal variable.
decimal d = 310.23m;
Now to convert it to Int64, use the Convert.ToInt64() method.
long res;
res = Convert.ToInt64(d);
Let us see another example −
 Live Demo
using System;
class Demo {
   static void Main() {
      decimal d = 190.66m;
      long res;
      res = Convert.ToInt64(d);
      Console.WriteLine("Converted Decimal '{0}' to Int64 value {1}", d, res);
   }
}
Converted Decimal '190.66' to Int64 value 191
C program demonstrating the concepts of strings using Pointers

An array of characters is called a string.
The syntax for declaring an array is as follows −
char stringname [size];
For example − char string[50]; string of length 50 characters
Using single character constant −
char string[10] = { ‘H’, ‘e’, ‘l’, ‘l’, ‘o’ ,‘\0’}
Using string constants −
char string[10] = "Hello":;
Accessing − There is a control string "%s" used for accessing the string till it encounters ‘\0’.
Now, let us understand what are the arrays of pointers in C programming language.
It is an array whose elements are ptrs to the base add of the string.
It is declared and initialized as follows −
char *a[ ] = {"one", "two", "three"};
Here, a[0] is a pointer to the base add of string "one".
    a[1] is a pointer to the base add of string "two".
    a[2] is a pointer to the base add of string "three".
Following is a C program demonstrating the concepts of strings −
 Live Demo
#include<stdio.h>
#include<string.h>
void main(){
   //Declaring string and pointers//
   char *s="Meghana";
   //Printing required O/p//
   printf("%s\n",s);//Meghana//
   printf("%c\n",s);//If you take %c, we should have * for string. Else you
   will see no output////
   printf("%c\n",*s);//M because it's the character in the base address//
   printf("%c\n",*(s+4));//Fifth letter a because it's the character in the (base address+4)th position//
   printf("%c\n",*s+5);//R because it will consider character in the base address + 5 in alphabetical order//
}
When the above program is executed, it produces the following result −
Meghana
M
a
R
Consider another example.
Given below is a C program demonstrating the concepts of printing characters using the post increment and pre increment operators −
 Live Demo
#include<stdio.h>
#include<string.h>
void main(){
   //Declaring string and pointers//
   char *s="Meghana";
   //Printing required O/p//
   printf("%s\n",s);//Meghana//
   printf("%c\n",++s+3);//s becomes 2nd position - 'e'. O/p is Garbage value//
   printf("%c\n",s+++3);//s becomes 3rd position - 'g'. O/p is Garbage value//
   printf("%c\n",*++s+3);//s=3 becomes incremented by 1 = 'h'.s becomes 4th
   position.h+3 - k is the O/p//
   printf("%c\n",*s+++3);//s=4 - h is the value. h=3 = k will be the O/p. S is incremented by 1 now. s=5th position//
}
When the above program is executed, it produces the following result −
Meghana
d
d
k
k
Convert Floats to Integers in a Pandas DataFrame - GeeksforGeeks

20 Aug, 2020
Let us see how to convert float to integer in a Pandas DataFrame. We will be using the astype() method to do this. It can also be done using the apply() method.
Method 1: Using DataFrame.astype() method
First of all we will create a DataFrame:
# importing the libraryimport pandas as pd  # creating a DataFramelist = [['Anton Yelchin', 36, 75.2, 54280.20],         ['Yul Brynner', 38, 74.32, 34280.30],         ['Lev Gorn', 31, 70.56, 84280.50],        ['Alexander Godunov', 34, 80.30, 44280.80],         ['Oleg Taktarov', 40, 100.03, 45280.30],        ['Dmitriy Pevtsov', 33, 72.99, 70280.25],         ['Alexander Petrov', 42, 85.84, 25280.75]]df = pd.DataFrame(list, columns =['Name', 'Age', 'Weight', 'Salary'])display(df)
Output :
Example 1 : Converting one column from float to int using DataFrame.astype()
# displaying the datatypesdisplay(df.dtypes)  # converting 'Weight' from float to intdf['Weight'] = df['Weight'].astype(int)  # displaying the datatypesdisplay(df.dtypes)
Output :
Example 2: Converting more than one column from float to int using DataFrame.astype()
# displaying the datatypesdisplay(df.dtypes)  # converting 'Weight' and 'Salary' from float to intdf = df.astype({"Weight":'int', "Salary":'int'})   # displaying the datatypesdisplay(df.dtypes)
Output :
Method 2: Using DataFrame.apply() method
First of all we will create a DataFrame.
# importing the moduleimport pandas as pd  # creating a DataFramelist = [[15, 2.5, 100.22], [20, 4.5, 50.21],         [25, 5.2, 80.55], [45, 5.8, 48.86],         [40, 6.3, 70.99], [41, 6.4, 90.25],         [51, 2.3, 111.90]]df = pd.DataFrame(list, columns = ['Field_1', 'Field_2', 'Field_3'],                  index = ['a', 'b', 'c', 'd', 'e', 'f', 'g'])display(df)
Output :
Example 1: Converting a single column from float to int using DataFrame.apply(np.int64)
# importing the moduleimport numpy as np  # displaying the datatypesdisplay(df.dtypes)  # converting 'Field_2' from float to intdf['Field_2'] = df['Field_2'].apply(np.int64)  # displaying the datatypesdisplay(df.dtypes)
Output :
Example 2: Converting multiple columns from float to int using DataFrame.apply(np.int64)
# displaying the datatypesdisplay(df.dtypes)  # converting 'Field_2' and 'Field_3' from float to intdf['Field_2'] = df['Field_2'].apply(np.int64)df['Field_3'] = df['Field_3'].apply(np.int64)  # displaying the datatypesdisplay(df.dtypes)
Output :
Python pandas-dataFrame
Python Pandas-exercise
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Install PIP on Windows ?
Read a file line by line in Python
Enumerate() in Python
Iterate over a list in Python
Different ways to create Pandas Dataframe
Python program to convert a list to string
Create a Pandas DataFrame from Lists
Python String | replace()
Reading and Writing to text files in Python
*args and **kwargs in Python
count() function in PHP

The count() function counts elements in an array, or properties in an object. It returns the number of elements in an array.
count(arr, mode)

arr − The specified array.
arr − The specified array.
mode − Specifies the mode. Possible values are 0 or 1. 0: Do not count all the elements, 1: Count all the elements.
mode − Specifies the mode. Possible values are 0 or 1. 0: Do not count all the elements, 1: Count all the elements.
The count() function returns the number of elements in an array −
The following is an example −
 Live Demo
<?php
   $products = array("Electronics","Footwear"); echo count($products);
?>
2
DAX Information - ISLOGICAL function

Checks whether a value is a logical value (TRUE or FALSE), and returns TRUE or FALSE.
ISLOGICAL (<value>) 

value
The value that you want to test.
TRUE or FALSE.
= ISLOGICAL (5>4) returns TRUE. 

    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
Add Text to ggplot2 Plot in R - GeeksforGeeks

30 May, 2021
In this article, we are going to see how to add Text to the ggplot2 plot in R Programming Language.
To do this annotate() is used. It is useful for adding small annotations (such as text labels) or if you have your data in vectors, and for some reason don’t want to put them in a data frame.
Syntax:
annotate(geom,x = NULL,y = NULL, xmin = NULL, xmax = NULL, ymin = NULL, ymax = NULL, xend = NULL, yend = NULL, ..., na.rm = FALSE)
Parameters:
geom: name of geom to use for annotation
x, y, xmin, ymin, xmax, ymax, xend, yend: positioning aesthetics – you must specify at least one of these.
...: Other arguments passed on to layer(). These are often aesthetics, used to set an aesthetic to a fixed value, like color = “red” or size = 3.
na.rm: If FALSE, the default, missing values are removed with a warning.
Example:
R
library("ggplot2")  gfg_data <- data.frame(x = c(1,2,3,4,5),                            y = c(4,3,2,5,1))gfg_data           gfg_plot<- ggplot(gfg_data, aes(x, y)) +     geom_point()  gfg_plot +  annotate("text", x = 4, y = 3,                     label = "GeeksForGeeks")
Output:
To annotate multiple test elements to the ggplot2 plot user needs to call annotate() function of the ggplot2 package multiple times with the required parameters in the R programming language.
Example:
R
library("ggplot2")  gfg_data <- data.frame(x = c(1,2,3,4,5),                            y = c(4,3,2,5,1))gfg_data   gfg_plot<- ggplot(gfg_data, aes(x, y)) +     geom_point()  gfg_plot +  annotate("text", x = 1.2, y = 5,                     label = "GeeksForGeeks") + annotate("text", x = 4.7, y = 1,          label = "GeeksForGeeks")   
Output:
To modify the color and the size of the text added to the ggplot2 plot using annotate() function, the user needs to add col and size as the arguments of the annotate function from the ggplot2 package and specify the required parameter into this function and this will lead to the change in the size and the color of the text added to ggplot2 plot in the R programming language.
Example:
R
library("ggplot2")  gfg_data <- data.frame(x = c(1,2,3,4,5),                            y = c(4,3,2,5,1))  gfg_data           gfg_plot<- ggplot(gfg_data, aes(x, y)) +     geom_point()  gfg_plot +  annotate("text", x = 2, y = 5,                      label = "GeeksForGeeks",                     col = "green", size = 10) +  annotate("text", x = 4.7, y = 1,            label = "GeeksForGeeks",           col = "green", size = 5)  
Output:
Picked
R-ggplot
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
How to remove multiple selected items in listbox in Tkinter? - GeeksforGeeks

02 Feb, 2021
Prerequisite: Tkinter, Listbox in Tkinter
Python offers multiple options for developing GUI (Graphical User Interface). Out of all the GUI methods, Tkinter is the most commonly used method. It is a standard Python interface to the Tk GUI toolkit shipped with Python. Python with Tkinter is the fastest and easiest way to create GUI applications.
In this article, we will learn how to remove multiple selected checkboxes in Listbox Using Tkinter in Python.
Let’s Understand step by step implementation:-
1. Create Normal Tkinter Window
Python3
from tkinter import *  root = Tk()root.geometry("200x200")  root.mainloop()
Output:
2. Add Listbox using Listbox() method
Syntax: 
Listbox(root, bg, fg, bd, height, width, font, ..) 
Python3
# Import Modulefrom tkinter import *  # Create Objectroot = Tk()  # Set Geometryroot.geometry("200x200")  # Add Listboxlistbox = Listbox(root, selectmode=MULTIPLE)listbox.pack()  # Listbox Items Listitems = ["Apple", "Orange", "Grapes", "Banana", "Mango"]  # Iterate Through Items list for item in items:    listbox.insert(END, item)  Button(root, text="delete").pack()  # Execute Tkinterroot.mainloop()
Output:
3. Remove Selected Item From Listbox
Get a List of selected Items from Listbox using the curselection() method.
Iterate through all list and remove item using delete() method
Below is the implementation:-
Python3
# Import Modulefrom tkinter import *  # Function will remove selected Listbox itemsdef remove_item():    selected_checkboxs = listbox.curselection()      for selected_checkbox in selected_checkboxs[::-1]:        listbox.delete(selected_checkbox)  # Create Objectroot = Tk()  # Set Geometryroot.geometry("200x200")  # Add Listboxlistbox = Listbox(root, selectmode=MULTIPLE)listbox.pack()  # Listbox Items Listitems = ["Apple", "Orange", "Grapes", "Banana", "Mango"]  # Iterate Through Items list for item in items:    listbox.insert(END, item)  Button(root, text="delete", command=remove_item).pack()  # Execute Tkinterroot.mainloop()
Output:
Picked
Python-tkinter
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
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 | Pandas dataframe.groupby()
Python | Get unique values from a list
Python | sympy.prime() method - GeeksforGeeks

26 Aug, 2019
With the help of sympy.prime() method, we can find the nth prime, with the primes indexed as prime(1) = 2, prime(2) = 3, etc.
Syntax: prime(n)
Parameter:n – It denotes the nth prime number.
Returns: Returns the nth prime number.
Example #1:
# import sympy from sympy import prime  n = 5  # Use prime() method nth_prime = prime(n)       print("The {}th prime is {}".format(n, nth_prime))  
Output:
The 5th prime is 11

Example #2:
# import sympy from sympy import prime  n = 23  # Use prime() method nth_prime = prime(n)       print("The {}rd prime is {}".format(n, nth_prime))        
Output:
The 23rd prime is 83

SymPy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
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()
Batch Script - SUBST

This batch command assigns a drive letter to a local folder, displays current assignments, or removes an assignment.
Subst [driveletter]

@echo off 
Subst p:
P: will be assigned as the drive letter for the current folder.
 Print
 Add Notes
 Bookmark this page