code-rag-bench/online-tutorials huggingface dataset:
Matcher quoteReplacement(String) method in Java with Examples - GeeksforGeeks

26 Nov, 2018
The quoteReplacement(String string) method of Matcher Class is used to get the replacement String literal of the String passed as parameter. This String literal acts as the parameter for the replace methods. Hence quoteReplacement() method acts as the intermediate in the replace methods.
Syntax:
public static String quoteReplacement(String string)

Parameters: This method takes a parameter string which is the String to be replaced in the Matcher.
Return Value: This method returns a String literal which is the replacement String for the matcher.
Below examples illustrate the Matcher.quoteReplacement() method:
Example 1:
// Java code to illustrate quoteReplacement() method  import java.util.regex.*;  public class GFG {    public static void main(String[] args)    {          // Get the regex to be checked        String regex = "Geek";          // Create a pattern from regex        Pattern pattern = Pattern.compile(regex);          // Get the String to be matched        String            stringToBeMatched            = "GeeksForGeeks Geeks for For Geeks Geek";          // Create a matcher for the input String        Matcher matcher            = pattern                  .matcher(stringToBeMatched);          // Get the String to be replaced        String stringToBeReplaced = "Geeks";          // Get the String literal        // using quoteReplacement() method        System.out.println(            matcher                .quoteReplacement(stringToBeReplaced));    }}
Geeks

Example 2:
// Java code to illustrate quoteReplacement() method  import java.util.regex.*;  public class GFG {    public static void main(String[] args)    {          // Get the regex to be checked        String regex = "FGF";          // Create a pattern from regex        Pattern pattern            = Pattern.compile(regex);          // Get the String to be matched        String            stringToBeMatched            = "GFGFGFGFGFGFGFGFGFG FGF GFG GFG FGF";          // Create a matcher for the input String        Matcher matcher            = pattern.matcher(stringToBeMatched);          // Get the String to be replaced        String stringToBeReplaced = "GFG";          // Get the String literal        // using quoteReplacement() method        System.out.println(            matcher                .quoteReplacement(stringToBeReplaced));          System.out.println(            matcher                .replaceAll(                    matcher                        .quoteReplacement(                            stringToBeReplaced)));    }}
GFG
GGFGGGFGGGFGGGFGGFG GFG GFG GFG GFG

Reference: Oracle Doc
Java - util package
Java-Functions
Java-Matcher
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
HashMap in Java with Examples
Interfaces in Java
Stream In Java
ArrayList in Java
Initialize an ArrayList in Java
Stack Class in Java
Multidimensional Arrays in Java
Singleton Class in Java
Set in Java
Multithreading in Java
Calendar get() method in Java with Examples - GeeksforGeeks

14 Feb, 2019
The get(int field_value) method of Calendar class is used to return the value of the given calendar field in the parameter.
Syntax:
public int get(int field)
Parameters: The method takes one parameter field_value of integer type and refers to the calendar whose value is needed to be returned.
Return Value: The method returns the value of the passed field.
Below programs illustrate the working of get() Method of Calendar class:Example 1:
// Java Code to illustrate// get() Method  import java.util.*;  public class CalendarClassDemo    extends GregorianCalendar {    public static void main(String args[])    {        // Creating a calendar        Calendar calndr = Calendar.getInstance();          // Getting the value of all        // the calendar date fields        System.out.println("The given calendar's"                           + " year is: " + calndr.get(Calendar.YEAR));        System.out.println("The given calendar's"                           + " month is: " + calndr.get(Calendar.MONTH));        System.out.println("The given calendar's"                           + " day is: " + calndr.get(Calendar.DATE));    }}
The given calendar's year is: 2019
The given calendar's month is: 1
The given calendar's day is: 13

Example 2:
// Java Code to illustrate// get() Method  import java.util.*;  public class CalendarClassDemo    extends GregorianCalendar {    public static void main(String args[])    {        // Creating a calendar object        Calendar calndr = new GregorianCalendar(2018, 9, 2);          // Getting the value of all        // the calendar date fields        System.out.println("The given calendar's"                           + " year is: " + calndr.get(Calendar.YEAR));        System.out.println("The given calendar's"                           + " month is: " + calndr.get(Calendar.MONTH));        System.out.println("The given calendar's"                           + " day is: " + calndr.get(Calendar.DATE));    }}
The given calendar's year is: 2019
The given calendar's month is: 9
The given calendar's day is: 2

Reference: https://docs.oracle.com/javase/7/docs/api/java/util/Calendar.html#get(int)
Java-Calendar
Java-Functions
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Object Oriented Programming (OOPs) Concept in Java
HashMap in Java with Examples
Stream In Java
Interfaces in Java
How to iterate any Map in Java
ArrayList in Java
Initialize an ArrayList in Java
Stack Class in Java
Multidimensional Arrays in Java
Singleton Class in Java
HTTP headers | Pragma - GeeksforGeeks

