code-rag-bench/online-tutorials huggingface dataset:
Console.Clear Method in C#

The Console.Clear method in C# is used to clear the console buffer and corresponding console window of display information.
Following is the syntax −
public static void Clear ();
Let us now see an example before implementing the Console.Clear method −
using System;
public class Demo {
   public static void Main(){
      Uri newURI1 = new Uri("https://www.tutorialspoint.com/");
      Console.WriteLine("URI = "+newURI1);
      Console.WriteLine("String representation = "+newURI1.ToString());
      Uri newURI2 = new Uri("https://www.tutorialspoint.com/jquery.htm#abcd");
      Console.WriteLine("\nURI = "+newURI2);
      Console.WriteLine("String representation = "+newURI2.ToString());
      if(newURI1.Equals(newURI2))
         Console.WriteLine("\nBoth the URIs are equal!");
      else
         Console.WriteLine("\nBoth the URIs aren't equal!");
      Uri res = newURI1.MakeRelativeUri(newURI2);
      Console.WriteLine("Relative uri = "+res);
}
}
This will produce the following output before using Console.Clear() −
URI = https://www.tutorialspoint.com/
String representation = https://www.tutorialspoint.com/
URI = https://www.tutorialspoint.com/jquery.htm#abcd
String representation = https://www.tutorialspoint.com/jquery.htm#abcd
Both the URIs aren't equal!
Relative uri = jquery.htm#abcd
Let us now see the same example to implement the Console.Clear method −
using System;
public class Demo {
   public static void Main(){
      Uri newURI1 = new Uri("https://www.tutorialspoint.com/");
      Console.WriteLine("URI = "+newURI1);
      Console.WriteLine("String representation = "+newURI1.ToString());
      Uri newURI2 = new Uri("https://www.tutorialspoint.com/jquery.htm#abcd");
      Console.WriteLine("\nURI = "+newURI2);
      Console.WriteLine("String representation = "+newURI2.ToString());
      if(newURI1.Equals(newURI2))
         Console.WriteLine("\nBoth the URIs are equal!");
      else
         Console.WriteLine("\nBoth the URIs aren't equal!");
      Uri res = newURI1.MakeRelativeUri(newURI2);
      Console.WriteLine("Relative uri = "+res);
      Console.Clear();
      Console.WriteLine("Console cleared now!");
   }
}
This will produce the following output −
Console cleared now!
Find the Number of Substrings of One String Present in Other using C++

In this article, we are given two strings, and we need to find out how many substrings of the 1st string can be found in the 2nd string(the exact substring can occur multiple times). For example
Input : string1 = “fogl”
   string2 = “google”
Output : 6
Explanation : substrings of string1 present in string2 are [ “o”, “g”, “l”, “og”, “gl”,
“ogl” ].

Input : string1 = “ajva”
   string2 = “java”
Output : 5
Explanation : substrings of string1 present in string2 are [ “a”, “j”, “v”, “a”, “va” ].
Let's discuss how we can solve this problem of finding several substrings present in another string; looking at the examples; we understood that first, we have to see all the substrings of string1 and then we have to check each substring whether it is present in another string or not, If yes then increment the counter and after operating whole string check the result stored in the counter.
Here is the C++ syntax which we can use as an input to solve the given problem −
#include<iostream>
#include<string>
using namespace std;

int main() {
   string str1 = "ajva";
   string str2 = "java";
   int count = 0;// counter to store result
   int n = str1.length();

   for (int i = 0; i < n; i++) {

      string str3; // string3 is initialised to store all substrings of string1
      for (int j = i; j < n; j++) {
         str3 += str1[j];

         // checking whether substring present in another string or not
         if (str2.find(str3) != string::npos)
            count++;
      }
   }
   cout << "Number of substrings of one string present in other : "<< count;
   return 0;
}
Number of substrings of one string present in other : 5
Firstly, in this code, we are giving value to both the strings and initializing the counter with 0. We are going through the whole string and finding all the substrings possible of str1 and storing them in str3. Then we check each substring of str1, whether present in str2 or not; if yes, then increment the counter by 1 and we are finally printing the output stored in the counter variable.
This article finds the simple solution of finding the number of substrings of one string present in another string. We can write the same program in other languages such as C, java, python, and other languages. We hope you find this article helpful.
C++ | Virtual Functions | Question 6

28 Jun, 2021
Predict the output of following program.
#include<iostream>using namespace std;class Base{public:    virtual void show() = 0;};  class Derived : public Base { };  int main(void){    Derived q;    return 0;}
(A) Compiler Error: there cannot be an empty derived class(B) Compiler Error: Derived is abstract(C) No compiler ErrorAnswer: (B)Explanation: If we don’t override the pure virtual function in derived class, then derived class also becomes abstract class.
Quiz of this Question
C++-Virtual Functions
Virtual Functions
C Language
C++ Quiz
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Substring in C++
Function Pointer in C
Multidimensional Arrays in C / C++
Left Shift and Right Shift Operators in C/C++
Different Methods to Reverse a String in C++
C++ | Function Overloading and Default Arguments | Question 2
C++ | Static Keyword | Question 3
C++ | References | Question 4
C++ | new and delete | Question 4
C++ | const keyword | Question 1
Template Metaprogramming in C++

