code-rag-bench/online-tutorials huggingface dataset:
map emplace_hint() function in C++ STL - GeeksforGeeks

04 Jun, 2020
The map::emplace_hint() is a built-in function in C++ STL which inserts the key and its element in the map container with a given hint. It effectively increases the container size by one as map is the container that stores keys with the element value. The hint provided does not affect the position to be entered, it only increases the speed of insertion as it points to the position from where the search for the ordering is to be started. It inserts in the same order which is followed by the container. It works similarly to map::emplace() function but is at times faster then it if the user provides position accurately. It does not insert the key with the element if it is already present in the map container as the map stores unique key only.
Syntax:
map_name.emplace_hint(position, key, element)

Parameters: The function accepts three mandatory parameters key which are described as below:
key – specifies the key to be inserted in the map container.
element – specifies the element to the key which is to be inserted in the map container.
position – specifies the position from where the search operation for the ordering is to be started, hence making the insertion faster.
Return Value: Returns an iterator to the newly inserted element.If the insertion failed because the element already exists, returns an iterator to the already existing element with the equivalent key.
// C++ program to illustrate the// map::emplace_hint() function#include <bits/stdc++.h>using namespace std;  int main(){      // initialize container    map<int, int> mp;      // insert elements in random order    mp.emplace_hint(mp.begin(), 2, 30); // faster    mp.emplace_hint(mp.begin(), 1, 40); // faster    mp.emplace_hint(mp.begin(), 3, 60); // slower      // prints the elements    cout << "\nThe map is : \n";    cout << "KEY\tELEMENT\n";    for (auto itr = mp.begin(); itr != mp.end(); itr++)        cout << itr->first << "\t" << itr->second << endl;      return 0;}
The map is : 
KEY    ELEMENT
1    40
2    30
3    60

muhamedgenco
CPP-Functions
cpp-map
STL
C++
STL
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Inheritance in C++
C++ Classes and Objects
Constructors in C++
Bitwise Operators in C/C++
Socket Programming in C/C++
Operator Overloading in C++
Multidimensional Arrays in C / C++
Copy Constructor in C++
Virtual Function in C++
vector erase() and clear() in C++
PyQt - QSpinBox Widget

A QSpinBox object presents the user with a textbox which displays an integer with up/down button on its right. The value in the textbox increases/decreases if the up/down button is pressed.
By default, the integer number in the box starts with 0, goes upto 99 and changes by step 1. Use QDoubleSpinBox for float values.
Important methods of QSpinBox class are listed in the following table −
setMinimum()
Sets the lower bound of counter
setMaximum()
Sets the upper bound of counter
setRange()
Sets the minimum, maximum and step value
setValue()
Sets the value of spin box programmatically
Value()
Returns the current value
singleStep()
Sets the step value of counter
QSpinBox object emits valueChanged() signal every time when up/own button is pressed. The associated slot function can retrieve current value of the widget by value() method.
Following example has a label (l1) and spinbox (sp) put in vertical layout of a top window. The valueChanged() signal is connected to valuechange() method.
self.sp.valueChanged.connect(self.valuechange)

The valueChange() function displays the current value as caption of the label.
self.l1.setText("current value:"+str(self.sp.value()))

The complete code is as follows −
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *

class spindemo(QWidget):
   def __init__(self, parent = None):
      super(spindemo, self).__init__(parent)
      
      layout = QVBoxLayout()
      self.l1 = QLabel("current value:")
      self.l1.setAlignment(Qt.AlignCenter)
      layout.addWidget(self.l1)
      self.sp = QSpinBox()
		
      layout.addWidget(self.sp)
      self.sp.valueChanged.connect(self.valuechange)
      self.setLayout(layout)
      self.setWindowTitle("SpinBox demo")
		
   def valuechange(self):
      self.l1.setText("current value:"+str(self.sp.value()))

def main():
   app = QApplication(sys.argv)
   ex = spindemo()
   ex.show()
   sys.exit(app.exec_())
	
if __name__ == '__main__':
   main()
The above code produces the following output −

    146 Lectures 
     22.5 hours 

 ALAA EID
 Print
 Add Notes
 Bookmark this page
Absolute and Relative frequency in Pandas - GeeksforGeeks

20 Apr, 2020
Frequency is the number of occurrences of an outcome in the given sample. It can be termed in two different ways.
1. Absolute Frequency:It is the number of observations in a particular category. It has always an integer value or we can say it has discrete values.
Example:
Following data are given about pass or fail of students in an exam held of Mathematics in a class.P, P, F, P, F, P, P, F, F, P, P, P
where, P = Passed and F = Failed.
Solution:From the given data we can say that,There are 8 students who passed the examThere are 4 students who failed the exam
Implementation in Python:Let’s the result of 12 persons declared in two categories Pass(P) and Fail(F) is categorized as 1 and 0 respectively.
P, P, F, P, F, P, P, F, F, P, P, P
1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1