28 Nov, 2019
The Pragma is a no-cache general-type CORS-safe listed response header field in an HTTP/1.0 header which is intended to use in the request-response chain. A pragma header meant to prevent the client from caching the response, pragma means the browsers to tell the server and any intermediate caches that it wants a fresh version of the resource and vice-versa is not true.
Note: Pragma is not specified for HTTP responses that’s why it is not a reliable replacement for the general HTTP/1.1 Cache-Control header. It is used only for backwards compatibility with HTTP/1.0 clients.
Difference between Pragma and Cache-control headers: The Pragma is only defined as applicable to the requests by the client, and the Cache-Control may be used by both the requests of the clients and the response of the servers.
Syntax
Pragma: no-cache
Directives: It is same as Cache-Control: no-cache header. It forces the caches to submit the request to the origin server for validation before releasing a cached copy.
Example:
Pragma: no-cache
To check the Pragma in action go to Inspect Element -> Network check the header for Pragma like below. Pragma header is highlighted.
Browser Compatibility: The browsers compatible with Pragma header are listed below:
Google chrome 6.0 and above
Internet Explorer 9.0 and above
Firefox 4.0 and above
Opera 11.1 and above
Safari 5.0 and above
Samsung Internet
HTTP-headers
Picked
Technical Scripter
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
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 ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
Difference between var, let and const keywords in JavaScript
How to create footer to stay at the bottom of a Web page?
Differences between Functional Components and Class Components in React
Node.js fs.readFileSync() Method
Matcher toMatchResult() method in Java with Examples - GeeksforGeeks

26 Nov, 2018
The toMatchResult() method of Matcher Class is used to get the current result state of this Matcher.
Syntax:
public MatchResult toMatchResult()

Parameters: This method do not takes any parameter.
Return Value: This method returns a MatchResult with the current match result state of this Matcher.
Below examples illustrate the Matcher.toMatchResult() method:
Example 1:
// Java code to illustrate toMatchResult() method  import java.util.regex.*;  public class GFG {    public static void main(String[] args)    {          // Get the regex to be checked        String regex = "Geeks";          // Create a pattern from regex        Pattern pattern            = Pattern.compile(regex);          // Get the String to be matched        String stringToBeMatched            = "GeeksForGeeks";          // Create a matcher for the input String        Matcher matcher            = pattern                  .matcher(stringToBeMatched);          // Get the result state        // using toMatchResult() method        System.out.println("Result: "                           + matcher.toMatchResult());    }}
Result: java.util.regex.Matcher[pattern=Geeks region=0, 13 lastmatch=]
Example 2:
// Java code to illustrate toMatchResult() method  import java.util.regex.*;  public class GFG {    public static void main(String[] args)    {          // Get the regex to be checked        String regex = "GFG";          // Create a pattern from regex        Pattern pattern            = Pattern.compile(regex);          // Get the String to be matched        String stringToBeMatched            = "GFGFGFGFGFGFGFGFGFG";          // Create a matcher for the input String        Matcher matcher            = pattern                  .matcher(stringToBeMatched);          // Get the result state        // using toMatchResult() method        System.out.println("Result: "                           + matcher.toMatchResult());    }}
Result: java.util.regex.Matcher[pattern=GFG region=0, 19 lastmatch=]
Reference: Oracle Doc
Java - util package
Java-Functions
Java-Matcher
Java
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
Generics in Java
Introduction to Java
Comparator Interface in Java with Examples
Internal Working of HashMap in Java
Strings in Java
fullscreen_window driver method - Selenium Python - GeeksforGeeks

27 Apr, 2021
Selenium’s Python Module is built to perform automated testing with Python. Selenium Python bindings provides a simple API to write functional/acceptance tests using Selenium WebDriver. To open a webpage using Selenium Python, checkout – Navigating links using get method – Selenium Python. Just being able to go to places isn’t terribly useful. What we’d really like to do is to interact with the pages, or, more specifically, the HTML elements within a page. There are multiple strategies to find an element using Selenium, checkout – Locating Strategies. Selenium WebDriver offers various useful methods to control the session, or in other words, browser. For example, adding a cookie, pressing back button, navigating among tabs, etc. This article revolves around fullscreen_window driver method in Selenium. fullscreen_window method invokes the window manager-specific ‘full screen’ operation.Syntax –  
driver.fullscreen_window()
Example – Now one can use fullscreen_window method as a driver method as below –  
driver.get("https://www.geeksforgeeks.org/")
driver.fullscreen_window()
 
To demonstrate, fullscreen_window method of WebDriver in Selenium Python. Let’ s visit https://www.geeksforgeeks.org/ and operate on driver object.Program –  
Python3
# import webdriverfrom selenium import webdriver # create webdriver objectdriver = webdriver.Firefox() # get geeksforgeeks.orgdriver.get("https://www.geeksforgeeks.org/") # get geeksforgeeks.orgdriver.get("https://www.practice.geeksforgeeks.org/") # full screen windowdriver.fullscreen_window()
Output – Browser goes full screen as verified below –  
 
simmytarika5
Python-selenium
selenium
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 | os.path.join() method
Python | Get unique values from a list
Create a directory in Python
Defaultdict in Python
Python | Pandas dataframe.groupby()
How to create a TilePane using JavaFX?