19 Aug, 2021
Predict the output of following C++ program. 
CPP
#include <iostream>using namespace std; template<int n> struct funStruct{    enum { val = 2*funStruct<n-1>::val };}; template<> struct funStruct<0>{    enum { val = 1 };}; int main(){    cout << funStruct<8>::val << endl;    return 0;}
Output: 
256
The program calculates “2 raise to the power 8 (or 2^8)”. In fact, the structure funStruct can be used to calculate 2^n for any known n (or constant n). The special thing about above program is: calculation is done at compile time. So, it is compiler that calculates 2^8. To understand how compiler does this, let us consider the following facts about templates and enums:1) We can pass nontype parameters (parameters that are not data types) to class/function templates. 2) Like other const expressions, values of enumeration constants are evaluated at compile time. 3) When compiler sees a new argument to a template, compiler creates a new instance of the template.Let us take a closer look at the original program. When compiler sees funStruct<8>::val, it tries to create an instance of funStruct with parameter as 8, it turns out that funStruct<7> must also be created as enumeration constant val must be evaluated at compile time. For funStruct<7>, compiler need funStruct<6> and so on. Finally, compiler uses funStruct<1>::val and compile time recursion terminates. So, using templates, we can write programs that do computation at compile time, such programs are called template metaprograms. Template metaprogramming is in fact Turing-complete, meaning that any computation expressible by a computer program can be computed, in some form, by a template metaprogram. Template Metaprogramming is generally not used in practical programs, it is an interesting concept though. Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above. 
varshagumber28
kapoorsagar226
C Language
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | Reverse each word in a sentence

29 Jun, 2022
Given a long sentence, reverse each word of the sentence individually in the sentence itself. Examples:
Input : Geeks For Geeks is good to learn
Output : skeeG roF skeeG si doog ot nrael

Input : Split Reverse Join
Output : tilpS esreveR nioJ
We shall use Python’s built in library function to reverse each word individually in the string itself. Prerequisites : 1. split() 2. Reversing Techniques in Python 3. List Comprehension Method in python 4. join()
First split the sentence into list of words.
Reverse each word of the string in the list individually.
Join the words in the list to form a new sentence.
Below is the implementation of above idea.
Python3
# Python code to Reverse each word# of a Sentence individually # Function to Reverse wordsdef reverseWordSentence(Sentence):     # Splitting the Sentence into list of words.    words = Sentence.split(" ")         # Reversing each word and creating    # a new list of words    # List Comprehension Technique    newWords = [word[::-1] for word in words]         # Joining the new list of words    # to for a new Sentence    newSentence = " ".join(newWords)     return newSentence # Driver's CodeSentence = "GeeksforGeeks is good to learn"# Calling the reverseWordSentence# Function to get the newSentenceprint(reverseWordSentence(Sentence))
Output:
skeeGrofskeeG si doog ot nrael
Python is well known for its short codes. We shall do the same task but with lesser line of codes. 
Python3
# Python code to Reverse each word# of a Sentence individually # Function to Reverse wordsdef reverseWordSentence(Sentence):     # All in One line    return ' '.join(word[::-1] for word in Sentence.split(" ")) # Driver's CodeSentence = "Geeks for Geeks"print(reverseWordSentence(Sentence))   
Output:
skeeG rof skeeG
Approach#3: Using re.sub() function We can use re.sub() function to replace the words in sentence with reversed words in sentence. We capture the word in string with the help of group method and replace it with reversed word. 
Python3
# Python code to Reverse each word# of a Sentence individuallyimport re# Function to Reverse wordsdef reverseWordSentence(Sentence):     # substiting revrese word in place of word in sentence    newSentence = re.sub('(\w+)', lambda x : x.group()[::-1], Sentence)     return newSentence # Driver's CodeSentence = "GeeksforGeeks is good to learn"# Calling the reverseWordSentence# Function to get the newSentenceprint(reverseWordSentence(Sentence))
Output:
skeeGrofskeeG si doog ot nrael
Akanksha_Rai
shubham_singh
satyam00so
python-string
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Iterate over a list in Python
Introduction To PYTHON
PHP | log(), log10() Functions

30 Oct, 2020
Logarithm is the counter operation to exponentiation. The logarithm of a number is in fact the exponent to which the other number i.e. the base must be raised to produce that number. If the Euler’s Number ‘e’ is used as the base of any logarithmic operation it is then known as Natural Logarithmic Operation, another popular logarithmic operation is to take 10 as the base.
In PHP, the log() function is used to calculate the natural logarithm of a number if no base is specified and the log10() function calculates the base 10 logarithm of a number.
log() Function
Syntax:
float log ($arg, $base)

Parameters: The function can accept at most two parameters as follows:
$arg: This is a required parameter that refers to the number of whose the logarithm is to be calculated.
$base: This is an optional parameter that refers to the base of the logarithmic operation. If not given, M_E i.e. the Euler’s Number is used as Base to calculate the Natural Logarithm.
Return Type: This function returns the result of the logarithmic operation.
Examples:
Input :  $arg = M_E * M_E;
Output : 2

Input : $arg = 1024;
        $base = 2;
Output : 10    

Below program illustrates the working of log() in PHP:
<?php// PHP code to illustrate the working of log() Function $arg = 81;$base = 3;for(;$base<=$arg;$base*=$base)  echo 'log('.$arg.', '.$base.') = '.log($arg, $base)."\n";?>
Output:
log(81, 3) = 4
log(81, 9) = 2
log(81, 81) = 1

log10() Function
Syntax:
float log10 ($arg)