import pandas as pd  data = [1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1]  # Create Data Frame using pandas library# .value_counts() counts the number of # occurrences of particular observation  df = pd.Series(data).value_counts()print(df)
1    8
0    4
dtype: int64

 
2. Relative Frequency:It is the fraction of observations of a particular category in given data set. It has floating values and also represented in percentage. Let us consider the given example of passed and failed students in the Mathematics exam. Then,
relative frequency of passed students = 8 / ( 8 + 4 ) = 0.666 = 66.6 %relative frequency of failed students = 4 / ( 8 + 4 ) = 0.333 = 33.3 %
import pandas as pd  data = [1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1]  # Create Data Frame using pandas library# .value_counts() counts the number of # occurrences of particular observation  df = pd.Series(data).value_counts()      print(df / len(data))
1    0.666667
0    0.333333
dtype: float64

mkumarchaudhary06
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Python Dictionary
Read a file line by line in Python
Enumerate() in Python
How to Install PIP on Windows ?
Iterate over a list in Python
Different ways to create Pandas Dataframe
Reading and Writing to text files in Python
sum() function in Python
Create a Pandas DataFrame from Lists
How to drop one or multiple columns in Pandas Dataframe
How to clear screen in python?

In Python sometimes we have link the output and we want to clear the screen in the cell prompt we can clear the screen by pressing Control + l . But there are situations when we need to clear the screen programmatically depending on the amount of output from the program and how we want to format the output. In such case we need to put some commands in the python script which will clear the screen as and when needed by the program.
We need the system() from the OS module of python to clear up the screen. For different platforms like windows and Linux we need to pass different commands as shown in the example below. Also we use the ‘_’ variable which is used to hold the value of last expression in interpreter.
import os
from time import sleep
# The screen clear function
def screen_clear():
   # for mac and linux(here, os.name is 'posix')
   if os.name == 'posix':
      _ = os.system('clear')
   else:
      # for windows platfrom
      _ = os.system('cls')
   # print out some text
print("The platform is: ", os.name)
print("big output\n"* 5)
# wait for 5 seconds to clear screen
sleep(5)
# now call function we defined above
screen_clear()
Running the above code gives us the following result −
The platform is: nt
big output
big output
big output
big output
big output
The above output gets cleared after 5 seconds from the result window.
issubset() function in Python

In this article, we will learn the implementation and usage of issubset() function available in the Python Standard Library.
The issubset() method returns boolean True when all elements of a set are present in another set (passed as an argument) otherwise, it returns boolean False.
In the figure given below B is a subset of A. In case A & B are identical sets mean that A is a proper subset of B. This means both sets contain the same elements in them.
<set 1>.issubset(<set 2>)
boolean True/False
Now let’s look at an illustration to understand the concept.
 Live Demo
A = {'t','u','t','o','r','i','a','l'}
B = {'t','u','t'}
C = {'p','o','i','n','t'}
print(B.issubset(A))
print(B.issubset(C))
A=set(str(A)+str(C))
print(C.issubset(A))
True
False
True
Here a check is made that all elements of B are contained in A which evaluates to be true. Similarly for the next statement output is produced.
Now we concatenated to sets to make it a subset forcefully by using typecasting as seen in the next statement.
Now let’s see what happens if we specify another type of iterable than set and pass it as an argument.
 Live Demo
A = ['t','u','t','o','r','i','a','l']
B = {'t','u','t'}
C = ('p','o','i','n','t')
D = {'p','o','i','n','t'}
print(B.issubset(A))
print(B.issubset(C))
A=set(str(A)+str(C))
print(D.issubset(A))
True
False
True
Here we passed tuple, string and list iterables to the issubset() function. These types are implicitly converted to set type so as to get the desired output.
We must also observe that the argument outside the function must always of type <set> so that the interpreter must know that comparison is between two sets and not any other type.
In this article, we learned how to use isubset() function in Python and what all types of arguments are allowed to be compared with the help of this function.
8085 program to sum of two 8 bit numbers without carry - GeeksforGeeks

30 Jan, 2019
Problem – Write an assembly language program to sum two 8 bit numbers without using carry operation in 8085 microprocessor.
Assumption:
The starting address of the program is 2000.Memory address of the first number is 2050.Memory address of the second number is 2051.Memory address of result is 2052.
The starting address of the program is 2000.
Memory address of the first number is 2050.
Memory address of the second number is 2051.
Memory address of result is 2052.
Example:
Input: 2050: 03
     : 2-51: 04