Once you create all the required nodes for your application you can arrange them using a layout. Where a layout is a process of calculating the position of objects in the given space. JavaFX provides various layouts in the javafx.scene.layout package.
In this layout, the nodes are arranged as a grid of uniformly sized tiles. You can create a tile pane in your application by instantiating the javafx.scene.layout.TilePane class.
On instantiating the TilePane class, by default, a horizontal tile pane will be created, you can change its orientation using the setOrientation() method.
On instantiating the TilePane class, by default, a horizontal tile pane will be created, you can change its orientation using the setOrientation() method.
You can set the maximum with of the pane using the setMaxWidth() method.
You can set the maximum with of the pane using the setMaxWidth() method.
To add nodes to this pane you can either pass them as arguments of the constructor or, add them to the observable list of the pane as −
getChildren().addAll();
import javafx.application.Application;
import javafx.collections.ObservableList;
import javafx.geometry.Orientation;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.TilePane;
import javafx.stage.Stage;
public class TilePaneExample extends Application {
   @Override
   public void start(Stage stage) {
      //Creating buttons
      Button one = new Button("one");
      one.setPrefSize(200, 100);
      Button two = new Button("Two");
      two.setPrefSize(200, 100);
      Button three = new Button("Three");
      three.setPrefSize(200, 100);
      Button four = new Button("Four");
      four.setPrefSize(200, 100);
      Button five = new Button("Five");
      five.setPrefSize(200, 100);
      Button six = new Button("six");
      six.setPrefSize(200, 100);
      Button seven = new Button("seven");
      seven.setPrefSize(200, 100);
      Button eight = new Button("eight");
      eight.setPrefSize(200, 100);
      Button nine = new Button("nine");
      nine.setPrefSize(200, 100);
      //Creating the tile pane
      TilePane tilePane = new TilePane();
      //Setting the orientation for the Tile Pane
      tilePane.setOrientation(Orientation.HORIZONTAL);
      //Setting the alignment for the Tile Pane
      tilePane.setTileAlignment(Pos.CENTER_LEFT);
      //Setting the preferred columns for the Tile Pane
      tilePane.setPrefRows(3);
      //Retrieving the observable list of the Tile Pane
      ObservableList list = tilePane.getChildren();
      //Adding the array of buttons to the pane
      list.addAll(one, two, three, four, five, six, seven, eight, nine);
      //Setting the Scene
      Scene scene = new Scene(tilePane, 600, 300);
      stage.setTitle("Tile Pane");
      stage.setScene(scene);
      stage.show();
   }
   public static void main(String args[]){
      launch(args);
   }
}
Assembly - STOS Instruction

The STOS instruction copies the data item from AL (for bytes - STOSB), AX (for words - STOSW) or EAX (for doublewords - STOSD) to the destination string, pointed to by ES:DI in memory.
The following example demonstrates use of the LODS and STOS instruction to convert an upper case string to its lower case value −
section	.text
   global _start        ;must be declared for using gcc
	
_start:	                ;tell linker entry point
   mov    ecx, len
   mov    esi, s1
   mov    edi, s2
	
loop_here:
   lodsb
   or      al, 20h
   stosb
   loop    loop_here	
   cld
   rep	movsb
	
   mov	edx,20	        ;message length
   mov	ecx,s2	        ;message to write
   mov	ebx,1	        ;file descriptor (stdout)
   mov	eax,4	        ;system call number (sys_write)
   int	0x80	        ;call kernel
	
   mov	eax,1	        ;system call number (sys_exit)
   int	0x80	        ;call kernel
	
section	.data
s1 db 'HELLO, WORLD', 0 ;source
len equ $-s1

section	.bss
s2 resb 20              ;destination
When the above code is compiled and executed, it produces the following result −
hello, world


    46 Lectures 
     2 hours 

 Frahaan Hussain

    23 Lectures 
     12 hours 

 Uplatz
 Print
 Add Notes
 Bookmark this page
Nested-if statement in Python - GeeksforGeeks

26 Mar, 2020
There come situations in real life when we need to make some decisions and based on these decisions, we decide what should we do next. Similar situations arise in programming also where we need to make some decisions and based on these decisions we will execute the next block of code. This is done with the help of decision-making statements in Python.
Example:
# Python program to demonstrate# decision making  i = 20; if (i < 15):     print ("i is smaller than 15")     print ("i'm in if Block") else:     print ("i is greater than 15")     print ("i'm in else Block") print ("i'm not in if and not in else Block") 
Output:
i is greater than 15
i'm in else Block
i'm not in if and not in else Block
We can have an if...elif...else statement inside another if...elif...else statement. This is called nesting in computer programming. Any number of these statements can be nested inside one another. Indentation is the only way to figure out the level of nesting. This can get confusing, so it must be avoided if we can.
Syntax:
if (condition1):
   # Executes when condition1 is true
   if (condition2): 
      # Executes when condition2 is true
   # if Block is end here
# if Block is end here
FlowChart
Example 1:
# Python program to demonstrate# nested if statement     num = 15if num >= 0:    if num == 0:        print("Zero")    else:        print("Positive number")else:    print("Negative number")
Output:
Positive number