Parameters: The function accepts a single parameter $arg which refers to the number of whose the logarithm is to be calculated.
Return Type: This function returns the result of the Base 10 logarithmic operation.
Examples:
Input :  $arg = 100;
Output : 2

Input : $arg = 10000;
        $base = 4;
Output : 10    

Below program illustrates the working of log10() in PHP:
<?php// PHP code to illustrate the working of log10() Function $arg = 100000;for(;$arg>=10;$arg/=10)  echo 'log10('.$arg.') = '.log10($arg)."\n";?>
Output:
log10(100000) = 5
log10(10000) = 4
log10(1000) = 3
log10(100) = 2
log10(10) = 1

Important points to note:
log() function is a very popular method to calculate logarithmic values.
PHP | exp() function is the functional counterpart of log().
arorakashish0911
PHP-function
PHP-math
PHP
Web Technologies
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to fetch data from localserver database and display on HTML table using PHP ?
Difference between HTTP GET and POST Methods
Different ways for passing data to view in Laravel
PHP | file_exists( ) Function
PHP | Ternary Operator
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
PyQt - QRadioButton Widget

A QRadioButton class object presents a selectable button with a text label. The user can select one of many options presented on the form. This class is derived from QAbstractButton class.
Radio buttons are autoexclusive by default. Hence, only one of the radio buttons in the parent window can be selected at a time. If one is selected, previously selected button is automatically deselected. Radio buttons can also be put in a QGroupBox or QButtonGroup to create more than one selectable fields on the parent window.
The following listed methods of QRadioButton class are most commonly used.
setChecked()
Changes the state of radio button
setText()
Sets the label associated with the button
text()
Retrieves the caption of button
isChecked()
Checks if the button is selected
Default signal associated with QRadioButton object is toggled(), although other signals inherited from QAbstractButton class can also be implemented.
Here two mutually exclusive radio buttons are constructed on a top level window.
Default state of b1 is set to checked by the statement −
Self.b1.setChecked(True)

The toggled() signal of both the buttons is connected to btnstate() function. Use of lambda allows the source of signal to be passed to the function as an argument.
self.b1.toggled.connect(lambda:self.btnstate(self.b1))
self.b2.toggled.connect(lambda:self.btnstate(self.b2))

The btnstate() function checks state of button emitting toggled() signal.
if b.isChecked() == True:
      print b.text()+" is selected"
   else:
      print b.text()+" is deselected"
		
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *

class Radiodemo(QWidget):

   def __init__(self, parent = None):
      super(Radiodemo, self).__init__(parent)
		
      layout = QHBoxLayout()
      self.b1 = QRadioButton("Button1")
      self.b1.setChecked(True)
      self.b1.toggled.connect(lambda:self.btnstate(self.b1))
      layout.addWidget(self.b1)
		
      self.b2 = QRadioButton("Button2")
      self.b2.toggled.connect(lambda:self.btnstate(self.b2))

      layout.addWidget(self.b2)
      self.setLayout(layout)
      self.setWindowTitle("RadioButton demo")
		
   def btnstate(self,b):
	
      if b.text() == "Button1":
         if b.isChecked() == True:
            print b.text()+" is selected"
         else:
            print b.text()+" is deselected"
				
      if b.text() == "Button2":
         if b.isChecked() == True:
            print b.text()+" is selected"
         else:
            print b.text()+" is deselected"
				
def main():

   app = QApplication(sys.argv)
   ex = Radiodemo()
   ex.show()
   sys.exit(app.exec_())
	
if __name__ == '__main__':
   main()
The above code produces the following output −
Button1 is deselected
Button2 is selected
Button2 is deselected
Button1 is selected
How to Eliminate Duplicate Values Based on Only One Column of the Table in SQL?

