code-rag-bench/online-tutorials huggingface dataset:
Euler Method for solving differential equation in C++

In this problem, we are given a differential equation f(x, y) = dy/dx with initial value y(x0) = y0. Our task is to find the solution of the equation using the Euler method for solving differential equations.
Euler method also known as forward euler Method is a first order numerical procedure to find the solution of the given differential equation using the given initial value.
For a differential equation f(x, y) = dy / dx. Euler method is defined as,
y(n+1) = y(n) + h * f( x(n), y(n) )
The value h is step size which is calculated as,
h = (x(n) - x(0)) / n
Live Demo
#include <iostream>
using namespace std;

float equation(float x, float y) {

   return (x + y);
}

void solveEquationEulers(float x0, float y, float h, float x) {

   float temp = 0.0;

   while (x0 < x) {
      temp = y;
      y = y + h * equation(x0, y);
      x0 = x0 + h;
   }
   cout<<"The solution of the differential equation at x = "<< x <<" is f(x, y) = "<<y;
}

int main()
{
   float x0 = 0;
   float y0 = 1;
   float h = 0.5;
   float x = 0.1;
   solveEquationEulers(x0, y0, h, x);
   return 0;
}
The solution of the differential equation at x = 0.1 is f(x, y) = 1.5
Microsoft Expression Web - Video

In this chapter, we will learn how to add videos to the website and which formats are supported in Expression Web. With the help of videos, you can easily attract the attention of potential customers to your company's products or services.
Microsoft Expression Web is a web design tool that simplifies the process of adding promotional, marketing, or training videos to webpages. You can easily insert your videos in Microsoft Expression's Design view.
By default, Expression Web supports video encoding formats like Silverlight, Adobe Flash, WMV, ASF, MWA, AVI, WVX and MPEG.
Let us now take an example to understand the process of adding a video in a step-by-step manner.
Step 1 − Add a new HTML file and call it videodemo.html.
Step 2 − Click the mouse at the location within the webpage where the video is to be inserted. Let’s say we want to add a video below the heading.
Step 3 − Go to the Insert menu → Media which will open the submenu containing the list of video player formats that Expressions supports by default. Let’s select Windows Media Player.
Step 4 − Locate the video you want to use. Select the video file's name and click the Insert button to insert it into the webpage. Save the file by pressing Ctrl + S and you will see the Save Embedded Files dialog box.
Step 5 − Click OK and you will see that the media file is added to the website folder.
Following is the code in the videodemo.html page.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns = "http://www.w3.org/1999/xhtml">  
   <head> 
      <meta content = "text/html; charset = utf-8" http-equiv = "Content-Type" /> 
      <title>Untitled 1</title> 
   </head>  
   
   <body> 
      <h1> Video Demo</h1> 
      <p> 
         <object id = "media1" height = "200" type = "video/x-ms-wmv" width = "200"> 
            <param name = "filename" value = "logo.wmv" /> 
         </object> 
      </p> 
   </body> 
</html> 
Step 6 − Let us now preview the webpage in a browser. You will see that the video is playing.

    16 Lectures 
     11.5 hours 

 SHIVPRASAD KOIRALA

    33 Lectures 
     3 hours 

 Abhishek And Pukhraj

    33 Lectures 
     5.5 hours 

 Abhishek And Pukhraj

    40 Lectures 
     6.5 hours 

 Syed Raza

    15 Lectures 
     2 hours 

 Harshit Srivastava, Pranjal Srivastava

    18 Lectures 
     1.5 hours 

 Pranjal Srivastava, Harshit Srivastava
 Print
 Add Notes
 Bookmark this page
Modifying prototypes in JavaScript

Following is the code for modifying prototypes in JavaScript −
 Live Demo
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
   body {
      font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
   }
   .result {
      font-size: 20px;
      font-weight: 500;
      color: blueviolet;
   }
</style>
</head>
<body>
<h1>Modifying prototypes in JavaScript</h1>
<div class="result"></div>
<button class="Btn">CLICK HERE</button>
<h3>Click on the above button to see the original and modified prototype function</h3>
<script>
   let resEle = document.querySelector(".result");
   let BtnEle = document.querySelector(".Btn");
   function Person(name, age, occupation) {
      this.name = name;
      this.age = age;
      this.occupation = occupation;
   }
   Person.prototype.displayInfo = function () {
      return `Name: ${this.name} Age: ${this.age} Occupation: ${this.occupation}<br>`;
   };
   let person1 = new Person("Shawn", 20, "student");
   let person2 = new Person("Rohan", 25, "Manager");
   BtnEle.addEventListener("click", () => {
      resEle.innerHTML =
      "Before Modifying prototype <br>" +
      person1.displayInfo() +person2.displayInfo();
      Person.prototype.displayInfo = function () {
         return `Occupation: ${this.occupation} Age: ${this.age} Name: ${this.name} <br> `;
      };
      resEle.innerHTML +="<br>After Modifying prototype <br>" +
      person1.displayInfo() +person2.displayInfo();
   });
</script>
</body>
</html>
On clicking the ‘CLICK HERE’ button −
What is the difference between method hiding and method overriding in Java?

When super class and the sub class contains same instance methods including parameters, when called, the super class method is overridden by the method of the sub class.
WIn this example super class and sub class have methods with same signature (method name and parameters) and when we try to invoke this method from the sub class the sub class method overrides the method in super class and gets executed.
 Live Demo
