code-rag-bench/online-tutorials huggingface dataset:
Get ceiling value of a number using Math.ceil in Java

In order to get the ceiling value of a number in Java, we use the java.lang.Math.ceil() method. The Math.ceil() method returns the smallest (closest to negative infinity) double value which is greater than or equal to the parameter and has a value which is equal to a mathematical integer on the number line. If the parameter is NaN or an infinity or positive zero or negative zero, then the result is the same as the argument. If the argument value is less than zero but greater than -1.0, then the value returned is negative zero.
Declaration − The java.lang.Math.ceil() method is declared as follows −
public static double ceil(double a)
Let us see a program to get the ceiling value of a number in Java.
Live Demo
import java.lang.Math;
public class Example {
   public static void main(String[] args) {
      // declaring and initialising some double values
      double a = -100.01d;
      double b = 34.6;
      double c = 600;
      // printing their ceiling values
      System.out.println("Ceiling value of " + a + " = " + Math.ceil(a));
      System.out.println("Ceiling value of " + b + " = " + Math.ceil(b));
      System.out.println("Ceiling value of " + c + " = " + Math.ceil(c));
   }
}
Ceiling value of -100.01 = -100.0
Ceiling value of 34.6 = 35.0
Ceiling value of 600.0 = 600.0
Difference Between COMMIT and ROLLBACK in SQL

In this post, we will understand the difference between COMMIT and ROLLBACK in SQL.
It validates the modifications that are made by the current transaction.
It validates the modifications that are made by the current transaction.
Once the COMMIT statement has been executed, the transaction can’t be rolled back using
ROLLBACK.
Once the COMMIT statement has been executed, the transaction can’t be rolled back using
ROLLBACK.
It occurs when the transaction is successfully executed.
It occurs when the transaction is successfully executed.
Syntax
COMMIT;
It removes the modifications that were made by the current transaction.
It removes the modifications that were made by the current transaction.
Once ROLLBACK is executed, the database would reach its previous state.
Once ROLLBACK is executed, the database would reach its previous state.
This is the state where the first statement of the transaction would be in execution.
This is the state where the first statement of the transaction would be in execution.
ROLLBACK happens when the transaction is aborted in between its execution.
ROLLBACK happens when the transaction is aborted in between its execution.
Syntax
ROLLBACK;
C# Program to pass Parameter to a Thread

To work with threads, add the following namespace in your code −
using System.Threading;
Firstly, you need to create a new thread in C# −
Thread thread = new Thread(threadDemo);
Above, threadDemo is our thread function.
Now pass a parameter to the thread −
thread.Start(str);
The parameter set above is −
String str = "Hello World!";
Let us see the complete code to pass a parameter to a thread in C#.
Live Demo
using System;
using System.Threading;
namespace Sample {
   class Demo {
      static void Main(string[] args) {
         String str = "Hello World!";
         // new thread
         Thread thread = new Thread(threadDemo);
         // passing parameter
         thread.Start(str);
      }
      static void threadDemo(object str) {
         Console.WriteLine("Value passed to the thread: "+str);
      }
   }
}
Value passed to the thread: Hello World!
What are factory functions in JavaScript ?

24 Jun, 2021
The Factory Function is similar to constructor functions/class functions, but instead of using new to create an object, factory functions simply creates an object and returns it.
Factory Functions are a very useful tool in JavaScript. Factory Functions in JavaScript are similar to constructor functions/class functions, but they do not require the use of the ‘this‘ keyword for inner values or the use of the ‘new‘ keyword when instantiating new objects. Factory Functions can contain inner values, methods, etc. just like normal regular functions. Factory Functions differ from regular functions as they always return an object, which will contain any value, method, etc.
Why it is useful?
If we have complex logic, and we have to create multiple objects again and again that have the same logic, we can write the logic once in a function and use that function as a factory to create our objects. It’s exactly the same as a real-world factory producing products.
 
Example 1: We have a factory function that will produce new robots with a single logic. Using this we can produce as many objects/robots as we want.
Javascript
<script>      // Function creating new objects     // without use of 'new' keyword    function createRobot(name) {        return {            name: name,            talk: function () {                console.log('My name is '                 + name + ', the robot.');            }        };    }      //Create a robot with name Chitti    const robo1 = createRobot('Chitti');      robo1.talk();        // Create a robot with name Chitti 2.O Upgraded    const robo2 = createRobot('Chitti 2.O Upgraded');      robo2.talk();</script>
Output:
My name is Chitti, the robot.
My name is Chitti 2.0 Upgraded, the robot.
Example 2:
Javascript
<script>      // Factory Function creating person    var Person = function (name, age) {          // creating person object        var person = {};          // parameters as keys to this object          person.name = name;        person.age = age;          // function to greet        person.greeting = function () {            return (                'Hello I am ' + person.name                     + '. I am ' + person.age                     + ' years old. '            );        };        return person;    };      var person1 = Person('Abhishek', 20);    console.log(person1.greeting());      var person2 = Person('Raj', 25);    console.log(person2.greeting());</script>
Output:
Hello I am Abhishek. I am 20 years old. 
Hello I am Raj. I am 25 years old. 
JavaScript-Questions
Picked
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
Remove elements from a JavaScript Array
Difference Between PUT and PATCH Request
Roadmap to Learn JavaScript For Beginners
JavaScript | Promises
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 ?
Converting string ‘yyyy-mm-dd’ into DateTime in Python