28 Nov, 2021
In SQL, some rows contain duplicate entries in a column. For deleting such rows, we need to use the DELETE keyword along with self-joining the table with itself. The same is illustrated below. For this article, we will be using the Microsoft SQL Server as our database.
Step 1: Create a Database. For this use the below command to create a database named GeeksForGeeks.
Query:
CREATE DATABASE GeeksForGeeks
Output:
Step 2: Use the GeeksForGeeks database. For this use the below command.
Query:
USE GeeksForGeeks
Output:
Step 3: Create a table BONUSES inside the database GeeksForGeeks. This table has 3 columns namely EMPLOYEE_ID, EMPLOYEE_NAME, and EMPLOYEE_BONUS containing the id of the employee, the name of the employee, and his/her bonus.
Query:
CREATE TABLE BONUSES(
EMPLOYEE_ID INT,
EMPLOYEE_NAME VARCHAR(10),
EMPLOYEE_BONUS INT);
Output:
Step 4: Describe the structure of the table BONUSES.
Query:
EXEC SP_COLUMNS BONUSES;
Output:
Step 5: Insert 10 rows into the BONUSES table.
Query:
INSERT INTO BONUSES VALUES(1,'RAJ',10000);
INSERT INTO BONUSES VALUES(2,'RAJIV',10000);
INSERT INTO BONUSES VALUES(3,'RAJ',20000);
INSERT INTO BONUSES VALUES(4,'SAMEER',20000);
INSERT INTO BONUSES VALUES(5,'PANKAJ',30000);
INSERT INTO BONUSES VALUES(6,'HARRY',30000);
INSERT INTO BONUSES VALUES(7,'VAUN',40000);
INSERT INTO BONUSES VALUES(8,'SANGWOO',40000);
INSERT INTO BONUSES VALUES(9,'SAM',50000);
INSERT INTO BONUSES VALUES(10,'TIM',50000);
Output:
Step 6: Display all the rows of the BONUSES table.
Query:
SELECT * FROM BONUSES;
Output:
Step 7: Delete rows from the table BONUSES which have duplicate entries in the column EMPLOYEE_BONUS. To achieve this, we use the DELETE function by self joining(use JOIN function on 2 aliases of the table i.e. B1 and B2) the table with itself and comparing the entries of the column EMPLOYEE_BONUS for different entries of the column EMPLOYEE_ID because ID is unique for each employee.
Syntax:
DELETE T1 FROM TABLE_NAME T1
JOIN TABLE_NAME T2
ON T1.COLUMN_NAME1 = T2.COLUMN_NAME1
AND T2.COLUMN_NAME2 < T1.COLUMN_NAME2;
Query:
DELETE B1 FROM BONUSES B1
JOIN BONUSES B2
ON B1.EMPLOYEE_BONUS = B2.EMPLOYEE_BONUS
AND B2.EMPLOYEE_ID < B1.EMPLOYEE_ID;
Output:
Step 8: Display all the rows of the updated BONUSES table.
Query:
SELECT * FROM BONUSES;
Note – No row has duplicate entries in the column EMPLOYEE_BONUS.
Output:
Step 9: Delete rows from the table BONUSES which have duplicate entries in the column EMPLOYEE_NAME.
Query:
DELETE B1 FROM BONUSES B1
JOIN BONUSES B2
ON B1.EMPLOYEE_NAME = B2.EMPLOYEE_NAME
AND B2.EMPLOYEE_ID < B1.EMPLOYEE_ID;
Output:
Step 10: Display all the rows of the updated BONUSES table.
Query:
SELECT * FROM BONUSES;
Note: No row has duplicate entries in the column EMPLOYEE_NAME.
Output:
Picked
SQL-Query
SQL-Server
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
SQL Query to Exclude Records if it Matches an Entry in Another Table

17 May, 2022
In this article, we will see, how to write the SQL Query to exclude records if it matches an entry in another table. We can perform the above function using the NOT IN operator in SQL. For obtaining the list of values we can write the subquery.
NOT IN operators acts as a negation of In operator and return the results excluding the items present in the specified list.
Syntax: NOT IN 
SELECT * FROM table_name WHERE column_name NOT IN (list);
Now, for the demonstration follow the below steps:
Step 1: Create a database
we can use the following command to create a database called geeks.
Query:
CREATE DATABASE geeks;
Step 2: Use the database
Use the below SQL statement to switch the database context to geeks:
Query:
USE geeks;
Step 3: Table definition
We have two tables named ‘demo_table1’ and ‘demo_table2’ in our geek’s database.
Query(demo_table1):
CREATE TABLE demo_table1(
NAME VARCHAR(20),
AGE INT,
CITY VARCHAR(20) );
Query(demo_table2):
CREATE TABLE demo_table2(
NAME VARCHAR(20),
AGE int);
Step 4: Insert data into a table
Query(demo_table1):
INSERT INTO demo_table1 VALUES
('Romy',23,'Delhi'),
('Rahul',23,'Delhi'),
('Nikhil',24,'Punjab'),
('Ranvir',23,'Punjab'),
('Samiksha',23,'Banglore'),
('Ashtha',24,'Banglore'),
('Tannu',30,'Patna'),
('Girish',30,'Patna'),
('Ram', 20 , 'Patna'),
('Raj', 12, 'Delhi');
Query(demo_table2):
INSERT INTO demo_table2 VALUES
('Fanny',25 ),
('Prem', 30), 
('Preeti',21),
('Samita',32),
('Rahul',23),
('Ranvir',23);
Step 5: View the content
Execute the below query to see the content of the table
Query:
SELECT * FROM demo_table1;
Output:
Query:
SELECT * FROM demo_table2;
Output:
Step 6: Exclude data from demo_table1 based on matches found in demo_table2
For the demonstration, exclude the data from demo_table1 whose values in the NAME column match the entries in the Name column of demo_table2.
Query:
SELECT * FROM demo_table1 WHERE NAME NOT IN (SELECT NAME FROM demo_table2);
Output:
We can see in the image that two entries are excluded as the values match from entry in demo_table2.
Alternate Method:
Alternatively, to exclude rows from demo_table1 whose values in the NAME column match the rows in the NAME column in demo_table2, we can perform it with left join.
As we know, the left join returns all the rows in the left table and only matches rows in the right table, so the right table column’s values will be NULL if they don’t have matching rows. Hence, we will this concept of the left join with a condition that the right table’s column value is null.
The query for the above content using Left Join and Condition:
select  t1.* from demo_table1 t1 left join demo_table2 t2 on t1.name = t2.name where t2.name is null
This returns, the required data set.
cr10acsmbyomnuv8xm2zdncmpmtnnbpo1eqf2v0z
Picked
SQL-Query
SQL-Server
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
HTML | <select> name Attribute - GeeksforGeeks