Output: 2052: 07 
Algorithm:
Load the first number to the accumulator through memory address 2050.Move the content of accumulator to the register B.Load the second number to the accumulator through memory address 2051.Add the content of accumulator and register B and result will be stored at the accumulator.Store the result from the accumulator to the memory address 2052.Terminate the program.
Load the first number to the accumulator through memory address 2050.
Move the content of accumulator to the register B.
Load the second number to the accumulator through memory address 2051.
Add the content of accumulator and register B and result will be stored at the accumulator.
Store the result from the accumulator to the memory address 2052.
Terminate the program.
Program:
Explanation:
LDA 2050: This instruction will load the number from memory to the accumulator.MOV B, A: This instruction will move the content of accumulator to the register B.LDA 2051: This instruction will load the number from memory to the accumulator.ADD B: This instruction will sum the content of the accumulator with the content of the register B.STA 2052: This instruction will store the content of accumulator to the memory address 2052.HLT: This instruction will terminate the program.
LDA 2050: This instruction will load the number from memory to the accumulator.
MOV B, A: This instruction will move the content of accumulator to the register B.
LDA 2051: This instruction will load the number from memory to the accumulator.
ADD B: This instruction will sum the content of the accumulator with the content of the register B.
STA 2052: This instruction will store the content of accumulator to the memory address 2052.
HLT: This instruction will terminate the program.
Hence we successfully sum the two 8 bit numbers without carry using 8085 microprocessor.
microprocessor
system-programming
Computer Organization & Architecture
microprocessor
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Architecture of 8085 microprocessor
Computer Organization and Architecture | Pipelining | Set 2 (Dependencies and Data Hazard)
Direct Access Media (DMA) Controller in Computer Architecture
Pin diagram of 8086 microprocessor
Difference between SRAM and DRAM
Computer Organization | Different Instruction Cycles
Shift Micro-Operations in Computer Architecture
I2C Communication Protocol
Difference between RISC and CISC processor | Set 2
Difference between Hardwired and Micro-programmed Control Unit | Set 2
What are the differences between default constructor and parameterized constructor in Java?

A default constructor is a 0 argument constructor which contains a no-argument call to the super class constructor.
To assign default values to the newly created objects is the main responsibility of default constructor.
Compiler writes a default constructor in the code only if the program does not write any constructor in the class.
The access modifier of default constructor is always the same as a class modifier but this rule is applicable only for “public” and “default” modifiers.
The compiler adds a default constructor to the code only when the programmer writes no constructor in the code.
If the programmer writes any constructor in the code, then the compiler doesn't add any constructor.
Every default constructor is a 0 argument constructor but every 0 argument constructor is not a default constructor.
The parameterized constructors are the constructors having a specific number of arguments to be passed.
The purpose of a parameterized constructor is to assign user-wanted specific values to the instance variables of different objects.
A parameterized constructor is written explicitly by a programmer.
The access modifier of default constructor is always the same as a class modifier but this rule is applicable only for “public” and “default” modifiers.
Live Demo
public class Student {
   int roll_no;
   String stu_name;
   Student(int i, String n) { // Parameterized constructor
      roll_no = i;
      stu_name = n;
   }
   void display() {
      System.out.println(roll_no+" "+stu_name);
   }
   public static void main(String args[]) {
      Student s1 = new Student(1,"Adithya");
      Student s2 = new Student(2,"Jai");
      s1.display();
      s2.display();
   }
}
In the above program, the programmer defines one parameterized constructor with 2 parameters. Now the compiler adds no default constructor to the code, and nor the programmer has written any 0 argument constructor.
1 Adithya
2 Jai
How to display a simple loading indicator between routes in react router ? - GeeksforGeeks