23 Aug, 2021
In this article, we are going to convert DateTime string of the format ‘yyyy-mm-dd’ into DateTime using Python. 
yyyy-mm-dd stands for year-month-day .
We can convert string format to datetime by using the strptime() function. We will use the  ‘%Y/%m/%d’  format to get the string to datetime.
Syntax:
datetime.datetime.strptime(input,format)
Parameter:
input is the string datetime
format is the format – ‘yyyy-mm-dd’
datetime is the module
Example: Python program to convert string datetime format to datetime
Python3
# import the datetime moduleimport datetime  # datetime in string format for may 25 1999input = '2021/05/25'  # formatformat = '%Y/%m/%d'  # convert from string format to datetime formatdatetime = datetime.datetime.strptime(input, format)  # get the date from the datetime using date() # functionprint(datetime.date())
2021-05-25

Example 2: Convert a list of string DateTime to DateTime
Python3
# import the datetime moduleimport datetime  # datetime in string format for list of datesinput = ['2021/05/25', '2020/05/25', '2019/02/15', '1999/02/4']  # formatformat = '%Y/%m/%d'for i in input:        # convert from string format to datetime format    # and get the date    print(datetime.datetime.strptime(i, format).date())
2021-05-25
2020-05-25
2019-02-15
1999-02-04

Picked
Python-datetime
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to iterate through Excel rows in Python?
Rotate axis tick labels in Seaborn and Matplotlib
Deque in Python
Queue in Python
Defaultdict in Python
Check if element exists in list in Python
Python Classes and Objects
Bar Plot in Matplotlib
reduce() in Python
Python | Get unique values from a list
Difference between NULL pointer, Null character (‘\0’) and ‘0’ in C with Examples

01 Jun, 2020
NULL Pointer:The integer constant zero(0) has different meanings depending upon it’s used. In all cases, it is an integer constant with the value 0, it is just described in different ways.If any pointer is being compared to 0, then this is a check to see if the pointer is a null pointer. This 0 is then referred to as a null pointer constant. The C standard defines that 0 is typecast to (void *) is both a null pointer and a null pointer constant.The macro NULL is provided in the header file “stddef.h”.
Below are the ways to check for a NULL pointer:
NULL is defined to compare equal to a null pointer as:if(pointer == NULL)

if(pointer == NULL)

Below if statement implicitly checks “is not 0”, so we reverse that to mean “is 0” as:if(!pointer) 

if(!pointer) 

Null Characters(‘\0’):‘\0’ is defined to be a null character. It is a character with all bits set to zero. This has nothing to do with pointers. ‘\0’ is (like all character literals) an integer constant with the value zero.
Below statement checks if the string pointer is pointing at a null character.if (!*string_pointer)
Below statement checks if the string pointer is pointing at a not-null character.if (*string_pointer)

Below statement checks if the string pointer is pointing at a null character.if (!*string_pointer)

if (!*string_pointer)

Below statement checks if the string pointer is pointing at a not-null character.if (*string_pointer)

if (*string_pointer)

In C language string is nothing but an array of char type. It stores each of the characters in a memory space of 1 byte. Each array is terminated with ‘\0’ or null character but if we store a ‘0’ inside a string both are not same according to the C language. ‘0’ means 48 according to the ASCII Table whereas ‘\0’ means 0 according to the ASCII table.
Below is the C program to print the value of ‘\0’ and ‘0’:
// C program to print the value of// '\0' and '0'#include <stdio.h>  // Driver Codeint main(){    // Print the value of    // '\0' and '0'    printf("\\0 is %d\n", '\0');    printf("0 is %d\n", '0');    return 0;}
\0 is 0
0 is 48

C Basics
C-Pointer Basics
C Programs
Difference Between
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
C Program to read contents of Whole File
Producer Consumer Problem in C
Difference between break and continue statement in C
C Hello World Program
Handling multiple clients on server with multithreading using Socket Programming in C/C++
Class method vs Static method in Python
Difference between BFS and DFS
Difference between var, let and const keywords in JavaScript
Difference Between Method Overloading and Method Overriding in Java
Differences between JDK, JRE and JVM
Regex - reusing patterns to capture groups in JavaScript?

For this, use regular expression with digit along with $.
var groupValues1 = "10 10 10";
var groupValues2 = "10 10 10 10";
var groupValues3 = "10 10";
var regularExpression = /^(\d+)(\s)\1\2\1$/;
var isValidGroup1 = regularExpression.test(groupValues1);
var isValidGroup2 = regularExpression.test(groupValues2);
var isValidGroup3 = regularExpression.test(groupValues3);
if(isValidGroup1==true)
   console.log("This is a valid group="+groupValues1);