27 May, 2019
The HTML <select> name Attribute is used to specify a name for the drop-down list. It is used to reference the form-data after submitting the form or to reference the element in a JavaScript.
Syntax:
<select name="text"> 
Attribute Values: It contains the value i.e name which specify the name for the <select> element.
Example:
<!DOCTYPE html><html>  <head>    <title>        HTML Select name Attribute    </title></head>  <body style="text-align:center;">      <h1 style="color:green;">         GeeksforGeeks     </h1>      <h2 style="font-family: Impact;">        HTML Select name Attribute     </h2>    <br> Select your preferred   course from the drop-down list:    <br>      <select name="Courses Titles" id="myCourses">        <option value="C++">c++</option>        <option value="Placement">Placement</option>        <option value="Java">Java</option>        <option value="Python">Python</option>    </select>  </body>  </html>
Output:
Supported Browsers:
Google Chrome
Firefox
Edge
Opera
Apple Safari
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
HTML-Attributes
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Insert Form Data into Database using PHP ?
REST API (Introduction)
How to position a div at the bottom of its container using CSS?
Form validation using HTML and JavaScript
HTML Cheat Sheet - A Basic Guide to HTML
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 ?
Difference between var, let and const keywords in JavaScript
Get Indian Railways Station code Using Python - GeeksforGeeks

29 Dec, 2020
Web scraping is a technique to fetch data from websites. While surfing on the web, many websites don’t allow the user to save data for personal use. One way is to manually copy-paste the data, which both tedious and time-consuming. Web Scraping is the automation of the data extraction process from websites. This event is done with the help of web scraping software known as web scrapers.
In this article, we are going to write Python scripts to scrape the Railways Station code using their city name.
Examples:
Input: new-delhi
Output: NDLS

Input: Patna
Output: PNBE

bs4: Beautiful Soup(bs4) is a Python library for pulling data out of HTML and XML files. This module does not come built-in with Python. To install this type the below command in the terminal.
pip install bs4

requests: Request allows you to send HTTP/1.1 requests extremely easily. This module also does not come built-in with Python. To install this type the below command in the terminal.
pip install requests

Let’s see the stepwise execution of the script.
Step 1: Import all dependence
Python3
# import moduleimport requestsfrom bs4 import BeautifulSoup
Step 2: Create a URL get function
Python3
# user define function # Scrape the data def getdata(url):     r = requests.get(url)     return r.text
Step 3:Now merge the City name into URL and pass the URL into the getdata() function and Convert that data into HTML code.
Python3
# input by geekstation = "new-delhi"  # urlurl = "https://www.mapsofindia.com/railways/station-code/"+station+".html"  # pass the url# into getdata functionhtmldata=getdata(url)soup = BeautifulSoup(htmldata, 'html.parser')  # display html codeprint(soup)
Output:
Step 4: Traverse the Station code from the HTML document.
Python3
# traverse the station codedata = []for item in soup.find("table", class_="extrtable").find_all('b'):    data.append(item.get_text())print(data[-1])
Output:
NDLS

Python web-scraping-exercises
python-utility
Web-scraping
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Read a file line by line in Python
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Iterate over a list in Python
Python String | replace()
*args and **kwargs in Python
Reading and Writing to text files in Python
Create a Pandas DataFrame from Lists
Java Program to Replace All Line Breaks from Strings - GeeksforGeeks

28 Oct, 2021
Given a string, write a Java program to replace all line breaks from the given String.
Examples
Input - Geeks
        For
        Geeks
        
Output - Geeks For Geeks
Line Break: A line break (“\n”) is a single character that defines the line change. 
In order to replace all line breaks from strings replace() function can be used.
String replace(): This method returns a new String object that contains the same sequence of characters as the original string, but with a given character replaced by another given character.
Syntax:
public String replace(char old,char new)
Parameters:
old: old character
new: new character
Returns value: Returns a string by replacing an old character with the new character
Java
// Java Program to Replace All// Line Breaks from Strings public class remove {    public static void main(String[] args)    {        String s = "Replace\n"                   + " all\n"                   + " line\n"                   + " breaks\n"                   + " from\n"                   + " strings";               System.out.println(            "Original String with line breaks - " + s);               // replacing line breaks from string        s = s.replace("\n", "");               System.out.println(            "String after replacing line breaks - " + s);    }}
Original String with line breaks - Replace
 all
 line
 breaks
 from
 strings
String after replacing line breaks - Replace all line breaks from strings
nishkarshgandhi
Java-Strings
Picked
Java
Java Programs
Java-Strings
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Stream In Java
Constructors in Java
Exceptions in Java
Functional Interfaces in Java
Different ways of Reading a text file in Java
Java Programming Examples
Convert Double to Integer in Java
Implementing a Linked List in Java using Class
How to Iterate HashMap in Java?
Program to print ASCII Value of a character
C | Operators | Question 16 - GeeksforGeeks

28 Jun, 2021
Predict the output of the below program:
#include <stdio.h>int main(){    printf("%d", 1 << 2 + 3 << 4);    return 0;}
(A) 112(B) 52(C) 512(D) 0Answer: (C)Explanation: The main logic behind the program is the precedence and associativity of the operators. The addition(+) operator has higher precedence than shift(<<) operator. So, the expression boils down to 1 << (2 + 3) << 4 which in turn reduces to (1 << 5) << 4 as the shift operator has left-to-right associativity.Quiz of this Question
C-Operators
Operators
C Language
C Quiz
Operators
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Substring in C++
Left Shift and Right Shift Operators in C/C++
Function Pointer in C
rand() and srand() in C/C++
std::string class in C++
Compiling a C program:- Behind the Scenes
Operator Precedence and Associativity in C
C | File Handling | Question 1
Output of C programs | Set 64 (Pointers)
C | Arrays | Question 7
CSS | translateZ() function - GeeksforGeeks