Example 2:
# Python program to demonstrate# nested if statement    i = 13  if (i == 13):     #  First if statement     if (i < 15):         print ("i is smaller than 15")               # Nested - if statement     # Will only be executed if statement above     # it is true     if (i < 12):         print ("i is smaller than 12 too")     else:         print ("i is greater than 12 and smaller than 15")
Output:
i is smaller than 15
i is greater than 12 and smaller than 15

python-basics
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Check if element exists in list in Python
Python | os.path.join() method
Selecting rows in pandas DataFrame based on conditions
Defaultdict in Python
Python | Get unique values from a list
Create a directory in Python
Python | Pandas dataframe.groupby()
Program to find list of all possible combinations of letters of a given string s in Python

Suppose we have a string s. We have to find all possible combinations of letters of s. If there are two strings with same set of characters, then show the lexicographically smallest of them. And one constraint is each character in s are unique.
So, if the input is like s = "pqr", then the output will be ['r', 'qr', 'q', 'pr', 'pqr', 'pq', 'p']
To solve this, we will follow these steps −
st_arr := a new list
for i in range size of s - 1 to 0, decrease by 1, dofor j in range 0 to size of st_arr - 1, doinsert (s[i] concatenate st_arr[j]) at the end of st_arrinsert s[i] at the end of st_arr
for j in range 0 to size of st_arr - 1, doinsert (s[i] concatenate st_arr[j]) at the end of st_arr
insert (s[i] concatenate st_arr[j]) at the end of st_arr
insert s[i] at the end of st_arr
return st_arr
Let us see the following implementation to get better understanding −
def solve(s):
   st_arr = []

   for i in range(len(s)-1,-1,-1):
      for j in range(len(st_arr)):
         st_arr.append(s[i]+st_arr[j])
      st_arr.append(s[i])
   return st_arr

s = "pqr"
print(solve(s))
"pqr"

['r', 'qr', 'q', 'pr', 'pqr', 'pq', 'p']
Python 3 - Membership Operators Example

Python’s membership operators test for membership in a sequence, such as strings, lists, or tuples. There are two membership operators as explained below −
#!/usr/bin/python3

a = 10
b = 20
list = [1, 2, 3, 4, 5 ]

if ( a in list ):
   print ("Line 1 - a is available in the given list")
else:
   print ("Line 1 - a is not available in the given list")

if ( b not in list ):
   print ("Line 2 - b is not available in the given list")
else:
   print ("Line 2 - b is available in the given list")

c = b/a
if ( c in list ):
   print ("Line 3 - a is available in the given list")
else:
   print ("Line 3 - a is not available in the given list")

When you execute the above program it produces the following result −
Line 1 - a is not available in the given list
Line 2 - b is not available in the given list
Line 3 - a is available in the given list


    187 Lectures 
     17.5 hours 

 Malhar Lathkar

    55 Lectures 
     8 hours 

 Arnab Chakraborty

    136 Lectures 
     11 hours 

 In28Minutes Official

    75 Lectures 
     13 hours 

 Eduonix Learning Solutions

    70 Lectures 
     8.5 hours 

 Lets Kode It

    63 Lectures 
     6 hours 

 Abhilash Nelson
 Print
 Add Notes
 Bookmark this page
Tracking Keyword Trends on Google Search with Pytrends | by Sidney Kung | Towards Data Science

Pytrends is an unofficial API for tracking Google Search trends, and we can use matplotlib to visualize these trends over time. You can read more about the package in the project’s GitHub repository here.
Well, we all know what Google Search is. We all use it several times a day, sometimes without a second thought, to access millions of search results for a wide range of topics. Fun fact, the Google Search Toolbar was first released in 2000 for Internet Explorer 5!
By looking at a time series visualization of Google Search keywords over a decade, we can draw valuable insights about almost any topic. Let’s dive right into an example. Let’s take a look at the trends for the keyword “Data Science”.
Here are the trends of the keyword “Data Science” from 2016 to 2021. I’ll share a tutorial on how you can generate this visualization too! It’s super easy.
With any package, we start with installing it onto the local machine. You can do this with a simple line.
! pip install pytrends
Once pytrends is installed, we are going to import the method TrendReq from the package.
from pytrends.request import TrendReq
Next, we need to connect to Google. We can use TrendReq and pass several parameters. For this example, we’ll use hl and tz.
# connect to googlepytrends = TrendReq(hl='en-US', tz=360)
The hl parameter specifies host language for accessing Google Trends. Please note that only https proxies will work, and you need to add the port number after the proxy ip address. The tz parameter is the timezone offset. So, for example, US CST is 360.
After the API has been initialized, we need to query the actual keyword term that we want to search for. To do that, we use the method build_payload to tell the API which keywords we want. As mentioned, we’re using “Data Science” for this example.
# keywords to search forpytrends.build_payload(kw_list=['data science'])
Now the hard part is over! Next, we just need to create a dataframe that holds the time series data for this query. There is an API method, Interest over Time, that returns historical, indexed data for when the keyword was searched most as shown on Google Trends’ Interest Over Time section.
# dataframetime_df = pytrends.interest_over_time()
Take a look at what the first 5 rows of that dataframe looks like by running a simple time_df.head().
Once everything has been set up, we can use matplotlib to visualize this dataframe! I won’t explain that part, but here is the full code that I used for this project. As you can see, the whole project only took about 22 lines of code to accomplish.
This mini exercise was just one of the many things that we can do with the pytrends package. For instance, we can look at the historical hourly interest, interest by region, related topics, related queries, and even more.
Feel free to install Pytrends and play around with the package yourself! There are an endless amount of terms to search.
Sass - if() Function