class Super{
   public void sample(){
      System.out.println("Method of the Super class");
   }
}
public class MethodOverriding extends Super {
   public void sample(){
      System.out.println("Method of the Sub class");
   }
   public static void main(String args[]){
      MethodOverriding obj = new MethodOverriding();
      obj.sample();
   }
}
Method of the Sub class

When super class and the sub class contains same methods including parameters, and if they are static and, when called, the super class method is hidden by the method of the sub class.
 Live Demo
class Super{
   public static void sample(){
      System.out.println("Method of the Super class");
   }
}
public class MethodHiding extends Super {
   public static void sample(){
      System.out.println("Method of the Sub class");
   }
   public static void main(String args[]){
      MethodHiding obj = new MethodHiding();
      obj.sample();
   }
}
Method of the Sub class
How to plot a Pandas Dataframe with Matplotlib?

We can plot Line Graph, Pie Chart, Histogram, etc. with a Pandas DataFrame using Matplotlib. For this, we need to import Pandas and Matplotlib libraries −
import pandas as pd
import matplotlib.pyplot as plt
Let us begin plotting −
Following is the code −
import pandas as pd
import matplotlib.pyplot as plt

# creating a DataFrame with 2 columns
dataFrame = pd.DataFrame(
   {
      "Car": ['BMW', 'Lexus', 'Audi', 'Mustang', 'Bentley', 'Jaguar'],
         "Reg_Price": [2000, 2500, 2800, 3000, 3200, 3500],
         "Units": [100, 120, 150, 170, 180, 200]
   }
)

# plot a line graph
plt.plot(dataFrame["Reg_Price"], dataFrame["Units"])
plt.show()
This will produce the following output −
Following is the code to plot a Pie Chart −
import pandas as pd
import matplotlib.pyplot as plt

# creating dataframe
dataFrame = pd.DataFrame({
   "Car": ['BMW', 'Lexus', 'Tesla', 'Mustang', 'Mercedes', 'Jaguar'],
      "Reg_Price": [7000, 1500, 5000, 8000, 9000, 6000]
})

# plot a Pie Chart for Registration Price column with label Car column
plt.pie(dataFrame["Reg_Price"], labels = dataFrame["Car"])
plt.show()
This will produce the following output −
Following is the code to plot Histogram −
import pandas as pd
import matplotlib.pyplot as plt

# creating dataframe
dataFrame = pd.DataFrame({
   "Car": ['BMW', 'Lexus', 'Tesla', 'Mustang', 'Mercedes', 'Jaguar'],"Reg_Price": [7000, 1500, 5000, 8000, 9000, 6000]
})

# plot a histogram for Registration Price column
plt.hist(dataFrame["Reg_Price"])
plt.show()
This will produce the following output −
Print anagrams together in Python using List and Dictionary

In this tutorial, we are going to write a program which finds and prints anagrams using list and dictionary. We have different approaches to every problem. Try to write code without following the tutorial. If you are not able to generate any ideas to write logic, follow the below steps.
1. Initialize a list of strings.
2. Initialize an empty dictionary.
3. Iterate through the list of strings.
   3.1. Sort the string and check if it is present in the dictionary as key or not.
      3.1.1. If the sorted string is already present dictionary as a key then, append the original string to the key.
   3.2 Else map an empty list with the sorted string as key and append the original to it.
4. Initialize an empty string.
5. Iterate through the dictionary items.
   5.1. Concatenate all the values to the empty string.
6. Print the string.
Let's write the code for the above algorithm.
## initializing the list of strings
strings = ["apple", "orange", "grapes", "pear", "peach"]
## initializing an empty dictionary
anagrams = {}
## iterating through the list of strings
for string in strings:
   ## sorting the string
   key = "".join(sorted(string))
      ## checking whether the key is present in dict or not
      if string in anagrams.keys():
         ## appending the original string to the key
         anagrams[key].append(string)
      else:
         ## mapping an empty list to the key
         anagrams[key] = []
         ## appending the string to the key
         anagrams[key].append(string)
## intializing an empty string
result = ""
## iterating through the dictionary
for key, value in anagrams.items():
   ## appending all the values to the result
   result += "".join(value) + " "
## printing the result
print(result)
If you run the above program, you will get the following output.
apple orange grapes pear peach
If you have any doubts regarding the tutorial, mention them in the comment section.
JAVA Character Class \p{javaWhitespace}

The character class \p{javaWhitespace} matches any whitespace character.
The following example shows the usage of JAVA character class matching.
package com.tutorialspoint;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class JavaCharacterClassDemo {
   private static final String REGEX = "\\p{javaWhitespace}";
   private static final String INPUT = "Bb12 \tc!";

   public static void main(String[] args) {
      // create a pattern
      Pattern  pattern = Pattern.compile(REGEX);
      
      // get a matcher object
      Matcher matcher = pattern.matcher(INPUT); 

      while(matcher.find()) {
         //Prints the start index of the match.
         System.out.println("Match String start(): "+matcher.start());
      }
   }
}
Let us compile and run the above program, this will produce the following result −
Match String start(): 4
Match String start(): 5

 Print
 Add Notes
 Bookmark this page
How to get file extension of file as a result of MySQL query?