07 Aug, 2019
The translateZ() function is an inbuilt function which is used to reposition the element along the z-axis in 3D space.
Syntax:
translateZ( t )
Parameters: This function accepts single parameter t which holds the length of translation corresponding to z-axis.
Below examples illustrate the translateZ() function in CSS:
Example 1:
<!DOCTYPE html><html>  <head>    <title>      CSS translateZ() function  </title>    <style>        body {            text-align: center;        }                  h1 {            color: green;        }                  .translateZ_image {            transform: perspective(200px) translateZ(100px);        }    </style></head>  <body>    <h1>GeeksforGeeks</h1>    <h2>CSS translateZ() function</h2>      <h4>Original Image</h4>    <img src="https://media.geeksforgeeks.org/wp-content/cdn-uploads/20190710102234/download3.png"         alt="GeeksforGeeks logo">    <br>      <h4>Translated image</h4>    <img class="translateZ_image"          src="https://media.geeksforgeeks.org/wp-content/cdn-uploads/20190710102234/download3.png"          alt="GeeksforGeeks logo"></body>  </html>
Output:
Example 2:
<!DOCTYPE html><html>  <head>    <title>      CSS translateZ() function  </title>    <style>        body {            text-align: center;        }                  h1 {            color: green;        }                  .GFG {            font-size: 35px;            font-weight: bold;            color: green;        }                  .geeks {            transform: perspective(              200px) translateZ(100px);        }    </style></head>  <body>    <h1>GeeksforGeeks</h1>    <h2>CSS translateZ() function</h2>      <h4>Original Element</h4>    <div class="GFG">      Welcome to GeeksforGeeks  </div>      <h4>Translated Element</h4>    <div class="GFG geeks">      Welcome to GeeksforGeeks  </div></body>  </html>
Output:
Supported Browsers: The browsers supported by translateZ() function are listed below:
Google Chrome
Internet Explorer
Firefox
Safari
Opera
CSS-Functions
CSS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Design a web page using HTML and CSS
How to set space between the flexbox ?
Form validation using jQuery
Search Bar using HTML, CSS and JavaScript
How to style a checkbox using CSS?
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 ?
Difference between var, let and const keywords in JavaScript
Ruby | Numeric abs() function - GeeksforGeeks

19 Jan, 2021
The abs is an inbuilt method in Ruby returns the absolute value of a number.  
Syntax: num.abs
Parameters: The function needs the number whose absolute value is to be returned. 
Return Value: It returns the absolute value of a numbers.
Example 1:  
Ruby
# Ruby program for abs() method in Numeric # Initialize two numbersnum = -19 # Prints absolute value of numputs  num.abs()
Output: 
19
Example 2: 
Ruby
# Ruby program for abs() method in Numeric # Initialize two numbersnum = 100 # Prints absolute value of numputs  num.abs()
Output: 
100
 
arorakashish0911
Ruby Numeric-class
Ruby-Methods
Ruby
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Ruby | Data Types
Ruby | Hash delete() function
Ruby | Array count() operation
Ruby | Enumerator each_with_index function
Ruby | String reverse Method
Ruby | Array reject() function
Ruby | Types of Iterators
Ruby Mixins
Ruby | Method overriding
Ruby | Array collect() operation
Create a Drop Caps Effect using CSS - GeeksforGeeks

23 Nov, 2020
Drop caps are define as the first capital letter of a paragraph in much larger font size that has the depth of two or more lines of normal text. 
The task can be done by using the CSS ::first-letter pseudo-element to create beautiful drop caps effect. The ::first-letter selector in CSS is used to apply style to the first letter of the first line of a block-level element, the condition is it should not be preceded by other content ( such as images or inline tables).
Syntax:
::first-letter {
    // CSS Property 
}
Example:
HTML
<!DOCTYPE html><html>  <head>    <style>        .gfg::first-letter {            font-size: 250%;            color: green;        }          div::first-letter {            font-size: 250%;            color: blue;            font-weight: bold;        }    </style></head>  <body style="text-align: center;">    <h1 style="color:green;">        How to create drop caps         effect using CSS    </h1>      <p>        <div>Geeks</div>        <div>For</div>        <div>Geeks</div>    </p>          <p class="gfg">        A computer science portal for geeks.    </p></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.
CSS-Misc
HTML-Misc
CSS
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to set space between the flexbox ?
Design a web page using HTML and CSS
Form validation using jQuery
How to style a checkbox using CSS?
Search Bar using HTML, CSS and JavaScript
How to set the default value for an HTML <select> element ?
Hide or show elements in HTML using display property
How to set input type date in dd-mm-yyyy format using HTML ?
REST API (Introduction)
How to Insert Form Data into Database using PHP ?
Fit Smooth Curve to Plot of Data in R - GeeksforGeeks