Based on the condition, this built-in if() function returns only one result from two possible outcomes. The result of the function can be referred to the variable that may not be defined or to have further calculations.
if( expression, value1, value2 )

The following example demonstrates the use of if() function in the SCSS file −
<html>
   <head>
      <title>Control Directives & Expressions</title>
      <link rel = "stylesheet" type = "text/css" href = "style.css"/>
   </head>
   
   <body>
      <h2>Welcome to TutorialsPoint</h2>
   </body>
</html>
Next, create file style.scss.
h2 {
   color: if( 1 + 1 == 2 , green , red);
}
You can tell SASS to watch the file and update the CSS whenever SASS file changes, by using the following command −
sass --watch C:\ruby\lib\sass\style.scss:style.css

Next, execute the above command; it will create the style.css file automatically with the following code −
h2 {
   color: green; 
}
Let us carry out the following steps to see how the above given code works −
Save the above given html code in if_function.html file.
Save the above given html code in if_function.html file.
Open this HTML file in a browser, an output is displayed as shown below.
Open this HTML file in a browser, an output is displayed as shown below.

    50 Lectures 
     5.5 hours 

 Code And Create

    124 Lectures 
     30 hours 

 Juan Galvan

    162 Lectures 
     31.5 hours 

 Yossef Ayman Zedan

    167 Lectures 
     45.5 hours 

 Muslim Helalee
 Print
 Add Notes
 Bookmark this page
Python | Pandas dataframe.get_dtype_counts() - GeeksforGeeks

19 Nov, 2018
Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier.
Pandas dataframe.get_dtype_counts() function returns the counts of dtypes in the given object. It returns a pandas series object containing the counts of all data types present in the pandas object. It works with pandas series as well as dataframe.
Syntax: DataFrame.get_dtype_counts()
Returns : value : Series : Counts of datatypes
For link to CSV file Used in Code, click here
Example #1: Use get_dtype_counts() function to find the counts of datatype of a pandas dataframe object.
# importing pandas as pdimport pandas as pd  # Creating the dataframe df = pd.read_csv("nba.csv")  # Print the dataframedf
Now apply the get_dtype_counts() function. Find out the frequency of occurrence of each data type in the dataframe.
# applying get_dtype_counts() function df.get_dtype_counts()
Output :
Notice, the output is a pandas series object containing the count of each data types in the dataframe. 
Example #2: Use get_dtype_counts() function over a selected no. of columns of the data frame only.
# importing pandas as pdimport pandas as pd  # Creating the dataframe df = pd.read_csv("nba.csv")  # Applying get_dtype_counts() function to # find the data type counts in modified dataframe.df[["Salary", "Name", "Team"]].get_dtype_counts()
Notice, the output is a pandas series object containing the count of each data types in the dataframe. We can verify all these results using this the dataframe.info() function.
# Find out the types of all columns in the dataframedf.info()
Output :
Python pandas-dataFrame
Python pandas-dataFrame-methods
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
Defaultdict in Python
Create a directory in Python
Python | os.path.join() method
Python | Pandas dataframe.groupby()
Python | Get unique values from a list
Alphanumeric sorting using JavaScript

We have a mixed array that we need to sort by alphabet and then by digit −
const arr = ['Ab-1', 'Ab-11', 'Ab-12', 'ab-10', 'ab-100', 'ab-101', 'ab2', 'ab-3', 'ab-105'];
The code for this will be −
const arr = ['Ab-1', 'Ab-11', 'Ab-12', 'ab-10', 'ab-100', 'ab-101', 'ab2', 'ab-3', 'ab-105'];
const alphaNumericSort = (arr = []) => {
   arr.sort((a, b) => {
      const aPart = a.split('-');
      const bPart = b.split('-');
      return aPart[0].toLowerCase().localeCompare(bPart[0].toLowerCase()) || aPart[1] - bPart[1];
   });
};
alphaNumericSort(arr);
console.log(arr);
And the output in the console will be −
[
   'Ab-1', 'ab-2',
   'ab-3', 'ab-10',
   'Ab-11', 'Ab-12',
   'ab-100', 'ab-101',
   'ab-105'
]
Scraping Twitter data using python for NLP | by Anshaj Khare | Towards Data Science