else
   console.log("This is not a valid group="+groupValues1);
if(isValidGroup2==true)
   console.log("This is a valid group="+groupValues2);
else
   console.log("This is not a valid group="+groupValues2);
if(isValidGroup3==true)
   console.log("This is a valid group="+groupValues3);
else
   console.log("This is not a valid group="+groupValues3);
To run the above program, you need to use the following command −
node fileName.js.
Here, my file name is demo188.js.
The below output matches only groups 3. This will produce the following output −
PS C:\Users\Amit\javascript-code> node demo188.js
This is a valid group=10 10 10
This is not a valid group=10 10 10 10
This is not a valid group=10 10
LocalDate getMonth() method in Java

28 Nov, 2018
The getMonth() method of LocalDate class in Java gets the month-of-year field using the Month enum.
Syntax:
public Month getMonth()

Parameter: This method does not accepts any parameter.
Return Value: The function returns the month of the year.
Below programs illustrate the getMonth() method of LocalDate in Java:Program 1:
// Program to illustrate the getMonth() method  import java.util.*;import java.time.*;  public class GfG {    public static void main(String[] args)    {        // Parses the date        LocalDate dt = LocalDate.parse("2018-11-27");          // Prints the day number        System.out.println(dt.getMonth());    }}
NOVEMBER

Program 2:
// Program to illustrate the getMonth() method  import java.util.*;import java.time.*;  public class GfG {    public static void main(String[] args)    {        // Parses the date        LocalDate dt = LocalDate.parse("2018-01-02");          // Prints the day number        System.out.println(dt.getMonth());    }}
JANUARY

Reference: https://docs.oracle.com/javase/10/docs/api/java/time/LocalDate.html#getMonth()
Java-Functions
Java-LocalDate
Java-time package
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | Test if tuple is distinct - GeeksforGeeks

03 Nov, 2019
Sometimes, while working with records, we have a problem in which we need to find if all elements of tuple are different. This can have applications in many domains including web development. Let’s discuss certain ways in which this task can be performed.
Method #1 : Using loopThis is a brute force way in which this task can be performed. In this, we just iterate through all tuple elements and put it in set if it’s the first occurrence. During the subsequence occurrence we check in set, if it exists, we return False.
# Python3 code to demonstrate working of# Test if tuple is distinct# Using loop  # initialize tuple test_tup = (1, 4, 5, 6, 1, 4)  # printing original tuple print("The original tuple is : " + str(test_tup))  # Test if tuple is distinct# Using loopres = True temp = set()for ele in test_tup:    if ele in temp:        res = False         break    temp.add(ele)  # printing resultprint("Is tuple distinct ? : " + str(res))
The original tuple is : (1, 4, 5, 6, 1, 4)
Is tuple distinct ? : False

 
Method #2 : Using set() + len()In this method, we convert the tuple into a set using set(), and then check it with original tuple length, if matches, means that it was a distinct tuple and returns True.
# Python3 code to demonstrate working of# Test if tuple is distinct# Using set() + len()  # initialize tuple test_tup = (1, 4, 5, 6)  # printing original tuple print("The original tuple is : " + str(test_tup))  # Test if tuple is distinct# Using set() + len()res = len(set(test_tup)) == len(test_tup)  # printing resultprint("Is tuple distinct ? : " + str(res))
The original tuple is : (1, 4, 5, 6)
Is tuple distinct ? : True

Python tuple-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Split string into list of characters
Python | Convert a list to dictionary
How to print without newline in Python?
Python | Pandas PeriodIndex.freq - GeeksforGeeks

20 Aug, 2021
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 PeriodIndex.freq attribute returns the time series frequency that is applied on the given PeriodIndex object.
Syntax : PeriodIndex.freqParameters : NoneReturn : Index  
Example #1: Use PeriodIndex.freq attribute to find the time series frequency of the given PeriodIndex object. 
Python3
# importing pandas as pdimport pandas as pd # Create the PeriodIndex objectpidx = pd.PeriodIndex(start='2005-12-21 08:45 ',              end='2005-12-21 11:55', freq='H') # Print the PeriodIndex objectprint(pidx)
Output : 
Now we will use the PeriodIndex.freq attribute to find the time series frequency of the given object.
Python3
# return the frequencypidx.freq
Output : 
As we can see in the output, the PeriodIndex.freq attribute has returned ‘Hourly’ frequency. This is the time series frequency that is applied on the given PeriodIndex object.
Example #2: Use PeriodIndex.freq attribute to find the time series frequency of the given PeriodIndex object. 
Python3
# importing pandas as pdimport pandas as pd # Create the PeriodIndex objectpidx = pd.PeriodIndex(start='2011-02-1 ',             end='2011-08-14', freq='M') # Print the PeriodIndex objectprint(pidx)
Output :  
Now we will use the PeriodIndex.freq attribute to find the time series frequency of the given object.
Python3
# return the frequencypidx.freq
Output :  
As we can see in the output, the PeriodIndex.freq attribute has returned the ‘Monthly’ frequency. This is the time series frequency that is applied on the given PeriodIndex object. 
anikakapoor
Pandas periodIndex
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Iterate over a list in Python
Python String | replace()
Reading and Writing to text files in Python
*args and **kwargs in Python
Create a Pandas DataFrame from Lists
Convert integer to string in Python
Compute the value of Quantile Function over F Distribution in R Programming - qf() Function - GeeksforGeeks