10 May, 2021
It is a good practice to display a loading screen while you prepare your page to display. It is very easy to display a simple loading indicator between routes in react-router. 
Creating React Application:
Step 1: Create a React application using the following command:npx create-react-app foldername
Step 1: Create a React application using the following command:
npx create-react-app foldername
Step 2: After creating your project folder i.e. foldername, move to it using the following command:cd foldername
Step 2: After creating your project folder i.e. foldername, move to it using the following command:
cd foldername
Project Structure: It will look like the following.
Create Home.js and App.js as shown in the above image.
Implementation: Now write down the following code in the App.js file. Here, App is our default component where we have written our code.
App.js
import React from "react";import { BrowserRouter as Router, Route } from "react-router-dom";import {useState} from "react";import Home from'./components/Home';  function App() {  return (    // Create route for each page, since we     // have only one page. So we are defining     // only one route.    <Router>      <Route path="/" exact component={Home} />    </Router>  );}  export default App;
Home.js
import React from "react";import {useEffect, useState} from "react";  const Home = () => {      // Set loading state to true initially    const [loading, setLoading] = useState(true);          useEffect(() => {      // Loading function to load data or       // fake it using setTimeout;      const loadData = async () => {          // Wait for two second        await new Promise((r) => setTimeout(r, 2000));          // Toggle loading state        setLoading((loading) => !loading);      };              loadData();    }, [])          // If page is in loading state, display     // loading message. Modify it as per your     // requirement.    if (loading) {        return <div>Loading....</div>    }          // If page is not in loading state, display page.    else {        return <h1>Home</h1>    }}  export default Home;
Step to Run Application: Run the application using the following command from the root directory of the project:
npm start
Output: Now open your browser and go to http://localhost:3000/, you will see the following output:
Result
Picked
React-Questions
ReactJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to set background images in ReactJS ?
How to create a table in ReactJS ?
How to navigate on path by button click in react router ?
ReactJS useNavigate() Hook
React-Router Hooks
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
Convert a string to an integer in JavaScript
HTML | <h1> to <h6> align Attribute - GeeksforGeeks

25 Feb, 2022
The HTML <h1> to <h6> align Attribute is used to specify the alignment of the <h> element or the content present inside the Heading Element.
Note: This attribute is not supported by HTML5.
Syntax:
<h1 align="left | right | center | justify">
Attribute Values:
left: It sets the content to the left-align. By default, it is aligned to left.
right: It sets the content to the right-align.
center: I sets the div element to the center.
justify: It sets the content to the justify position.
Examples:
<!DOCTYPE html><html>  <body>      <h1 align="center">center</h1>    <h2 align="left">left 2</h2>    <h3 align="right">right 3</h3>    <h4 align="justify">justify</h4>  </body>  </html>
Output :
Supported Browsers: The browsers supported by HTML h1 align Attribute are listed below:
Google Chrome
Internet Explorer
Firefox
Apple 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.
chhabradhanvi
HTML-Attributes
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)
Types of CSS (Cascading Style Sheet)
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
Get a random value between two values in MySQL?

To get the random value between two values, use MySQL rand() method with floor(). The syntax is as follows.
select FLOOR( RAND() * (maximumValue-minimumValue) + minimumValue) as anyVariableName;
Let us check with some maximum and minimum value. The maximum value we are considering is 200 and minimum is 100. The random number will be between 100 and 200 including 100 and 200 itself.
The query is as follows.
mysql> select FLOOR( RAND() * (200-100) + 100) as RandomValue;
The following is the output.
+-------------+
| RandomValue |
+-------------+
| 144         |
+-------------+
1 row in set (0.00 sec)
Now if we will run the same query again, the output will differ.
mysql> select FLOOR( RAND() * (200-100) + 100) as RandomValue;
The following is the output with a different value since these are random values between a range we set above.
+-------------+
| RandomValue |
+-------------+
| 184         |
+-------------+
1 row in set (0.00 sec)
What is the purpose of “NOT NULL WITH DEFAULT” clause used in DB2 table column?

When we define the DB2 table, we can declare any column as “NOT NULL” which means that in any case this column cannot store NULL value.
Now if we try to store a NULL value in this column in our COBOL-DB2 program using -1 value in the NULL indicator then our query will fail. In this case the SQLCODE field of SQLCA will give the error code as -407. As per the IBM documentation -407 error code states that−
“AN UPDATE, INSERT, OR SET VALUE IS NULL, BUT THE OBJECT COLUMN CANNOT CONTAIN NULL VALUES”.
Java Generics - Multiple Type Parameters

A Generic class can have muliple type parameters. Following example will showcase above mentioned concept.
Create the following java program using any editor of your choice.
GenericsTester.java
package com.tutorialspoint;

public class GenericsTester {
   public static void main(String[] args) {
      Box<Integer, String> box = new Box<Integer, String>();
      box.add(Integer.valueOf(10),"Hello World");
      System.out.printf("Integer Value :%d\n", box.getFirst());
      System.out.printf("String Value :%s\n", box.getSecond());

      Box<String, String> box1 = new Box<String, String>();
      box1.add("Message","Hello World");
      System.out.printf("String Value :%s\n", box1.getFirst());
      System.out.printf("String Value :%s\n", box1.getSecond());
   }
}

class Box<T, S> {
   private T t;
   private S s;

   public void add(T t, S s) {
      this.t = t;
      this.s = s;
   }

   public T getFirst() {
      return t;
   } 

   public S getSecond() {
      return s;
   } 
}
This will produce the following result.
Integer Value :10
String Value :Hello World
String Value :Message
String Value :Hello World


    16 Lectures 
     2 hours 

 Malhar Lathkar

    19 Lectures 
     5 hours 

 Malhar Lathkar

    25 Lectures 
     2.5 hours 

 Anadi Sharma

    126 Lectures 
     7 hours 

  Tushar Kale

    119 Lectures 
     17.5 hours 

 Monica Mittal

    76 Lectures 
     7 hours 

 Arnab Chakraborty
 Print
 Add Notes
 Bookmark this page
Python - Select multiple columns from a Pandas dataframe

Let’s say the following are the contents of our CSV file opened in Microsoft Excel −
At first, load data from a CSV file into a Pandas DataFrame −
dataFrame = pd.read_csv("C:\\Users\\amit_\\Desktop\\SalesData.csv")
To select multiple column records, use the square brackets. Mention the columns in the brackets and fetch multiple columns from the entire dataset −
dataFrame[['Reg_Price','Units']]

Following is the code −
import pandas as pd

# Load data from a CSV file into a Pandas DataFrame:
dataFrame = pd.read_csv("C:\\Users\\amit_\\Desktop\\SalesData.csv")
print("\nReading the CSV file...\n",dataFrame)

# displaying two columns
res = dataFrame[['Reg_Price','Units']];
print("\nDisplaying two columns : \n",res)
This will produce the following output −
Reading the CSV file...
       Car   Reg_Price   Units
0      BMW        2500     100
1    Lexus        3500      80
2     Audi        2500     120
3   Jaguar        2000      70
4  Mustang        2500     110

Displaying two columns :
    Reg_Price   Units
0        2500     100
1        3500      80
2        2500     120
3        2000      70
4        2500     110
Feature Flag Hooks for React & Azure App Config | Towards Data Science

There are two things I love, Microsoft Azure (my go-to cloud), and React.js for building scalable web applications.
Recently, I found a need to add dynamic configurations to my app and saw it as an opportunity to explore the Azure App Configuration Service in more detail.
Complementing Azure Key Vault (which is used to store application secret) App Configuration makes it easier to implement the following scenarios:
Centralize management and distribution of hierarchical configuration data for different environments and geographies
Dynamically change application settings without the need to redeploy or restart an application
Control feature availability in real-time
Scenario: I have a landing page, and at the top of this landing page is a simple dismissible banner alert that looks something like this:
My Goal: I want to leverage feature flags and and dynamic configurations to:
Show this alert whenever I want to convey a system message to my users.Change the text in this alert to reflect the message I wish to convey.
Show this alert whenever I want to convey a system message to my users.
Change the text in this alert to reflect the message I wish to convey.
For brevity, I assume you have already created an App Configuration Service in Azure. In this case, please navigate to: Settings > Access keys and copy the primary read-only Connection string for later.
Navigate to the Feature Manager and click Add to create a new flag.
Navigate to the Feature Manager and click Add to create a new flag.
2. Add the following properties and enable the flag, then click: Apply to save.
3. Navigate to the Configuration explorer and select Create to add a new Key-Value configuration (caution: there is also an option to reference a Key Vault secret, but remember that React may expose this on the client side).
4. Add the following configuration details, then click: Apply
Install the @azure/app-configuration NPM package using:
npm i @azure/app-configuration
In your React project, create a new file called useFeatureFlag.js into which you paste the following code snippet.
The function useFeatureFlag takes in a key, which matches that which we configured in the App Configuration portal earlier, and returns true of this flag is enabled, false if it is disabled.
Similarly, the function useConfiguration takes in a key, which matches a configuration we set earlier, and returns the configuration string.
On the landing page, we can now import the two hooks to conditionally render our Alert with the given message defined in the Azure Portal.
Now, we can simple toggle the flag on or off and see the change reflected in production, without requiring us to re-deploy our application:
Done! 👊🏻
If this article helped you get started with Feature Flags in Azure (or you managed to implement a different provider’s SDK with my custom hook), feel free to drop a comment below and make my day with a coffee.
TypeScript - Passing Arrays to Functions

You can pass to the function a pointer to an array by specifying the array's name without an index.
var names:string[] = new Array("Mary","Tom","Jack","Jill")  

function disp(arr_names:string[]) {
   for(var i = 0;i<arr_names.length;i++) { 
      console.log(names[i]) 
   }  
}  
disp(names)

On compiling, it will generate following JavaScript code −
//Generated by typescript 1.8.10
var names = new Array("Mary", "Tom", "Jack", "Jill");
function disp(arr_names) {
   for (var i = 0; i < arr_names.length; i++) {
      console.log(names[i]);
   }
}
disp(names);

Its output is as follows −
Mary 
Tom 
Jack 
Jill


    45 Lectures 
     4 hours 

 Antonio Papa

    41 Lectures 
     7 hours 

 Haider Malik

    60 Lectures 
     2.5 hours 

 Skillbakerystudios

    77 Lectures 
     8 hours 

 Sean Bradley

    77 Lectures 
     3.5 hours 

 TELCOMA Global

    19 Lectures 
     3 hours 

 Christopher Frewin
 Print
 Add Notes
 Bookmark this page
PyQt5 | How to change the process bar color ?

22 Apr, 2020
In this article we will see how to change the color of progress bar. By default, the color of process bar is green although PyQt5 allows us to change the color using the style sheets.
In order to do this we will use setStyleSheet method and will edit the CSS chunk file of process bar.
Syntax :
bar.setStyleSheet("QProgressBar::chunk "
                  "{"
                    "background-color: red;"
                  "}")

Action performed : It will change the color of process bar.
# importing librariesfrom PyQt5.QtWidgets import * from PyQt5 import QtCore, QtGuifrom PyQt5.QtGui import * from PyQt5.QtCore import * import sys    class Window(QMainWindow):        def __init__(self):        super().__init__()          # setting title        self.setWindowTitle("Python ")          # setting geometry        self.setGeometry(100, 100, 600, 400)          # calling method        self.UiComponents()          # showing all the widgets        self.show()      # method for widgets    def UiComponents(self):          # creating progress bar        bar = QProgressBar(self)          # setting geometry to progress bar        bar.setGeometry(200, 150, 200, 30)          # set value to progress bar        bar.setValue(70)          # changing the color of process bar        bar.setStyleSheet("QProgressBar::chunk "                          "{"                          "background-color: red;"                          "}")    # 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.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Iterate over a list in Python
Python Classes and Objects
Convert integer to string in Python
Program to find Prime Numbers Between given Interval in C++

In this tutorial, we will be discussing a program to find prime numbers between given intervals.
For this we would be provided with two integers. Our task is to find the prime numbers in that particular range.
 Live Demo
#include <bits/stdc++.h>
using namespace std;
int main() {
   int a, b, i, j, flag;
   //getting lower range
   a = 3;
   //getting upper range
   b = 12;
   cout << "\nPrime numbers between "
   << a << " and " << b << " are: ";
   for (i = a; i <= b; i++) {
      if (i == 1 || i == 0)
      continue;
      flag = 1;
      for (j = 2; j <= i / 2; ++j) {
         if (i % j == 0) {
            flag = 0;
            break;
         }
      }
      if (flag == 1)
      cout << i << " ";
   }
   return 0;
}
Prime numbers between 3 and 12 are: 3 5 7 11
Python | Removing Initial word from string

04 Jul, 2019
During programming, sometimes, we can have such a problem in which it is required that first word from the string has to be removed. These kind of problems are common and one should be aware about the solution for such problems. Let’s discuss certain ways in which this problem can be solved.
Method #1 : Using split()This task can be performed using the split function which performs a split of words and separates the first word of string with the entire words.
# Python3 code to demonstrate working of# Removing Initial word from string# Using split()  # initializing string test_str = "GeeksforGeeks is best"  # printing original string print("The original string is : " + test_str)  # Using split()# Removing Initial word from stringres = test_str.split(' ', 1)[1]  # printing result print("The string after omitting first word is : " + str(res))
The original string is : GeeksforGeeks is best
The string after omitting first word is : is best

 
Method #2 : Using partition()The partition function is used to perform this particular task in comparatively lesser internal task as compared to function used in above method.
# Python3 code to demonstrate working of# Removing Initial word from string# Using partition()  # initializing string test_str = "GeeksforGeeks is best"  # printing original string print("The original string is : " + test_str)  # Using partition()# Removing Initial word from stringres = test_str.partition(' ')[2]  # printing result print("The string after omitting first word is : " + str(res))
The original string is : GeeksforGeeks is best
The string after omitting first word is : is best

Python string-programs
Python
Python Programs
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 OOPs Concepts
Introduction To PYTHON
How to drop one or multiple columns in Pandas Dataframe
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python | Convert string dictionary to dictionary
Python Program for Fibonacci numbers
Create Quantiles of a Data Set in R Programming – quantile() Function

19 Jun, 2020
quantile() function in R Language is used to create sample quantiles within a data set with probability[0, 1]. Such as first quantile is at 0.25[25%], second is at 0.50[50%], and third is at 0.75[75%].
Syntax: quantile(x)
Parameters:x: Data set
Example 1:
# R program to create# quantiles of a data set# Create a data frame d <- data.frame( name = c("Abhi", "Bhavesh", "Chaman", "Dimri"),                   age = c(7, 5, 9, 16),                   ht = c(46, NA, NA, 69),                  school = c("yes", "yes", "no", "no") )  # Calling quantile() Functionquantile(d$age)
Output:
   0%   25%   50%   75%  100% 
 5.00  6.50  8.00 10.75 16.00 

Example 2:
# R program to create# quantiles of a data set  # Calling pre-defined data setBOD  # Calling quantile() Functionquantile(BOD$demand)quantile(BOD$Time)
Output:
  Time demand
1    1    8.3
2    2   10.3
3    3   19.0
4    4   16.0
5    5   15.6
6    7   19.8
    0%    25%    50%    75%   100% 
 8.300 11.625 15.800 18.250 19.800 
  0%  25%  50%  75% 100% 
1.00 2.25 3.50 4.75 7.00 

R DataFrame-Function
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
How to Split Column Into Multiple Columns in R DataFrame?
Group by function in R using Dplyr
How to Change Axis Scales in R Plots?
How to filter R DataFrame by values in a column?
Logistic Regression in R Programming
R - if statement
Replace Specific Characters in String in R
How to import an Excel File into R ?
Joining of Dataframes in R Programming
Reorder array based on condition in JavaScript?

Let’s say we have an array of object that contains the scores of some players in a card game −
const scorecard = [{
   name: "Zahir",
   score: 23
}, {
      name: "Kabir",
      score: 13
}, {
      name: "Kunal",
      score: 29
}, {
      name: "Arnav",
      score: 42
}, {
      name: "Harman",
      score: 19
}, {
      name: "Rohit",
      score: 41
}, {
      name: "Rajan",
      score: 34
}];
We also have a variable by the name of selfName that contains the name of a particular player −
const selfName = 'Arnav';
We are required to write a function that sorts the scorecard array in alphabetical order and
makes sure the object with name same as selfName appears at top (at index 0).
Therefore, let’s write the code for this problem −
const scorecard = [{
   name: "Zahir",
   score: 23
}, {
      name: "Kabir",
      score: 13
}, {
      name: "Kunal",
      score: 29
}, {
      name: "Arnav",
      score: 42
}, {
      name: "Harman",
      score: 19
}, {
      name: "Rohit",
      score: 41
}, {
      name: "Rajan",
      score: 34
}];
const selfName = 'Arnav';
const sorter = (a, b) => {
   if(a.name === selfName){
      return -1;
   };
   if(b.name === selfName){
      return 1;
   };
   return a.name < b.name ? -1 : 1;
};
scorecard.sort(sorter);
console.log(scorecard);
The output in the console will be −
[
   { name: 'Arnav', score: 42 },
   { name: 'Harman', score: 19 },
   { name: 'Kabir', score: 13 },
   { name: 'Kunal', score: 29 },
   { name: 'Rajan', score: 34 },
   { name: 'Rohit', score: 41 },
   { name: 'Zahir', score: 23 }
]
numpy.std() in Python

28 Nov, 2018
numpy.std(arr, axis = None) : Compute the standard deviation of the given data (array elements) along the specified axis(if any)..
Standard Deviation (SD) is measured as the spread of data distribution in the given data set.For example :
x = 1 1 1 1 1 
Standard Deviation = 0 . 

y = 9, 2, 5, 4, 12, 7, 8, 11, 9, 3, 7, 4, 12, 5, 4, 10, 9, 6, 9, 4 
Step 1 : Mean of distribution 4 = 7
Step 2 : Summation of (x - x.mean())**2 = 178
Step 3 : Finding Mean = 178 /20 = 8.9 
This Result is Variance.
Step 4 : Standard Deviation = sqrt(Variance) = sqrt(8.9) = 2.983..

Parameters :arr : [array_like]input array.axis : [int or tuples of int]axis along which we want to calculate the standard deviation. Otherwise, it will consider arr to be flattened (works on all the axis). axis = 0 means SD along the column and axis = 1 means SD along the row.out : [ndarray, optional]Different array in which we want to place the result. The array must have the same dimensions as expected output.dtype : [data-type, optional]Type we desire while computing SD.
Results : Standard Deviation of the array (a scalar value if axis is none) or array with standard deviation values along specified axis.
Code #1:
# Python Program illustrating # numpy.std() method import numpy as np    # 1D array arr = [20, 2, 7, 1, 34]  print("arr : ", arr) print("std of arr : ", np.std(arr))  print ("\nMore precision with float32")print("std of arr : ", np.std(arr, dtype = np.float32))  print ("\nMore accuracy with float64")print("std of arr : ", np.std(arr, dtype = np.float64))
Output :
arr :  [20, 2, 7, 1, 34]
std of arr :  12.576167937809991

More precision with float32
std of arr :  12.576168

More accuracy with float64
std of arr :  12.576167937809991

 Code #2:
# Python Program illustrating # numpy.std() method import numpy as np      # 2D array arr = [[2, 2, 2, 2, 2],         [15, 6, 27, 8, 2],        [23, 2, 54, 1, 2, ],        [11, 44, 34, 7, 2]]       # std of the flattened array print("\nstd of arr, axis = None : ", np.std(arr))     # std along the axis = 0 print("\nstd of arr, axis = 0 : ", np.std(arr, axis = 0))    # std along the axis = 1 print("\nstd of arr, axis = 1 : ", np.std(arr, axis = 1))
Output :
std of arr, axis = None :  15.3668474320532

std of arr, axis = 0 :  [ 7.56224173 17.68473918 18.59267329  3.04138127  0.        ]

std of arr, axis = 1 :  [ 0.          8.7772433  20.53874388 16.40243884]

Python numpy-Statistics Functions
Python-numpy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Iterate over a list in Python
Python OOPs Concepts
Python | Difference between Pandas.copy() and copying through variables

17 Sep, 2018
Pandas .copy() method is used to create a copy of a Pandas object. Variables are also used to generate copy of an object but variables are just pointer to an object and any change in new data will also change the previous data.
The following examples will show the difference between copying through variables and Pandas.copy() method.
Example #1: Copying through variablesIn this example, a sample Pandas series is made and copied in a new variable. After that, some changes are made in the new data and compared with the old data.
# importing pandas moduleimport pandas as pd  # creating sample seriesdata = pd.Series(['a', 'b', 'c', 'd'])  # creating copy of seriesnew = data  # assigning new valuesnew[1]='Changed value'  # printing dataprint(new)print(data)
Output:As shown in the output image, the changes made in new data are also reflected in the old data since the new variable was just a pointer to old one. Example #2: Using Pandas.copy() methodIn this example, pandas.copy() method is used to copy a data and some changes are made in the new data. The changes are then compared to old data.
# importing pandas moduleimport pandas as pd  # creating sample seriesdata = pd.Series(['a', 'b', 'c', 'd'])  # creating copy of seriesnew = data.copy()  # assigning new valuesnew[1]='Changed value'  # printing dataprint(new)print(data)
Output:As shown in the output image, the changes in new data are independent and didn’t change anything in old one.
Python pandas-series
Python pandas-series-methods
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
Python | os.path.join() method
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
How to add a Tab in JTabbedPane with Java?

Let us first create a JTabbedPane −
JTabbedPane tabbedPane = new JTabbedPane();
Create some panels −
JPanel panel1, panel2, panel3, panel4, panel5;
panel1 = new JPanel();
panel2 = new JPanel();
panel3 = new JPanel();
panel4 = new JPanel();
panel5 = new JPanel();
Now, add tabs using the addTab() method and set the panels as well in which the tabs would be visible −
tabbedPane.addTab("PHP", panel1);
tabbedPane.addTab("Blockchain ", panel2);
tabbedPane.addTab("Matlab", panel3);
tabbedPane.addTab("JSP ", panel4);
tabbedPane.addTab("Servlet", panel5);
The following is an example to add a tab in 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("PHP", panel1);
      tabbedPane.addTab("Blockchain ", panel2);
      tabbedPane.addTab("Matlab", panel3);
      tabbedPane.addTab("JSP ", panel4);
      tabbedPane.addTab("Servlet", panel5);
      frame.add(tabbedPane);
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.setSize(550,350);
      frame.setVisible(true);
   }
}
Remove all duplicates from a given string in C#