“In God we trust. All others must bring data.” — W. Edwards Deming
If you’re starting in the incredible field of NLP, you’ll want to get your hands dirty with real textual data that you can use to play around with the concepts you’ve learned. Twitter is an excellent source of such data. In this post, I’ll be presenting a scraper that you can use to scrape the tweets of the topics that you’re interested in and get all nerdy once you’ve obtained your dataset.
I’ve used this amazing library that you can find here. I’ll go over how to install and use this library and also suggest some methods to make the entire process faster using parallelization.
The library can be installed using pip3 using the following command
pip3 install twitter_scraper
The next task is to create a list of keywords that you want to use for scraping twitter. You’ll be searching twitter for these keywords and hence it is important that you make a comprehensive list of keywords that you’re interested in.
Before we run our program to extract all the keywords, we’ll run our program with one keyword and print out the fields that we can extract from the object. In the code below, I’ve shown how to iterate over the returned object and print out the fields that you want to extract. You can see that we have the following fields that we extract
Tweet IDIs a retweet or notTime of the tweetText of the tweetReplies to the tweetTotal retweetsLikes to the tweetEntries in the tweet
Tweet ID
Is a retweet or not
Time of the tweet
Text of the tweet
Replies to the tweet
Total retweets
Likes to the tweet
Entries in the tweet
Now that we’ve decided what kind of data we want to store from our object, we’ll run our program sequentially to obtain the tweets of topics we’re interested in. We’ll do this using our familiar for loop to go over each keyword one by one and store the successful results.
From the documentation,
Multiprocessing is a package that supports spawning processes using an API similar to the threading module. The multiprocessing package offers both local and remote concurrency, effectively side-stepping the Global Interpreter Lock by using subprocesses instead of threads. Due to this, the multiprocessing module allows the programmer to fully leverage multiple processors on a given machine.
First, we’ll implement a function to scrape the data.
Next, we’ll create subprocesses to run our code in parallel.
As you can see, we reduced our process time to almost 1/4th of sequential execution. You can use this method for similar tasks and make your python code much faster.
How to convert a string into integer in JavaScript?

To convert a string to an integer parseInt() function is used in javascript. parseInt() function returns Nan( not a number) when the string doesn’t contain number. If a string with a number is sent then only that number will be returned as the output. This function won't accept spaces. If any particular number with spaces is sent then the part of the number that presents before space will be returned as the output.
parseInt(value);
This function takes a string and converts it into an integer. If there is no integer present in the string, NaN will be the output.
In the following example, various cases of strings such as only strings, strings with numbers, etc have been taken and sent through the parseInt() function. Later on, their integer values, if present, have displayed as shown in the output.
<html>
<body>
<script>
   var a = "10";
   var b = parseInt(a);
   document.write("value is " + b);
   var c = parseInt("423-0-567");
   document.write("</br>");
   document.write('value is ' + c);
   document.write("</br>");
   var d = "string";
   var e = parseInt(d);
   document.write("value is " + e);
   document.write("</br>");
   var f = parseInt("2string");
   document.write("value is " + f);
</script>
</body>
</html>
value is 10
value is 423
value is NaN
value is 2
Arduino - nested loop

C language allows you to use one loop inside another loop. The following example illustrates the concept.
for ( initialize ;control; increment or decrement) {
   // statement block
   for ( initialize ;control; increment or decrement) {
      // statement block
   }
}

for(counter = 0;counter <= 9;counter++) {
   //statements block will executed 10 times
   for(i = 0;i <= 99;i++) {
      //statements block will executed 100 times
   }
}

    65 Lectures 
     6.5 hours 

 Amit Rana

    43 Lectures 
     3 hours 

 Amit Rana

    20 Lectures 
     2 hours 

 Ashraf Said

    19 Lectures 
     1.5 hours 

 Ashraf Said

    11 Lectures 
     47 mins

 Ashraf Said

    9 Lectures 
     41 mins

 Ashraf Said
 Print
 Add Notes
 Bookmark this page
How to copy a section of one Array to another in C#?

The Array.Copy() method in C# is used to copy section of one array to another array.
The following is the syntax −
Array.Copy(src, dest, length);
Here,
src = array to be copied
src = array to be copied
dest = destination array
dest = destination array
length = how many elements to copy
length = how many elements to copy
The following is an example showing the usage of Copy(,,) method of array class in C# −
using System;

class Program {
   static void Main() {
      int[] arrSource = new int[4];
      arrSource[0] = 1;
      arrSource[1] = 2;
      arrSource[2] = 3;
      arrSource[3] = 4;

      int[] arrTarget = new int[2];

      Array.Copy(arrSource, arrTarget, 2);

      Console.WriteLine("Destination Array ...");
      foreach (int value in arrTarget) {
         Console.WriteLine(value);
      }
   }
}
Return the Index label if some condition is satisfied over a column in Pandas Dataframe

