code-rag-bench/online-tutorials huggingface dataset:
Python program to check the validity of a Password?

Here given a password, our task is to check that this Password is valid or not. Here we use re module that provide regular expression and re.search() is used for checking the validation of alphabets, digits or special characters.
Step 1: first we take an alphanumeric string as a password.
Step 2: first check that this string should minimum 8 characters.
Step 3: the alphabets must be between a-z.
Step 4: At least one alphabet should be in Uppercase A-Z.
Step 5: At least 1 number or digit between 0-9.
Step 6: At least 1 character from [_ or @ or $].

# Python program to check valid password 
import re 
passw = input("Enter Password ::>")
fl = 0
while True:   
   if (len(passw)<8): 
      fl= -1
      break
   elif not re.search("[a-z]", passw): 
      fl = -1
      break
   elif not re.search("[A-Z]", passw): 
        fl = -1
        break
    elif not re.search("[0-9]", passw): 
      fl = -1
      break
   elif not re.search("[_@$]", passw): 
      fl = -1
      break
   elif re.search("\s", passw): 
      fl = -1
      break
   else: 
      fl = 0
      print(" This Is Valid Password") 
      break
if fl ==-1: 
   print("Not a Valid Password") 
Enter Password ::> vbnA@hj9
This Is Valid Password
Java Examples - Display a colors in a frame

How to display colours in a frame?
Following example displays how to a display all the colors in a frame using setRGB method of image class.
import java.awt.Graphics;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage;
import javax.swing.JComponent;
import javax.swing.JFrame;

public class Main extends JComponent {
   BufferedImage image;
   public void initialize() {
      int width = getSize().width;
      int height = getSize().height;
      int[] data = new int[width * height];
      int index = 0;
      
      for (int i = 0; i < height; i++) {
         int red = (i * 255) / (height - 1);
         for (int j = 0; j < width; j++) {
            int green = (j * 255) / (width - 1);
            int blue = 128;
            data[index++] = (red<<16) | (green<<8) | blue;
         }
      }
      image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
      image.setRGB(0, 0, width, height, data, 0, width);
   }
   public void paint(Graphics g) {
      if (image == null)
      initialize();
      g.drawImage(image, 0, 0, this);
   }
   public static void main(String[] args) {
      JFrame f = new JFrame("Display Colours");
      f.getContentPane().add(new Main());
      f.setSize(300, 300);
      f.setLocation(100, 100);
      f.addWindowListener(new WindowAdapter() {
         public void windowClosing(WindowEvent e) {
            System.exit(0);
         }
      });
      f.setVisible(true);
   }
}
The above code sample will produce the following result.
Displays all the colours in a frame.

The following is an example to display colours in a frame.
import java.awt.Color;
import java.awt.Dimension;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;