Here is the string.
string str = "ppqqrr";
Now, use Hashset to map the string to char. This will remove the duplicate characters from a string.
var res = new HashSet<char>(str);
Let us see the complete example −
 Live Demo
using System;
using System.Linq;
using System.Collections.Generic;
namespace Demo {
   class Program {
      static void Main(string[] args) {
         string str = "ppqqrr";
         Console.WriteLine("Initial String: "+str);
         var res = new HashSet<char>(str);
         Console.Write("New String after removing duplicates:");
         foreach (char c in res){
            Console.Write(c);
         }  
      }
   }
}
Initial String: ppqqrr
New String after removing duplicates:pqr
Add similar value multiple times in a Python list

There are occasions when we need to show the same number or string multiple times in a list. We may also generate these numbers or strings for the purpose of some calculations. Python provides some inbuilt functions which can help us achieve this.
This is the most used method. Here we use the * operator which will create a repetition of the characters which are mentioned before the operator.
 Live Demo
given_value ='Hello! '
repeated_value = 5*given_value
print(repeated_value)
Running the above code gives us the following result:
Hello! Hello! Hello! Hello! Hello!
The itertools module provides repeat function. This function takes the repeatable string as parameter along with number of times the string has to be repeated. The extend function is also used to create the next item for the list which holds the result.
 Live Demo