26 Jan, 2019
Given a Dataframe, return all those index labels for which some condition is satisfied over a specific column.
Solution #1: We can use simple indexing operation to select all those values in the column which satisfies the given condition.
# importing pandas as pdimport pandas as pd  # Create the dataframedf = pd.DataFrame({'Date':['10/2/2011', '11/2/2011', '12/2/2011', '13/2/2011'],                   'Product':['Umbrella', 'Matress', 'Badminton', 'Shuttle'],                   'Last_Price':[1200, 1500, 1600, 352],                   'Updated_Price':[1250, 1450, 1550, 400],                   'Discount':[10, 10, 10, 10]})  # Create the indexesdf.index =['Item 1', 'Item 2', 'Item 3', 'Item 4']  # Print the dataframeprint(df)
Output :
Now, we want to find out the index labels of all items whose ‘Updated_Price’ is greater than 1000.
# Select all the rows which satisfies the criteria# convert the collection of index labels to list.Index_label = df[df['Updated Price']>1000].index.tolist()  # Print all the labelsprint(Index_label)
Output :As we can see in the output, the above operation has successfully evaluated all the values and has returned a list containing the index labels. Solution #2: We can use Pandas Dataframe.query() function to select all the rows which satisfies some condition over a given column.
# importing pandas as pdimport pandas as pd  # Create the dataframedf = pd.DataFrame({'Date':['10/2/2011', '11/2/2011', '12/2/2011', '13/2/2011'],                   'Product':['Umbrella', 'Matress', 'Badminton', 'Shuttle'],                   'Last_Price':[1200, 1500, 1600, 352],                   'Updated_Price':[1250, 1450, 1550, 400],                   'Discount':[10, 10, 10, 10]})  # Create the indexesdf.index =['Item 1', 'Item 2', 'Item 3', 'Item 4']  # Print the dataframeprint(df)
Output :
Now, we want to find out the index labels of all items whose ‘Updated_Price’ is greater than 1000.
# Select all the rows which satisfies the criteria# convert the collection of index labels to list.Index_label = df.query('Updated_Price > 1000').index.tolist()  # Print all the labelsprint(Index_label)
Output :
pandas-dataframe-program
Python pandas-dataFrame
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to unset JavaScript variables?

22 Apr, 2019
To know how to unset a variable we must know what are JS variables and how to declare a variable first. JavaScript variables are containers for storing data values. Variables can be declared using the ‘var’ keyword.
Example:
var x = 5;
In the above code declaration, the value 5 has been assigned to the variable ‘x’. The unsetting of a variable means to destroy it once its purpose in the code has been fulfilled.
Here a question arises, do we really need to unset the variables in JavaScript once their job is done?The answer is ‘No’. Also, it should be kept in mind that, variables set in the global scope cannot be deleted. It is advised to use var to declare variables in JS, however, the property declared using var keyword cannot be deleted as well. However, if the variable x was defined without using the ‘var’ keyword, then deleting it would have been possible using this method.
nxt = undefined;  // window is used in JS to access//  the global variableswindow.nxt = 'I am next'; delete window.nxt;
As far as memory management goes, the JavaScript interpreter performs automatic garbage collection for memory management. The job of a garbage collector is to track memory allocation and find when a piece of the allocated memory is no longer needed, in such a case the memory will be freed automatically. The ‘Garbage Collector’ frees the programmer from the worries of the destruction or reallocation of the objects.
Also, as already mentioned above, the variable cannot be destroyed in JavaScript. So, what could be done now? Some developers may suggest using ‘delete’, but the delete operator removes a property from an object. It cannot remove a variable. So what’s the closest thing that can be done to unset a variable in JS?
We cannot undeclare a variable. However, we can set its value to undefined for the purpose
nxt = undefined;
Example 1: This example describes delete keywords when var is not used.
<script>x = 20;delete x;console.log(x);</script>
Output:
There will be no output in the console, as x gets deleted in this case. However, when var will be used to declare the value of x, the delete function will not work.
Example 2: The delete doesn’t work when var is used.
<script>var x = 20;delete x;console.log(x);</script>
Output:The console will display output as 20. ‘var’ has been used to initialize the value of x and thus ‘delete’ function will not work in this case.
JavaScript-Misc
Picked
JavaScript
Web Technologies
Web technologies Questions
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
HTML | <script> async Attribute

02 Jun, 2022
The HTML,<script> async attribute is a boolean attribute. When present, it specifies that the script will be executed asynchronously when it is available. This attribute only works for external scripts (and used only in when src attribute is present ).Note: There are so many ways in which external script execute:  
when async is present: The script is executed asynchronously with the rest of the page (the script will be executed while the page continues the parsing)
when async is not present and defer is present: The script is executed when the page has finished parsing
If neither async or defer is present: The script is fetched and executed immediately before the browser continues parsing the page
Syntax:  
<script async>
Example: Index.html  
html
<!DOCTYPE html><html> <body>    <center>        <h1 style="color:green">          Geeksforgeeks      </h1>        <p id="p1">Hello GFG</p>          <script src="geeks.js" async></script>    </center></body> </html>
geeks.js  
javascript
alert("Hello GFG"); 
Output:  
Supported Browsers: The browsers supported by HTML <script> async attribute are listed below  
Google Chrome 1.0 and above
Edge 12 and above
Firefox 1 and above
Apple Safari 
Opera 
Internet Explorer
 
simmytarika5
kumargaurav97520
HTML-Attributes
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to call a function repeatedly every 5 seconds in JavaScript ?