public class Panel { 
   public static void main(String[] args) { 
      SwingUtilities.invokeLater(new Runnable() { 
         public void run() { 
            displayJFrame();
         } 
      }); 
   } 
   static void displayJFrame() { 
      JFrame frame = new JFrame("Tutorialspoint");
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.setBackground(Color.red);
      frame.setPreferredSize(new Dimension(400, 300));
QuickSort - GeeksforGeeks

28 Jun, 2021
Like Merge Sort, QuickSort is a Divide and Conquer algorithm. It picks an element as pivot and partitions the given array around the picked pivot. There are many different versions of quickSort that pick pivot in different ways ... More on Quick Sort
2  5  1  7  9  12  11  10 
 
Writing code in comment? Please use ide.geeksforgeeks.org, generate link and share the link here.
Must Do Coding Questions for Companies like Amazon, Microsoft, Adobe, ...
Must Do Coding Questions for Product Based Companies
Git - Difference Between Git Fetch and Git Pull
ReactJS useNavigate() Hook
SDE SHEET - A Complete Guide for SDE Preparation
How to Install and Use NVM on Windows?
DSA Sheet by Love Babbar
Java Threads
Top 20 Puzzles Commonly Asked During SDE Interviews
Spring Boot - Exception Handling
Replace Spaces in Column Names in R DataFrame

23 Sep, 2021
In this article, we will replace spaces in column names of a dataframe in R Programming Language.
Let’s create a Dataframe with 4 columns with 3 rows:
R
# create  a dataframe with 4 columns and 3 rowsdata = data.frame("web technologies" = c("php","html","js"),                  "backend  tech" = c("sql","oracle","mongodb"),                  "middle ware technology" = c("java",".net","python"))  # displaydata
Output:
In the above example, we can see that there are blank spaces in column names, so we will replace that blank spaces
In this methods we will use gsub function, gsub() function in R Language is used to replace all the matches of a pattern from a string. If the pattern is not found the string will be returned as it is.
Syntax: gsub(” “, “replace”, colnames(dataframe))
Parameters:
first parameter takes space
second parameter takes replacing character that replaces blank space
third parameter takes column names of the dataframe by using colnames() function
Example: R program to create a dataframe and replace dataframe columns with different synbols
R
# create  a dataframe with 4 columns and 3 rowsdata=data.frame("web technologies"=c("php","html","js"),                 "backend  tech"=c("sql","oracle","mongodb"),                "middle ware technology"= c("java",".net","python"),                check.names=FALSE)        # replace blank with underscore             print( gsub(" ", "_", colnames(data)))    # replace blank with dot operator             print( gsub(" ", ".", colnames(data)))  # replace blank with * operator             print( gsub(" ", "*", colnames(data)))
Output:
[1] “web_technologies”       “backend__tech”          “middle_ware_technology”
[1] “web.technologies”       “backend..tech”          “middle.ware.technology”
[1] “web*technologies”       “backend**tech”          “middle*ware*technology”
We can do this by using make.names() function.
Syntax: make.names(colnames(dataframe))
Where, dataframe is the input dataframe
Example: R program to replace dataframe column names using make.names
R
# create  a dataframe with 4 columns and 3 rowsdata = data.frame("web technologies" = c("php","html","js"),                   "backend  tech" = c("sql","oracle","mongodb"),                  "middle ware technology" = c("java",".net","python"),                  check.names = FALSE)      # replace blank by using make.names             print( make.names(colnames(data)))
Output:
[1] “web.technologies”       “backend..tech”          “middle.ware.technology”
Picked
R DataFrame-Programs
R-DataFrame
R Language
R Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Lodash _.startCase() Method

03 Sep, 2020
The _.startCase() method is used to convert the string to start the case.
Syntax:
_.startCase( [string=''] )

Parameters: This method accepts a single parameter as mentioned above and described below:
string: This parameter holds the string to convert.
Return Value: This method returns the start of the case string.
Below example illustrate the Lodash _.startCase() method in JavaScript:
Example 1:
Javascript
// Requiring the lodash library  const _ = require("lodash");         // Use of _.startCase() method console.log(_.startCase('geeks for geeks')); console.log(_.startCase('geeksforgeeks'));console.log(_.startCase('@#$%geeksforgeeks@#$%'));
Output:
'Geeks For Geeks'
'Geeksforgeeks'
'Geeksforgeeks'

Example 2:  
Javascript
// Requiring the lodash library  const _ = require("lodash");         // Use of _.startCase() method console.log(_.startCase(null)); console.log(_.startCase('123456789'));console.log(_.startCase("gfg.Id"));
Output:
''
'123456789'
'Gfg Id'

JavaScript-Lodash
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Differences between Bit Rate and Baud Rate

Both Bit rate and Baud rate are used in data communication. Bit rate and Baud rate are related using below formula.
Bit Rate = Baud rate x the number of bit per baud
Following are the important differences between Pure Aloha and Slotted Aloha.
MySQL statement to copy data from one table and insert into another table

For this, you can use INSERT INTO....SELECT statement. Let us first create a table −
mysql> create table DemoTabe1 (Marks int);
Query OK, 0 rows affected (0.66 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTabe1 values(68);
Query OK, 1 row affected (0.18 sec)
mysql> insert into DemoTabe1 values(89);
Query OK, 1 row affected (0.14 sec)
mysql> insert into DemoTabe1 values(99);
Query OK, 1 row affected (0.17 sec)
mysql> insert into DemoTabe1 values(39);
Query OK, 1 row affected (0.11 sec)
mysql> insert into DemoTabe1 values(49);
Query OK, 1 row affected (0.12 sec)
Display all records from the table using select statement −
mysql> select *from DemoTabe1;
This will produce the following output −
+-------+
| Marks |
+-------+
| 68    |
| 89    |
| 99    |
| 39    |
| 49    |
+-------+
5 rows in set (0.00 sec)
Following is the query to create second table −
mysql> create table DemoTabe2 (Score int);
Query OK, 0 rows affected (0.66 sec)
Here is the query for inserting data to another table −
mysql> insert into DemoTabe2(Score) select Marks from DemoTabe1;
Query OK, 5 rows affected (0.16 sec)
Records: 5 Duplicates: 0 Warnings: 0
Display all records from the table using select statement −
mysql> select *from DemoTabe2;
This will produce the following output. Now the same records are visible in the second table −
+-------+
| Score |
+-------+
| 68    |
| 89    |
| 99    |
| 39    |
| 49    |
+-------+
5 rows in set (0.00 sec)
Finding n most frequent words from a sentence in JavaScript

For the purpose of this question, we define a sentence as a string that contains English alphabets and punctuations and a word is a substring of that sentence joined together by whitespaces.
We are required to write a JavaScript function that takes in a sentence string, str, as the first argument and a number, num, as the second argument. The function should first count the frequency of each word in the sentence and then return an array of length num containing num most frequent words placed according to decreasing frequencies.
For example −
If the input sentence and the number is −
const str = 'i am a good coder and i know that i can solve a problem';
const num = 2;
Then the output should be −
const output = ['i', 'a'];
because 'i' appears for 3 times while 'a' appears for 2 times in the array and they are the 2 most frequent words in the string.
The code for this will be −
 Live Demo
const str = 'i am a good coder and i know that i can solve a problem';
const num = 2;
const findMostFrequent = (str = '', num = 1) => {
   const strArr = str.split(' ');
   const map = {};
   strArr.forEach(word => {
      if(map.hasOwnProperty(word)){
         map[word]++;
      }else{
         map[word] = 1;
      }
   });
   const frequencyArr = Object.keys(map).map(key => [key, map[key]]);
   frequencyArr.sort((a, b) => b[1] - a[1]);
   return frequencyArr.slice(0, num).map(el => el[0]);
};
console.log(findMostFrequent(str, num));
And the output in the console will be −
[ 'i', 'a' ]
Cascade notation in Dart Programming

Cascade notation is used when we want to operate a sequence of operations on the same object. The cascade notation is denoted by the (..) symbol.
It is similar to method chaining that we have in other programming languages and it does save us plenty of steps and need of temporary variable.
Consider the following example for a representation of how the cascade notation works in Dart.
 Live Demo
class Sample{
   var a;
   var b;
   void showA(x){
      this.a = x;
   }
   void showB(y){
      this.b = y;
   }
   void printValues(){
      print(this.a);
      print(this.b);
   }
}
void main(){
   Sample sampleOne = new Sample();
   sampleOne.showA(2);
   sampleOne.showB(3);
   sampleOne.printValues();

   Sample sampleTwo = new Sample();
   sampleTwo..showA(2)
   ..showB(3)
   ..printValues();
}
In the above example, we have two objects created of a single class and we are calling three methods that are present in the above class. When we call the three methods on the object instance sampleOne, we are explicitly typing the name of the object three times followed by the dot notation and the call to methods.
In the second case, the sampleTwo is written only once and we made use of the cascade operator to call the methods we want.
It should be noted that we can't have semicolons(;) between the consecutive method calls as it will confuse the compiler and we will get an error.
2
3
2
3
BitArray.LeftShift() Method in C# with Examples - GeeksforGeeks

27 Mar, 2019
BitArray class manages a array of bit values, which are represented as Booleans, where true indicates bit is 1 and false indicates bit is 0. This class is contained in namespace, System.Collections. BitArray.LeftShift(Int32) method is used to shift the bits of the bit array to the left by one position and adds zeros on the shifted position. Original BitArray object will be modified on performing the operation Left shift.
Syntax: public System.Collections.BitArray LeftShift (int count);
Parameter:count is an immutable value type that represents signed integers with values that range from negative 2,147,483,648 through positive 2,147,483,647.
Return value : It returns Bit Array.
Example 1: Suppose we have the bit array 10011 we want to shift it Left by two positions.
The final result is 00110.
// C# program to illustrate the// BitArray.LeftShift() Methodusing System;using System.Collections;  class GeeksforGeeks {      // Main Method    public static void Main()    {          // Creating a BitArray        BitArray BitArr = new BitArray(5);          // Initializing values in BitArr        BitArr[0] = true;        BitArr[1] = true;        BitArr[2] = false;        BitArr[3] = false;        BitArr[4] = true;          // function calling        Display(BitArr.LeftShift(2));    }      // Displaying the result    public static void Display(IEnumerable myList)    {        foreach(Object obj in myList)        {            Console.WriteLine(obj);        }    }}
False
False
True
True
False

Example 2: Suppose we have the bit array 100011 we want to shift it left by three positions.
The final result is 000100.
// C# program to illustrate the// BitArray.LeftShift() Methodusing System;using System.Collections;  class GeeksforGeeks {      // Main Method    public static void Main()    {          // Creating a BitArray        BitArray BitArr = new BitArray(6);          // Initializing values in BitArr        BitArr[0] = true;        BitArr[1] = false;        BitArr[2] = false;        BitArr[3] = false;        BitArr[4] = true;        BitArr[5] = true;          // function calling        Display(BitArr.LeftShift(3));    }      // Displaying the result    public static void Display(IEnumerable myList)    {        foreach(Object obj in myList)        {            Console.WriteLine(obj);        }    }}
False
False
False
True
False
False

Reference:
https://docs.microsoft.com/en-us/dotnet/api/system.collections.bitarray.leftshift?view=netcore-2.2
CSharp-Collections-BitArray
CSharp-Collections-Namespace
CSharp-method
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
C# | Method Overriding
C# Dictionary with examples
Difference between Ref and Out keywords in C#
C# | Delegates
Top 50 C# Interview Questions & Answers
C# | Constructors
Introduction to .NET Framework
Extension Method in C#
C# | Class and Object
C# | Abstract Classes
Python Modules

Consider a module to be the same as a code library.
A file containing a set of functions you want to include in your application.
To create a module just save the code you want in a file with the file extension .py:
Save this code in a file named mymodule.py
Now we can use the module we just created, by using the import statement:
Import the module named mymodule, and call the greeting function:
Note: When using a function from a module, use the syntax: module_name.function_name.
The module can contain functions, as already described, but also variables of 
all types (arrays, dictionaries, objects etc):
Save this code in the file mymodule.py
Import the module named mymodule, and access the person1 dictionary:
You can name the module file whatever you like, but it must have the file extension 
.py
You can create an alias when you import a module, by using the as keyword:
Create an alias for mymodule called mx:
There are several built-in modules in Python, which you can import whenever you like.
Import and use the platform module:
There is a built-in function to list all the function names (or variable 
names) in a module. The dir() function:
List all the defined names belonging to the platform module:
Note: The dir() function can be used on all 
  modules, also the ones you create yourself.
You can choose to import only parts from a module, by using the from keyword.
The module named mymodule has one function 
and one dictionary:
Import only the person1 dictionary from the module:
Note: When importing using the from 
  keyword, do not use the module name when referring to elements in the module. 
  Example: person1["age"], not
mymodule.person1["age"]
What is the correct syntax to import a module named "mymodule"?
 mymodule

Start the Exercise
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.
flush - Unix, Linux Command

flush [generic Postfix daemon options]


The record is implemented as a per-destination logfile with
as contents the queue IDs of deferred mail. A logfile is
append-only, and is truncated when delivery is requested
for the corresponding destination. A destination is the
part on the right-hand side of the right-most @ in
an email address.


Per-destination logfiles of deferred mail are maintained only for
eligible destinations. The list of eligible destinations is
specified with the fast_flush_domains configuration parameter,
which defaults to $relay_domains.


This server implements the following requests:


Delete empty per-destination logfiles that were not updated in
$fast_flush_purge_time days.


This request completes in the background.




Upon receipt of a request to deliver mail for an eligible
destination, the flush(8) server requests delivery of all messages
that are listed in that destination’s logfile, regardless of the
recipients of those messages. This is not an issue for mail
that is sent to a relay_domains destination because
such mail typically only has recipients in one domain.




The text below provides only a parameter summary. See
postconf(5) for more details including examples.

/var/spool/postfix/flush, "fast flush" logfiles.

smtpd(8), SMTP server
qmgr(8), queue manager
postconf(5), configuration parameters
master(5), generic daemon options
master(8), process manager
syslogd(8), system logging



ETRN_README, Postfix ETRN howto



This service was introduced with Postfix version 1.0.

Wietse Venema
IBM T.J. Watson Research
P.O. Box 704
Yorktown Heights, NY 10598, USA


Advertisements


    129 Lectures 
     23 hours 

 Eduonix Learning Solutions

    5 Lectures 
     4.5 hours 

 Frahaan Hussain

    35 Lectures 
     2 hours 

 Pradeep D

    41 Lectures 
     2.5 hours 

 Musab Zayadneh

    46 Lectures 
     4 hours 

 GUHARAJANM

    6 Lectures 
     4 hours 

 Uplatz
 Print
 Add Notes
 Bookmark this page
Expressing numbers in expanded form - JavaScript

Suppose we are given a number 124 and are required to write a function that takes this number as input and returns its expanded form as a string.
The expanded form of 124 is −
'100+20+4'
Following is the code −
const num = 125;
const expandedForm = num => {
   const numStr = String(num);
   let res = '';
   for(let i = 0; i < numStr.length; i++){
      const placeValue = +(numStr[i]) * Math.pow(10, (numStr.length - 1 - i));
      if(numStr.length - i > 1){
         res += `${placeValue}+`
      }else{
         res += placeValue;
      };
   };
   return res;
};
console.log(expandedForm(num));
Following is the output in the console −
100+20+5
DAX Time Intelligence - DATESQTD function

Returns a table that contains a column of the dates for the quarter to date, in the current context.
DATESQTD (<dates>) 

dates
A column that contains dates.
A table containing a single column of date values.
The dates parameter can be any of the following −
A reference to a date/time column.
A reference to a date/time column.
A table expression that returns a single column of date/time values.
A table expression that returns a single column of date/time values.
A Boolean expression that defines a single-column table of date/time values.
A Boolean expression that defines a single-column table of date/time values.
Constraints on Boolean expressions −
The expression cannot reference a calculated field.
The expression cannot reference a calculated field.
The expression cannot use CALCULATE function.
The expression cannot use CALCULATE function.
The expression cannot use any function that scans a table or returns a table, including aggregation functions.
The expression cannot use any function that scans a table or returns a table, including aggregation functions.
However, a Boolean expression can use any function that looks up a single value, or that calculates a scalar value.
= CALCULATE ( 
   SUM (Sales [Sales Amount]), DATESQTD (Sales [Date])
) 

    53 Lectures 
     5.5 hours 

 Abhay Gadiya

    24 Lectures 
     2 hours 

 Randy Minder

    26 Lectures 
     4.5 hours 

 Randy Minder
 Print
 Add Notes
 Bookmark this page
Scala Collections - Array with Range

Use of range() method to generate an array containing a sequence of increasing integers in a given range. You can use final argument as step to create the sequence; if you do not use final argument, then step would be assumed as 1.
Let us take an example of creating an array of range (10, 20, 2): It means creating an array with elements between 10 and 20 and range difference 2. Elements in the array are 10, 12, 14, 16, and 18.
Another example: range (10, 20). Here range difference is not given so by default it assumes 1 element. It create an array with the elements in between 10 and 20 with range difference 1. Elements in the array are 10, 11, 12, 13, ..., and 19.
The following example program shows how to create an array with ranges.
import Array._
object Demo {
   def main(args: Array[String]) {
      var myList1 = range(10, 20, 2)
      var myList2 = range(10,20)
      // Print all the array elements
      for ( x <- myList1 ) {
         print( " " + x )
      }
      println()
      for ( x <- myList2 ) {
         print( " " + x )
      }
   }
}
Save the above program in Demo.scala. The following commands are used to compile and execute this program.
\>scalac Demo.scala
\>scala Demo

10 12 14 16 18
10 11 12 13 14 15 16 17 18 19


    82 Lectures 
     7 hours 

 Arnab Chakraborty

    23 Lectures 
     1.5 hours 

 Mukund Kumar Mishra

    52 Lectures 
     1.5 hours 

 Bigdata Engineer

    76 Lectures 
     5.5 hours 

 Bigdata Engineer

    69 Lectures 
     7.5 hours 

 Bigdata Engineer

    46 Lectures 
     4.5 hours 

 Stone River ELearning
 Print
 Add Notes
 Bookmark this page
HTML <noscript> Tag - GeeksforGeeks

17 Mar, 2022
The <noscript> tag in HTML is used to display the text for those browsers which does not support script tag or the browsers disable the script by the user. This tag is used in both <head> and <body> tag.
Note: This tag is used in those browsers only which does not support scripts.
Syntax:  
<noscript> Contents... </noscript>
Below example illustrates the <noscript> tag in HTML:
Example: 
HTML
<html> <body>    <h1>GeeksforGeeks</h1>    <h2>HTML noscript Tag</h2>    <script>        document.write("GeeksforGeeks!")    </script>    <!-- noscript tag starts -->    <noscript>A computer science portal</noscript>    <!-- noscript tag ends --> </body> </html>
Output: 
Supported Browsers: 
Google Chrome
Internet Explorer
Firefox
Opera
Safari
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
Vishal_Khoda
arorakashish0911
ghoshsuman0129
HTML-Tags
Technical Scripter 2018
HTML
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
How to set the default value for an HTML <select> element ?
How to update Node.js and NPM to next version ?
How to set input type date in dd-mm-yyyy format using HTML ?
Hide or show elements in HTML using display property
How to Insert Form Data into Database using PHP ?
REST API (Introduction)
CSS to put icon inside an input element in a form
Types of CSS (Cascading Style Sheet)
How to remove a directory recursively using Python?

If you want to delete a folder containing all files and folders you want to remove, you can remove the folder(or tree) as follows:
>>> import shutil
>>> shutil.rmtree('my_folder')
Concatenate strings from two fields into a third field in MongoDB?

To concatenate strings from two fields into a third field, you can use the following syntax
db.yourCollectionName.aggregate(
   [
      { $project: { "yourNewFieldName": { $concat: [ "$yourFieldName1", " yourDellimiterValue ", "$yourFieldName2" ] } } }
   ]
);
Let us first create a collection with documents
>db.concatenateStringsDemo.insertOne({"StudentFirstName":"John","StudentLastName":"Doe"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5c9bb7362d66697741252444")
}
>db.concatenateStringsDemo.insertOne({"StudentFirstName":"John","StudentLastName":"Smith"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5c9bb7402d66697741252445")
}
>db.concatenateStringsDemo.insertOne({"StudentFirstName":"Carol","StudentLastName":"Taylor"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5c9bb74c2d66697741252446")
}
>db.concatenateStringsDemo.insertOne({"StudentFirstName":"David","StudentLastName":"Miller"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5c9bb7752d66697741252447")
}
>db.concatenateStringsDemo.insertOne({"StudentFirstName":"James","StudentLastName":"Williams"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5c9bb7862d66697741252448")
}
Following is the query to display all documents from a collection with the help of find() method
> db.concatenateStringsDemo.find().pretty();
This will produce the following output
{
   "_id" : ObjectId("5c9bb7362d66697741252444"),
   "StudentFirstName" : "John",
   "StudentLastName" : "Doe"
}
{
   "_id" : ObjectId("5c9bb7402d66697741252445"),
   "StudentFirstName" : "John",
   "StudentLastName" : "Smith"
}
{
   "_id" : ObjectId("5c9bb74c2d66697741252446"),
   "StudentFirstName" : "Carol",
   "StudentLastName" : "Taylor"
}
{
   "_id" : ObjectId("5c9bb7752d66697741252447"),
   "StudentFirstName" : "David",
   "StudentLastName" : "Miller"
}
{
   "_id" : ObjectId("5c9bb7862d66697741252448"),
   "StudentFirstName" : "James",
   "StudentLastName" : "Williams"
}
Following is the query to concatenate strings from two fields into a third field. We are concatenating the fields “StudentFirstName” and “StudentLastName” here into a third field
> db.concatenateStringsDemo.aggregate(
... [
... { $project: { "StudentFullName": { $concat: [ "$StudentFirstName", " / ", "$StudentLastName" ] } } }
... ]
... );
This will produce the following output
{ "_id" : ObjectId("5c9bb7362d66697741252444"), "StudentFullName" : "John / Doe" }
{ "_id" : ObjectId("5c9bb7402d66697741252445"), "StudentFullName" : "John / Smith" }
{ "_id" : ObjectId("5c9bb74c2d66697741252446"), "StudentFullName" : "Carol / Taylor" }
{ "_id" : ObjectId("5c9bb7752d66697741252447"), "StudentFullName" : "David / Miller" }
{ "_id" : ObjectId("5c9bb7862d66697741252448"), "StudentFullName" : "James / Williams" }
How to call a method of a class in C#

To call a method, use the name of the method after the object name, for example, −
obj1. Display();
Let’s say the class name is ApplicationOne, so to call the method −
ApplicationOne one = new ApplicationOne();

//calling the displayMax method
ret = one.displayMax(a, b);
The following is the example showing how to call a method in C# −
 Live Demo
using System;

namespace Demp {
   class ApplicationOne {
      public int displayMax(int num1, int num2) {
         /* local variable declaration */
         int result;

         if (num1 > num2)
         result = num1;
         else
         result = num2;
         return result;
      }

      static void Main(string[] args) {
         /* local variable definition */
         int a = 700;
         int b = 400;
         int ret;
         ApplicationOne one = new ApplicationOne();

         ret = one.displayMax(a, b);
         Console.WriteLine("Max value is : {0}", ret );
         Console.ReadLine();
      }
   }
}
Max value is : 700
Angular ng Bootstrap Alert Component - GeeksforGeeks

06 Jul, 2021
Angular ng bootstrap is a bootstrap framework used with angular to create components with great styling and this framework is very easy to use and is used to make responsive websites.
In this article, we will see how to use Alert in angular ng bootstrap. Alert is used to provide contextual feedback messages for typical user actions with the handful of available.
Installation syntax:
ng add @ng-bootstrap/ng-bootstrap
Approach:
First, install the angular ng bootstrap using the above-mentioned command.
Import ng bootstrap module in module.tsimport { NgbModule } from '@ng-bootstrap/ng-bootstrap';

imports: [
  NgbModule
]

import { NgbModule } from '@ng-bootstrap/ng-bootstrap';

imports: [
  NgbModule
]

In app.component.html make an alert component.
Serve the app using ng serve.
 
Example 1:
app.component.html
<p>  <ngb-alert [dismissible]="false"              type='success'>    <strong>GeeksforGeeks</strong>  </ngb-alert></p>
app.module.ts
import { NgModule } from '@angular/core';  // Importing forms moduleimport { FormsModule, ReactiveFormsModule  } from '@angular/forms';import { BrowserModule } from '@angular/platform-browser';import { BrowserAnimationsModule } from '@angular/platform-browser/animations';  import { AppComponent }   from './app.component';import { NgbModule }from '@ng-bootstrap/ng-bootstrap';   @NgModule({  bootstrap: [    AppComponent  ],  declarations: [    AppComponent  ],  imports: [    FormsModule,    BrowserModule,    BrowserAnimationsModule,    ReactiveFormsModule,    NgbModule  ]})export class AppModule { }
Output:
Example 2:
app.component.html
<p>  <ngb-alert [dismissible]="true"             type='success'>    <strong>GeeksforGeeks</strong>  </ngb-alert></p>
app.module.ts
import { NgModule } from '@angular/core';  // Importing forms moduleimport { FormsModule, ReactiveFormsModule  } from '@angular/forms';import { BrowserModule } from '@angular/platform-browser';import { BrowserAnimationsModule } from '@angular/platform-browser/animations';   import { AppComponent }   from './app.component';import { NgbModule }from '@ng-bootstrap/ng-bootstrap';   @NgModule({  bootstrap: [    AppComponent  ],  declarations: [    AppComponent  ],  imports: [    FormsModule,    BrowserModule,    BrowserAnimationsModule,    ReactiveFormsModule,    NgbModule  ]})export class AppModule { }
Output:
Reference: https://ng-bootstrap.github.io/#/components/alert/examples
Angular-ng-bootstrap
AngularJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Angular PrimeNG Dropdown Component
Angular PrimeNG Calendar Component
Angular 10 (blur) Event
Angular PrimeNG Messages Component
How to make a Bootstrap Modal Popup in Angular 9/8 ?
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
Java Program to evaluate mathematical expressions in String

To evaluate mathematical expression in String, use Nashorn JavaScript in Java i.e. scripting. Nashorn invoke dynamics feature, introduced in Java 7 to improve performance.
For scripting, use the ScriptEngineManager class for the engine −
ScriptEngineManager scriptEngineManager = new ScriptEngineManager();
ScriptEngine scriptEngine = scriptEngineManager.getEngineByName("JavaScript");
Now for JavaScript code from string, use eval i.e. execute the script. Here, we are evaluating mathematical expressions in a string −
Object ob = scriptEngine.eval("9 + 15 + 30");
System.out.println("Result of evaluating mathematical expressions in String = "+ob);
 Live Demo
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
public class Main {
   public static void main(String[] args) throws Exception {
      ScriptEngineManager scriptEngineManager = new ScriptEngineManager();
      ScriptEngine scriptEngine = scriptEngineManager.getEngineByName("JavaScript");
      // JavaScript code from String
      Object ob = scriptEngine.eval("9 + 15 + 30");
      System.out.println("Result of evaluating mathematical expressions in String = "+ob);
   }
}
Result of evaluating mathematical expressions in String = 54
Minimum Remove to Make Valid Parentheses in C++

Suppose we have a string s of '(' , ')' and lowercase English characters. We have to remove the minimum number of parentheses ( '(' or ')', in any positions ) so that the resulting parenthese string is valid and return any valid string. A parentheses string is valid when all of these criteria are fulfilled −
It is the empty string, contains lowercase characters only, or
It is the empty string, contains lowercase characters only, or
It can be written as the form of AB (A concatenated with B), where A and B are valid strings, or
It can be written as the form of AB (A concatenated with B), where A and B are valid strings, or
It can be written as the form of (A), where A is a valid string.
It can be written as the form of (A), where A is a valid string.
So if the input is like “a)b(c)d”, then the output will be “ab(c)d”
To solve this, we will follow these steps −
Define a stack st
Define a stack st
for i in range 0 to size of sif s[i] = ‘(’, then insert i into stotherwise when s[i] is ‘)’, thenif stack is not empty, then pop from stack, otherwise s[i] = ‘*’
for i in range 0 to size of s
if s[i] = ‘(’, then insert i into st
if s[i] = ‘(’, then insert i into st
otherwise when s[i] is ‘)’, thenif stack is not empty, then pop from stack, otherwise s[i] = ‘*’
otherwise when s[i] is ‘)’, then
if stack is not empty, then pop from stack, otherwise s[i] = ‘*’
if stack is not empty, then pop from stack, otherwise s[i] = ‘*’
while st is not empty,s[top element of stack] = ‘*’pop from stack
while st is not empty,
s[top element of stack] = ‘*’
s[top element of stack] = ‘*’
pop from stack
pop from stack
ans := empty string
ans := empty string
for i in range 0 to size of s – 1if s[i] is not ‘*’, then ans := ans + s[i]
for i in range 0 to size of s – 1
if s[i] is not ‘*’, then ans := ans + s[i]
if s[i] is not ‘*’, then ans := ans + s[i]
return ans
return ans
Let us see the following implementation to get better understanding −
 Live Demo
#include <bits/stdc++.h>
using namespace std;
class Solution {
   public:
   string minRemoveToMakeValid(string s) {
      stack <int> st;
      for(int i = 0; i < s.size(); i++){
         if(s[i] == '(')st.push(i);
         else if(s[i] == ')'){
            if(!st.empty())st.pop();
            else s[i] = '*';
         }
      }
      while(!st.empty()){
         s[st.top()] = '*';
         st.pop();
      }
      string ans = "";
     for(int i = 0; i < s.size(); i++){
        if(s[i] != '*')ans += s[i];
      }
      return ans;
   }
};
main(){
   Solution ob;
   cout << (ob.minRemoveToMakeValid("a)b(c)d"));
}
"a)b(c)d"
ab(c)d
Draw Dot Patterns Using Turtle in Python - GeeksforGeeks

10 Jul, 2020
Prerequisite: Turtle Programming Basics
Turtle is an inbuilt module in Python. It provides drawing using a screen (cardboard) and turtle (pen). To draw something on the screen, we need to move the turtle (pen). To move turtle, there are some functions i.e forward(), backward(), etc.
Following steps are used :
Import turtle
Make turtle
Define a function to draw a square with dots
Call that function
Hide the turtle.
Below is the implementation :
Python3
# import package and making objectimport turtle     pen = turtle.Turtle()  # method to draw square with dots# space --> distance between dots# x     --> side of squaredef draw(space,x):  for i in range(x):    for j in range(x):                # dot        pen.dot()                  # distance for another dot        pen.forward(space)    pen.backward(space*x)          # direction    pen.right(90)    pen.forward(space)    pen.left(90)  # Main Sectionpen.penup()draw(10,8)  # hide the turtlepen.hideturtle()
Output :
Following steps are used :
Import turtle
Make turtle
Define a function to draw a rectangle with dots
Call that function
Hide the turtle.
Below is the implementation :
Python3
# import package and making objectimport turtle     pen = turtle.Turtle()  # method to draw rectangle with dots# space --> distance between dots# x     --> height of rectangle# y     --> width of rectangledef draw(space,x,y):  for i in range(x):    for j in range(y):                # dot        pen.dot()                  # distance for another dot        pen.forward(space)    pen.backward(space*y)          # direction    pen.right(90)    pen.forward(space)    pen.left(90)  # Main Sectionpen.penup()draw(10,5,12)  # hide the turtlepen.hideturtle()
Output :
Following steps are used :
Import turtle
Make turtle
Define a function to draw a diamond with dots
Call that function
Hide the turtle.
Below is the implementation :
Python3
# import package and making objectimport turtle     pen = turtle.Turtle()  # method to draw diamond with dots# space --> distance between dots# x     --> side of diamonddef draw(space,x):  for i in range(x):    for j in range(x):                  # dot        pen.dot()                  # distance for another dot        pen.forward(space)    pen.backward(space*x)          # direction    pen.right(90)    pen.forward(space)    pen.left(90)  # Main Sectionpen.penup()  # direction to form diamondpen.left(45)draw(10,8)  # hide the turtlepen.hideturtle()
Output :
Python-turtle
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()
Python | Get unique values from a list
Defaultdict in Python
Python | os.path.join() method
Python Classes and Objects
Create a directory in Python
Python 3 - dictionary copy() Method

The method copy() returns a shallow copy of the dictionary.
Following is the syntax for copy() method −
dict.copy()

NA
This method returns a shallow copy of the dictionary.
The following example shows the usage of copy() method.
#!/usr/bin/python3

dict1 = {'Name': 'Manni', 'Age': 7, 'Class': 'First'}
dict2 = dict1.copy()
print ("New Dictionary : ",dict2)
When we run above program, it produces the following result −
New dictionary :  {'Name': 'Manni', 'Age': 7, 'Class': 'First'}


    187 Lectures 
     17.5 hours 

 Malhar Lathkar

    55 Lectures 
     8 hours 

 Arnab Chakraborty

    136 Lectures 
     11 hours 

 In28Minutes Official

    75 Lectures 
     13 hours 

 Eduonix Learning Solutions

    70 Lectures 
     8.5 hours 

 Lets Kode It

    63 Lectures 
     6 hours 

 Abhilash Nelson
 Print
 Add Notes
 Bookmark this page
Deriving a Class in Java

A class can be derived from the base class in Java by using the extends keyword. This keyword is basically used to indicate that a new class is derived from the base class using inheritance. It can also be said that it is used to extend the functionality of the class.
A program that demonstrates this is given as follows:
 Live Demo
class A {
   void funcA() {
      System.out.println("This is class A");
   }
}
class B extends A {
   void funcB() {
      System.out.println("This is class B");
   }
}
public class Demo {
   public static void main(String args[]) {
      B obj = new B();
      obj.funcA();
      obj.funcB();
   }
}
This is class A
This is class B
Now let us understand the above program.
The class A contains a member function funcA(). The class B uses the extends keyword to derive from class A. It also contains a member function funcB(). A code snippet which demonstrates this is as follows:
class A {
   void funcA() {
      System.out.println("This is class A");
   }
}
class B extends A {
   void funcB() {
      System.out.println("This is class B");
   }
}
In the main() method in class Demo, an object obj of class B is created. Then the functions funcA() and funcB() are called. A code snippet which demonstrates this is as follows:
public class Demo {
   public static void main(String args[]) {
      B obj = new B();
      obj.funcA();
      obj.funcB();
   }
}
String format for Double in C#

Use the static method String.Format for form double string format in C#.
For three decimal places −
String.Format("{0:0.000}", 987.383);
String.Format("{0:0.000}", 987.38);
String.Format("{0:0.000}", 987.7899);
For thousands separator −
String.Format("{0:0,0.0}", 54567.46);
String.Format("{0:0,0}", 54567.46);
To format string −
using System;

class Demo {

   public static void Main(String[] args) {
      Console.WriteLine("Three decimal places...");
   
      Console.WriteLine( String.Format("{0:0.000}", 987.383));
      Console.WriteLine( String.Format("{0:0.000}", 987.38));
      Console.WriteLine(String.Format("{0:0.000}", 987.7899));
   
      Console.WriteLine("Thousands Separator...");
      Console.WriteLine(String.Format("{0:0,0.0}", 54567.46));
      Console.WriteLine(String.Format("{0:0,0}", 54567.46));
   }
}
Lodash _.dictionary() Method - GeeksforGeeks

30 Sep, 2020

The Lodash _.dictionary() method returns a function that will attempt to look up a field that it is given.
Syntax:
funct = _.dictionary( object );

Parameters: This method accepts single parameter as mentioned above and described below:
object: This method takes the object from which the field is to be searched.
Return Value: This method returns a function that will attempt to look up a field that is given.
Note: This will not work in normal JavaScript because it requires the lodash.js contrib library to be installed. Lodash.js contrib library can be installed using npm install lodash-contrib.
Example 1:
Javascript
 

 
 










// Defining underscore lodash variable  
var _ = require('lodash-contrib');  
  
var ob = { gfg : "GeeksforGeeks" }  
var gfgg = _.dictionary( ob );  
    
console.log(gfgg("gfg"));






Output:
GeeksforGeeks

Example 2:
Javascript
 

 
 










// Defining underscore lodash variable  
var _ = require('lodash-contrib');  
  
var ob = { gfg : "GeeksforGeeks" }  
var gfgg = _.dictionary( ob );  
    
console.log(gfgg("geek"));






Output:
undefined


JavaScript-Lodash


JavaScript


Web Technologies

Writing code in comment? 
                                    Please use ide.geeksforgeeks.org, 
                                    generate link and share the link here.
                                
Difference between var, let and const keywords in JavaScript
Difference Between PUT and PATCH Request
How to get character array from string in JavaScript?
How to detect browser or tab closing in JavaScript ?
How to get selected value in dropdown list using JavaScript ?
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 fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
How to convert MySQL null to 0 using COALESCE() function?

You can use the COALESCE() function to convert MySQL null to 0
SELECT COALESCE(yourColumnName,0) AS anyAliasName FROM yourTableName;
Let us first create a table. The query to create a table is as follows
mysql> create table convertNullToZeroDemo
   -> (
   -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   -> Name varchar(20),
   -> Salary int
   -> );
Query OK, 0 rows affected (1.28 sec)
Insert some records in the table using insert command.
The query is as follows
mysql> insert into convertNullToZeroDemo(Name,Salary) values('John',NULL);
Query OK, 1 row affected (0.20 sec)
mysql> insert into convertNullToZeroDemo(Name,Salary) values('Carol',5610);
Query OK, 1 row affected (0.10 sec)
mysql> insert into convertNullToZeroDemo(Name,Salary) values('Bob',NULL);
Query OK, 1 row affected (0.15 sec)
mysql> insert into convertNullToZeroDemo(Name,Salary) values('David',NULL);
Query OK, 1 row affected (0.12 sec)
Display all records from the table using select statement.
The query is as follows
mysql> select *from convertNullToZeroDemo;
The following is the output
+----+-------+--------+
| Id | Name  | Salary |
+----+-------+--------+
| 1  | John  | NULL   |
| 2  | Carol | 5610   |
| 3  | Bob   | NULL   |
| 4  | David | NULL   |
+----+-------+--------+
4 rows in set (0.05 sec)
Here is the query to convert MySQL NULL to 0 using COALESCE() function
mysql> select coalesce(Salary,0) as `CONVERT_NULL _TO_0` from convertNullToZeroDemo;
The following is the output
+--------------------+
| CONVERT_NULL _TO_0 |
+--------------------+
| 0                  |
| 5610               |
| 0                  |
| 0                  |
+--------------------+
4 rows in set (0.00 sec)