from itertools import repeat
given_value ='Hello! '
new_list=[]
new_list.extend(repeat(given_value,5))
print(new_list)
Running the above code gives us the following result:
['Hello! ', 'Hello! ', 'Hello! ', 'Hello! ', 'Hello! ']
We can also use the extend() to create a list of the string to be repeated by using range and for loop. First we declare an empty list then keep extending it by adding elements created by the for loop. The range() decided how many times the for loop gets executed.
 Live Demo
given_value ='Hello! '
new_list=[]
new_list.extend([given_value for i in range(5)])
print(new_list)
Running the above code gives us the following result:
['Hello! ', 'Hello! ', 'Hello! ', 'Hello! ', 'Hello! ']
IF Function in Tableau - GeeksforGeeks

24 Oct, 2020
In this article, we will learn about if function and its use in Tableau. For this first look into two terms:
Tableau: Tableau is a very powerful data visualization tool that can be used by data analysts, scientists, statisticians, etc. to visualize the data and get a clear opinion based on the data analysis. Tableau is very famous as it can take in data and produce the required data visualization output in a very short time.
IF Function: Tableau If Function is one of the foremost useful decision-making functions. If the function tests the condition and depending upon the condition result, it’ll return the output.
How IF function works:
It starts with “IF” function evaluating the 1st logical expression corresponding to set/sequence of values and when the logical expression becomes True, it returns the respective specified value as result.
If the first doesn’t match then it moves to another if i.e ELSEIF and checks the same as for IF.
If in logical expressions no match is found then the value of default i.e; ELSE return expression is used.
Syntax of IF Function:
This function checks the given <expression> and returns the corresponding value as a result. The syntax is :
IF <Expression1> THEN <Statement1>
ELSEIF <Expression2> THEN <Statement2>
ELSEIF <Expression3> THEN <Statement3>
.....
ELSEIF <ExpressionN> THEN <StatementN>
ELSE <Statement>
END

Dataset used in the given examples is Dataset.
Example 1: (IF-END)
In this example, we simply create a new calculated field by using the IF function on a field.
View a new calculated field.
Use in Visualization.
It has a drawback that creates null values in case of the false condition.
Example 2: (IF-ELSE-END)
In this example, we simply edit that previously calculated field by using the IF-ELSE function in the same field.
View a new calculated field.
Use in Visualization.
It overcomes a drawback that creates null values in case of the false condition.
Example 3: (IF-ELSEIF-ELSE-END)
In this example, we simply create a new calculated field by using the IF-ELSEIF-ELSE function on a field.
View a new calculated field.
Use in Visualization.
Tableau
Tableau
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Introduction to Tableau
Word Cloud in Tableau
Tableau - Operators
Funnel Chart in Tableau
Create a Dashboard in Tableau
Tableau - Data Terminology
Scatter plot in Tableau
Line graph in Tableau
Replacing data source in Tableau
LOD expression in Tableau