25 Jun, 2020
qf() function in R Language is used to compute the value of quantile function over F distribution for a sequence of numeric values. It also creates a density plot of quantile function over F Distribution.
Syntax: qf(x, df1, df2)
Parameters:x: Numeric Vectordf: Degree of Freedom
Example 1:
# R Program to compute value of# Quantile Function over F Distribution  # Creating a sequence of x-valuesx <- seq(0, 1, by = 0.2)  # Calling qf() Functiony <- qf(x, df1 = 2, df2 = 3)y
Output:
[1] 0.0000000 0.2405958 0.6085817 1.2630236 2.8860266       Inf

Example 2:
# R Program to compute the value of# Quantile Function over F Distribution  # Creating a sequence of x-valuesx <- seq(0, 1, by = 0.02)  # Calling qf() Functiony <- qf(x, df1 = 2, df2 = 3)  # Plot a graphplot(y)
Output:
R Statistics-Function
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Filter data by multiple conditions in R using Dplyr
Loops in R (for, while, repeat)
Change Color of Bars in Barchart using ggplot2 in R
How to change Row Names of DataFrame in R ?
Remove rows with NA in one column of R DataFrame
How to Change Axis Scales in R Plots?
Group by function in R using Dplyr
How to Split Column Into Multiple Columns in R DataFrame?
K-Means Clustering in R Programming
Logistic Regression in R Programming
How to select a drop-down menu option value with Selenium (Python)?

We can select a drop-down menu option value with Selenium webdriver.
The Select class in Selenium is used to handle drop-down. In an html document, the drop-down is identified with the <select> tag.
Let us see the html structure of a drop-down.
For using the methods of Select class we have to import selenium.webdriver.support.select.Select in our code. Let us discuss the methods available to select an option from drop-down−
select_by_visible_text (arg) – The arg which is passed as a parameter to the method is selected if it matches with the text which is visible in the dropdown.Syntax−sel = Select (driver.find_element_by_id ("name"))sel.select_by_visible_text ('Visible Text')
select_by_visible_text (arg) – The arg which is passed as a parameter to the method is selected if it matches with the text which is visible in the dropdown.
Syntax−
sel = Select (driver.find_element_by_id ("name"))
sel.select_by_visible_text ('Visible Text')
select_by_value (arg) – The arg which is passed as a parameter to the method is selected if it matches with the option value in the dropdown.Syntax−sel = Select (driver.find_element_by_id ("name"))sel.select_by_value ('Value')
select_by_value (arg) – The arg which is passed as a parameter to the method is selected if it matches with the option value in the dropdown.
Syntax−
sel = Select (driver.find_element_by_id ("name"))
sel.select_by_value ('Value')
select_by_index (arg) – The arg which is passed as a parameter to the method is selected if it matches with the option index in the dropdown.The index begins from zero.Syntax−sel = Select (driver.find_element_by_id ("name"))sel.select_by_index (1)
select_by_index (arg) – The arg which is passed as a parameter to the method is selected if it matches with the option index in the dropdown.
The index begins from zero.
Syntax−
sel = Select (driver.find_element_by_id ("name"))
sel.select_by_index (1)
from selenium import webdriver
from selenium.webdriver.support.select import Select
import timedriver = webdriver.Chrome(executable_path="C:\\chromedriver.exe")
driver.implicitly_wait(0.5)
driver.get("https://www.tutorialspoint.com/selenium/selenium_automation_practice.htm")
# identify dropdown with Select class
sel = Select(driver.find_element_by_xpath("//select[@name='continents']"))
#select by select_by_visible_text() method
sel.select_by_visible_text("Europe")
time.sleep(0.8)
#select by select_by_index() method
sel.select_by_index(0)
driver.close()
What is the Application Cache and why it is used in HTML5 ?

18 Aug, 2021
The task is to learn about the application cache in HTML5. HTML stands for HyperText Markup Language and it is used to design web pages using a markup language. HTML5 is current or we can also say that it’s the 5th version of HTML.
Application Cache in HTML5: The current version of HTML5 introduces application cache, which means that a web application is cached, and accessible without an internet connection. Now we can make an offline web application that will run without an internet connection by just creating a manifest file in our application. 
Syntax:
<html manifest="demo.appcache">
Structure of HTML file: HTML is nothing but just an element tag that comes after the doctype tag in HTML structure. 
 