In order to get file extension of file as a result of SQL query, you can use SUBSTRING_INDEX().
The syntax is as follows
select substring_index(yourColumnName,'.',-1) as anyAliasName from yourTableName;
To understand the above syntax, let us create a table. The query to create a table is as follows
mysql> create table getFileExtensionDemo
   -> (
   -> File_Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   -> File_Name text
   -> );
Query OK, 0 rows affected (0.53 sec)
Insert some records in the table using insert command.
The query is as follows
mysql> insert into getFileExtensionDemo(File_Name) values('John.AllMySQLConcept.doc');
Query OK, 1 row affected (0.17 sec)
mysql> insert into getFileExtensionDemo(File_Name) values('Introductiontojava.txt');
Query OK, 1 row affected (0.17 sec)
mysql> insert into getFileExtensionDemo(File_Name) values('C and C++.AllDataStructureandAlgorithm.pdf');
Query OK, 1 row affected (0.14 sec)
mysql> insert into getFileExtensionDemo(File_Name) values('C.Users.Desktop.AllMySQLScript.sql');
Query OK, 1 row affected (0.39 sec)
Display all records from the table using select statement.
The query is as follows
mysql> select *from getFileExtensionDemo;
The following is the output
+---------+--------------------------------------------+
| File_Id | File_Name                                  |
+---------+--------------------------------------------+
| 1       | John.AllMySQLConcept.doc                   |
| 2       | Introductiontojava.txt                     |
| 3       | C and C++.AllDataStructureandAlgorithm.pdf |
| 4       | C.Users.Desktop.AllMySQLScript.sql         |
+---------+--------------------------------------------+
4 rows in set (0.00 sec)
Here is the query to get the extension of file as a result of query
mysql> select substring_index(File_Name,'.',-1) as AllFileExtension from getFileExtensionDemo;
The following is the output with only the file extensions
+------------------+
| AllFileExtension |
+------------------+
| doc              |
| txt              |
| pdf              |
| sql              |
+------------------+
4 rows in set (0.20 sec)
Rexx - Subroutines

In any programming language, the entire program is broken into logical modules. This makes it easier to write code that can be maintained easily. This is a basic requirement for any programming language.
In Rexx, modules can be written using Subroutines and functions. Let’s look at the subroutines in detail.
The syntax of a function declaration is as follows −
FunctionName: 
   Statement#1 
   Statement#2 
   .... 
   Statement#N

Where,
FunctionName − This is the name assigned to the subroutine.
FunctionName − This is the name assigned to the subroutine.
Statement#1 .. Statement#N − These are the list of statements that make up the subroutine.
Statement#1 .. Statement#N − These are the list of statements that make up the subroutine.
The following program is a simple example showing the use of subroutines.
/* Main program */ 
call add 
exit 
add: 
a = 5 
b = 10 
c = a + b 
say c 
The following things should be noted about the above program −
We are defining a subroutine called add.
We are defining a subroutine called add.
The subroutine does a simple add functionality.
The subroutine does a simple add functionality.
The exit statement has to be used to signify the end of the main program.
The exit statement has to be used to signify the end of the main program.
The output of the above program would be as follows −
15

It is also possible to work with arguments in Rexx. The following example shows how this can be achieved.
/* Main program */ 
call add 1,2 
exit 
add: 
PARSE ARG a,b 
c = a + b 
say c
The following things should be noted about the above program −
We are defining a subroutine called add which takes on 2 parameters.
We are defining a subroutine called add which takes on 2 parameters.
In the subroutines, the 2 parameters are parsed using the PARSE and ARG keyword.
In the subroutines, the 2 parameters are parsed using the PARSE and ARG keyword.
The output of the above program would be as follows −
3

Let’s look at some other methods available for arguments.
This method is used to return the number of arguments defined for the subroutine.
Syntax −
arg() 

Parameters − None
Return Value − This method returns the number of arguments defined for the subroutine.
Example −
/* Main program */ 
call add 1,2 
exit 
add: 
PARSE ARG a,b 

say arg() 
c = a + b 
say c 
When we run the above program we will get the following result.
2 
3 

This method is used to return the value of the argument at the specific position.
Syntax −
arg(index)

Parameters
Index − Index position of the argument to be returned.
Index − Index position of the argument to be returned.
Return Value − This method returns the value of the argument at the specific position.
Example −
/* Main program */ 
call add 1,2 
exit 
add: 
PARSE ARG a,b 

say arg(1) 
c = a + b 
say c 
When we run the above program we will get the following result.
1 
3 

 Print
 Add Notes
 Bookmark this page
Difference between "grid" and "pack" geometry managers in Tkinter

In order to view the widgets on the screen, we have to first associate each and every widget with the geometry manager. There are three ways in which we can view our widgets in the application. The Grid and Pack geometry manager are mostly used in many applications.
The Pack geometry manager is one of the simplest geometry managers. We can use Pack manager to provide additional properties to the widgets such as padding, position respect to the X and Y axis, and expand property. It works on the basis of single row and single column. All the properties of Pack manager are applicable to all the widgets in Tkinter Library.
Often, the Grid geometry manager is used for complex application development. It is manly used where we need to arrange many widgets inside a window such that they don't interfere with each other. Grid geometry manager works similar to the basic coordinate geometry system. It provides a layout feature to all the widget where we can place the widget in X and Y directionally. It works on the basis of multiple rows and multiple columns.
# Import the required library
from tkinter import *
from tkinter import ttk

# Create an instance of tkinter frame or window
win= Tk()