13 Dec, 2021
The setInterval() method in JavaScript can be used to perform periodic evaluation of expression or call a JavaScript function. Syntax: 
setInterval(function, milliseconds, param1, param2, ...)
Parameters: This function accepts the following parameters:  
function: This parameter holds the function name which to be called periodically.
milliseconds: This parameter holds the period, in milliseconds, setInterval() calls/executes the function above.
param1, param2, ... : Some additional parameters to be passed as input parameters to function.
Return Value: This method returns the ID representing timer set by the method. This ID can be used to clear/unset the timer by calling clearInterval() method and passing it this ID as a parameter.Example: Suppose we want to create a reminder timer which goes off every 5 seconds and alerts through a JavaScript alert box.
javascript
<!DOCTYPE html><html> <head>    <title>        How to call a function        repeatedly every 5        seconds in JavaScript ?    </title></head> <body>      <p>        Click the button to start        timer, you will be alerted        every 5 seconds until you        close the window or press        the button to stop timer    </p>           <button onclick="startTimer()">        Start Timer    </button>         <button onclick="stopTimer()">        Stop Timer    </button>         <script>        var timer;                 function startTimer() {            timer = setInterval(function() {                alert("5 seconds are up");            }, 5000);        }                 function stopTimer() {            alert("Timer stopped");            clearInterval(timer);        }    </script></body> </html>
Output:  
Before clicking the button:  
After clicking the button:  
In the above example, the setInterval() method repeatedly evaluates an expression/calls a function. The way to clear/unset the timer set by setInterval() method is to use the clearInterval() method and passing it the ID/value returned on calling setInterval().
akshaysingh98088
ruhelaa48
JavaScript-Misc
Picked
JavaScript
Web Technologies
Web technologies Questions
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python program to find largest number in a list

08 Jun, 2022
Given a list of numbers, the task is to write a Python program to find the largest number in given list. Examples:
Input : list1 = [10, 20, 4]
Output : 20

Input : list2 = [20, 10, 20, 4, 100]
Output : 100
Method 1 : Sort the list in ascending order and print the last element in the list. 
Python3
# Python program to find largest# number in a list # list of numberslist1 = [10, 20, 4, 45, 99] # sorting the listlist1.sort() # printing the last elementprint("Largest element is:", list1[-1])
Largest element is: 99
Method 2 : Using max() method 
Python3
# Python program to find largest# number in a list # list of numberslist1 = [10, 20, 4, 45, 99]  # printing the maximum elementprint("Largest element is:", max(list1))
Chapters
descriptions off, selected
captions settings, opens captions settings dialog
captions off, selected
English
This is a modal window.
Beginning of dialog window. Escape will cancel and close the window.
End of dialog window.
Largest element is: 99
Method 3 : Find max list element on inputs provided by user 
Python3
# Python program to find largest# number in a list # creating empty listlist1 = [] # asking number of elements to put in listnum = int(input("Enter number of elements in list: ")) # iterating till num to append elements in listfor i in range(1, num + 1):    ele = int(input("Enter elements: "))    list1.append(ele)     # print maximum elementprint("Largest element is:", max(list1))
Output:
Enter number of elements in list: 4
Enter elements: 12
Enter elements: 19
Enter elements: 1
Enter elements: 99
Largest element is: 99
Method 4 : Without using built in functions in python: 
Python3
# Python program to find largest# number in a list def myMax(list1):     # Assume first number in list is largest    # initially and assign it to variable "max"    max = list1[0] # Now traverse through the list and compare    # each number with "max" value. Whichever is    # largest assign that value to "max'.    for x in list1:        if x > max :             max = x         # after complete traversing the list    # return the "max" value    return max  # Driver codelist1 = [10, 20, 4, 45, 99]print("Largest element is:", myMax(list1))
Largest element is: 99
Method: Use the max() and def functions to find the largest element in a given list. The max() function prints the largest element in the list.  
Python3
# Python code# To find the largest number in a list def maxelement(lst):  # displaying largest element  # one line solution  print(max(lst)) # driver code# input listlst = [20, 10, 20, 4, 100]# the above input can also be given as# lst = list(map(int, input().split()))  # -> taking input from the usermaxelement(lst) # this code is contributed by gangarajula laxmi
100
inboxofanirban
laxmigangarajula03
Python list-programs
python-list
Python
Python Programs
python-list
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | GATE-CS-2014-(Set-2) | Question 65

20 Jun, 2017
A FAT (file allocation table) based file system is being used and the total overhead of each entry in the FAT is 4 bytes in size. Given a 100 x 106 bytes disk on which the file system is stored and data block size is 103 bytes, the maximum size of a file that can be stored on this disk in units of 106 bytes is ____________.
(A) 99.55 to 99.65(B) 100.5 to 101.4(C) 97.2 to 98.5(D) 89.1 to 91.2Answer: (A)Explanation:
Here block size is 10^3 B.
No. of entries in the FAT = Disk capacity/ Block size 
                          = 10^8/10^3 
                          = 10^5
Total space consumed by FAT = 10^5 *4B 
                            = 0.4*10^6B
Max. size of file that can be stored = 100*10^6-0.4*10^6
                                     = 99.6*10^6B.
So answer 99.6.
Quiz of this Question
GATE-CS-2014-(Set-2)
GATE-GATE-CS-2014-(Set-2)
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.