HTML
<!DOCTYPE html><html>  <!-- In this element we will add an attribute       called manifest attribute-->  <head>    <title>Page Title</title>  </head>  <body>    <h2>Welcome To GFG</h2>    <p>It is a paragraph element</p>    </body></html>
Let us understand the concept of application cache with the help of an example.
Approach: 
Create an HTML file with the manifest attribute.
Create another HTML file then link it to the previously created HTML file.
Example: The name of the main file is “index.html”. First, the main file will execute and when you try to open the linked page the next page will run. After that, you just have to go offline and reload the page. the content of the page will still work fine.
HTML
<!DOCTYPE html><html manifest="demo.appcache">  <body>    Welcome to GeeksForGeeks.    <p>      Try opening <a href="index2.html">this page</a>,      then go offline, and reload the page. The content       should still work.    </p>    </body></html>
HTML
<!DOCTYPE html><html manifest="demo.appcache">  <body>    Welcome to GFG, a computer science portal for geeks.  </body></html>
Output: 
Uses of the application cache are:
Offline browsing: The users can use the application whenever they want to access the site when they’re offline
Speed: When the data is already stored then it is easy to access data with the greater speed, cached resources load faster than uncached resources.
Reduced server load: The browser will only download updated resources from the server.
Supported browsers:
Chrome 4.0 and above
Internet 10.0 and above
Mozilla Firefox 3.5 and above
Opera 11.5 and above
Safari 4.0
HTML-Questions
HTML5
Picked
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
REST API (Introduction)
Design a Tribute Page using HTML & CSS
Build a Survey Form using HTML and CSS
Angular File Upload
Design a web page using HTML and CSS
Installation of Node.js on Linux
Difference between var, let and const keywords in JavaScript
How to fetch data from an API in ReactJS ?
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
How to replace line breaks with <br> using JavaScript ?