# Set the size of the window
win.geometry("700x350")

# Add Label and Button widgets
Button(win, text= "Button-1").grid(row=0, column=1, padx= 10, pady=20)
# Button(win, text= "Button-2").pack(padx= 10, pady=20)

win.mainloop()
Now, uncomment the Button-2 widget and comment out the Button-1 widget to see the resultant output.
Write a C program to convert uppercase to lowercase letters without using string convert function

Before going to know about how to convert upper case to lower case letters without string convert function.
Let us have a look on program to convert upper to lower using convert function, then you will get a clarity on what we are doing in the program −
#include <stdio.h>
#include <string.h>
int main(){
   char string[50];
   printf("enter a string to convert to lower case\n");
   gets(string); /reading the string
   printf("The string in lower case: %s\n", strlwr(string)); //strlwr converts all upper    to
   lower
   return 0;
}
enter a string to convert to lower case
CProgramming LangUage
The string in lower case: cprogramming language
Now let's see the program to convert upper to lower without using predefined function −
#include<stdio.h>
void main(){
   //Declaring variable for For loop (to read each position of alphabet) and string//
   int i;
   char string[40];
   //Reading string//
   printf("Enter the string : ");
   gets(string);
   //For loop to read each alphabet//
   for(i=0;string[i]!='\0';i++){
      if(string[i]>=65&&string[i]<=90){
         string[i]=string[i]+32;
      }
   }
   printf("The converted lower case string is : ");
   puts(string);
}
Enter the string : TUTORIALSPOINT
The converted lower case string is : tutorialspoint
DAX Text - SUBSTITUTE function

Replaces the existing text with a new text in a text string.
SUBSTITUTE (<text>, <old_text>, <new_text>, <instance_num>) 

text
The text in which you want to substitute the existing text with a new text, or a reference to a column containing text.
old_text
The existing text that you want to replace.
new_text
The text you want to replace old_text with.
instance_num
Optional.
The occurrence of old_text you want to replace.
If omitted, every instance of old_text is replaced.
A string of text.
SUBSTITUTE function is case-sensitive. If the case does not match between find_text and old_text, SUBSTITUTE will not replace the text.
If find_text is “Not” and within_text contains “not”, SUBSTITUTE will not replace the text.
If find_text is “Not” and within_text contains “not”, SUBSTITUTE will not replace the text.
DAX SUBSTITUTE function is similar to DAX REPLACE function.
You can use SUBSTITUTE function if you want to replace the specific text in a text string.
You can use SUBSTITUTE function if you want to replace the specific text in a text string.
You can use REPLACE function, if you want to replace any text of variable length that occurs at a specific position in a text string.
You can use REPLACE function, if you want to replace any text of variable length that occurs at a specific position in a text string.
= SUBSTITUTE([Product],"Powder","Lotion") 
replaces all instances of “Powder” with “Lotion” in the Product column. If “Powder” is not found in any of the rows of the Product column, nothing is changed.

    53 Lectures 
     5.5 hours 

 Abhay Gadiya

    24 Lectures 
     2 hours 

 Randy Minder

    26 Lectures 
     4.5 hours 

 Randy Minder
 Print
 Add Notes
 Bookmark this page
TensorFlow - Optimizers

Optimizers are the extended class, which include added information to train a specific model. The optimizer class is initialized with given parameters but it is important to remember that no Tensor is needed. The optimizers are used for improving speed and performance for training a specific model.
The basic optimizer of TensorFlow is −
tf.train.Optimizer

This class is defined in the specified path of tensorflow/python/training/optimizer.py.
Following are some optimizers in Tensorflow −
Stochastic Gradient descent
Stochastic Gradient descent with gradient clipping
Momentum
Nesterov momentum
Adagrad
Adadelta
RMSProp
Adam
Adamax
SMORMS3
We will focus on the Stochastic Gradient descent. The illustration for creating optimizer for the same is mentioned below −
def sgd(cost, params, lr = np.float32(0.01)):
   g_params = tf.gradients(cost, params)
   updates = []
   
   for param, g_param in zip(params, g_params):
      updates.append(param.assign(param - lr*g_param))
   return updates
The basic parameters are defined within the specific function. In our subsequent chapter, we will focus on Gradient Descent Optimization with implementation of optimizers.

    61 Lectures 
     9 hours 

 Abhishek And Pukhraj

    57 Lectures 
     7 hours 

 Abhishek And Pukhraj

    52 Lectures 
     7 hours 

 Abhishek And Pukhraj

    52 Lectures 
     6 hours 

 Abhishek And Pukhraj

    29 Lectures 
     3.5 hours 

 Mohammad Nauman

    82 Lectures 
     4 hours 

 Anis Koubaa
 Print
 Add Notes
 Bookmark this page
Is it possible to create static constructor in java?

A constructor is used to initialize an object when it is created. It is syntactically similar to a method. The difference is that the constructors have same name as their class and, have no return type.
There is no need to invoke constructors explicitly these are automatically invoked at the time of instantiation.
No, we cannot create a Static constructor in java You can use the access specifiers public, protected & private with constructors.
If we try to use static before a constructor a compile time error will be generated saying “modifier static not allowed here”.
In the following Java example, we are trying to create a static constructor.
 Live Demo
