code-rag-bench/online-tutorials huggingface dataset:
How to read multiple text files from a folder in Python?(Tkinter)

Python is capable of handling files, objects, and creating different applications. We can use Python's extensions and packages to build and develop fully featured applications.
Suppose you want to control the files in your system; then Python provides an OS Module which has system-enabled functionalities to allow you interact with the files in the operating system.
Let us see how we can read multiple text files from a folder using the OS module in Python.
Import the OS module in your notebook.
Import the OS module in your notebook.
Define a path where the text files are located in your system.
Define a path where the text files are located in your system.
Create a list of files and iterate over to find if they all are having the correct extension or not.
Create a list of files and iterate over to find if they all are having the correct extension or not.
Read the files using the defined function in the module.
Read the files using the defined function in the module.
# Import the required libraries
import os

# Define the location of the directory
path =r"C:/Users/Sairam/Documents/"

# Change the directory
os.chdir(path)

def read_files(file_path):
   with open(file_path, 'r') as file:
      print(file.read())

# Iterate over all the files in the directory
for file in os.listdir():
   if file.endswith('.txt'):
      # Create the filepath of particular file
      file_path =f"{path}/{file}"

read_files(file_path)
Sample 1
========
Welcome to Tutorialspoint.

You are browsing the best resource for Online Education.

Sample 2
========
A distributed ledger is a type of data structure which resides across multiple computer devices, generally spread across locations or regions.

Distributed ledger technology (DLT) includes blockchain technologies and smart contracts.

While distributed ledgers existed prior to Bitcoin, the Bitcoin blockchain marks the convergence of a host of technologies, including timestamping of transactions, Peer-to-Peer (P2P) networks, cryptography, and shared computational power, along with a new consensus algorithm.
We have two text files in the specified location and the program read the contents of these two files and displayed the text on the console.
How to convert a PDF to byte array in Java?

You can read data from a PDF file using the read() method of the FileInputStream class this method requires a byte array as a parameter.
import java.io.File;
import java.io.FileInputStream;
import java.io.ByteArrayOutputStream;

public class PdfToByteArray {
   public static void main(String args[]) throws Exception {
      File file = new File("sample.pdf");
      FileInputStream fis = new FileInputStream(file);
      byte [] data = new byte[(int)file.length()];
      fis.read(data);
      ByteArrayOutputStream bos = new ByteArrayOutputStream();
      data = bos.toByteArray();
   }
}
Using Update statement with TINYINT in MySQL?

Let us first create a table. We have set one of the columns with type TINYINT −
mysql> create table DemoTable
   -> (
   -> EmployeeId int,
   -> isMarried tinyint
   -> );