19 Sep, 2021
Given a multiline string and the task is to replace line breaks with <br> tag.
Example:
Input: `Geeks for Geeks is a computer science portal where people study computer science`Output: “Geeks for Geeks is <br> a computer science portal <br> where people study computer science”
To achieve this we have the following methods :
Method 1: Using Regex, in this example, we are creating a paragraph and a button and on clicking the button we are changing (Adding the <br>)the text of the paragraph.
We are using the String.replace() method of regex to replace the new line with <br>.
The String.replace() is an inbuilt method in JavaScript that is used to replace a part of the given string with another string or a regular expression. The original string will remain unchanged.
Example 1:
HTML
<!DOCTYPE html><html>  <body>    <p id="para"></p>      <p>      <button onClick="myFunc()">Change</button>      <script>        let str = `Geeks for Geeks is           a computer science portal           where people study computer science`;         let para = document.getElementById("para");         para.innerHTML = str;         function myFunc() {          // Replace the \n with <br>          str = str.replace(/(?:\r\n|\r|\n)/g, "<br>");           // Update the value of paragraph          para.innerHTML = str;        }      </script>    </p>   </body></html>
Output:
The initial output
After clicking the button
Method 2: Using split and join, in this method, we split the string from the delimiter “\n” which returns an array of substrings, and then we join the Array using the join method and pass <br /> so that every joining contains <br />.
 
Example 2:
HTML
<!DOCTYPE html><html>  <body>    <p id="para"></p>      <p>      <button onClick="myFunc()">Change</button>      <script>        let str = `Geeks for Geeks is           a computer science portal           where people study computer science`;         let para = document.getElementById("para");         para.innerHTML = str;         function myFunc() {          // Replace the \n with <br>          str = str.split("\n").join("<br />");          // Update the value of paragraph          para.innerHTML = str;        }      </script>    </p>   </body></html>
Output:
The initial output
After clicking the button
sweetyty
javascript-functions
JavaScript-Methods
JavaScript-Questions
JavaScript-RegExp
javascript-string
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
Hide or show elements in HTML using display property
How to append HTML code to a div using JavaScript ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Installation of Node.js on Linux
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 ?
Python | Working with .docx module

07 Jul, 2018
Word documents contain formatted text wrapped within three object levels. Lowest level- Run objects, Middle level- Paragraph objects and Highest level- Document object.So, we cannot work with these documents using normal text editors. But, we can manipulate these word documents in python using the python-docx module.
1. The first step is to install this third-party module python-docx. You can use pip “pip install python-docx” or download the tarball from here. Here’s the Github repository.
2. After installation import “docx” NOT “python-docx”.3. Use “docx.Document” class to start working with the word document.
Code #1:
# import docx NOT python-docximport docx  # create an instance of a word documentdoc = docx.Document()  # add a heading of level 0 (largest heading)doc.add_heading('Heading for the document', 0)  # add a paragraph and store # the object in a variabledoc_para = doc.add_paragraph('Your paragraph goes here, ')  # add a run i.e, style like # bold, italic, underline, etc.doc_para.add_run('hey there, bold here').bold = Truedoc_para.add_run(', and ')doc_para.add_run('these words are italic').italic = True  # add a page break to start a new pagedoc.add_page_break()  # add a heading of level 2doc.add_heading('Heading level 2', 2)  # pictures can also be added to our word document# width is optionaldoc.add_picture('path_to_picture')  # now save the document to a locationdoc.save('path_to_document')
Output:
Notice the page break in the second page. Code #2: Now, to open a word document, create an instance along with passing the path to the document.
# import the Document class # from the docx modulefrom docx import Document  # create an instance of a # word document we want to opendoc = Document('path_to_the_document')  # print the list of paragraphs in the documentprint('List of paragraph objects:->>>')print(doc.paragraphs)  # print the list of the runs # in a specified paragraphprint('\nList of runs objects in 1st paragraph:->>>')print(doc.paragraphs[0].runs)  # print the text in a paragraph print('\nText in the 1st paragraph:->>>')print(doc.paragraphs[0].text)  # for printing the complete documentprint('\nThe whole content of the document:->>>\n')for para in doc.paragraphs:    print(para.text)
Output:
List of paragraph objects:->>>
[<docx.text.paragraph.Paragraph object at 0x7f45b22dc128>,
<docx.text.paragraph.Paragraph object at 0x7f45b22dc5c0>,
<docx.text.paragraph.Paragraph object at 0x7f45b22dc0b8>,
<docx.text.paragraph.Paragraph object at 0x7f45b22dc198>,
<docx.text.paragraph.Paragraph object at 0x7f45b22dc0f0>]

List of runs objects in 1st paragraph:->>>
[<docx.text.run.Run object at 0x7f45b22dc198>]

Text in the 1st paragraph:->>>
Heading for the document

The whole content of the document:->>>

Heading for the document
Your paragraph goes here, hey there, bold here, and these words are italic


Heading level 2


Reference: https://python-docx.readthedocs.io/en/latest/#user-guide.
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Wand save() method in Python

22 Apr, 2020
Whenever we manipulate an image and want to preserve image for further image, we use save() function. save() function saves the image into the file or filename. It saves the final manipulated image in your disk.
Syntax :
# image manipulation codewand.image.save(file = file_object or                 filename='filename.format')
Parameters :It has only two parameter and takes only one at a time.
Now let’s see code to save image.
Example #1: Save image to the disk.
# import Image from wand.image modulefrom wand.image import Image  # read image using with Image(filename ='koala.png') as img:    # manipulate image    img.rotate(90 * r)      # save final image after    img.save(filename ='final.png')
Output :
In output an image named koala.png will be saved in disk
Example #2:
We can save image to output stream using save() function too. For example, the following code converts koala.png image into JPEG, gzips it, and then saves it to koala.jpg.gz:
# import gzipimport gzip  # import Image from wand.image modulefrom wand.image import Image  # create gz compressed filegz = gzip.open('koala.jpg.gz')  # read image using Image() functionwith Image(filename ='pikachu.png') as img:    # get format of image    img.format = 'jpeg'      # save image to output stream using save() function    img.save(file = gz)gz.close()
Output :
A compressed file named koala.jpg.gz get saved in disk

Image-Processing
Python-wand
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python | os.path.join() method
Python OOPs Concepts
How to drop one or multiple columns in Pandas Dataframe
Introduction To PYTHON
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | datetime.timedelta() function
Python | Get unique values from a list
How to List All Tables in Oracle?

28 Oct, 2021
In this article, we will discuss all the methods to list all tables in the oracle SQL Database.
We have three types of a subset of tables available to use as identifiers which in turn help us to sort the required table names. Here, are the following types of table identifiers in the Oracle SQL Database.
1. DBA_tables:
If the user is SYSTEM or has access to dba_tables data dictionary view, then use the given below query:
Query:
SELECT owner, table_name FROM dba_tables;
This query returns the following list of tables that contain all the tables that are there in the entire database.
Output:
2. All_tables:
If the user does not have access or privilege to view the dba_tables it can still get a list of all the tables that it has access to using the following SQL query. This SQL query gives the list of tables that can be accessed by the user along with its owner.
Query:
SELECT owner, table_name FROM all_tables;
This query returns the following list of tables that contain all the tables that the user has access to in the entire database.
Output:
3. User_tables
If the user wants the list of all tables owned/created by him only, then use the following SQL query to get a list of tables. The following query does not return the name of the owner as it is the user itself for all the tables.
Query:
SELECT table_name FROM user_tables;
This query returns the following list of tables that contain all the tables owned by the user in the entire database.
Output:
Oracle
Picked
SQL
Oracle
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Update Multiple Columns in Single Update Statement in SQL?
Window functions in SQL
SQL | Sub queries in From Clause
What is Temporary Table in SQL?
SQL using Python
SQL Query to Find the Name of a Person Whose Name Starts with Specific Letter
SQL Query to Convert VARCHAR to INT
RANK() Function in SQL Server
SQL Query to Compare Two Dates
SQL Query to Insert Multiple Rows
p5.js | point() Function

17 Jan, 2020
The point() function is an inbuilt function in p5.js which is used to draw the point in a given coordinate position.
Syntax:
point( x, y, [z])
Parameters: This function accept three parameters which are described below
x: It is used to set the x-coordinate of point.
y: It is used to set the y-coordinate of point.
z: It is used to set the z-coordinate in WebGL mode.
Example 1:
function setup() {      // Create Canvas of given size     createCanvas(400, 300);  }  function draw() {      // Use point() function to draw point    point(50, 50);    point(150, 50);    point(50, 150);    point(150, 150);      // Use strokeWeight() function to set    // the weight of point    strokeWeight(10);}
Output:
Example 2:
function setup() {           // Create Canvas of given size     createCanvas(400, 300); }   function draw() {           // Set the background color    background('green');          // Set the stroke weight    strokeWeight(10);      // Set stroke color    stroke('white');      // Draw point    point(50, 50);        point(50, 250);        point(350, 50);        point(350, 250);        point(200, 150);    } 
Output:
Online editor: https://editor.p5js.org/Environment Setup: https://www.geeksforgeeks.org/p5-js-soundfile-object-installation-and-methods/
Reference: https://p5js.org/reference/#/p5/point
JavaScript-p5.js
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Set JavaScript object values to null?

In order to set object values to null, you need to get all the keys from the object and need to set
null. You can use for loop or forEach() loop.
Following is the JavaScript code with name records. We will set the object value to null −
const object=[
   {
      FirstName:"John"
   },
   {
      FirstName:"David"
   },
   {
      FirstName:"Bob"
   }
]
Object.keys(object).forEach(key => object[key]=null);
console.log(object);
To run the above program, you need to use the following command −
node fileName.js.
Here, my file name is demo31.js.
This will produce the following output −
PS C:\Users\Amit\JavaScript-code> node demo31.js
[ null, null, null ]
Above, all the values are now set to NULL.
p5.js | square() Function - GeeksforGeeks

17 Jan, 2020
The square() function is an inbuilt function in p5.js which is used to draw the square on the screen. A square contains four equal sides and four angles each of 90 degrees. It is the special case of a rectangle where width and height are equal.
Syntax:
square( x, y, s, tl, tr, br, bl )
Parameters: This function accept many parameters as mentioned above and described below:
x: It is used to set the x-coordinate of square.
y: It is used to set the y-coordinate of square.
s: It is used to set the size of side of square.
tl: It is optional parameter and used to set the radius of top-left corner.
tr: It is optional parameter and used to set the radius of top-right corner.
br: It is optional parameter and used to set the radius of bottom-right corner.
bl: It is optional parameter and used to set the radius of bottom-left corner.
Example 1:
function setup() {            // Create Canvas of given size     createCanvas(300, 300);    }    function draw() {            background(220);           // Use color() function    let c = color('green');       // Use fill() function to fill color    fill(c);         // Draw a square    square(50, 50, 200);     } 
Output:
Example 2:
function setup() {            // Create Canvas of given size     createCanvas(300, 300);    }    function draw() {            background(220);           // Use color() function    let c = color('green');       // Use fill() function to fill color    fill(c);         // Draw a square    square(50, 50, 200, 20);     } 
Output:
Example 3:
function setup() {            // Create Canvas of given size     createCanvas(300, 300);    }    function draw() {            background(220);           // Use color() function    let c = color('green');       // Use fill() function to fill color    fill(c);         // Draw a square    square(50, 50, 200, 10, 20, 30, 40);     } 
Output:
Online editor: https://editor.p5js.org/Environment Setup: https://www.geeksforgeeks.org/p5-js-soundfile-object-installation-and-methods/
Reference: https://p5js.org/reference/#/p5/square
JavaScript-p5.js
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Remove elements from a JavaScript Array
Difference between var, let and const keywords in JavaScript
Difference Between PUT and PATCH Request
How to Use the JavaScript Fetch API to Get Data?
JavaScript | Promises
Remove elements from a JavaScript Array
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
Lodash _.entries() Method - GeeksforGeeks

13 Apr, 2021
The _.entries() method is used to create an array of keyed-value pairs for the specified object. If object is a map or set, its entries are returned.
Syntax:
_.entries(object)
Parameters: This method accepts single parameter as mentioned above and described below:
object: This parameter holds the object to query.
Return Value: This method returns the key-value pairs.
Example 1:
Javascript
// Defining Lodash variableconst _ = require('lodash'); // Specifying a functionfunction gfg() {  this.A = 5;  this.B = 10;  this.C = 15;} // Calling the _.entries() function_.entries(new gfg);
 
 
Output:
 
[ [ 'A', 5 ], [ 'B', 10 ], [ 'C', 15 ] ]
 
Example 2: In the below code, a set is taken as the object, hence the function _.entries() returns its entries.
 
Javascript
// Defining Lodash variableconst _ = require('lodash'); // Initializing a setconst object = {a: {b: 1}}; // Calling the _.entries() function_.entries(object);
 
 
Output:
 
[ [ 'a', { b: 1 } ] ]
 
Note: This will not work in normal JavaScript because it requires the lodash library to be installed.
 
arorakashish0911
JavaScript-Lodash
JavaScript
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
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
How to calculate the number of days between two dates in javascript?
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
Implementing of strtok() function in C++

12 Dec, 2021
The strtok() function is used in tokenizing a string based on a delimiter. It is present in the header file “string.h” and returns a pointer to the next token if present, if the next token is not present it returns NULL. To get all the tokens the idea is to call this function in a loop.
Header File:
#include <string.h>
Syntax: 
char *strtok(char *s1, const char *s2);
In this article, we will discuss the implementation of this function in which two things must be taken into consideration:
Maintain the state of the string to make sure how many tokens we have already extracted.
Secondly, maintain the list of extracted tokens in an array to return it.
Steps:
Create a function strtok() which accepts string and delimiter as an argument and return char pointer.
Create a static variable input to maintain the state of the string.
Check if extracting the tokens for the first time then initialize the input with it.
If the input is NULL and all the tokens are extracted then return NULL.
In this step, start extracting tokens and store them in the array result[].
Now, iterate a loop until NULL occurs or the delimiter then return the result by including ‘\0’.
When the end of the string is reached and if it requires then manually add a ‘\0‘ and include this corner case in the end.
Below is the implementation of the same:
C++
// C++ program to demonstrate the function// strtok() to tokenized the string#include <bits/stdc++.h>using namespace std;char* mystrtok(char* s, char d){    // Stores the state of string    static char* input = NULL;     // Initialize the input string    if (s != NULL)        input = s;     // Case for final token    if (input == NULL)        return NULL;     // Stores the extracted string    char* result = new char[strlen(input) + 1];    int i = 0;     // Start extracting string and    // store it in array    for (; input[i] != '\0'; i++) {         // If delimiter is not reached        // then add the current character        // to result[i]        if (input[i] != d)            result[i] = input[i];         // Else store the string formed        else {            result[i] = '\0';            input = input + i + 1;            return result;        }    }     // Case when loop ends    result[i] = '\0';    input = NULL;     // Return the resultant pointer    // to the string    return result;} // Driver Codeint main(){    // Given string str    char str[90] = "It, is my, day";     // Tokenized the first string    char* ptr = mystrtok(str, ' ');     // Print current tokenized string    cout << ptr << endl;     // While ptr is not NULL    while (ptr != NULL) {        // Tokenize the string        ptr = mystrtok(NULL, ' ');         // Print the string        cout << ptr << endl;    }    return 0;}
It,
is
my,
day
 
saurabh1990aror
CPP-Library
cpp-string
C++
C++ Programs
Strings
Strings
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
title driver method – Selenium Python

15 May, 2020
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 title driver method in Selenium. title method gets the title of the current page.
Syntax –
driver.title
Example –Now one can use title method as a driver method as below –
diver.get("https://www.geeksforgeeks.org/")
driver.title

To demonstrate, title method of WebDriver in Selenium Python. Let’ s visit https://www.geeksforgeeks.org/ and operate on driver object. Let’s get title,
Program –
# import webdriverfrom selenium import webdriver  # create webdriver objectdriver = webdriver.Firefox()  # get geeksforgeeks.orgdriver.get("https://www.geeksforgeeks.org/")  # get titleprint(driver.title)
Output –Screenshot added –
Terminal output –
Python-selenium
selenium
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Arden's Theorem

Theory of Computation
Arden's Theorem is basically used to find out regular expression with properties of a Finite Automaton. The Arden's Theorem is also called Arden's Lemma. It is a mathematical statement. As we know, a language is a set of strings. These sets can be specified by the meaning of some language expression. This is evaluated by language operations. It is valuable for checking the equivalence of two regular expressions along with the conversion of DFA to a regular expression.
The main applications of Arden's Theorem are as follows:
To determine the regular expression of finite automata.
It helps in checking the equivalence of two regular expressions.
Suppose, an alphabet Σ having two regular expressions P and Q. If P does not contain a null string, then -
It means, whenever the equation is in the form of R=Q+RP, we can directly replace this with R=QP∗.
Here, we have proved that R=QP∗ is the unique solution of R=Q+RP.
R=Q+RP

R=Q+[Q+RP]P 

// Put R = Q+RP 
R = Q + QP + RPP 

// Let's put the value R = Q+RP, repeatedly in place of R 
R = Q + QP +[Q+RP]PP 
R = Q + QP + QPP + RPPP 
R = Q + QP + QP2 + QP3 + QP4 + .. .. 
R = Q(1 + P + P2 + P3 + ....) 

// Hence Proved
R = QP∗ 

Here is the following DFA state diagram, we will construct the regular expression using Arden's theorem-
The state equations of the above DFA are-
A = ∈ + A0 + B0 
B = A1 + B1 

//substitute the value of B 
B = A1 + (A1 + B1)1 
B = A1 + A11 + B11 

//.. Arden's theorem
B = A11* 

Now, substitute the value for B in A -
A = ∈ + A0 + B0 
A = ∈ + A0 + (A11*)0 
A = ∈ + A0 + A11*0 
A = ∈ + A(0 + 11*0) 

//..Using Arden's theorem 
A = ∈(0 + 11*0)* 

// Hence Proved
A = (0 + 11*0)*