code-rag-bench/online-tutorials huggingface dataset:
PyQt5 Label – Getting Blur effect object - GeeksforGeeks

10 May, 2020
In this article we will see how we can get blur effect object of the label by default there is no blur effect to the label although we can create blur effect then add it to the label with the help of setGraphicsEffect method.
In order to do this we have to do the following –
1. Create a label2. Set geometry to the label3. Create a QGraphicsBlurEffect object4. Add this object to the label with the help of setGraphicsEffect method5. Get the opacity object with the help of graphicsEffect method
Note : This object have same properties of the original object
Syntax :
# creating a blur effect
blur_effect = QGraphicsBlurEffect()

# adding blur effect to the label
label.setGraphicsEffect(blur_effect)

# getting the blur object
object = label.graphicsEffect()

Below is the implementation
# importing librariesfrom PyQt5.QtWidgets import * from PyQt5 import QtCore, QtGuifrom PyQt5.QtGui import * from PyQt5.QtCore import * import sys    class Window(QMainWindow):      def __init__(self):        super().__init__()          # setting title        self.setWindowTitle("Python ")          # setting geometry        self.setGeometry(100, 100, 600, 400)          # calling method        self.UiComponents()          # showing all the widgets        self.show()      # method for widgets    def UiComponents(self):          # creating label        label = QLabel("Label", self)          # setting geometry to the label        label.setGeometry(200, 100, 150, 60)          # setting alignment to the label        label.setAlignment(Qt.AlignCenter)          # setting font        label.setFont(QFont('Arial', 15))          # setting style sheet of the label        label.setStyleSheet("QLabel"                            "{"                            "border : 2px solid green;"                            "background : lightgreen;"                            "}")          # creating a blur effect        self.blur_effect = QGraphicsBlurEffect()          # adding blur effect to the label        label.setGraphicsEffect(self.blur_effect)          # result label        result = QLabel(self)          # setting geometry of the result label        result.setGeometry(200, 200, 300, 30)          # getting the blur object        object = label.graphicsEffect()          # setting text to the result label        result.setText(str(object))    # create pyqt5 appApp = QApplication(sys.argv)  # create the instance of our Windowwindow = Window()  # start the appsys.exit(App.exec())
Output :
Python PyQt5-Label
Python-gui
Python-PyQt
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Install PIP on Windows ?
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | Pandas dataframe.groupby()
Defaultdict in Python
Python | Get unique values from a list
Python Classes and Objects
Python | os.path.join() method
Create a directory in Python
How to change file extension in Python?

When changing the extension, you're basically just renaming the file and changing the extension. In order to do that, you need to split the filename by '.' and replace the last entry by the new extension you want. You can do this using the os.rename method. 
>>> import os
>>> my_file = 'my_file.txt'
>>> base = os.path.splitext(my_file)[0]
>>> os.rename(my_file, base + '.bin')
This will rename my_file.txt to my_file.bin
How to Create an Infinite Loop in Windows Batch File? - GeeksforGeeks

23 Mar, 2020
An infinite loop in Batch Script refers to the repetition of a command infinitely. The only way to stop an infinitely loop in Windows Batch Script is by either pressing Ctrl + C or by closing the program.
Syntax: Suppose a variable ‘a’
:a
your command here
goto a

Here, you need to know how to create a batch file in windows. It is very simple. First, copy the code in a notepad file and save this file with .bat extension. To run or execute the file, double click on it or type the file name on cmd.
Example 1: Let’s start by looping a simple command, such as ‘echo’. ‘echo‘ commands is analogous to ‘print’ command like in any other programming languages. Save the below code in a notepad file like sample.bat and double click on it to execute.
@echo off
:x
echo Hello! My fellow GFG Members!
goto x

Output:
To stop this infinite loop, press Ctrl + C and then press y and then Enter.
Example 2: Suppose we want to loop the command ‘tree’. ‘tree’ command pulls and shows directory and file path in the form of a branching tree.
@echo off REM turning off the echo-ing of the commands below
color 0a REM changing font color to light green
cd c:\ REM put the directory name of which you want the tree of in place of c
:y REM you can add any other variable in place of y
tree 
goto y

Note: ‘REM’ command is only used for typing comments in the batch script program, you can ignore them while typing the program. They are only put for the understanding of the program script and have no real use in the program. Here you can see the below option also.
@echo off 
color 0a 
cd c:\ 
:y 
tree 
goto y

Output:
Batch-script
TechTips
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Add External JAR File to an IntelliJ IDEA Project?
How to Delete Temporary Files in Windows 10?
How to Convert Kotlin Code to Java Code in Android Studio?
How to Install Z Shell(zsh) on Linux?
Difference between RUN vs CMD vs ENTRYPOINT Docker Commands
How to Install Flutter on Windows?
How to Access Localhost on Mobile Browsers?
How to Clone Android Project from GitHub in Android Studio?
Basic Linux Commands for day to day life
How to Install Selenium WebDriver on MacOS?
Tryit Editor v3.7

Tryit: Style the ::marker pseudo-element
How to convert Integer array list to float array in Java?

To convert integer array list to float array, let us first create an integer array list −
ArrayList < Integer > arrList = new ArrayList < Integer > ();
arrList.add(25);
arrList.add(50);
arrList.add(100);
arrList.add(200);
arrList.add(300);
arrList.add(400);
arrList.add(500);
Now, convert integer array list to float array. We have first set the size to the float array. With that, each and every value of the integer array is assigned to the float array −
final float[] arr = new float[arrList.size()];
int index = 0;
for (final Integer value: arrList) {
   arr[index++] = value;
}
 Live Demo