16 May, 2021
In this article, we will learn about the concept to fit a smooth curve to the plot of data in R Programming. Smoothing is an important concept in data analysis. It is also known n as curve fitting and low pass filtering. The most common non-parametric method used for smoothing is loess() function. Loess is an abbreviation for Local Regression used to fit multiple regressions in the local neighborhoods. The span argument is used to control the size of the neighborhood. The size ranges between 0 and 1. The greater is the span value, the more smooth will be the fitted curve.
Use of Loess() function: Loess() function is used on a numerical vector to smoothen it. It is also used to predict the Y locally.
Syntax: loess(y ~ x)
Return: It smooth curve to plot of data 
Example 1: Below is an implementation to fit a smooth curve to a plot:
R
# Create example dataset.seed(159632)             x <- 1:80y <- sort(rnorm(80))  # Apply loess functionvalues <- loess(y ~ x)    plot(x, y)                      lines(predict(values),      col = "blue",      lwd = 2)
Output:
In the above example loess() function is used to fit a smooth curve into plot. The lwd parameter is used to specify the line type of the smooth curve. The arguments x and y are used to provide coordination to the plot. The loess function will then set a smooth curve in the plot.
Example 2: Another example is illustrated using loess() function:
R
x <- c(7  ,5,  2,  9,  1,  9,  17,  8,  9, 10)y <- c(12, 14, 16, 18, 20, 2,  4,  6,  8,  7 )values <- loess(y ~ x)  plot(x, y)lines(predict(values), col = 'red', lwd = 2)
Output: 
In the above example, X and Y axis values are plotted. The smooth curve is fitted using the loess function. The prediction will be an array of the appropriate dimensions in a smooth fitted curve.
Picked
R-Charts
R-Graphs
R-plots
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Change Color of Bars in Barchart using ggplot2 in R
Group by function in R using Dplyr
How to Change Axis Scales in R Plots?
How to Split Column Into Multiple Columns in R DataFrame?
Replace Specific Characters in String in R
How to filter R DataFrame by values in a column?
How to import an Excel File into R ?
Time Series Analysis in R
R - if statement
How to filter R dataframe by multiple conditions?
Fontstyle module in Python - GeeksforGeeks

17 Jan, 2022
Sometimes terminal text can be hard to read, the fontstyle module is package hosted on pypi.org for manipulating text. It can be used to break up the noise with some additional formatting, add colors, font weights and other styles to make it more readable. It also supports substring formatting for extra prettiness!
pip install fontstyle
Format text
Preserve formatting
Remove formatting
1) fonstyle.apply(): This method adds formatting to the entire input argument string.
Syntax: fonstyle.apply(“STRING”,”all/possible/formatting/options”)
Available Colors: BLACK, BLUE, CYAN, DARKCYAN, GREEN, PURPLE, RED, YELLOW, WHITE
BackGround of Text: BLACK_BG, BLUE_BG, CYAN_BG, GREEN_BG, PURPLE_BG, RED_BG, YELLOW_BG, WHITE_BG
Formatting Arguments: ‘BLINK’, ‘BOLD’, ‘FAINT’, ‘HIDDEN’, ‘ITALIC’, ‘INVERSE’, ‘STRIKE’, ‘UNDERLINE’, ‘END’
2) fontstyle.erase(): This method is used to remove the formatting. 
3) fontstyle.preserve(): This method returns the original text before formatting without removing the actual formatting of the text.
Below are some programs which depict the use of fontstyle module in Python:
Example 1:
Python3
# import moduleimport fontstyle # format texttext = fontstyle.apply('GEEKSFORGEEKS', 'bold/Italic/red/GREEN_BG') # display textprint(text)
Output:
Here, we apply various formatting arguments like font color, background color, bold, italic on the given string.
Example 2:
Python3
# import required moduleimport fontstyle # display formatted textprint(fontstyle.apply('GEEKSFORGEEKS',                      'bold/Italic/red/UNDERLINE/GREEN_BG')) print(fontstyle.apply('GEEKSFORGEEKS',                      'bold/Italic/red/INVERSE/UNDERLINE/GREEN_BG'))
Output:
Here is another example of how to format text using this module.
Example 3:
Python3
# import moduleimport fontstyle # apply formattingtext = fontstyle.apply(    'GEEKSFORGEEKS', 'bold/Italic/red/INVERSE/2UNDERLINE/GREEN_BG') # display textprint(text) # preserved textprint(fontstyle.preserve(text))
Output:
In this program, preserve() method is used to display the original text before formatting.
Note: You must specify which formatting you want to erase else it will erase last updated formatting
Example 4:
Python3
# import required moduleimport fontstyle # format texttext = fontstyle.apply(    'GEEKSFORGEEKS', 'bold/Italic/red/INVERSE/2UNDERLINE/GREEN_BG') # display textprint(text) # remove formattingtext = fontstyle.erase(a, 'bold/Italic/red/INVERSE/2UNDERLINE/GREEN_BG') # display original textprint(text)
Output:
adnanirshad158
python-modules
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Python | Get unique values from a list
Python | os.path.join() method
Defaultdict in Python
Create a directory in Python
Python | Pandas dataframe.groupby()
How to change Matplotlib color bar size in Python? - GeeksforGeeks