public class Student {
   public String name;
   public int age;
   public static Student(){
      System.out.println("Constructor of the Student class");
   }
   public void display(){
      System.out.println("Name of the Student: "+this.name );
      System.out.println("Age of the Student: "+this.age );
   }
   public static void main(String args[]) {
      new Student().display();
   }
}
On compiling the above program generates the following error −
Student.java:6: error: modifier static not allowed here
   public static Student(){
                ^
1 error
Python Tweepy – Getting the description of a user - GeeksforGeeks

18 Jun, 2020
In this article we will see how we can get the description of a user. The description of the describes a user account. The description attribute is optional and is Nullable.
Identifying the description in the GUI :
In the above mentioned profile the description is : Your one-stop destination to attain Coding Nirvana...
In order to get the description we have to do the following :
Identify the user ID or the screen name of the profile.Get the User object of the profile using the get_user() method with the user ID or the screen name.From this object, fetch the description attribute present in it.
Identify the user ID or the screen name of the profile.
Get the User object of the profile using the get_user() method with the user ID or the screen name.
From this object, fetch the description attribute present in it.
Example 1: Consider the following profile :We will use the user ID to fetch the user. The user ID of the above mentioned profile is 57741058.
# import the moduleimport tweepy  # assign the values accordinglyconsumer_key = ""consumer_secret = ""access_token = ""access_token_secret = ""  # authorization of consumer key and consumer secretauth = tweepy.OAuthHandler(consumer_key, consumer_secret)  # set access to user's access key and access secret auth.set_access_token(access_token, access_token_secret)  # calling the api api = tweepy.API(auth)  # the ID of the userid = 57741058  # fetching the useruser = api.get_user(id)  # fetching the descriptiondescription = user.description  print("The description of the user is : " + description)
Output :
The description of the user is : Your one-stop destination to attain Coding Nirvana...

Example 2: Consider the following profile :We will use the screen name to fetch the user. The screen name of the above mentioned profile is PracticeGfG.
# the screen name of the userscreen_name = "PracticeGfG"  # fetching the useruser = api.get_user(screen_name)  # fetching the descriptiondescription = user.description  print("The description of the user is : " + description)
Output :
The description of the user is : Platform to practice programming problems. Solve 
company interview questions and improve your coding intellect!

Python-Tweepy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Defaultdict in Python
Python | Get unique values from a list
Python | os.path.join() method
Selecting rows in pandas DataFrame based on conditions
Create a directory in Python
Python | Pandas dataframe.groupby()
SQLAlchemy Core - Using Functions

Some of the important functions used in SQLAlchemy are discussed in this chapter.
Standard SQL has recommended many functions which are implemented by most dialects. They return a single value based on the arguments passed to it. Some SQL functions take columns as arguments whereas some are generic. Thefunc keyword in SQLAlchemy API is used to generate these functions.
In SQL, now() is a generic function. Following statements renders the now() function using func −
from sqlalchemy.sql import func
result = conn.execute(select([func.now()]))
print (result.fetchone())
Sample result of above code may be as shown below −
(datetime.datetime(2018, 6, 16, 6, 4, 40),)

On the other hand, count() function which returns number of rows selected from a table, is rendered by following usage of func −
from sqlalchemy.sql import func
result = conn.execute(select([func.count(students.c.id)]))
print (result.fetchone())
From the above code, count of number of rows in students table will be fetched.
Some built-in SQL functions are demonstrated using Employee table with following data −
The max() function is implemented by following usage of func from SQLAlchemy which will result in 85, the total maximum marks obtained −
from sqlalchemy.sql import func
result = conn.execute(select([func.max(employee.c.marks)]))
print (result.fetchone())
Similarly, min() function that will return 56, minimum marks, will be rendered by following code −
from sqlalchemy.sql import func
result = conn.execute(select([func.min(employee.c.marks)]))
print (result.fetchone())
So, the AVG() function can also be implemented by using the below code −
from sqlalchemy.sql import func
result = conn.execute(select([func.avg(employee.c.marks)]))
print (result.fetchone())

Functions are normally used in the columns clause of a select statement. 
They can also be given label as well as a type. A label to function allows the result 
to be targeted in a result row based on a string name, and a type is required when 
you need result-set processing to occur.from sqlalchemy.sql import func

result = conn.execute(select([func.max(students.c.lastname).label('Name')]))

print (result.fetchone())

    21 Lectures 
     1.5 hours 

 Jack Chan
 Print
 Add Notes
 Bookmark this page
Take screenshot of full page with Selenium Python with chromedriver.

We can take a screenshot of a full page with Selenium webdriver in Python with chromedriver. First of all, we shall obtain the original window size with the get_window_size method.
Then with the help of JavaScript Executor we shall fetch the complete height and width of the page which is opened on the browser. Then set the window size to that dimension with the set_window_size method.
Next, capture the screenshot of the entire content within the body tag in the html with the screenshot method. This method accepts the path of the screenshot that will be captured as a parameter.
from selenium import webdriver
#set chromodriver.exe path
driver = webdriver.Chrome(executable_path="C:\\chromedriver.exe")
driver.maximize_window()
#launch URL
driver.get("https://www.tutorialspoint.com/index.htm")
#get window size
s = driver.get_window_size()
#obtain browser height and width
w = driver.execute_script('return document.body.parentNode.scrollWidth')
h = driver.execute_script('return document.body.parentNode.scrollHeight')
#set to new window size
driver.set_window_size(w, h)
#obtain screenshot of page within body tag
driver.find_element_by_tag_name('body').screenshot("tutorialspoint.png")
driver.set_window_size(s['width'], s['height'])
driver.quit()
A new file called tutorialspoint.png gets created in the project folder.
Right−click on it and then select Properties. The Properties for pop−up comes up. Copy the location field.
Open it in a browser.
How to implement MySQL CASE with OR condition?

Here is the syntax of MySQL CASE OR condition
SELECT yourColumnName1,.....N ,
   CASE WHEN yourColumnName2=0 or yourColumnName2IS NULL THEN 'yourMessage1'
ELSE 'yourMessage2'
END AS yourAliasName
FROM yourTableName;
To understand the above syntax, let us create a table. The query to create a table is as follows
mysql> create table ReservationSystems
   - > (
   - > Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   - > Name varchar(20),
   - > isSeatConfirmed tinyint
   - > );
Query OK, 0 rows affected (0.61 sec)
Insert some records in the table using insert command.
The query is as follows
mysql> insert into ReservationSystems(Name,isSeatConfirmed) values('Larry',0);
Query OK, 1 row affected (0.12 sec)
mysql> insert into ReservationSystems(Name,isSeatConfirmed) values('Bob',1);
Query OK, 1 row affected (0.15 sec)
mysql> insert into ReservationSystems(Name,isSeatConfirmed) values('Mike',NULL);
Query OK, 1 row affected (0.14 sec)
mysql> insert into ReservationSystems(Name,isSeatConfirmed) values('David',1);
Query OK, 1 row affected (0.17 sec)
mysql> insert into ReservationSystems(Name,isSeatConfirmed) values('Carol',0);
Query OK, 1 row affected (0.19 sec)
mysql> insert into ReservationSystems(Name,isSeatConfirmed) values('James',1);
Query OK, 1 row affected (0.11 sec)
Display all records from the table using select statement.
The query is as follows
mysql> select *from ReservationSystems;
The following is the output
+----+-------+-----------------+
| Id | Name  | isSeatConfirmed |
+----+-------+-----------------+
|  1 | Larry |               0 |
|  2 | Bob   |               1 |
|  3 | Mike  |            NULL |
|  4 | David |               1 |
|  5 | Carol |               0 |
|  6 | James |               1 |
+----+-------+-----------------+
6 rows in set (0.00 sec)
Here is the MySQL CASE with OR condition
mysql> select Name,
   - > CASE WHEN isSeatConfirmed=0 or isSeatConfirmed IS NULL THEN 'YOUR SEAT IS NOT CONFIRMED'
   - > ELSE 'YOUR SEAT IS CONFIRMED'
   - > END AS SEATCONFIRMSTATUS
   - > FROM ReservationSystems;
The following is the output
+-------+----------------------------+
| Name  | SEATCONFIRMSTATUS          |
+-------+----------------------------+
| Larry | YOUR SEAT IS NOT CONFIRMED |
| Bob   | YOUR SEAT IS CONFIRMED     |
| Mike  | YOUR SEAT IS NOT CONFIRMED |
| David | YOUR SEAT IS CONFIRMED     |
| Carol | YOUR SEAT IS NOT CONFIRMED |
| James | YOUR SEAT IS CONFIRMED     |
+-------+----------------------------+
6 rows in set (0.00 sec)
Date.valueOf() function in JavaScript

The Date object is a data type built into the JavaScript language. Date objects are created with the new Date( ) as shown below.
Once a Date object is created, a number of methods allow you to operate on it. Most methods simply allow you to get and set the year, month, day, hour, minute, second, and millisecond fields of the object, using either local time or UTC (universal, or GMT) time.
The valueOf() function of the date object returns its primitive value.
Its Syntax is as follows
dateObj.valueOf()
 Live Demo
<html>
<head>
   <title>JavaScript Example</title>
</head>
<body>
   <script type="text/javascript">
      var dateObj = new Date('September 26, 89 12:4:25:96');
      document.write("Current Time: "+dateObj.valueOf());
   </script>
</body>
</html>
Current Time: 622794865096
If you do not pass anything to the constructor of the date object it returns the number of milliseconds from 1 January 1970 00:00:00 UTC to current date.
 Live Demo
<html>
<head>
   <title>JavaScript Example</title>
</head>
<body>
   <script type="text/javascript">
      var dateObj = new Date('September 26, 89 12:4:25:96');
      document.write("Current Time: "+dateObj.valueOf());
   </script>
</body>
</html>
Current Time: 622794865096
Since we have maximum 31 days in a month the date should be between 1 to 31 else this function returns NaN.
 Live Demo
<html>
<head>
   <title>JavaScript Example</title>
</head>
<body>
   <script type="text/javascript">
      var dateObj = new Date('September 38, 1989');
      document.write("Current Time: "+dateObj.valueOf());
   </script>
</body>
</html>
Current Time: NaN
Convert an Unordered Factor to an Ordered Factor in R Programming - as.ordered() Function - GeeksforGeeks

04 Jun, 2020
as.ordered() function in R Language takes an unordered factor as argument and converts it into an ordered factor.
Syntax: as.ordered(factor)
Parameters:factor: Unordered Factor to be converted
Example 1:
# Creating a vector x<-c("North", "North", "East", "West")   # Converting vector into factorDirections <- factor(x)  # Using as.ordered() Function# to order an unordered factoras.ordered(Directions)
Output:
[1] North North East  West 
Levels: East < North < West

Example 2:
# creating vector size size = c("small", "large", "large", "small",           "medium", "large", "medium", "medium")   sizes <- ordered(c("small", "large", "large",                    "small", "medium"))     # Using as.ordered() Function# to order an unordered factoras.ordered(sizes)
Output:
[1] small  large  large  small  medium
Levels: large < medium < small

R Factor-Function
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Change Color of Bars in Barchart using ggplot2 in R
Group by function in R using Dplyr
How to Change Axis Scales in R Plots?
How to Split Column Into Multiple Columns in R DataFrame?
Replace Specific Characters in String in R
How to filter R DataFrame by values in a column?
How to import an Excel File into R ?
R - if statement
Time Series Analysis in R
Plot mean and standard deviation using ggplot2 in R
Difference between Multiprocessing and Multithreading - GeeksforGeeks

08 Jun, 2020
Both Multiprocessing and Multithreading are used to increase the computing power of a system.
Multiprocessing:Multiprocessing is a system that has more than one or two processors. In Multiprocessing, CPUs are added for increasing computing speed of the system. Because of Multiprocessing, There are many processes are executed simultaneously. Multiprocessing are classified into two categories:
1. Symmetric Multiprocessing
2. Asymmetric Multiprocessing 
Multithreading:Multithreading is a system in which multiple threads are created of a process for increasing the computing speed of the system. In multithreading, many threads of a process are executed simultaneously and process creation in multithreading is done according to economical.
Difference between Multiprocessing and Multithreading:
ashushrma378
Difference Between
GATE CS
Operating Systems
Operating Systems
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 IPv4 and IPv6
Difference Between Method Overloading and Method Overriding in Java
Difference between Process and Thread
Difference between Clustered and Non-clustered index
Layers of OSI Model
ACID Properties in DBMS
TCP/IP Model
Types of Operating Systems
Normal Forms in DBMS
How to display the value of each bar in a bar chart using Matplotlib? - GeeksforGeeks

14 Feb, 2022
In this article, we are going to see how to display the value of each bar in a bar chart using Matplotlib. There are two different ways to display the values of each bar in a bar chart in matplotlib –
Using matplotlib.axes.Axes.text() function.
Use matplotlib.pyplot.text() function.
Example 1: Using matplotlib.axes.Axes.text() function:
This function is basically used to add some text to the location in the chart. This function return string, this is always used with the syntax “for index, value in enumerate(iterable)” with iterable as the list of bar values to access each index, value pair in iterable so at it can add the text at each bar.
Python3
import osimport numpy as npimport matplotlib.pyplot as plt x = [0, 1, 2, 3, 4, 5, 6, 7]y = [160, 167, 17, 130, 120, 40, 105, 70]fig, ax = plt.subplots()width = 0.75ind = np.arange(len(y)) ax.barh(ind, y, width, color = "green") for i, v in enumerate(y):    ax.text(v + 3, i + .25, str(v),            color = 'blue', fontweight = 'bold')plt.show()
Output:
Example 2: Use matplotlib.pyplot.text() function:
Call matplotlib.pyplot.barh(x, height) with x as a list of bar names and height as a list of bar values to create a bar chart. Use the syntax “for index, value in enumerate(iterable)” with iterable as the list of bar values to access each index, value pair in iterable. At each iteration, call matplotlib.pyplot.text(x, y, s) with x as value, y as index, and s as str(value) to label each bar with its size.
Python3
import matplotlib.pyplot as pltx = ["A", "B", "C", "D"]y = [1, 2, 3, 4]plt.barh(x, y) for index, value in enumerate(y):    plt.text(value, index,             str(value)) plt.show()
Output:
sumitgumber28
Picked
Python-matplotlib
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Read JSON file using Python
Adding new column to existing DataFrame in Pandas
Python map() function
How to get column names in Pandas dataframe
Python Dictionary
Taking input in Python
Read a file line by line in Python
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
DateTime.ToUniversalTime() Method in C# - GeeksforGeeks

04 Feb, 2019
This method is used to convert the value of the current DateTime object to Coordinated Universal Time (UTC).
Syntax: public DateTime ToUniversalTime ();
Return Value: This method returns an object whose Kind property is Utc, and whose value is the UTC equivalent to the value of the current DateTime object, or MaxValue if the converted value is too large to be represented by a DateTime object, or MinValue if the converted value is too small to be represented by a DateTime object.
Below programs illustrate the use of DateTime.ToUniversalTime() Method:
Example 1:
// C# program to demonstrate the// DateTime.ToUniversalTime()// Methodusing System;  class GFG {      // Main Method    public static void Main()    {          // creating object of DateTime        DateTime date = new DateTime(2010, 1,                                1, 4, 0, 15);          // getting UTC from DateTime        // using ToUniversalTime() method;        DateTime value = date.ToUniversalTime();          // Display the ShortTime        Console.WriteLine("UTC is {0}", value);    }}
UTC is 01/01/2010 04:00:15

Example 2:
// C# program to demonstrate the// DateTime.ToUniversalTime()// Methodusing System;  class GFG {      // Main Method    public static void Main()    {        // calling check() method        check(new DateTime(2010, 1,                     3, 4, 0, 15));          check(new DateTime(2010, 1,                     5, 4, 0, 15));    }      public static void check(DateTime date)    {          // getting UTC from DateTime        // using ToUniversalTime() method;        DateTime value = date.ToUniversalTime();          // Display the ShortTime        Console.WriteLine("UTC of {0} is {1}",                                 date, value);    }}
UTC of 01/03/2010 04:00:15 is 01/03/2010 04:00:15
UTC of 01/05/2010 04:00:15 is 01/05/2010 04:00:15

Reference:
https://docs.microsoft.com/en-us/dotnet/api/system.datetime.touniversaltime?view=netframework-4.7.2
CSharp DateTime Struct
CSharp-method
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
C# | Abstract Classes
Difference between Ref and Out keywords in C#
C# | Class and Object
C# | Constructors
Introduction to .NET Framework
C# | String.IndexOf( ) Method | Set - 1
C# | Replace() Method
C# | Arrays
C# | Encapsulation
HashSet in C# with Examples
Sorting strings from the text file - GeeksforGeeks

24 Nov, 2020
Given a text file “file.txt” that consists of strings, the task is to sort all the strings in alphabetical order in that text file.
Approach: The idea is to use the concept of File Handling and a text file(say file.txt) that contains all the strings. Below are the steps:
Create the file using fopen() and insert names into the file using fprintf().
Close the file using fclose().
Reopen the file for reading the names.
Read or scan the names from the file using fscanf() and store it in a vector of strings.
Sort the given string stored in the vector using the sort() function.
Now, insert the sorted string in that file and print it.
Below is the implementation of the above approach:
C++
// C++ program to sort given array// of string stored in a file#include <bits/stdc++.h>#include <cstdlib>#include <cstring>#include <fstream>using namespace std;  // Driver Codeint main(){    int N, i, j;      // File pointer to open file    FILE* f;      // fopen() for creating of a file    f = fopen("file.txt", "w");      // Input number of strings    // to be inserted in file    cin >> n;      vector<int> name(N);      // Insert the strings into file    for (i = 0; i < n; i++) {          // Insert names in file        cin >> name[i];          // Writing into the file        fprintf(f, "%s", name[i]);    }      // Close the file    fclose(f);      // Reopening in read mode    f = fopen("file.txt", "r");      // Check does file exist or not    if (f == NULL) {        cout << "File doesn't exist!";        return 0;    }      // Read the file until it    // encounters end of line    while (!feof(f)) {        fscanf(f, "%s", name[i]);        i++;    }    n = i - 1;      // Sort the strings    sort(name.begin(), name.end());      // Insert the strings into file    // after sorting    for (i = 0; i < n; i++) {          // Write into the file        fprintf(f, "%s", name[i]);    }      // Print the sorted names    for (i = 0; i < n; i++) {        cout << name[i] << '\n';    }      return 0;}
Input File:
Output File:
C-File Handling
cpp-file-handling
File Handling
C++ Programs
Sorting
Strings
Strings
Sorting
File Handling
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Passing a function as a parameter in C++
Program to implement Singly Linked List in C++ using class
Const keyword in C++
cout in C++
Dynamic _Cast in C++
Python | Pandas Series.replace() - GeeksforGeeks

10 Feb, 2019
Pandas series is a One-dimensional ndarray with axis labels. The labels need not be unique but must be a hashable type. The object supports both integer- and label-based indexing and provides a host of methods for performing operations involving the index.
Pandas Series.replace() function is used to replace values given in to_replace with value. The values of the Series are replaced with other values dynamically.
Syntax: Series.replace(to_replace=None, value=None, inplace=False, limit=None, regex=False, method=’pad’)
Parameter :to_replace : How to find the values that will be replaced.value : Value to replace any values matching to_replace with.inplace : If True, in place.limit : Maximum size gap to forward or backward fill.regex : Whether to interpret to_replace and/or value as regular expressionsmethod : The method to use when for replacement, when to_replace is a scalar, list or tuple and value is None.
Returns : Object after replacement.
Example #1: Use Series.replace() function to replace some values from the given Series object.
# importing pandas as pdimport pandas as pd  # Creating the Seriessr = pd.Series([10, 25, 3, 11, 24, 6])  # Create the Indexindex_ = ['Coca Cola', 'Sprite', 'Coke', 'Fanta', 'Dew', 'ThumbsUp']  # set the indexsr.index = index_  # Print the seriesprint(sr)
Output :
Now we will use Series.replace() function to replace the old values with the new ones.
# replace 3 by 1000result = sr.replace(to_replace = 3, value = 1000)  # Print the resultprint(result)
Output :
As we can see in the output, the Series.replace() function has successfully replaced the old value with the new one. Example #2 : Use Series.replace() function to replace some values from the given Series object.
# importing pandas as pdimport pandas as pd  # Creating the Seriessr = pd.Series(['New York', 'Chicago', 'Toronto', 'Lisbon', 'Rio'])  # Create the Indexindex_ = ['City 1', 'City 2', 'City 3', 'City 4', 'City 5']   # set the indexsr.index = index_  # Print the seriesprint(sr)
Output :
Now we will use Series.replace() function to replace the old values with the new ones using a list.
# replace the old ones in the list with # the new valuesresult = sr.replace(to_replace = ['New York', 'Rio'], value = ['London', 'Brisbane'])  # Print the resultprint(result)
Output :As we can see in the output, the Series.replace() function has successfully replaced the old value with the new one using the list.
Python pandas-series
Python pandas-series-methods
Python-pandas
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()