import java.util.ArrayList;
public class Demo {
   public static void main(String[] args) {
      ArrayList<Integer>arrList = new ArrayList<Integer>();
      arrList.add(25);
      arrList.add(50);
      arrList.add(100);
      arrList.add(200);
      arrList.add(300);
      arrList.add(400);
      arrList.add(500);
      final float[] arr = new float[arrList.size()];
      int index = 0;
      for (final Integer value: arrList) {
         arr[index++] = value;
      }
      System.out.println("Elements of float array...");
      for (Float i: arr) {
         System.out.println(i);
      }
   }
}
Elements of float array...
25.0
50.0
100.0
200.0
300.0
400.0
500.0
\strut - Tex Command

\strut - Used to create an invisible box with no width, height 8.6pt and depth 3pt.
{ \strut}
\strut command creates an invisible box with no width, height 8.6pt and depth 3pt.

\sqrt{(\ )}
\sqrt{\mathstrut\rm mathstrut}
\sqrt{\strut\rm strut}


( )(mathstrutstrut


\Tiny
\sqrt{(\ )}
\sqrt{\mathstrut\rm mathstrut}
\sqrt{\strut\rm strut}


( )(mathstrutstrut


\Large
\sqrt{(\ )}
\sqrt{\mathstrut\rm mathstrut}
\sqrt{\strut\rm strut}


( )(mathstrutstrut



\sqrt{(\ )}
\sqrt{\mathstrut\rm mathstrut}
\sqrt{\strut\rm strut}


( )(mathstrutstrut


\sqrt{(\ )}
\sqrt{\mathstrut\rm mathstrut}
\sqrt{\strut\rm strut}

\Tiny
\sqrt{(\ )}
\sqrt{\mathstrut\rm mathstrut}
\sqrt{\strut\rm strut}


( )(mathstrutstrut


\Tiny
\sqrt{(\ )}
\sqrt{\mathstrut\rm mathstrut}
\sqrt{\strut\rm strut}

\Large
\sqrt{(\ )}
\sqrt{\mathstrut\rm mathstrut}
\sqrt{\strut\rm strut}


( )(mathstrutstrut


\Large
\sqrt{(\ )}
\sqrt{\mathstrut\rm mathstrut}
\sqrt{\strut\rm strut}


    14 Lectures 
     52 mins

 Ashraf Said

    11 Lectures 
     1 hours 

 Ashraf Said

    9 Lectures 
     1 hours 

 Emenwa Global, Ejike IfeanyiChukwu

    29 Lectures 
     2.5 hours 

 Mohammad Nauman

    14 Lectures 
     1 hours 

 Daniel Stern

    15 Lectures 
     47 mins

 Nishant Kumar
 Print
 Add Notes
 Bookmark this page
ggplot2 - Bubble Plots & Count Charts

Bubble plots are nothing but bubble charts which is basically a scatter plot with a third numeric variable used for circle size. In this chapter, we will focus on creation of bar count plot and histogram count plots which is considered as replica of bubble plots.
Following steps are used to create bubble plots and count charts with mentioned package −
Load the respective package and the required dataset to create the bubble plots and count charts.
> # Load ggplot
> library(ggplot2)
>
> # Read in dataset
> data(mpg)
> head(mpg)
# A tibble: 6 x 11
manufacturer  model  displ  year  cyl  trans      drv   cty  hwy  fl  class
<chr> <chr> <dbl> <int> <int> <chr> <chr> <int> <int> <chr> <chr>
1 audi        a4     1.8    1999  4    auto(l5)   f     18   29   p   compa~
2 audi        a4     1.8    1999  4    manual(m5) f     21   29   p   compa~
3 audi        a4     2      2008  4    manual(m6) f     20   31   p   compa~
4 audi        a4     2      2008  4    auto(av)   f     21   30   p   compa~
5 audi        a4     2.8    1999  6    auto(l5)   f     16   26   p   compa~
6 audi        a4     2.8    1999  6    manual(m5) f     18   26   p   compa~

The bar count plot can be created using the following command −
> # A bar count plot
> p <- ggplot(mpg, aes(x=factor(cyl)))+
+ geom_bar(stat="count")
> p

The histogram count plot can be created using the following command −
> # A historgram count plot
> ggplot(data=mpg, aes(x=hwy)) +
+    geom_histogram( col="red",
+       fill="green",
+       alpha = .2,
+       binwidth = 5)

Now let us create the most basic bubble plot with the required attributes of increasing the dimension of points mentioned in scattered plot.
ggplot(mpg, aes(x=cty, y=hwy, size = pop)) +geom_point(alpha=0.7)

The plot describes the nature of manufacturers which is included in legend format. The values represented include various dimensions of “hwy” attribute.
 Print
 Add Notes
 Bookmark this page
M_Expensive statement in SAP HANA

This can be checked using system view M_EXPENSIVE_STATEMENTS.
SELECT * FROM M_EXPENSIVE_STATEMENTS
In SAP HANA, the M_EXPENSIVE_STATEMENTS view provides convenient access to the most expensive statements that were executed on the system. A statement is considered being expensive if its runtime exceeds a particular threshold. Please note that the expensive statements trace needs to be activated first in the Performance → Expensive Statements Trace screen in the SAP HANA studio. Click Configure the Trace Configuration dialog
Creating Index in Column based tables in SAP HANA

Note that an index not necessary to be NOT NULL. You can create an Index in SAP HANA database by using below query:
CREATE INDEX IDX_MY_INDEX ON TABLE1 (MY_COLUMN);
To know more about SAP HANA database, Modeling, and Administration features, you can refer our SAP HANA Text and Video tutorials:
https://www.tutorialspoint.com/sap_hana/
https://www.tutorialspoint.com/sap_hana_online_training/index.asp
How to change the legend shape using ggplot2 in R?

By default, the shape of legend is circular but we can change it by using the guides function of ggplot2 package. For example, if we have a data frame with two numerical columns say x and y, and one categorical column Group then the scatterplot between x and y for different color values of categories in categorical column Group having different shape of legends can be created by using the below command −
ggplot(df,aes(x,y,color=Group))+geom_point()+guides(colour=guide_legend(override.aes=list(shape=0)))
Here, we can change the shape argument value to any value between starting from 0 to 25.
Consider the below data frame −
 Live Demo
x<-rpois(20,5)
y<-rpois(20,2)
Group<-sample(c("Male","Female"),20,replace=TRUE)
df<-data.frame(x,y,Group)
df
   x  y  Group
1  7  1  Female
2  7  0  Female
3  4  2  Male
4  3  2  Male
5  2  1  Male
6  9  0  Female
7  5  4  Male
8  3  1  Female
9  5  1  Female
10 6  1  Female
11 3  2  Male
12 5  1  Male
13 4  1  Male
14 5  3  Female
15 1  6  Female
16 5  3  Male
17 4  2  Female
18  5 5  Female
19 2  3  Female
20 5  4  Male
Loading ggplot2 package and creating scatterplot between x and y with different colors for Group values −
library(ggplot2)
ggplot(df,aes(x,y,color=Group))+geom_point()
Creating the scatterplot between x and y with different legend shape −
ggplot(df,aes(x,y,color=Group))+geom_point()+guides(colour=guide_legend(override.aes=list(shape=17)))
Java - String substring() Method

This method has two variants and returns a new string that is a substring of this string. The substring begins with the character at the specified index and extends to the end of this string or up to endIndex – 1, if the second argument is given.
Here is the syntax of this method −
public String substring(int beginIndex)

Here is the detail of parameters −
beginIndex − the begin index, inclusive.
beginIndex − the begin index, inclusive.
The specified substring.
import java.io.*;
public class Test {

   public static void main(String args[]) {
      String Str = new String("Welcome to Tutorialspoint.com");

      System.out.print("Return Value :" );
      System.out.println(Str.substring(10) );

   }
}
This will produce the following result −
Return Value : Tutorialspoint.com


    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
How to extract date from text using Python regular expression?

The following code using Python regex extracts the date from given string
import datetime
from datetime import date
import re
s = "Jason's birthday is on 1991-09-21"
match = re.search(r'\d{4}-\d{2}-\d{2}', s)
date = datetime.datetime.strptime(match.group(), '%Y-%m-%d').date()
print date
This gives the output
1991-09-21
Deep dive into Parameters and Arguments in Python - GeeksforGeeks

24 Oct, 2020
There is always a little confusion among budding developers between a parameter and an argument, this article focuses to clarify the difference between them and help you to use them effectively.
A parameter is the variable defined within the parentheses during function definition. Simply they are written when we declare a function. 
Example:
Python3
# Here a,b are the parametersdef sum(a,b):  print(a+b)    sum(1,2)
Output:
3

An argument is a value that is passed to a function when it is called. It might be a variable, value or object passed to a function or method as input. They are written when we are calling the function.
Example:
Python3
def sum(a,b):  print(a+b)    # Here the values 1,2 are argumentssum(1,2)
Output:
3

Python functions can contain two types of arguments:
Positional Arguments
Keyword Arguments
Positional Arguments are needed to be included in proper order i.e the first argument is always listed first when the function is called, second argument needs to be called second and so on.
Example:
Python3
def person_name(first_name,second_name):  print(first_name+second_name)    # First name is Ram placed first# Second name is Babu place secondperson_name("Ram","Babu")
Output:
RamBabu

Keyword Arguments is an argument passed to a function or method which is preceded by a keyword and an equal to sign. The order of keyword argument with respect to another keyword argument does not matter because the values are being explicitly assigned.
Python3
def person_name(first_name,second_name):  print(first_name+second_name)  # Here we are explicitly assigning the values person_name(second_name="Babu",first_name="Ram")
Output:
RamBabu

Python-Functions
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?
How to drop one or multiple columns in Pandas Dataframe
Check if element exists in list in Python
Selecting rows in pandas DataFrame based on conditions
Python | os.path.join() method
Defaultdict in Python
Create a directory in Python
Python | Get unique values from a list
Python | Pandas dataframe.groupby()
Find all close matches of input string from a list in Python

Suppose we are given a word and we want to find its closest matches. Not an exact match but other words which have some close resemblance in pattern with the given word. For this we use a module called difflib and use its method named get_close_matches.
This method is part of the module difflib and gives us the match with possible patterns which we specify. Below is the syntax.
difflib.get_close_matches(word, possibilities, n, cutoff)
word: It is the word to which we need to find the match.
Possibilities: This is the patterns which will be compared for matching.
n: Maximum number of close matches to return. Should be greater than 0.
Cutoff: The possibilities that do not score this float value between 0 and 1 are ignored.
Running the above code gives us the following result −
In the below example we take a word and also a list of possibilities or patterns that need to be compared. Then we apply the method to get the result needed.
 Live Demo
from difflib import get_close_matches

word = 'banana'
patterns = ['ana', 'nana', 'ban', 'ran','tan']

print('matched words:',get_close_matches(word, patterns))
Running the above code gives us the following result −
matched words: ['nana', 'ban', 'ana']
MongoDB inverse of query to return all items except specific documents?

To get documents except some specific documents, use noralongwithand. Let us first create a collection with documents −
> db.demo1.insertOne({"StudentName":"Chris","StudentMarks":38});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e08a4f025ddae1f53b62216")
}
> db.demo1.insertOne({"StudentName":"David","StudentMarks":78});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e08a4f725ddae1f53b62217")
}
> db.demo1.insertOne({"StudentName":"Mike","StudentMarks":96});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e08a4fd25ddae1f53b62218")
}
Following is the query to display all documents from a collection with the help of find() method −
> db.demo1.find().pretty();
This will produce the following output −
{
   "_id" : ObjectId("5e08a4f025ddae1f53b62216"),
   "StudentName" : "Chris",
   "StudentMarks" : 38
}
{
   "_id" : ObjectId("5e08a4f725ddae1f53b62217"),
   "StudentName" : "David",
   "StudentMarks" : 78
}
{
   "_id" : ObjectId("5e08a4fd25ddae1f53b62218"),
   "StudentName" : "Mike",
   "StudentMarks" : 96
}
Here is the query to get inverse of query −
> db.demo1.find({$nor:[{$and:[{'StudentName':'David'},{'StudentMarks':78}]}]});
This will produce the following output. The result displays Student records with marks except 78 −
{ "_id" : ObjectId("5e08a4f025ddae1f53b62216"), "StudentName" : "Chris", "StudentMarks" : 38 }
{ "_id" : ObjectId("5e08a4fd25ddae1f53b62218"), "StudentName" : "Mike", "StudentMarks" : 96 }
Solidity - Cryptographic Functions

Solidity provides inbuilt cryptographic functions as well. Following are important methods −
keccak256(bytes memory) returns (bytes32) − computes the Keccak-256 hash of the input.
keccak256(bytes memory) returns (bytes32) − computes the Keccak-256 hash of the input.
ripemd160(bytes memory) returns (bytes20) − compute RIPEMD-160 hash of the input.
ripemd160(bytes memory) returns (bytes20) − compute RIPEMD-160 hash of the input.
sha256(bytes memory) returns (bytes32) − computes the SHA-256 hash of the input.
sha256(bytes memory) returns (bytes32) − computes the SHA-256 hash of the input.
ecrecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) returns (address) − recover the address associated with the public key from elliptic curve signature or return zero on error. The function parameters correspond to ECDSA values of the signature: r - first 32 bytes of signature; s: second 32 bytes of signature; v: final 1 byte of signature. This method returns an address.
ecrecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) returns (address) − recover the address associated with the public key from elliptic curve signature or return zero on error. The function parameters correspond to ECDSA values of the signature: r - first 32 bytes of signature; s: second 32 bytes of signature; v: final 1 byte of signature. This method returns an address.
Following example shows the usage of cryptographic function in Solidity.
pragma solidity ^0.5.0;

contract Test {   
   function callKeccak256() public pure returns(bytes32 result){
      return keccak256("ABC");
   }  
}
Run the above program using steps provided in Solidity First Application chapter.
0: bytes32: result 0xe1629b9dda060bb30c7908346f6af189c16773fa148d3366701fbaa35d54f3c8


    38 Lectures 
     4.5 hours 

 Abhilash Nelson

    62 Lectures 
     8.5 hours 

 Frahaan Hussain

    31 Lectures 
     3.5 hours 

 Swapnil Kole
 Print
 Add Notes
 Bookmark this page
Tryit Editor v3.7

Tryit: Responsive webdesign intro
Go - Nested for Loops

Go programming language allows to use one loop inside another loop. The following section shows a few examples to illustrate the concept −
The syntax for a nested for loop statement in Go is as follows −
for [condition |  ( init; condition; increment ) | Range] {
   for [condition |  ( init; condition; increment ) | Range] {
      statement(s);
   }
   statement(s);
}

The following program uses a nested for loop to find the prime numbers from 2 to 100 −
package main

import "fmt"

func main() {
   /* local variable definition */
   var i, j int

   for i = 2; i < 100; i++ {
      for j = 2; j <= (i/j); j++ {
         if(i%j==0) {
            break; // if factor found, not prime
         }
      }
      if(j > (i/j)) {
         fmt.Printf("%d is prime\n", i);
      }
   }  
}
When the above code is compiled and executed, it produces the following result −
2 is prime
3 is prime
5 is prime
7 is prime
11 is prime
13 is prime
17 is prime
19 is prime
23 is prime
29 is prime
31 is prime
37 is prime
41 is prime
43 is prime
47 is prime
53 is prime
59 is prime
61 is prime
67 is prime
71 is prime
73 is prime
79 is prime
83 is prime
89 is prime
97 is prime


    64 Lectures 
     6.5 hours 

 Ridhi Arora

    20 Lectures 
     2.5 hours 

 Asif Hussain

    22 Lectures 
     4 hours 

 Dilip Padmanabhan

    48 Lectures 
     6 hours 

 Arnab Chakraborty

    7 Lectures 
     1 hours 

 Aditya Kulkarni

    44 Lectures 
     3 hours 

 Arnab Chakraborty
 Print
 Add Notes
 Bookmark this page
Python – Negative index of Element in List

20 Oct, 2020
Given a list of elements, find its negative index in the List.
Input : test_list = [5, 7, 8, 2, 3, 5, 1], K = 2 Output : -4 Explanation : 2 is 4th element from rear.
Input : test_list = [5, 7, 8, 2, 3, 5, 1], K = 5 Output : -2 Explanation : 5 is 2nd element from rear. 
Method #1 : Using index() + len()
In this, we get the index of the element using index(), and then subtract it from the list length to get the required result.
Python3
# Python3 code to demonstrate working of# Negative index of Element# Using index() + len() # initializing listtest_list = [5, 7, 8, 2, 3, 5, 1] # printing original listprint("The original list is : " + str(test_list)) # initializing ElementK = 3 # getting length using len() and subtracting index from itres = len(test_list) - test_list.index(K) # printing resultprint("The required Negative index : -" + str(res))
  Output:
The original list is : [5, 7, 8, 2, 3, 5, 1]
The required Negative index : -3
 
Method #2 : Using ~ operator + list slicing + index()
In this, we reverse the list using slicing, and use ~ operator to get negation, index() is used to get the desired negative index. 
Python3
# Python3 code to demonstrate working of# Negative index of Element# Using ~ operator + list slicing + index() # initializing listtest_list = [5, 7, 8, 2, 3, 5, 1] # printing original listprint("The original list is : " + str(test_list)) # initializing ElementK = 3 # -1 operator to reverse list, index() used to get indexres = ~test_list[::-1].index(K) # printing resultprint("The required Negative index : " + str(res))
 Output:
The original list is : [5, 7, 8, 2, 3, 5, 1]
The required Negative index : -3
pulkitagarwal03pulkit
Python list-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
How to initialize array in Ruby

24 Oct, 2019
In this article, we will learn how to initialize the array in Ruby. There are several ways to create an array. Let’s see each of them one by one.
new method can be used to create the arrays with the help of dot operator. Using arguments we can provide the size to array and elements to array.
Without any argument –
# creating array using new method  # without passing any parameter arr = Array.new()   # displaying the size of arrays # using size method puts arr.size 
Output:
0
Passing size of array as parameter –
# creating array using new method  # passing one parameter i.e. the  # size of array arr2 = Array.new(7)   # displaying the length of arrays # using length method  puts arr2.length 
Output:
7
Passing size of array and elements as parameter –
# creating array using new method  # passing two parameters i.e. the  # size of array & element of array arr3 = Array.new(4, "GFG")   puts "#{arr3}"
Output:
["GFG", "GFG", "GFG", "GFG"]
In Ruby, [] is known as the literal constructor which can be used to create the arrays.
# Ruby program to demonstrate the  # creation of array using literal  # constructor[] and to find the size  # and length of array     # creating array of characters arr = Array['a', 'b', 'c', 'd', 'e', 'f']     # displaying array elements puts "#{arr}"    # displaying array size puts "Size of arr is: #{arr.size}"    # displaying array length puts "Length of arr is: #{arr.length}"
Output:
["a", "b", "c", "d", "e", "f"]
[1, 2, 3, 4, 5, 6, 7]
Size of arr is: 6
Length of arr is: 6
arr1 = ('1'..'6').to_a  # displaying array elements puts "#{arr1}"  arr2 = *'11'..'15'puts "#{arr2}"
Output:
["1", "2", "3", "4", "5", "6"]
["11", "12", "13", "14", "15"]

Ruby Array
Ruby
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Tkinter – ListBox Widget

26 Mar, 2020
Tkinter is a GUI toolkit used in python to make user-friendly GUIs.Tkinter is the most commonly used and the most basic GUI framework available in python. Tkinter uses an object-oriented approach to make GUIs.
Note: For more information, refer to Python GUI – tkinter
The ListBox widget is used to display different types of items. These items must be of the same type of font and having the same font color. The items must also be of Text type. The user can select one or more items from the given list according to the requirement.
Syntax:
listbox = Listbox(root, bg, fg, bd, height, width, font, ..) 

Optional parameters
root – root window.
bg – background colour
fg – foreground colour
bd – border
height – height of the widget.
width – width of the widget.
font – Font type of the text.
highlightcolor – The colour of the list items when focused.
yscrollcommand – for scrolling vertically.
xscrollcommand – for scrolling horizontally.
cursor – The cursor on the widget which can be an arrow, a dot etc.
Common methods
yview – allows the widget to be vertically scrollable.
xview – allows the widget to be horizontally scrollable.
get() – to get the list items in a given range.
activate(index) – to select the lines with a specified index.
size() – return the number of lines present.
delete(start, last) – delete lines in the specified range.
nearest(y) – returns the index of the nearest line.
curseselection() – returns a tuple for all the line numbers that are being selected.
Example 1:
from tkinter import *    # create a root window.top = Tk()  # create listbox objectlistbox = Listbox(top, height = 10,                   width = 15,                   bg = "grey",                  activestyle = 'dotbox',                   font = "Helvetica",                  fg = "yellow")  # Define the size of the window.top.geometry("300x250")    # Define a label for the list.  label = Label(top, text = " FOOD ITEMS")   # insert elements by their# index and names.listbox.insert(1, "Nachos")listbox.insert(2, "Sandwich")listbox.insert(3, "Burger")listbox.insert(4, "Pizza")listbox.insert(5, "Burrito")  # pack the widgetslabel.pack()listbox.pack()    # Display untill User # exits themselves.top.mainloop()
OutputExample 2: Let’s Delete the elements from the above created listbox
# Delete Items from the list#  by specifying the index.listbox.delete(2)
Output
Python-tkinter
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Read JSON file using Python
Python map() function
Adding new column to existing DataFrame in Pandas
How to get column names in Pandas dataframe
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 ?
Iterate over a list in Python
SQL Query to get information of employee where employee Is Not Assigned to the Department

01 Apr, 2021
In this article, we will discuss the overview of SQL query and our main focus will be on how to get information of employee where employee Is Not Assigned to the Department in SQL. Let’s discuss it step by step.
Introduction :Queries help us to interact with the database for various operations of data retrieval, updating, deletion, and inserting. In this article let us see a query to get the information of an employee where the employee is not assigned to any department. When in a table if any attribute is not assigned with any value it would be the NULL so let us execute the query on a table in the database company.
Step-1: Creating a database –Creating a database company by using the following SQL query as follows.
CREATE DATABASE company;
Output :
Step-2: Using the database –Using the database company using the following SQL query as follows.
USE company;
Output :
Step-3: Creating a table –Creating a table employee with 5 columns using the following SQL query as follows.
CREATE TABLE employee
(
emp_id varchar(20),
emp_name varchar(20),
emp_dept varchar(20),
emp_age INT,
emp_sex varchar(8)
);
Output :
Step-4: Verifying the database –To view the description of the database using the following SQL query as follows.
DESCRIBE employee;
Output :
Step-5: Inserting data into the table –Inserting rows into employee table using the following SQL query as follows.
 INSERT INTO employee VALUES('E00001','JHONNY','BACKEND DEVELOPER',26,'male');
 INSERT INTO employee VALUES('E00002','DARSHI',NULL,27,'male');
 INSERT INTO employee VALUES('E00003','JASMINE',NULL,37,'female');
 INSERT INTO employee VALUES('E00004','LILLY',NULL,47,'female');
 INSERT INTO employee VALUES('E00005','RONALD','UI DEVELOPER',26,'male'); 
Output :
Step-6: Verifying the inserted data –Viewing the table employee after inserting rows by using the following SQL query as follows.
SELECT* FROM employee;
Output :
Query to find the employees whose departments are not assigned :Here, we will see how to query to find the employees whose departments are not assigned by using the following SQL query as follows.
Syntax :
SELECT*
FROM table_name
WHERE column_name  IS NULL;
Selecting Data Query –
 SELECT*
 FROM employee
 WHERE emp_dept IS NULL;
Output :In this table, all the employee records whose department is NULL value are obtained. 
Query to find the employees whose departments are assigned :Here, we will see how to query to find the employees whose departments are assigned using the following SQL as follows.
Syntax :
SELECT *
FROM table_name
WHERE column_name IS NOT NULL;
Selecting Query –
SELECT *
FROM employee
WHERE emp_dept IS NOT NULL;
Output :All the records of an employee whose department is assigned are obtained.
   
DBMS-SQL
Picked
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between Private and Protected in C++ with Example - GeeksforGeeks

03 Jan, 2022
Protected
Protected access modifier is similar to that of private access modifiers, the difference is that the class member declared as Protected are inaccessible outside the class but they can be accessed by any subclass(derived class) of that class.Example:  
CPP
// C++ program to demonstrate// protected access modifier #include <bits/stdc++.h>using namespace std; // base classclass Parent {     // protected data membersprotected:    int id_protected;}; // sub class or derived classclass Child : public Parent { public:    void setId(int id)    {         // Child class is able to access the inherited        // protected data members of the base class         id_protected = id;    }     void displayId()    {        cout << "id_protected is: "             << id_protected << endl;    }}; // main functionint main(){     Child obj1;     // member function of the derived class can    // access the protected data members of the base class     obj1.setId(81);    obj1.displayId();    return 0;}
id_protected is: 81
 
Private
The class members declared as private can be accessed only by the functions inside the class. They are not allowed to be accessed directly by any object or function outside the class. Only the member functions or the friend functions are allowed to access the private data members of a class.Example: 
CPP
// C++ program to demonstrate private// access modifier #include <iostream>using namespace std; class Circle {     // private data memberprivate:    double radius;     // public member functionpublic:    void compute_area(double r)    {        // member function can access private        // data member radius        radius = r;         double area = 3.14 * radius * radius;         cout << "Radius is: " << radius << endl;        cout << "Area is: " << area;    }}; // main functionint main(){    // creating object of the class    Circle obj;     // trying to access private data member    // directly outside the class    obj.compute_area(1.5);     return 0;}
Radius is: 1.5
Area is: 7.065
 
Difference between Private and Protected
itskawal2000
access modifiers
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Map in C++ Standard Template Library (STL)
Bitwise Operators in C/C++
Socket Programming in C/C++
Operator Overloading in C++
Multidimensional Arrays in C / C++
Templates in C++ with Examples
vector erase() and clear() in C++
rand() and srand() in C/C++
unordered_map in C++ STL
Object Oriented Programming in C++
How to multiply only one column in an R data frame with a number?

To multiply only one column with a number, we can simply use the multiplication operator * but need to replace the original column with the new values. For example, if we have a data frame called df that contains three columns x1, x2, and x3, and we want to multiply the second column x2 with 2 then it can be done as dfx2<−dfx2*2.
 Live Demo
Consider the below data frame −
set.seed(212)
x1<−rpois(20,2)
x2<−rpois(20,5)
x3<−rpois(20,2)
df1<−data.frame(x1,x2,x3)
df1
x1 x2 x3
1 1 5 3
2 3 5 1
3 3 6 4
4 1 0 2
5 0 3 1
6 0 7 4
7 4 10 4
8 4 8 3
9 1 7 0
10 2 2 0
11 2 1 1
12 2 7 1
13 3 2 1
14 1 3 3
15 1 3 2
16 3 5 2
17 3 2 1
18 1 4 1
19 2 5 2
20 4 6 2
Replacing the column x2 by multiplying the values in it with 2 −
df1$x2<−df1$x2*2
df1
x1 x2 x3
1 1 10 3
2 3 10 1
3 3 12 4
4 1 0 2
5 0 6 1
6 0 14 4
7 4 20 4
8 4 16 3
9 1 14 0
10 2 4 0
11 2 2 1
12 2 14 1
13 3 4 1
14 1 6 3
15 1 6 2
16 3 10 2
17 3 4 1
18 1 8 1
19 2 10 2
20 4 12 2
 Live Demo
y1<−rnorm(20)
y2<−rnorm(20)
y3<−rnorm(20)
y4<−rnorm(20)
df2<−data.frame(y1,y2,y3,y4)
df2
y1 y2 y3 y4
1 0.17051839 −1.07371818 0.717652086 −0.6692174
2 0.26654381 −0.82881794 1.144774784 1.0708255
3 1.17587680 −0.03197159 −0.257318856 −0.2734330
4 0.79978274 1.14677652 −1.052941918 0.8212265
5 0.36352605 0.95455643 0.002662389 0.8991729
6 −0.52918622 −1.19824723 1.121770768 −0.1345990
7 −1.30278723 0.90339625 −1.637918585 −0.3986243
8 −2.01380274 −0.61700004 1.319289169 1.4223520
9 −0.10499300 −0.99640769 1.508072921 −0.8711021
10 −0.57019817 0.23396114 0.371342290 −0.5071846
11 −0.92964644 −2.82593133 −0.191162636 0.2482026
12 −0.62824719 1.39458991 −0.250602510 −0.5094344
13 −1.16899182 0.48402510 0.849597620 0.5386604
14 −0.12800221 −1.01570468 −1.370769300 0.3641254
15 1.60649960 1.00993852 −0.181644717 0.7057080
16 −0.09581029 −0.40099838 0.392519844 −1.6369244
17 −0.43375271 −0.29316467 −0.233208374 0.1270293
18 −0.96182839 0.54334525 1.550101688 2.0853380
19 −1.50775746 −0.89573880 0.366389303 0.3372866
20 1.90255916 −1.41836692 0.428073142 −0.1576013
Replacing the column y1 by multiplying the values in it with *1 −
df2$y1<−df2$y1*(−1)
df2
y1 y2 y3 y4
1 −0.17051839 −1.07371818 0.717652086 −0.6692174
2 −0.26654381 −0.82881794 1.144774784 1.0708255
3 −1.17587680 −0.03197159 −0.257318856 −0.2734330
4 −0.79978274 1.14677652 −1.052941918 0.8212265
5 −0.36352605 0.95455643 0.002662389 0.8991729
6 0.52918622 −1.19824723 1.121770768 −0.1345990
7 1.30278723 0.90339625 −1.637918585 −0.3986243
8 2.01380274 −0.61700004 1.319289169 1.4223520
9 0.10499300 −0.99640769 1.508072921 −0.8711021
10 0.57019817 0.23396114 0.371342290 −0.5071846
11 0.92964644 −2.82593133 −0.191162636 0.2482026
12 0.62824719 1.39458991 −0.250602510 −0.5094344
13 1.16899182 0.48402510 0.849597620 0.5386604
14 0.12800221 −1.01570468 −1.370769300 0.3641254
15 −1.60649960 1.00993852 −0.181644717 0.7057080
16 0.09581029 −0.40099838 0.392519844 −1.6369244
17 0.43375271 −0.29316467 −0.233208374 0.1270293
18 0.96182839 0.54334525 1.550101688 2.0853380
19 1.50775746 −0.89573880 0.366389303 0.3372866
20 −1.90255916 −1.41836692 0.428073142 −0.1576013
C# Program to make a copy of an existing file

Use File.Copy method to make copy of an existing file.
Add the path of the file you want to copy.
String myPath = @"D:\one.txt";
Now copy the above file to the following file −
String myPath = @"D:\one.txt";
Use the File.Copy method with both the source and destination file.
File.Copy(myPath,newpath);
using System;
using System.IO;
public class Program {
   public static void Main() {
      String myPath = @"D:\one.txt";
      // the file will get copied here
      String newpath = @"D:\two.txt";
      // copying file
      File.Copy(myPath,newpath);
   }
}
Java String trim() Method

❮ String Methods

Remove whitespace from both sides of a string:
String myStr = "       Hello World!       ";
System.out.println(myStr);
System.out.println(myStr.trim());

Try it Yourself »

The trim() method removes whitespace from both ends of a string.
Note: This method does not change the original string.
public String trim()

None.
We just launchedW3Schools videos
Get certifiedby completinga course today!
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com
Your message has been sent to W3Schools.
C library function - gmtime()

The C library function struct tm *gmtime(const time_t *timer) uses the value pointed by timer to fill a tm structure with the values that represent the corresponding time, expressed in Coordinated Universal Time (UTC) or GMT timezone.
Following is the declaration for gmtime() function.
struct tm *gmtime(const time_t *timer)
timeptr − This is the pointer to a time_t value representing a calendar time.
timeptr − This is the pointer to a time_t value representing a calendar time.
This function returns pointer to a tm structure with the time information filled in. Below is the detail of timeptr structure −
struct tm {
   int tm_sec;         /* seconds,  range 0 to 59          */
   int tm_min;         /* minutes, range 0 to 59           */
   int tm_hour;        /* hours, range 0 to 23             */
   int tm_mday;        /* day of the month, range 1 to 31  */
   int tm_mon;         /* month, range 0 to 11             */
   int tm_year;        /* The number of years since 1900   */
   int tm_wday;        /* day of the week, range 0 to 6    */
   int tm_yday;        /* day in the year, range 0 to 365  */
   int tm_isdst;       /* daylight saving time             */	
};
The following example shows the usage of gmtime() function.
#include <stdio.h>
#include <time.h>

#define BST (+1)
#define CCT (+8)

int main () {

   time_t rawtime;
   struct tm *info;

   time(&rawtime);
   /* Get GMT time */
   info = gmtime(&rawtime );
   
   printf("Current world clock:\n");
   printf("London : %2d:%02d\n", (info->tm_hour+BST)%24, info->tm_min);
   printf("China  : %2d:%02d\n", (info->tm_hour+CCT)%24, info->tm_min);

   return(0);
}
Let us compile and run the above program that will produce the following result −
Current world clock:
London : 14:10
China : 21:10


    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
Find a form feed character with JavaScript RegExp.

To find a form feed character with JavaScript Regular Expression, use the following −
\f
You can try to run the following code to find a form feed character. It returns the position where the form feed (\f) character is found −
<html>
   <head>
      <title>JavaScript Regular Expression</title>
   </head>
   <body>
      <script>
         var myStr = "100% \f Responsive!";
         var reg = /\f/;
         var match = myStr.search(reg);
         
         document.write(match);
      </script>
   </body>
</html>
AngularJS | ng-form Directive - GeeksforGeeks

29 Mar, 2019
The ng-form Directive in AngularJS is used to create nested form i.e. one form inside the other form. It specifies an inherit control from HTML form. It creates control group inside a form directive which can be used to determine the validity of a sub-group of controls.
Syntax:
<ng-form [name="string"]> Contents... </ng-form>

Example 1: This example uses ng-form Directive to hide the input text fields and display its content.
<!DOCTYPE html><html>  <head>    <title>ng-form Directive</title>          <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js">    </script> </head>  <body ng-app="" style="text-align:center">          <h1 style="color:green;">GeeksforGeeks</h1>    <h2 style="">ng-form Directive</h2>      <div>        <ng-form ng-hide="isDetail">            Full Name:            <input type="text" ng-model="fName">            <br><br>            Username:            <input type="text" ng-model="uName">            <br>        </ng-form>        <br>        <input type="button" ng-click="isDetail=true"                value="Click it!" />                          <div ng-show="isDetail">            First Name:<b>{{fName}}</b><br />            User Name:<b>{{uName}}</b><br />        </div>    </div></body>  </html>                    
Output:Before Clicking the button:After Clicking the button:
Example 2: This example uses ng-form Directive to validate email and save it.
<!DOCTYPE html><html>  <head>    <title>ng-form Directive</title>          <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js">    </script> </head>  <body ng-app="" style="text-align:center">          <h1 style="color:green;">GeeksforGeeks</h1>    <h2 style="">ng-form Directive</h2>      <div>        <ng-form ng-submit="save(user)" name="myForm" novalidate>                      Enter Email:            <input type="email" name="uname"                required ng-model="user.userName"><br>                              <span style="color:red" ng-show="myForm.uname.$error.required                    && myForm.uname.$dirty">Email is required</span>            <br>                          <button ng-disabled="!myForm.$valid" type="submit">                save            </button>        </ng-form>    </div></body>  </html>                    
Output:Invalid Input:Valid Input:
AngularJS-Directives
AngularJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Top 10 Angular Libraries For Web Developers
Angular PrimeNG Dropdown Component
Angular 10 (blur) Event
How to make a Bootstrap Modal Popup in Angular 9/8 ?
Angular 10 (focus) Event
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
MongoDB query by sub-field?

You can use dot(.) notation to query by subfield. Let us create a collection with a document. The query to create a collection with a document is as follows −
> db.queryBySubFieldDemo.insertOne(
   ... {
      ... "StudentPersonalDetails" : {"StudentName" : "John","StudentHobby" :"Photography"},
      ... "StudentScores" : {"MathScore" : 56}
   ... }
... );
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5c92c2995259fcd195499808")
}
> db.queryBySubFieldDemo.insertOne(
   ... {
      ... "StudentPersonalDetails" : {"StudentName" : "Chris","StudentHobby" :"Reading"},
      ... "StudentScores" : {"MathScore" : 97}
   ... }
... );
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5c92c2df5259fcd195499809")
}
Display all documents from a collection with the help of find() method. The query is as follows −
> db.queryBySubFieldDemo.find().pretty();
The following is the output −
{
   "_id" : ObjectId("5c92c2995259fcd195499808"),
   "StudentPersonalDetails" : {
      "StudentName" : "John",
      "StudentHobby" : "Photography"
   },
   "StudentScores" : {
      "MathScore" : 56
   }
}
{
   "_id" : ObjectId("5c92c2df5259fcd195499809"),
   "StudentPersonalDetails" : {
      "StudentName" : "Chris",
      "StudentHobby" : "Reading"
   },
   "StudentScores" : {
      "MathScore" : 97
   }
}
Here is the query by subfield −
> db.queryBySubFieldDemo.find({"StudentPersonalDetails.StudentName":"Chris"}).pretty();
The following is the output −
{
   "_id" : ObjectId("5c92c2df5259fcd195499809"),
   "StudentPersonalDetails" : {
      "StudentName" : "Chris",
      "StudentHobby" : "Reading"
   },
   "StudentScores" : {
      "MathScore" : 97
   }
}
Palindrome array - JavaScript

We are required to write a JavaScript function that takes in an array of literals and checks if elements are the same or not if read from front or back i.e. palindrome.
Let’s write the code for this function −
const arr = [1, 5, 7, 4, 15, 4, 7, 5, 1];
const isPalindrome = arr => {
   const { length: l } = arr;
   const mid = Math.floor(l / 2);
   for(let i = 0; i <= mid; i++){
      if(arr[i] !== arr[l-i-1]){
         return false;
      };
   };
   return true;
};
console.log(isPalindrome(arr));
The output in the console: −
true