03 Jan, 2021
Colorbar is a separate axis that provides a current colormap indicating mapping of data-points into colors. In this article, We are going to change Matplotlib color bar size in Python. There are several ways with which you can resize your color-bar or adjust its position. Let’s see it one by one.
Method 1: Resizing color-bar using shrink keyword argument
Using the shrink attribute of colorbar() function we can scale the size of the colorbar. 
Syntax : matplotlib.pyplot.colorbar(mappable=None, shrink=scale)
Basically, we are multiplying by some factor to the original size of the color-bar. In the below example by using 0.5 as a factor, We are having the original color-bar size.
Example 1:  
Python3
# importing libraryimport matplotlib.pyplot as plt  # Some data to show as an imagedata = [[1, 2, 3],        [4, 5, 6]]  # Call imshow() to display 2-D data as an imageimg = plt.imshow(data)  # Scaling colorbar by factor 0.5plt.colorbar(shrink=0.5)plt.show()
Output: 
Using_shrink_attribute
Example 2: In this example, we are using factor 0.75. Similarly, you can use any factor to change the color-bar size. The default value of the shrink attribute is 1.
Python3
import matplotlib.pyplot as pltimport matplotlib.image as mpimgfig, ax = plt.subplots()  # getting rid of axisplt.axis('off')  # Reading saved image from folderimg = mpimg.imread(r'img.jpg')  # displaying imageplt.imshow(img)  # Scaling by factor 0.75plt.colorbar(shrink=0.75)plt.show()
Output: 
Using_shrink_attribute
Method 2: Using AxesDivider class
With this class, you can change the size of the colorbar axes however height will be the same as the current axes. Here we are using axes_divider.make_axes_locatable function which returns the AxisDivider object for our current axes in which our image is shown.
Example: 
Python3
# importing librariesimport matplotlib.pyplot as pltfrom mpl_toolkits.axes_grid1 import make_axes_locatable  fig, ax = plt.subplots()# Reading image from folder  img = mpimg.imread(r'img.jpg')image = plt.imshow(img)  # Locating current axesdivider = make_axes_locatable(ax)  # creating new axes on the right# side of current axes(ax).# The width of cax will be 5% of ax# and the padding between cax and ax# will be fixed at 0.05 inch.colorbar_axes = divider.append_axes("right",                                    size="10%",                                    pad=0.1)# Using new axes for colorbarplt.colorbar(image, cax=colorbar_axes)plt.show()
Output: 
Using_AxisDivider
Picked
Python-matplotlib
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python Classes and Objects
How to drop one or multiple columns in Pandas Dataframe
Defaultdict in Python
Python | Get unique values from a list
Python | os.path.join() method
Create a directory in Python
Python | Pandas dataframe.groupby()
HTTP headers | Accept - GeeksforGeeks

07 Nov, 2019
The HTTP Accept header is a request type header. The Accept header is used to inform the server by the client that which content type is understandable by the client expressed as MIME-types. By using the Content-negotiation the server selects a proposal of the content type and informs the client of its choice with the Content-type response header. If the Accept header is not present in the request, then the server assumes that the client accepts all types of media.
Syntax:
Accept: <MIME_type>/<MIME_subtype> | <MIME_type>/* | */*
Directives: This header accept below mentioned directives:
<MIME_type>/<MIME_subtype>: This directive holds the type/subtype of the web content that the client will received by content-type header which is chosen by the server from Accept header. Basically it holds the single mime type like text/html.
<MIME_type>/*: This directive holds the type but can accept any subtyping like image/* means the image can be jpg, png, or can svg everything will be accepted.
*/* This directive accepts any kind of type/subtype.
Example:
This example accepts the text type with the subtype of html.Accept: text/html
Accept: text/html
This example accept any image subtype does not bother.Accept: image/*
Accept: image/*
To check this Accept in action go to Inspect Element -> Network check the request header for Accept like below, Accept is highlighted you can see.
Supported Browsers: The browsers are compatible with HTTP Accept header are listed below:
Google Chrome
Internet Explorer
Firefox
Safari
Opera
HTTP-headers
Picked
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Remove elements from a JavaScript Array
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
How to create footer to stay at the bottom of a Web page?
Node.js fs.readFileSync() Method
How to set the default value for an HTML <select> element ?
File uploading in React.js
How to apply style to parent if it has child with CSS?
Material - File Icons

This chapter explains the usage of Google's (Material) File icons. Assume that custom is the CSS class name where we defined the size and color, as shown in the example given below.
<!DOCTYPE html>
<html>
   <head>
      <link href = "https://fonts.googleapis.com/icon?family=Material+Icons" rel = "stylesheet">
		
      <style>
         i.custom {font-size: 2em; color: green;}
      </style>
		
   </head>
	
   <body>
      <i class = "material-icons custom">accessibility</i>
   </body>
	
</html>
The following table contains the usage and results of Google's (Material) File icons. Replace the < body > tag of the above program with the code given in the table to get the respective outputs −

    26 Lectures 
     2 hours 

 Neha Gupta

    20 Lectures 
     2 hours 

 Asif Hussain

    43 Lectures 
     5 hours 

 Sharad Kumar

    411 Lectures 
     38.5 hours 

 In28Minutes Official

    71 Lectures 
     10 hours 

 Chaand Sheikh

    207 Lectures 
     33 hours 

 Eduonix Learning Solutions
 Print
 Add Notes
 Bookmark this page
How to flatten a shallow list in Python?

A simple and straightforward solution is to append items from sublists in a flat list using two nested for loops.
lst = [[10, 20, 30, 40], [50, 60, 70, 80], [90, 100, 110, 120]]
flatlist = []
for sublist in lst:
   for item in sublist:
      flatlist.append(item)
print (flatlist)
A more compact and Pythonic solution is to use chain() function from itertools module.
>>> lst  =[[10, 20, 30, 40], [50, 60, 70, 80], [90, 100, 110, 120]]
>>> import itertools
>>> flatlist = list(itertools.chain(*lst))
>>> flatlist
[10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]