Query OK, 0 rows affected (6.84 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values(101,true);
Query OK, 1 row affected (1.94 sec)
mysql> insert into DemoTable values(102,false);
Query OK, 1 row affected (0.76 sec)
mysql> insert into DemoTable values(103,true);
Query OK, 1 row affected (1.14 sec)
mysql> insert into DemoTable values(104,true);
Query OK, 1 row affected (1.22 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+------------+----------+
| EmployeeId | isMarried|
+------------+----------+
|        101 |        1 |
|        102 |        0 |
|        103 |        1 |
|        104 |        1 |
+------------+----------+
4 rows in set (0.00 sec)
Here is the query to implement UPDATE statement with TINYINT −
mysql> update DemoTable
   -> set isMarried=false
   -> where EmployeeId=103;
Query OK, 1 row affected (1.24 sec)
Rows matched: 1 Changed: 1 Warnings: 0
Let us check the table records once again −
mysql> select *from DemoTable;
This will produce the following output −
+------------+----------+
| EmployeeId | isMaried |
+------------+----------+
|        101 |        1 |
|        102 |        0 |
|        103 |        0 |
|        104 |        1 |
+------------+----------+
4 rows in set (0.00 sec)
IDE | GeeksforGeeks | A computer science portal for geeks

Please enter your email address or userHandle.
1234567https://www.trybooking.com/events/landing?eid=857380https://zenodo.org/communities/-zh-917717-deified/https://zenodo.org/communities/-zh-917717-deified/about/https://zenodo.org/communities/zh-917717-deified-tw/about/https://tw-film-hd-quality.blogspot.com/2022/01/2021-deified-4k-1080p.htmlhttp://cpp.sh/5gexghttps://www.peeranswer.com/question/61d7e3fd5dde529f067064b5ההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
https://ide.geeksforgeeks.org/BHOQ5q9SIV
prog.c:1:6: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â before â:â token
Check if the Hashtable contains a specific value in C#

To check if the Hashtable contains a specific value, the code is as follows −
 Live Demo
using System;
using System.Collections;
public class Demo {
   public static void Main(){
      Hashtable hash = new Hashtable();
      hash.Add("1", "A");
      hash.Add("2", "B");
      hash.Add("3", "C");
      hash.Add("4", "D");
      hash.Add("5","E");
      hash.Add("6", "F");
      hash.Add("7", "G");
      hash.Add("8","H");
      hash.Add("9", "I");
      hash.Add("10", "J");
      Console.WriteLine("Hashtable Key and Value pairs...");
      foreach(DictionaryEntry entry in hash){
         Console.WriteLine("{0} and {1} ", entry.Key, entry.Value);
      }
      Console.WriteLine("Is Hashtable having fixed size? = "+hash.IsFixedSize);
      Console.WriteLine("If Hashtable read-only? = "+hash.IsReadOnly);
      Console.WriteLine("The Hashtable consists of the value? = "+hash.ContainsValue("H"));
   }
}
This will produce the following output −
Hashtable Key and Value pairs...
10 and J
1 and A
2 and B
3 and C
4 and D
5 and E
6 and F
7 and G
8 and H
9 and I
Is Hashtable having fixed size? = False If Hashtable read-only? = False The Hashtable consists of the value? = True
Let us see another example −
 Live Demo
using System;
using System.Collections;
public class Demo {
   public static void Main(){
      Hashtable hash = new Hashtable();
      hash.Add("One", "Katie");
      hash.Add("Two", "John");
      hash.Add("Three", "Barry");
      hash.Add("Four", "Mark");
      hash.Add("Five","Harry");
      hash.Add("Six", "Nathan");
      hash.Add("Seven", "Tom");
      hash.Add("Eight","Andy");
      hash.Add("Nine", "Illeana");
      hash.Add("Ten", "Tim");
      Console.WriteLine("Hashtable Key and Value pairs...");
      foreach(DictionaryEntry entry in hash){
         Console.WriteLine("{0} and {1} ", entry.Key, entry.Value);
   }
      Console.WriteLine("Is Hashtable having fixed size? = "+hash.IsFixedSize);
      Console.WriteLine("If Hashtable read-only? = "+hash.IsReadOnly);
      Console.WriteLine("The Hashtable consists of the key? = "+hash.ContainsKey("Seven"));
      Console.WriteLine("The Hashtable consists of the value? = "+hash.ContainsValue("Illeana"));
   }
}
This will produce the following output −
Hashtable Key and Value pairs...
One and Katie
Ten and Tim
Five and Harry
Three and Barry
Seven and Tom
Two and John
Four and Mark
Eight and Andy
Nine and Illeana
Six and Nathan
Is Hashtable having fixed size? = False If Hashtable read-only? = False
The Hashtable consists of the key? = True
The Hashtable consists of the value? = True
Biopython - Sequence File Formats - GeeksforGeeks

22 Oct, 2020
Bio.SeqIO module of Biopython provides a wide range of simple uniform interfaces to input and output the desired file formats. This file formats can only deal with the sequences as a SeqRecord object. Lowercase strings are used while specifying the file format. The same formats are also supported by the Bio.AlignIO module. The list of the file formats is given below :
Below implementation explains about how to parse two of the most popular sequence file formats, i.e. FASTA and GenBank.
It is the most basic file format to store sequence data. Originally FASTA was a software package created during early evolution of Bioinformatics for sequence alignment of proteins and DNA, mostly used for searching similarities. Below is a simple example of parsing FASTA file format:
Example:
To get the input file used click here.
Python3
# Import librariesfrom Bio.SeqIO import parse  # file path/locationfile = open('is_orchid.fasta')   # Parsing the FASTA filefor record in parse(file, "fasta"):     print(record.id)
Output:
Richer sequence format for genes which includes various annotations. Parsing the GenBank format is as simple as changing the format option in Biopython parse method. Below is a simple example of parsing GenBank file format:
Example:
To get the input file used click here.
Python3
# Import librariesfrom Bio import SeqIOfrom Bio.SeqIO import parse  # Parsing Sequenceseq_record = next(parse(open('is_orchid.gbk'), 'genbank'))  # Sequence IDprint("\nSequence ID :", seq_record.id)  # Sequence Nameprint("\nSequence Name :", seq_record.name)  # Sequenceprint("\nSequence  :", seq_record.seq)  # Sequence Descriptionprint("\nSequence ID :", seq_record.description)  # Sequence Annotationsprint("\nSequence Annotations :", seq_record.annotations)
Output:
Python-BioPython
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 drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Defaultdict in Python
Python | Get unique values from a list
Python | os.path.join() method
Selecting rows in pandas DataFrame based on conditions
Create a directory in Python
Python | Pandas dataframe.groupby()
Calculating the area of a triangle using its three sides in JavaScript

We are required to write a JavaScript function that takes in the three sides of a triangle and uses Heron’s formula to calculate its area.
Following is the code −
 Live Demo
const s1 = 10;
const s2 = 8;
const s3 = 7;
const findArea = (s1, s2, s3) => {
   const arr = [];
   const arguments = [s1, s2, s3];
   for(let i = 0; i < arguments.length; i++){
      arr.push(arguments[i]);
   };
   let s = (arr[0] + arr[1] + arr[2]) / 2;
   return Math.sqrt(s * (s - arr[0]) * (s - arr[1]) * (s - arr[2]));
};
console.log(findArea(s1, s2, s3));
27.810744326608734
Minimum Cost to Connect Sticks in C++

Suppose we have some sticks with positive integer lengths. We can connect any two sticks of lengths X and Y into one stick by paying a cost of X + Y. This will be performed until there is one stick remaining. We have to find the minimum cost of connecting all the given sticks into one stick in this way. So if the stack is [2,4,3], then the output will be 14.
To solve this, we will follow these steps −
Define a max heap priority queue pq
insert all elements of s into pq
ans := 0
while pq has more than one elementtemp := top of the queue, delete top from pqtemp := temp + top element of pq, and delete from pqans := ans + tempinsert temp into pq
temp := top of the queue, delete top from pq
temp := temp + top element of pq, and delete from pq
ans := ans + temp
insert temp into pq
return ans
Let us see the following implementation to get a better understanding −
 Live Demo
#include <bits/stdc++.h>
using namespace std;
class Solution {
public:
   int connectSticks(vector<int>& s) {
      priority_queue <int, vector<int>, greater<int> > pq;
      for(int i =0;i<s.size();i++)pq.push(s[i]);
      int ans = 0;
      while(pq.size()>1){
         int temp = pq.top();
         pq.pop();
         temp += pq.top();
         pq.pop();
         ans+=temp;
         pq.push(temp);
      }
      return ans;
   }
};
main(){
   vector<int> v = {2,4,3};
   Solution ob;
   cout <<ob.connectSticks(v);
}
[2,4,3]
14
Tryit Editor v3.7

Tryit: HTML nav element
How to round down to 2 decimals a float using Python?

Python's round() function requires two arguments. First is the number to be rounded. Second argument decides the number of decimal places to which it is rounded. To round the number to 2 decimals, give second argument as 2. If third digit after decimal point is greater than 5, last digit is increased by 1.
>>> round(1.4756,2)
1.48
>>> round(1.3333,2)
1.33
How to use ButtonGroup Component in ReactJS? - GeeksforGeeks

22 Jan, 2021
The ButtonGroup component can be used to group related buttons. Material UI for React has this component available for us and it is very easy to integrate. We can use ButtonGroup Component in ReactJS using the following approach:
Creating React Application And Installing Module:
Step 1: Create a React application using the following command:
npx create-react-app foldername
Step 2: After creating your project folder i.e. foldername, move to it using the following command:
cd foldername
Step 3: After creating the ReactJS application, Install the material-ui modules using the following command:
npm install @material-ui/core
Project Structure: It will look like the following.
Project Structure
App.js: Now write down the following code in the App.js file. Here, App is our default component where we have written our code.
Javascript
import React, { useState } from 'react';import Button from '@material-ui/core/Button';import ButtonGroup from '@material-ui/core/ButtonGroup';  const App = () => {    const [message, setMessage] = useState('')    return (    <div style={{      margin: 'auto',      display: 'block',      width: 'fit-content'    }}>      <h3>How to use GroupButton Component in ReactJS?</h3>      <ButtonGroup color="primary"                    aria-label="outlined primary button group">        <Button          onClick={()=> {            setMessage('You just clicked First Button')          }}        >First Button</Button>        <Button           onClick={()=> {            setMessage('You just clicked Second Button')          }}        >Second Button</Button>        <Button           onClick={()=> {            setMessage('You just clicked Third Button')          }}        >Third Button</Button>      </ButtonGroup>          <h3>{message}</h3>    </div>  );}  export default App;
Step to Run Application: Run the application using the following command from the root directory of the project:
npm start
Output: Now open your browser and go to http://localhost:3000/, you will see the following output:
JavaScript
ReactJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
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 remove duplicate elements from JavaScript Array ?
How to get selected value in dropdown list using JavaScript ?
How to fetch data from an API in ReactJS ?
How to redirect to another page in ReactJS ?
How to pass data from child component to its parent in ReactJS ?
How to pass data from one component to other component in ReactJS ?
{{ form.as_ul }} - Render Django Forms as list - GeeksforGeeks

13 Feb, 2020
Django forms are an advanced set of HTML forms that can be created using python and support all features of HTML forms in a pythonic way. Rendering Django Forms in the template may seem messy at times but with proper knowledge of Django Forms and attributes of fields, one can easily create excellent Form with all powerful features. In this article, Form is rendered as list in the template.
Illustration of {{ form.as_ul }} using an Example. Consider a project named geeksforgeeks having an app named geeks.
Refer to the following articles to check how to create a project and an app in Django.
How to Create a Basic Project using MVT in Django?
How to Create an App in Django ?
Let’s create a sample Django Form to render it and show as an example. In geeks > forms.py, enter following code
from django import forms   # creating a form class InputForm(forms.Form):       first_name = forms.CharField(max_length = 200)    last_name = forms.CharField(max_length = 200)    roll_number = forms.IntegerField(                     help_text = "Enter 6 digit roll number"                     )    password = forms.CharField(widget = forms.PasswordInput())
Now we need a View to render this form into a template. Let’s create a view,
from django.shortcuts import renderfrom .forms import InputForm   # Create your views here.def home_view(request):    context ={}    context['form']= InputForm()    return render(request, "home.html", context)
Finally, we will create the template where we need the form to be placed. In templates > home.html,
<form action = "" method = "post">    {% csrf_token %}    <ul>        {{ form.as_ul }}    </ul>    <input type="submit" value="Submit"></form>
Here {{ form.as_ul }} will render them as list cells wrapped in <li> tags. Let’s check whether this is working acordingly or not. Open http://localhost:8000/
Let’s check the source code whether the form is rendered as a list or not. By rendering as a list it is meant that all input fields will be enclosed in <li> tags.Here is the demonstration,
{{ form.as_table }} will render them as table cells wrapped in <tr> tags
{{ form.as_p }} will render them wrapped in <p> tags
NaveenArora
Django-forms
Python Django
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Python String | replace()
Reading and Writing to text files in Python
*args and **kwargs in Python
Create a Pandas DataFrame from Lists
How To Convert Python Dictionary To JSON?
Convert integer to string in Python
How to call a function using the OptionMenu widget in Tkinter?

Let's take an example and see how to call a function using OptionMenu widget in Tkinter. In the example, we will use a StringVar object and call its get() method. A StringVar object in Tkinter can help manage the value of a widget.
We will create an OptionMenu widget and fill it with a list of strings. When the user selects an option, it will invoke a function which in turn will print the selected option as a label.
Import the tkinter library and create an instance of tkinter frame.
Import the tkinter library and create an instance of tkinter frame.
Set the size of the frame using geometry method.
Set the size of the frame using geometry method.
Create a set of strings and save it in a variable, data.
Create a set of strings and save it in a variable, data.
Next, use the StringVar() constructor to create a StringVar object. It helps to manage the value of a widget, which is an OptionMenu in this case.
Next, use the StringVar() constructor to create a StringVar object. It helps to manage the value of a widget, which is an OptionMenu in this case.
Create a list of strings "options" and an OptionMenu. Set the values of the OptionMenu by passing the StringVar object and "options".
Create a list of strings "options" and an OptionMenu. Set the values of the OptionMenu by passing the StringVar object and "options".
Create a label to display the selected option from the OptionMenu.
Create a label to display the selected option from the OptionMenu.
Create a user-defined function "OptionMenu_Select" to print the selected item from the OptionMenu in the label.
Create a user-defined function "OptionMenu_Select" to print the selected item from the OptionMenu in the label.
Use the parameter command=OptionMenu_Select to invoke the user-defined function when the user selects an option.
Use the parameter command=OptionMenu_Select to invoke the user-defined function when the user selects an option.
Finally, run the mainloop of the application window.
Finally, run the mainloop of the application window.
# Import the tkinter library
from tkinter import *

# Create an instance of tkinter frame
root = Tk()
root.geometry("700x300")

# Create the option and Check Button Event
def OptionMenu_Select(event):
label_city.config(text="You have selected: " + var.get())

# Create the variables
var = StringVar();
var.set("Select a City")

options = ["Mumbai", "Chennai", "Bhubaneswar", "Pune", "Patna", "Bhopal", "Surat", "Hyderabad", "New Delhi", "Lucknow"]
OptionMenu(root, var, *(options), command=OptionMenu_Select).pack(pady=50)

label_city=Label(root, font="Calibri,12,bold")
label_city.pack(padx=20, pady=20)

root.mainloop()
It will produce the following output −
When the user selects an option, it will display the selected option
as a label −
Explain Java command line arguments.

You can pass n number of arguments from the command line while executing the program, separating them with spaces.
java ClassName 10 20 30 . . . . .
The main method accepts/reads the values you have passed into an array of the type String.
public class
   public static void main(String[] args){
}
These arguments are known as command line arguments.
After writing a Java program we will compile it using the command javac and run it using the command javas. Consider the following code −
public class Sample{
   public static void main(String[] args){
      int a = 20;
      int b = 30;
      int c = a+b;
      System.out.println("Sum of the two numbers is "+c);
   }
}
We would compile and run it from command line as shown below −
Here, we are hard coding (fixing to a specific value) the values of a and b which is not recommendable. To handle this, you can accept parameters from user using classes from I/O package or Scanner.
Another way is to use command line arguments.
In the following example we are rewriting the above program, by accepting the (two integer) values from the command line. And, we are extracting these two from the String array in the main method and converting them to integer −
public class Sample {
   public static void main(String[] args){
      int a = Integer.parseInt(args[0]);
      int b = Integer.parseInt(args[1]);
      int c = a+b;
      System.out.println("Sum of the two numbers is "+c);
   }
}
You can compile and, run the program by passing the values at execution line through command prompt as shown below:
Java Regex - MatchResult Interface

The java.util.regex.MatchResult interface represents the result of a match operation. This interface contains query methods used to determine the results of a match against a regular expression. The match boundaries, groups and group boundaries can be seen but not modified through a MatchResult.
Following is the declaration for java.util.regex.MatchResult interface −
public interface MatchResult

Returns the offset after the last character matched.
Returns the offset after the last character of the subsequence captured by the given group during this match.
Returns the input subsequence matched by the previous match.
Returns the input subsequence captured by the given group during the previous match operation.
Returns the number of capturing groups in this match result's pattern.
Returns the start index of the match.
Returns the start index of the subsequence captured by the given group during this match.
 Print
 Add Notes
 Bookmark this page
MongoDB - $pull Operator - GeeksforGeeks

10 May, 2020
MongoDB provides different types of array update operators to update the values of the array fields in the documents and $pull operator is one of them. This operator is used to remove all the instances of the value or the value that matches the specified condition from the existing array.
Syntax:
{ $pull: { <field1>: <value|condition>, <field2>: <value|condition>, ... } }
Here, <field> can specify with dot notation in embedded/nested documents or an array.
In $pull operator, if you specify the <condition> and the array contains the embedded/nested documents, then this operator applies the <condition> as if each array item were a document in a collection.
If you specify a <value> in the $pull operator to remove is an array, then this operator will remove only those items in the array that match the specified <value>. Here, the order must be same.
If you specify a <value> in the $pull operator to remove is a document, then this operator will remove only those items in the array that have exact same fields and values. Here, the order of the fields can differ.
You can use this operator with methods like update(), findAndModify(), etc., according to your requirement.
In the following examples, we are working with:
Database: GeeksforGeeksCollection: contributorDocument: two documents that contain the details of the contributor in the form of field-value pairs.
In this example, we are removing the specified elements, i.e., [“C#”, “Perl”] from the language field.
db.contributor.update({},... {$pull: {language: {$in: ["C#", "Perl"]}}},... {multi: true})
In this example, we are removing semester marks that are less than and equal to ($lte) 73 from the personal.semesterMarks field in the document that matches the specified condition, i.e., name: “Rohit”.
db.contributor.update({name: "Rohit"},                       {$pull: {"personal.semesterMarks": {$lte: 75}}})
In this example, we are removing language: “Java” and tArticles: 50 items from the array of documents, i.e., articles field.
db.contributor.update({}, ... {$pull: {articles: {language: "Java", tArticles: 50}}}, ... {multi: true})
MongoDB
MongoDB-operators
MongoDB
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Spring Boot JpaRepository with Example
Aggregation in MongoDB
MongoDB - db.collection.Find() Method
MongoDB - Check the existence of the fields in the specified collection
Mongoose Populate() Method
How to build a basic CRUD app with Node.js and ReactJS ?
Upsert in MongoDB
How to connect MongoDB with ReactJS ?
MongoDB - Distinct() Method
MongoDB - limit() Method
Replace dot with comma on MySQL SELECT?

To replace dot with comma on SELECT, you can use REPLACE().
 Following is the syntax −
select replace(yourColumnName, '.' , ',' ) from yourTableName;
Let us first create a table −
mysql> create table DemoTable
(
   Value float
);
Query OK, 0 rows affected (0.63 sec)
Insert records in the table using insert command −
mysql> insert into DemoTable values(4.56);
Query OK, 1 row affected (0.15 sec)
mysql> insert into DemoTable values(456.23);
Query OK, 1 row affected (0.12 sec)
mysql> insert into DemoTable values(1078.3);
Query OK, 1 row affected (0.22 sec)
mysql> insert into DemoTable values(2000.50);
Query OK, 1 row affected (0.26 sec)
mysql> insert into DemoTable values(78.99);
Query OK, 1 row affected (0.16 sec)
Display records from the table using select command −
mysql> select *from DemoTable;
This will produce the following output −
+--------+
| Value  |
+--------+
| 4.56   |
| 456.23 |
| 1078.3 |
| 2000.5 |
| 78.99  |
+--------+
5 rows in set (0.00 sec)
Following is the query to replace dot with comma on SELECT −
mysql> select replace(Value,'.',',') from DemoTable;
This will produce the following output −
+------------------------+
| replace(Value,'.',',') |
+------------------------+
| 4,56                   |
| 456,23                 |
| 1078,3                 |
| 2000,5                 |
| 78,99                  |
+------------------------+
5 rows in set (0.07 sec)
Java Program to set the height of only a single row in a JTable with multiple rows

To set the row height, use the setRowHeight and set a parameter that would be the number of pixels you need to set the row height.
However, if you want to set the row height of a single row then you need to use the same method, but set an additional parameter as shown below −
table.setRowHeight(3, 30);
The above sets row height to 30 pixels for row index 4.
The following is an example to set the height of a row in a table −
package my;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
public class SwingDemo {
   public static void main(String[] argv) throws Exception {
      DefaultTableModel tableModel = new DefaultTableModel();
      JTable table = new JTable(tableModel);
      tableModel.addColumn("Language/ Technology");
      tableModel.addColumn("Text Tutorial");
      tableModel.addColumn("Video Tutorial");
      tableModel.addColumn("Interview QA");
      tableModel.addRow(new Object[] { "Blockchain", "Yes", "No", "Yes"});
      tableModel.addRow(new Object[] { "C#", "Yes", "Yes", "Yes"});
      tableModel.addRow(new Object[] { "Java", "Yes", "No", "Yes"});
      tableModel.addRow(new Object[] { "NodeJS", "No", "Yes", "Yes"});
      tableModel.addRow(new Object[] { "MVC", "Yes", "No", "Yes"});
      tableModel.addRow(new Object[] { "ASP.NET", "Yes", "Yes", "Yes"});
      tableModel.addRow(new Object[] { "F#", "Yes", "No", "Yes"});
      tableModel.addRow(new Object[] { "SharePoint", "Yes", "Yes", "Yes"});
      tableModel.addRow(new Object[] { "AWS", "No", "No", "Yes"});
      table.setRowHeight(3, 30);
      JFrame f = new JFrame();
      f.setSize(600, 400);
      f.add(new JScrollPane(table));
      f.setVisible(true);
   }
}
The output is as follows. Here, we have set the row height for row 4 −
Load and unload a table in SAP HANA using SQL query

In SAP HANA, it is possible to manually load and unload individual tables and table columns.
You can perform loading of table to precisely measure the total or “worst case” amount of memory used by a particular table.
A table is unload from database to actively free up memory.
You can use following SQL queries to perform load/unload of table −
LOAD <table_name>
UNLOAD <table_name>
SQL Tryit Editor v1.6

SELECT * FROM Customers
WHERE City LIKE 'ber%';
​
Edit the SQL Statement, and click "Run SQL" to see the result.
This SQL-Statement is not supported in the WebSQL Database.
The example still works, because it uses a modified version of SQL.
Your browser does not support WebSQL.
Your are now using a light-version of the Try-SQL Editor, with a read-only Database.
If you switch to a browser with WebSQL support, you can try any SQL statement, and play with the Database as much as you like. The Database can also be restored at any time.
Our Try-SQL Editor uses WebSQL to demonstrate SQL.
A Database-object is created in your browser, for testing purposes.
You can try any SQL statement, and play with the Database as much as you like. The Database can be restored at any time, simply by clicking the "Restore Database" button.
WebSQL stores a Database locally, on the user's computer. Each user gets their own Database object.
WebSQL is supported in Chrome, Safari, Opera, and Edge(79).
If you use another browser you will still be able to use our Try SQL Editor, but a different version, using a server-based ASP application, with a read-only Access Database, where users are not allowed to make any changes to the data.
Python - Merge Pandas DataFrame with Right Outer Join

To merge Pandas DataFrame, use the merge() function. The right outer join is implemented on both the DataFrames by setting under the “how” parameter of the merge() function i.e. −
how = “right”
At first, let us import the pandas library with an alias −
import pandas as pd

Create two dataframes to be merged −
# Create DataFrame1
dataFrame1 = pd.DataFrame(
   {
      "Car": ['BMW', 'Lexus', 'Audi', 'Mustang', 'Bentley', 'Jaguar'],"Units": [100, 150, 110, 80, 110, 90]
   }
)

# Create DataFrame2
dataFrame2 = pd.DataFrame(
   {
      "Car": ['BMW', 'Lexus', 'Tesla', 'Mustang', 'Mercedes', 'Jaguar'],"Reg_Price": [7000, 1500, 5000, 8000, 9000, 6000]
   }
)
Merge DataFrames with common column Car and "right" in "how" parameter implements Right Outer Join −
mergedRes = pd.merge(dataFrame1, dataFrame2, on ='Car', how ="right")

Following is the code −
import pandas as pd

# Create DataFrame1
dataFrame1 = pd.DataFrame(
   {
      "Car": ['BMW', 'Lexus', 'Audi', 'Mustang', 'Bentley', 'Jaguar'],"Units": [100, 150, 110, 80, 110, 90]
   }
)

print"DataFrame1 ...\n",dataFrame1

# Create DataFrame2
dataFrame2 = pd.DataFrame(
   {
      "Car": ['BMW', 'Lexus', 'Tesla', 'Mustang', 'Mercedes', 'Jaguar'],"Reg_Price": [7000, 1500, 5000, 8000, 9000, 6000]

   }
)

print"\nDataFrame2 ...\n",dataFrame2

# merge DataFrames with common column Car and "right" in "how" parameter implements Right Outer Join
mergedRes = pd.merge(dataFrame1, dataFrame2, on ='Car', how ="right")
print"\nMerged dataframe with right outer join...\n", mergedRes
This will produce the following output −
DataFrame1 ...
       Car   Units
0      BMW     100
1    Lexus     150
2     Audi     110
3  Mustang      80
4  Bentley     110
5   Jaguar      90

DataFrame2 ...
        Car   Reg_Price
0       BMW        7000
1     Lexus        1500
2     Tesla        5000
3   Mustang        8000
4  Mercedes        9000
5    Jaguar        6000

Merged dataframe with right outer join...
        Car   Units   Reg_Price
0       BMW   100.0        7000
1     Lexus   150.0        1500
2   Mustang    80.0        8000
3    Jaguar    90.0        6000
4     Tesla     NaN        5000
5  Mercedes     NaN        9000
Finding average marks of students for different subjects and display only the highest average marks in MySQL

For this, you can use subquery. Let us first create a table −
mysql> create table DemoTable
(
   StudentName varchar(40),
   StudentMarks int
);
Query OK, 0 rows affected (0.50 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('Adam',56);
Query OK, 1 row affected (0.14 sec)
mysql> insert into DemoTable values('Chris',78);
Query OK, 1 row affected (0.13 sec)
mysql> insert into DemoTable values('Adam',89);
Query OK, 1 row affected (0.13 sec)
mysql> insert into DemoTable values('Robert',98);
Query OK, 1 row affected (0.19 sec)
mysql> insert into DemoTable values('Chris',65);
Query OK, 1 row affected (0.11 sec)
mysql> insert into DemoTable values('Robert',34);
Query OK, 1 row affected (0.20 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+-------------+--------------+
| StudentName | StudentMarks |
+-------------+--------------+
| Adam        |           56 |
| Chris       |           78 |
| Adam        |           89 |
| Robert      |           98 |
| Chris       |           65 |
| Robert      |           34 |
+-------------+--------------+
6 rows in set (0.00 sec)
Following is the query to find average marks of students and display only the highest average marks −
mysql> select max(avSal.StudentMarks)
from (select avg(StudentMarks) as `StudentMarks` from DemoTable group by StudentName) as avSal;
This will produce the following output −
+-------------------------+
| max(avSal.StudentMarks) |
+-------------------------+
|                 72.5000 |
+-------------------------+
1 row in set (0.09 sec)
How to flush the internal buffer in Python?

Python buffers writes to files. That is, file.write returns before the data is actually written to your hard drive. The main motivation of this is that a few large writes are much faster than many tiny writes, so by saving up the output of file.write until a bit has accumulated, Python can maintain good writing speeds.
file.flush forces the data to be written out at that moment. To flush contents you wrote actually to the file, use:
with open("my_file.txt", "w+") as file:
    file.write("foo")
    file.write("bar")
     file.flush()
Java - String Buffer append() Method

This method updates the value of the object that invoked the method. The method takes boolean, char, int, long, Strings, etc.
Here is a separate method for each primitive data type −
public StringBuffer append(boolean b)
public StringBuffer append(char c)
public StringBuffer append(char[] str)
public StringBuffer append(char[] str, int offset, int len)
public StringBuffer append(double d)
public StringBuffer append(float f)
public StringBuffer append(int i)
public StringBuffer append(long l)
public StringBuffer append(Object obj)
public StringBuffer append(StringBuffer sb)
public StringBuffer append(String str)

Here is the detail of parameters −
Here the parameter depends on what you are trying to append in the String Buffer.
Here the parameter depends on what you are trying to append in the String Buffer.
These methods return the updated StringBuffer objects.
public class Test {

   public static void main(String args[]) {
      StringBuffer sb = new StringBuffer("Test");
      sb.append(" String Buffer");
      System.out.println(sb); 
   }  
}
This will produce the following result −
Test String Buffer


    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
Difference between ++*p, *p++ and *++p in c++

In this section we will see what are the differences between *ptr++, *++ptr and ++*ptr in C++.
Here we will see the precedence of postfix++ and prefix++ in C or C++. The precedence of prefix ++ or -- has higher priority than dereference operator ‘*’ and postfix ++ or -- has priority higher than both prefix ++ and dereference operator ‘*’.
When ptr is a pointer, then *ptr++ indicates *(ptr++) and ++*prt refers ++(*ptr)
 Live Demo
#include<iostream>
using namespace std;
int main() {
   char arr[] = "Hello World";
   char *ptr = arr;
   ++*ptr;
   cout << *ptr;
   return 0;
}
I
So here at first ptr is pointing ‘H’. after using ++*ptr it increases H by 1, and now the value is ‘I’.
#include<iostream>
using namespace std;
int main() {
   char arr[] = "Hello World";
   char *ptr = arr;
   *ptr++;
   cout << *ptr;
   return 0;
}
e
So here at first ptr is pointing ‘H’. after using *ptr++ it increases the pointer, so ptr will point to the next element. so the result is ‘e’.
 Live Demo
#include<iostream>
using namespace std;
int main() {
   char arr[] = "Hello World";
   char *ptr = arr;
   *++ptr;
   cout << *ptr;
   return 0;
}
e
In this example also we are increasing the ptr using ++, where the precedence of pre-increment ++ is higher, then it increases the pointer first, then taking the value using *. so it is printing ‘e’.
Selenium Webdriver submit() vs click().

The click() and submit() functions are quite similar in terms of functionalities. However there are minor differences. Let us discuss some differences between them.
The submit() function is applicable only for <form> and makes handling of form easier. It can be used with any element inside a form. The click() is only applicable to buttons with type submit in a form.
The submit() function shall wait for the page to load however the click() waits only if any explicit wait condition is provided. If a form has a submit of type button, the submit() method cannot be used. Also, if a button is outside <form>, then submit() will not work.
Thus we see that click() works for both type buttons irrespective of the fact that the button is inside or outside of <form>. Let us take up the below form for implementation.
Code Implementation with submit().
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import java.util.concurrent.TimeUnit;
public class SubmitForm{
   public static void main(String[] args) {
      System.setProperty("webdriver.chrome.driver", "C:\\Users\\ghs6kor\\Desktop\\Java\\chromedriver.exe");
      WebDriver driver = new ChromeDriver();
      String url = "https://www.facebook.com/";
      driver.get(url);
      driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
      // identify elements
      driver.findElement(By.id("email")).sendKeys("abc@gmail.com");
      driver.findElement(By.id("pass")).sendKeys("123456");
      // submitting form with submit()
      driver.findElement(By.id("pass")).submit();
      driver.quit()
   }
}
Code Implementation with click().
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import java.util.concurrent.TimeUnit;
public class ClickForm{
   public static void main(String[] args) {
      System.setProperty("webdriver.chrome.driver", "C:\\Users\\ghs6kor\\Desktop\\Java\\chromedriver.exe");
      WebDriver driver = new ChromeDriver();
      String url = "https://www.facebook.com/";
      driver.get(url);
      driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
      // identify elements
      driver.findElement(By.id("email")).sendKeys("abc@gmail.com");
      driver.findElement(By.id("pass")).sendKeys("123456");
      // submitting form with click()
      driver.findElement(By.name("login")).click();
      driver.quit()
   }
}
Avoid Unexpected string concatenation in JavaScript?

To avoid unexpected string concatenation while concatenating strings, multiple strings, and numbers, use backticks.
We have the following −
const concatValue = 'John,David,Mike';
var friendNames= `${concatValue}`;
The above value is concatenated with a string and number −
var studentNameWithFriends=` ${concatValue}| 'Carol' | 24 ` ;
Following is the complete JavaScript code for concatenation −
const concatValue = 'John,David,Mike';
var friendNames= `${concatValue}`;
var studentNameWithFriends=` ${concatValue}| 'Carol' | 24 ` ;
console.log(friendNames);
console.log(studentNameWithFriends);
To run the above program, you need to use the following command −
node fileName.js.
Here, my file name is demo37.js
This will produce the following output −
PS C:\Users\Amit\JavaScript-code> node demo37.js
John,David,Mike
John,David,Mike| 'Carol' | 24
How to set the current figure in Matplotlib?

Using the figure() method, we can set the current figure.
Create a new figure, or activate an existing figure, with the window title “Welcome to figure 1”.
Create a new figure, or activate an existing figure, with the window title “Welcome to figure 1”.
Create a new figure, or activate an existing figure, with the window title “Welcome to figure 2”.
Create a new figure, or activate an existing figure, with the window title “Welcome to figure 2”.
Using plt.show(), show the figures.
Using plt.show(), show the figures.
from matplotlib import pyplot as plt

plt.figure("Welcome to figure 1")
plt.figure("Welcome to figure 2")    # Active Figure

plt.show()
How to calculate the ln of a given number in JavaScript?


To calculate the ln of a given number, use the Math.log() method in JavaScript. This method returns the natural logarithm (base E) of a number. If the value of a number is negative, the return value is always NaN.
You can try to run the following code to get the ln of a given number −
<html>
   <head>
      <title>JavaScript Math log() Method</title>
   </head>
   <body>
      <script>
         var value = Math.log(2);
         document.write("Value : " + value );
      </script>
   </body>
</html>
Java.util.BitSet.flip() in Java

16 Aug, 2018
There are two variants of flip() method. This article depicts about all of them as follows:
1. flip(int value) : This method removes the value specified in the argument.
public void flip(int value)

Parameters : 
value :  the value to flip.
Return ValueThis method does not return a value.

// Java code to demonstrate the// working of flip(int value) in Bitset  import java.util.*;  public class Flip1 {  public static void main(String[] args) {         // declaring bitset  BitSet bset = new BitSet(6);     // assigning values to bset  bset.set(0);  bset.set(1);  bset.set(2);  bset.set(3);    // printing the original set  System.out.println("The original bitset is : " + bset);     // using flip() to remove 2  bset.flip(2);         //  printing final bitset  // 2 is removed  System.out.println("The flipped bitset is : " + bset);  }}
Output:
The original bitset is : {0, 1, 2, 3}
The flipped bitset is : {0, 1, 3}

2. flip(int fromnum, int tonum) : This method sets each bit from the specified fromnum (inclusive) to the specified tonum (exclusive) to the complement of its current value, i.e removes fromnum to tonum-1 values.
public void flip(int fromnum,int tonum)
Parameters : 
fromnum :  start number to begin flipping.
tonum :  last-1 number to end flipping.
Return Value : 
This method does not return a value.

// Java code to demonstrate the// working of flip(int fromnum, int tonum) in Bitset  import java.util.*;  public class Flip2 {  public static void main(String[] args) {         // declaring bitset  BitSet bset = new BitSet(6);     // assigning values to bset  bset.set(0);  bset.set(1);  bset.set(2);  bset.set(3);    // printing the original set  System.out.println("The original bitset is : " + bset);     // using flip(fromnum,tonum) to remove 1 and 2  bset.flip(1,3);         //  printing final bitset  // 1 and 2 are removed  System.out.println("The flipped bitset is : " + bset);  }}
Output:
The original bitset is : {0, 1, 2, 3}
The flipped bitset is : {0, 3}

This article is contributed by Astha Tyagi. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Java - util package
Java-BitSet
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.