code-rag-bench/online-tutorials huggingface dataset:
Spring Boot CLI - Environment Setup

Spring is a Java-based framework; hence, we need to set up JDK first. Following are the steps needed to setup Spring Boot CLI along with JDK installation.
You can download the latest version of SDK from Oracle's Java site − Java SE Downloads. You will find instructions for installing JDK in downloaded files, follow the given instructions to install and configure the setup. Finally set PATH and JAVA_HOME environment variables to refer to the directory that contains java and javac, typically java_install_dir/bin and java_install_dir respectively.
If you are running Windows and have installed the JDK in C:\jdk-11.0.11, you would have to put the following line in your C:\autoexec.bat file.
set PATH=C:\jdk-11.0.11;%PATH% 
set JAVA_HOME=C:\jdk-11.0.11 

Alternatively, on Windows NT/2000/XP, you will have to right-click on My Computer, select Properties → Advanced → Environment Variables. Then, you will have to update the PATH value and click the OK button.
On Unix (Solaris, Linux, etc.), if the SDK is installed in /usr/local/jdk-11.0.11 and you use the C shell, you will have to put the following into your .cshrc file.
setenv PATH /usr/local/jdk-11.0.11/bin:$PATH 
setenv JAVA_HOME /usr/local/jdk-11.0.11

You can download the latest version of Spring Boot CLI API as ZIP archive from https://repo.spring.io/release/org/springframework/boot/spring-boot-cli/. Once you download the installation, unpack the zip distribution into a convenient location. For example, in E:\Test\spring-boot-cli-2.6.3 on Windows, or /usr/local/spring-boot-cli-2.6.3 on Linux/Unix.
Make sure you set your CLASSPATH variable on this directory properly otherwise you will face a problem while running your application.
Or set the path in command prompt temporarily to run the spring boot application as shown below −
E:/Test/> set path=E:\Test\spring-boot-cli-2.6.3-bin\spring-2.6.3\bin;%PATH%

Run the following command on command prompt to verify the installation −
E:/Test/> spring --version

It should print the following output confirming the successful installation −
Spring CLI v2.6.3

 Print
 Add Notes
 Bookmark this page
Python | Pandas Series.drop() - GeeksforGeeks

15 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.drop() function return Series with specified index labels removed. It remove elements of a Series based on specifying the index labels.
Syntax: Series.drop(labels=None, axis=0, index=None, columns=None, level=None, inplace=False, errors=’raise’)
Parameter :labels : Index labels to drop.axis : Redundant for application on Series.index, columns : Redundant for application on Series, but index can be used instead of labels.level : For MultiIndex, level for which the labels will be removed.inplace : If True, do operation inplace and return None.errors : If ‘ignore’, suppress error and only existing labels are dropped.
Returns : dropped : pandas.Series
Example #1: Use Series.drop() function to drop the values corresponding to the passed index labels in the given series object.
# importing pandas as pdimport pandas as pd  # Creating the Seriessr = pd.Series([80, 25, 3, 25, 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.drop() function to drop the values corresponding to the passed index labels in the given series object.
# drop the passed labelsresult = sr.drop(labels = ['Sprite', 'Dew'])   # Print the resultprint(result)
Output :
As we can see in the output, the Series.drop() function has successfully dropped the entries corresponding to the passed index labels. Example #2 : Use Series.drop() function to drop the values corresponding to the passed index labels in the given series object.
# importing pandas as pdimport pandas as pd  # Creating the Seriessr = pd.Series([11, 11, 8, 18, 65, 18, 32, 10, 5, 32, 32])  # Create the Indexindex_ = pd.date_range('2010-10-09', periods = 11, freq ='M')  # set the indexsr.index = index_  # Print the seriesprint(sr)
Output :
Now we will use Series.drop() function to drop the values corresponding to the passed index labels in the given series object.
# drop the passed labelsresult = sr.drop(labels = [pd.Timestamp('2010-12-31'),                           pd.Timestamp('2011-04-30'), pd.Timestamp('2011-08-31')])  # Print the resultprint(result)
Output :
As we can see in the output, the Series.drop() function has successfully dropped the entries corresponding to the passed index labels.
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?
Python Classes and Objects
How to drop one or multiple columns in Pandas Dataframe
Defaultdict in Python
Python | Get unique values from a list
Python | os.path.join() method
Create a directory in Python
Python | Pandas dataframe.groupby()
How to generate QR Codes with a custom logo using Python ? - GeeksforGeeks

23 Jan, 2022
In this article, we will discuss how to generate a QR code with an image at its center. We are going to generate a QR code of any text, link, etc., and put an image in the center of that QR code such that it represents a branded QR code
Pillow: It is a lightweight image processing tool that aid in editing, creating, and saving images. Pillow supports many image file formats including BMP, PNG, JPEG, and TIFF. It can be installed using the below command:
pip install Pillow
QRcode: It is an external python library used to generate QR codes. It can be installed using the below command:
pip install qrcode
Python3
# import modulesimport qrcodefrom PIL import Image # taking image which user wants# in the QR code centerLogo_link = 'g4g.jpg' logo = Image.open(Logo_link) # taking base widthbasewidth = 100 # adjust image sizewpercent = (basewidth/float(logo.size[0]))hsize = int((float(logo.size[1])*float(wpercent)))logo = logo.resize((basewidth, hsize), Image.ANTIALIAS)QRcode = qrcode.QRCode(    error_correction=qrcode.constants.ERROR_CORRECT_H) # taking url or texturl = 'https://www.geeksforgeeks.org/' # adding URL or text to QRcodeQRcode.add_data(url) # generating QR codeQRcode.make() # taking color name from userQRcolor = 'Green' # adding color to QR codeQRimg = QRcode.make_image(    fill_color=QRcolor, back_color="white").convert('RGB') # set size of QR codepos = ((QRimg.size[0] - logo.size[0]) // 2,       (QRimg.size[1] - logo.size[1]) // 2)QRimg.paste(logo, pos) # save the QR code generatedQRimg.save('gfg_QR.png') print('QR code generated!')
Output:
QR code generated!
QR code:
When you run the program then it will take the input image and the base width. After that, the image will be reshaped and a QRcode object will be created.
Using the QRcode object various attributes will be assigned such as data or URL will be linked to the QR code using add_data() method, color of the QR code will be assigned using the make_image() method and the reshaped image will be placed in the QR code using the paste() method.
Finally, the generated QR code will be saved in a given location using the save() method.
sagar0719kumar
python-modules
python-utility
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Python | Get unique values from a list
Python | os.path.join() method
Create a directory in Python
Defaultdict in Python
Python | Pandas dataframe.groupby()
How to Calculate Correlation Between Two Columns in Pandas? - GeeksforGeeks

30 Nov, 2021
In this article, we will discuss how to calculate the correlation between two columns in pandas
Correlation is used to summarize the strength and direction of the linear association between two quantitative variables. It is denoted by r and values between -1 and +1. A positive value for r indicates a positive association, and a negative value for r indicates a negative association.
By using corr() function we can get the correlation between two columns in the dataframe.
Syntax:
dataframe[‘first_column’].corr(dataframe[‘second_column’])
where,
dataframe is the input dataframe
first_column is correlated with second_column of the dataframe
Python3
# import pandas moduleimport pandas as pd # create dataframe with 3 columnsdata = pd.DataFrame({    "column1": [12, 23, 45, 67],    "column2": [67, 54, 32, 1],    "column3": [34, 23, 56, 23]})# display dataframeprint(data) # correlation between column 1 and column2print(data['column1'].corr(data['column2'])) # correlation between column 2 and column3print(data['column2'].corr(data['column3'])) # correlation between column 1 and column3print(data['column1'].corr(data['column3']))
Output:
 column1  column2  column3
0       12       67       34
1       23       54       23
2       45       32       56
3       67        1       23
-0.9970476685163736
0.07346999975265099
0.0
It is also possible to get element-wise correlation for numeric valued columns using just corr() function.
Syntax:
dataset.corr()
Python3
# import pandas moduleimport pandas as pd # create dataframe with 3 columnsdata = pd.DataFrame({    "column1": [12, 23, 45, 67],    "column2": [67, 54, 32, 1],    "column3": [34, 23, 56, 23]})# get correlation between element wiseprint(data.corr())
Output:
          column1   column2  column3
column1  1.000000 -0.997048  0.00000
column2 -0.997048  1.000000  0.07347
column3  0.000000  0.073470  1.00000
rkbhola5
Picked
Python pandas-dataFrame
Python pandas-dataFrame-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()
How to dynamically change color by percentage CSS ? - GeeksforGeeks

16 Apr, 2021
In this article, we will learn How to dynamically change color by percentage CSS.
Approach: We can dynamically change the color of any element by percentage using the filter property in CSS. The brightness() function of the filter property is used to dynamically change color by percentage. The brightness function takes a value in percentage to set the brightness of that color.
Syntax:
filter: brightness(value);
Example: In the below example we set the background color of the element white. But when we hover on the paragraph its background color changes 50% because we set a filter that changes the background color of the paragraph by 50%.
HTML
<!DOCTYPE html><html lang="en"><head>    <title>Document</title>    <style>        .gfg{            font-size: 40px;            color: green;            border: solid 2px red ;            background-color: white;        }        p:hover{            /* Change brightness */            filter: brightness(50%);        }    </style></head><body>    <p class="gfg">GeeksforGeeks</p>  </body></html>
Output:
CSS-Basics
CSS-Properties
CSS-Questions
Picked
CSS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to create footer to stay at the bottom of a Web page?
Types of CSS (Cascading Style Sheet)
Create a Responsive Navbar using ReactJS
Design a web page using HTML and CSS
How to position a div at the bottom of its container using CSS?
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Convert a string to an integer in JavaScript
How to calculate the number of days between two dates in javascript?
Absolute Positioning Using CSS

We can define positioning of an element in CSS as absolute which renders the element relative to the first positioned (except static) parent. Elements with positioning method as absolute are positioned by CSS Positioning properties (left, right, top and bottom).
Let’s see an example for CSS Absolute Positioning Method −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<style>
p {
   margin: 0;
   position: absolute;
   top: 50%;
   left: 50%;
   transform: translate(-50%, -50%);
}
div:first-child {
   background-color: orange;
   text-align: center;
}
div:last-child {
   width: 250px;
   height: 100px;
   margin: auto;
   background-color: turquoise;
   position: absolute;
   z-index: -1;
   top:0;
   left: 0;
   right: 0;
   bottom: 0;
}
</style>
</head>
<body>
<div>Demo text</div>
<p>ICC is International Cricket Council is the governing body of Cricket founded in 1909........</p>
<div>
</div>
</body>
</html>
Following is the output for above code −
Let’s see another example for positioning methods −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<style>
div {
   border: 2px double #a43356;
   margin: 5px;
   padding: 5px;
}
#d1 {
   position: relative;
   height: 10em;
}
#d2 {
   position: absolute;
   width: 20%;
   bottom: 10px; /*relative to parent d1*/
}
#d3 {
   position: fixed;
   width: 30%;
   top:10em; /*relative to viewport*/
}
</style>
</head>
<body>
<div id="d1">MySQL is the most popular Open Source Relational SQL Database Management System. 
MySQL is one of the best RDBMS being used for developing various web-based software applications. <mark>relative</mark>
<div id="d2"><mark>absolute</mark></div>
<div id="d3"><mark>fixed</mark></div>
</div>
</body>
</html>
Following is the output for above code −
Basic Python Programming Challenges

In this tutorial, we are going to write a solution for a challenge.
We have to generate a random set of basic arithmetic operations. The user will give the number of questions, and we have to generate questions. After every question, the user will answer it. At the end of the program, we have to give the score. Let's try it.
# importing random and operator modules
import random
import operator
# main function
# taking number of questions that we have to generate
def main(n):
   print("Welcome to the quiz\nYou should answer floats upto 2 decimals")
   # initialising score to 0
   score = 0
   # loop to generate n questions
   for i in range(n):
      # getting answer and correctness of a question
      is_correct, answer = question(i)
      # checking whether is_correct is True or not
      if is_correct:
         # increment score by 1 if correct
         score += 1
         print('Correct Congrats!')
      else:
         # printing the correct answer
         print(f'Incorrect! Answer: {answer}')
   # displaying the total score
   print(f'Total score: {score}')
# function for the question
def question(n):
   # getting answer from the generate_function
   answer = generate_question()
   # taking answer from the user
   user_answer = float(input("Answer: "))
   # returning answer to the main function
   return user_answer == answer, answer
# function to generate a random question
def generate_question():
   # initialising operators for random generation
   operators = {
      '+' : operator.add,
      '-' : operator.sub,
      '*' : operator.mul,
      '/' : operator.truediv,
      '//' : operator.floordiv,
      '%' : operator.mod
   }
   # initialising numbers for expressions
   nums = [i for i in range(10)]
   # getting two random numbers from nums for calculation
   _1, _2 = nums[random.randint(0, 9)], nums[random.randint(0, 9)]
   # generating random operator from the list of operators
   symbol = list(operators.keys())[random.randint(0, 5)]
   # calculating the answer
   answer = round(operators.get(symbol)(_1, _2), 2)
   print(f'{_1} {symbol} {_2}?')
   return answer
if __name__ == '__main__':
   main(5)
If you run the above code, you will get the following results.
Welcome to the quiz
You should answer floats upto 2 decimals
5 + 7?
Answer: 12
Correct Congrats!
9 / 9?
Answer: 1
Correct Congrats!
4 + 7?
Answer: 11
Correct Congrats!
6 // 6?
Answer: 1.0
Correct Congrats!
9 % 3?
Answer: 0
Correct Congrats!
Total score: 5
You can also improve the question by adding some more features like increasing difficulty, generating easy to hard questions, etc.., Try it yourself. I hope you enjoyed the tutorial. If you have any doubts, mention them in the comment section.
MySQL query to set values for NULL occurrence

Find NULL values using the IS NULL and update the new values using MySQL UPDATE and SET −
update yourTableName
set yourColumnName=yourValue
where yourColumnName IS NULL;
Let us first create a table −
mysql> create table DemoTable768 (
   Clientid int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   ClientName varchar(100),
   ClientAge int
);
Query OK, 0 rows affected (0.47 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable768(ClientName,ClientAge) values('John',23);
Query OK, 1 row affected (0.21 sec)
mysql> insert into DemoTable768(ClientName,ClientAge) values(NULL,26);
Query OK, 1 row affected (0.11 sec)
mysql> insert into DemoTable768(ClientName,ClientAge) values('Carol',28);
Query OK, 1 row affected (0.53 sec)
mysql> insert into DemoTable768(ClientName,ClientAge) values(NULL,24);
Query OK, 1 row affected (0.16 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable768;
This will produce the following output -
+----------+------------+-----------+
| Clientid | ClientName | ClientAge |
+----------+------------+-----------+
|        1 | John       |        23 |
|        2 | NULL       |        26 |
|        3 | Carol      |        28 |
|        4 | NULL       |        24 |
+----------+------------+-----------+
4 rows in set (0.00 sec)
Following is the query to set values for NULL occurrence −
mysql> update DemoTable768
   set ClientName='Chris'
    where ClientName IS NULL;
Query OK, 2 rows affected (0.41 sec)
Rows matched: 2 Changed: 2 Warnings: 0
Let us check the description of the view −
mysql> select *from DemoTable768;
This will produce the following output -
+----------+------------+-----------+
| Clientid | ClientName | ClientAge |
+----------+------------+-----------+
|        1 | John       |        23 |
|        2 | Chris      |        26 |
|        3 | Carol      |        28 |
|        4 | Chris      |        24 |
+----------+------------+-----------+
4 rows in set (0.00 sec)
Setting the limits on a colorbar of a contour plot in Matplotlib

To set the limits on a colorbar of a countour plot in Matplotlib, we can take the following steps −
Set the figure size and adjust the padding between and around the subplots.
Create x and y data points using numpy.
Get the data using x and y.
Get the coordinate matrices from the coordinate vectors.
Initialize vmin and vmax to set the limits on a colorbar of a contour plot in matplotlib.
Plot contours using contourf() method.
Make the colorbar using scalar mappable within the range of vmin and vmax.
To display the figure, use show() method.
from matplotlib import pyplot as plt
import numpy as np
from matplotlib.cm import ScalarMappable

plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True

x = np.arange(20)
y = np.arange(20)

data = x[:, None] + y[None, :]
X, Y = np.meshgrid(x, y)

vmin = 0
vmax = 15

fig, ax = plt.subplots()

qcs = ax.contourf(
      X, Y, data,
      vmin=vmin, vmax=vmax
)

fig.colorbar(
   ScalarMappable(norm=qcs.norm, cmap=qcs.cmap),
   ticks=range(vmin, vmax+5, 5)
)

plt.show()
Powershell - Set System Time

Set-Date cmdlet is used to set System Time.
In this example, we're using Get-Date to get current date
Type the following command in PowerShell ISE Console
get-date -displayHint time
You can see following output in PowerShell console.
10:04:18 AM

In this example, we're using Set-Date to adjust to 60 minutes.
Type the following commands in PowerShell ISE Console
> $timeToAdd = New-TimeSpan -Minutes -60
> set-date -adjust $timeToAdd
You can see following output in PowerShell console.
Saturday, May 05, 2018 11:05:16 AM

Now revert back to substract added time to current date.
Type the following command in PowerShell ISE Console
> $timeToAdd = New-TimeSpan -Minutes -60
> set-date -adjust $timeToAdd
You can see following output in PowerShell console.
Saturday, May 05, 2018 10:08:54 AM


    15 Lectures 
     3.5 hours 

 Fabrice Chrzanowski

    35 Lectures 
     2.5 hours 

 Vijay Saini

    145 Lectures 
     12.5 hours 

 Fettah Ben
 Print
 Add Notes
 Bookmark this page
Java JDOM Parser - Create XML Document

Here is the XML file that we need to create −
<?xml version = "1.0" encoding = "UTF-8"?>
<cars>
   <supercars company = "Ferrari">
      <carname type = "formula one">Ferrari 101</carname>
      <carname type = "sports">Ferrari 202</carname>
   </supercars>
</cars>
import java.io.IOException;

import org.jdom2.Attribute;
import org.jdom2.Document;
import org.jdom2.Element;
import org.jdom2.output.Format;
import org.jdom2.output.XMLOutputter;


public class CreateXmlFileDemo {

   public static void main(String[] args) {

      try{
         //root element
         Element carsElement = new Element("cars");
         Document doc = new Document(carsElement);

         //supercars element
         Element supercarElement = new Element("supercars");
         supercarElement.setAttribute(new Attribute("company","Ferrari"));

         //supercars element
         Element carElement1 = new Element("carname");
         carElement1.setAttribute(new Attribute("type","formula one"));
         carElement1.setText("Ferrari 101");

         Element carElement2 = new Element("carname");
         carElement2.setAttribute(new Attribute("type","sports"));
         carElement2.setText("Ferrari 202");

         supercarElement.addContent(carElement1);
         supercarElement.addContent(carElement2);

         doc.getRootElement().addContent(supercarElement);

         XMLOutputter xmlOutput = new XMLOutputter();

         // display ml
         xmlOutput.setFormat(Format.getPrettyFormat());
         xmlOutput.output(doc, System.out); 
      } catch(IOException e) {
         e.printStackTrace();
      }
   }
}
This would produce the following result −
<?xml version = "1.0" encoding = "UTF-8"?>
<cars>
   <supercars company = "Ferrari">
      <carname type = "formula one">Ferrari 101</carname>
      <carname type = "sports">Ferrari 202</carname>
   </supercars>
</cars>


    16 Lectures 
     2 hours 

 Malhar Lathkar

    19 Lectures 
     5 hours 

 Malhar Lathkar

    25 Lectures 
     2.5 hours 

 Anadi Sharma

    126 Lectures 
     7 hours 

  Tushar Kale

    119 Lectures 
     17.5 hours 

 Monica Mittal

    76 Lectures 
     7 hours 

 Arnab Chakraborty
 Print
 Add Notes
 Bookmark this page
SQLAlchemy ORM - Eager Loading

Eager load reduces the number of queries. SQLAlchemy offers eager loading functions invoked via query options which give additional instructions to the Query. These options determine how to load various attributes via the Query.options() method.
We want that Customer.invoices should load eagerly. The orm.subqueryload() option gives a second SELECT statement that fully loads the collections associated with the results just loaded. The name “subquery” causes the SELECT statement to be constructed directly via the Query re-used and embedded as a subquery into a SELECT against the related table.
from sqlalchemy.orm import subqueryload
c1 = session.query(Customer).options(subqueryload(Customer.invoices)).filter_by(name = 'Govind Pant').one()
This results in the following two SQL expressions −
SELECT customers.id 
AS customers_id, customers.name 
AS customers_name, customers.address 
AS customers_address, customers.email 
AS customers_email
FROM customers
WHERE customers.name = ?
('Govind Pant',)

SELECT invoices.id 
AS invoices_id, invoices.custid 
AS invoices_custid, invoices.invno 
AS invoices_invno, invoices.amount 
AS invoices_amount, anon_1.customers_id 
AS anon_1_customers_id
FROM (
   SELECT customers.id 
   AS customers_id
   FROM customers
   WHERE customers.name = ?) 
   
AS anon_1 
JOIN invoices 
ON anon_1.customers_id = invoices.custid 
ORDER BY anon_1.customers_id, invoices.id 2018-06-25 18:24:47,479 
INFO sqlalchemy.engine.base.Engine ('Govind Pant',)
To access the data from two tables, we can use the below program −
print (c1.name, c1.address, c1.email)

for x in c1.invoices:
   print ("Invoice no : {}, Amount : {}".format(x.invno, x.amount))
The output of the above program is as follows −
Govind Pant Gulmandi Aurangabad gpant@gmail.com
Invoice no : 3, Amount : 10000
Invoice no : 4, Amount : 5000

The other function is called orm.joinedload(). This emits a LEFT OUTER JOIN. Lead object as well as the related object or collection is loaded in one step.
from sqlalchemy.orm import joinedload
c1 = session.query(Customer).options(joinedload(Customer.invoices)).filter_by(name='Govind Pant').one()
This emits following expression giving same output as above −
SELECT customers.id 
AS customers_id, customers.name 
AS customers_name, customers.address 
AS customers_address, customers.email 
AS customers_email, invoices_1.id 
AS invoices_1_id, invoices_1.custid 
AS invoices_1_custid, invoices_1.invno 
AS invoices_1_invno, invoices_1.amount 
AS invoices_1_amount

FROM customers 
LEFT OUTER JOIN invoices 
AS invoices_1 
ON customers.id = invoices_1.custid

WHERE customers.name = ? ORDER BY invoices_1.id
('Govind Pant',)
The OUTER JOIN resulted in two rows, but it gives one instance of Customer back. This is because Query applies a “uniquing” strategy, based on object identity, to the returned entities. Joined eager loading can be applied without affecting the query results.
The subqueryload() is more appropriate for loading related collections while joinedload() is better suited for many-to-one relationship.

    21 Lectures 
     1.5 hours 

 Jack Chan
 Print
 Add Notes
 Bookmark this page
var keyword in C#

22 Jun, 2020
Keywords are the words in a language that are used for some internal process or represent some predefined actions. var is a keyword, it is used to declare an implicit type variable, that specifies the type of a variable based on initial value.
Syntax:
var variable_name = value;
Example:
Input: a = 637
       b = -9721087085262

Output: value of a 637, type System.Int32
        value of b -9721087085262, type System.Int64

Input: c = 120.23f
       d = 150.23m
       e = G
       f = Geeks
Output: value of c 120.23, type System.Single
        value of d 150.23, type System.Decimal
        value of e G, type System.Char
        value of f Geeks, type System.String

Example 1:
// C# program for var keywordusing System;using System.Text;  class GFG {      static void Main(string[] args)    {          var a = 637;        var b = -9721087085262;          // to print their type of variables        Console.WriteLine("value of a {0}, type {1}", a, a.GetType());        Console.WriteLine("value of b {0}, type {1}", b, b.GetType());    }}
Output:
value of a 637, type System.Int32
value of b -9721087085262, type System.Int64

Example 2:
// C# program for var keywordusing System;using System.Text;  namespace Test {  class GFG {      static void Main(string[] args)    {          var c = 120.23f;        var d = 150.23m;        var e = 'G';        var f = "Geeks";          // to print their type of variables        Console.WriteLine("value of c {0}, type {1}", c, c.GetType());        Console.WriteLine("value of d {0}, type {1}", d, d.GetType());        Console.WriteLine("value of e {0}, type {1}", e, e.GetType());        Console.WriteLine("value of f {0}, type {1}", f, f.GetType());          // hit ENTER to exit        Console.ReadLine();    }}}
Output:
value of c 120.23, type System.Single
value of d 150.23, type System.Decimal
value of e G, type System.Char
value of f Geeks, type System.String

CSharp-keyword
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
C# | Multiple inheritance using interfaces
Differences Between .NET Core and .NET Framework
Extension Method in C#
C# | List Class
C# | .NET Framework (Basic Architecture and Component Stack)
HashSet in C# with Examples
Lambda Expressions in C#
Switch Statement in C#
Partial Classes in C#
Hello World in C#
Python program to update a dictionary with the values from a dictionary list

03 Sep, 2021
Given a dictionary and dictionary list, update the dictionary with dictionary list values.
Input : test_dict = {“Gfg” : 2, “is” : 1, “Best” : 3}, dict_list = [{‘for’ : 3, ‘all’ : 7}, {‘and’ : 1, ‘CS’ : 9}] Output : {‘Gfg’: 2, ‘is’: 1, ‘Best’: 3, ‘for’: 3, ‘all’: 7, ‘and’: 1, ‘CS’: 9} Explanation : All dictionary keys updated in single dictionary.
Input : test_dict = {“Gfg” : 2, “is” : 1, “Best” : 3}, dict_list = [{‘for’ : 3, ‘all’ : 7}] Output : {‘Gfg’: 2, ‘is’: 1, ‘Best’: 3, ‘for’: 3, ‘all’: 7} Explanation : All dictionary keys updated in single dictionary. 
Method #1 : Using update() + loop
In this, we iterate through all the elements in loop, and perform update to update all the keys in dictionary to original dictionary.
Python3
# Python3 code to demonstrate working of# Update dictionary with dictionary list# Using update() + loop # initializing dictionarytest_dict = {"Gfg" : 2, "is" : 1, "Best" : 3} # printing original dictionaryprint("The original dictionary is : " + str(test_dict)) # initializing dictionary listdict_list = [{'for' : 3, 'all' : 7}, {'geeks' : 10}, {'and' : 1, 'CS' : 9}] for dicts in dict_list:         # updating using update()    test_dict.update(dicts) # printing resultprint("The updated dictionary : " + str(test_dict))
Output:
The original dictionary is : {‘Gfg’: 2, ‘is’: 1, ‘Best’: 3}  
The updated dictionary : {‘Gfg’: 2, ‘is’: 1, ‘Best’: 3, ‘for’: 3, ‘all’: 7, ‘geeks’: 10, ‘and’: 1, ‘CS’: 9}
Method #2 : Using ChainMap + ** operator
In this, we perform task of merging all list dictionaries into 1 using ChainMap and ** operator is used to merge target dictionary to merged dictionary.
Python3
# Python3 code to demonstrate working of# Update dictionary with dictionary list# Using ChainMap + ** operatorfrom collections import ChainMap # initializing dictionarytest_dict = {"Gfg" : 2, "is" : 1, "Best" : 3} # printing original dictionaryprint("The original dictionary is : " + str(test_dict)) # initializing dictionary listdict_list = [{'for' : 3, 'all' : 7}, {'geeks' : 10}, {'and' : 1, 'CS' : 9}] # ** operator extracts keys and re initiates.# ChainMap is used to merge dictionary listres = {**test_dict, **dict(ChainMap(*dict_list))} # printing resultprint("The updated dictionary : " + str(res))
Output:
The original dictionary is : {‘Gfg’: 2, ‘is’: 1, ‘Best’: 3}
The updated dictionary : {‘Gfg’: 2, ‘is’: 1, ‘Best’: 3, ‘for’: 3, ‘all’: 7, ‘geeks’: 10, ‘and’: 1, ‘CS’: 9}
rajeev0719singh
clintra
Python dictionary-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
TimeZone getDefault() Method in Java with Examples

02 Jan, 2019
The getDefault() method of TimeZone class in Java is used to know the default TimeZone for this system or host. This may vary in according to the implementation in different environment.
Syntax:
public static TimeZone getDefault()
Parameters: The method does not take any parameters.
Return Value: The method returns the default TimeZone of the host.
Below program illustrates the working of getDefault() Method of TimeZone:
// Java code to illustrate getDefault() method  import java.util.*;  public class TimeZoneDemo {    public static void main(String args[])    {        // Creating an object of TimeZone class.        TimeZone time_zone_default            = TimeZone.getDefault();          // Displaying the default TimeZone        System.out.println("Default TimeZone: "                           + time_zone_default);    }}
Default TimeZone: sun.util.calendar.ZoneInfo[id="Etc/UTC",
offset=0, dstSavings=0, useDaylight=false, transitions=0, lastRule=null]

Java - util package
Java-Functions
Java-TimeZone
Misc
Misc
Misc
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Virtualization In Cloud Computing and Types
Association Rule
Software Engineering | Prototyping Model
std::unique in C++
Distributed Database System
Find maximum (or minimum) sum of a subarray of size k
Introduction to Electronic Mail
Advantages and Disadvantages of OOP
Set add() method in Java with Examples
Zigzag (or diagonal) traversal of Matrix
How to get the current year using JavaScript ?

11 Nov, 2021
In this article, we will know how to get the current year using the build-in method in Javascript. The purpose is to get the current year by using JavaScript getFullYear() method that will return the full year in 4-digit format for some specified date. This method is used to fetch the year from a given Date object.
Syntax:
DateObject.getFullYear(); 
Parameter: This function does not accept any parameters.
Return Values: It returns the year for the given date.
Example: This example describes getting the current year. Generally, it is used to validate the input year in the 4-digit format on the website.
HTML
<!DOCTYPE html><html>  <body style="text-align:center;">    <h1>GeeksforGeeks</h1>    <h2>        How to get the current         year in JavaScript?    </h2>    <button onclick="geeks()"> click me </button>    <h4 id="myID"></h4>    <script>    function geeks() {                // Creating Date Object         var dateobj = new Date();                // Year from above object         // is being fetched using getFullYear()         var dateObject = dateobj.getFullYear();                // Printing current year         document.getElementById("myID").innerHTML =         "The Current Year is : " + dateObject;    }    </script></body>  </html>
Output:
 getting the current year
bhaskargeeksforgeeks
JavaScript-Questions
HTML
JavaScript
Web Technologies
Web technologies Questions
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Matplotlib.axes.Axes.axhline() in Python

13 Apr, 2020
Matplotlib is a library in Python and it is numerical – mathematical extension for NumPy library. The Axes Class contains most of the figure elements: Axis, Tick, Line2D, Text, Polygon, etc., and sets the coordinate system. And the instances of Axes supports callbacks through a callbacks attribute.
The Axes.axhline() function in axes module of matplotlib library is used to add a horizontal line across the axis.
Syntax:
Axes.axhline(self, y=0, xmin=0, xmax=1, **kwargs)
Parameters: This method accept the following parameters that are described below:
y: This parameter is the y position in data coordinates of the horizontal line with default value of 0.
xmin: This parameter should be between 0 and 1, 0 being the far left of the plot, 1 the far right of the plot.Its default value of 0.
xmax: This parameter should be between 0 and 1, 0 being the far left of the plot, 1 the far right of the plot. Its default value of 1.
Returns: This returns the following:
lines:This returns the list of Line2D objects representing the plotted data.
Below examples illustrate the matplotlib.axes.Axes.axhline() function in matplotlib.axes:
Example-1:
# Implementation of matplotlib functionimport matplotlib.pyplot as pltimport numpy as npimport matplotlib.collections as collections  t = np.arange(0.0, 2, 0.01)s1 = np.sin(4 * np.pi * t)s2 = 0.75 * np.sin(8 * np.pi * t)  fig, ax = plt.subplots()  ax.plot(t, s1, color ='black')ax.axhline(0, color ='green', lw = 2)ax.set_title('matplotlib.axes.Axes.axhline() Example')plt.show()
Output:
Example-2:
# Implementation of matplotlib functionimport matplotlib.pyplot as pltimport matplotlib.tri as mtriimport numpy as np  fig, ax = plt.subplots()x = np.arange(0, 8 * np.pi, 0.01)y = np.sin(x)ax.plot(x, y, color ='black')  threshold = 0.35ax.axhline(threshold, color ='green',           lw = 3, alpha = 0.7)  ax.fill_between(x, 0, 1, where = y > threshold,                color ='green', alpha = 0.8,                 transform = ax.get_xaxis_transform())  ax.set_title('matplotlib.axes.Axes.axhline() Example')plt.show()
Output:
Python-matplotlib
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Data Structures and Algorithms | Set 27

11 Nov, 2021
Following questions have been asked in GATE CS 2011 exam.
1) An undirected graph G(V, E) contains n ( n > 2 ) nodes named v1 , v2 ,....vn. Two nodes vi , vj are connected if and only if 0 < |i – j| <= 2. Each edge (vi, vj ) is assigned a weight i + j. A sample graph with n = 4 is shown below.
What will be the cost of the minimum spanning tree (MST) of such a graph with n nodes?(A) 1/12(11n^2 – 5n)(B) n^2 – n + 1(C) 6n – 11(D) 2n + 1
Answer: (B)Minimum spanning tree for 2 nodes would be
 (v1) _ (v2) 

Total weight 3
Minimum spanning tree for 3 nodes would be
 (v1) _ (v2) 
    |
 (v3)

Total weight= 3 + 4 = 7
Minimum spanning tree for 4 nodes would be
 (v1) _ (v2) _ (v4) 
    |
 (v3)

Total weight= 3 + 4 + 6 = 13
Minimum spanning tree for 5 nodes would be
 (v1) _ (v2) _ (v4) 
    |
 (v3)
    |
 (v5)

Total weight= 3 + 4 + 6 + 8 = 21
Minimum spanning tree for 6 nodes would be
 (v1) _ (v2) _ (v4) _ (v6)
    |
 (v3)
    |
 (v5)

Total weight= 3 + 4 + 6 + 8 + 10 = 31
We can observe from above examples that when we add kth node, the weight of spanning tree increases by 2k-2. Let T(n) be the weight of minimum spanning tree. T(n) can be written as
T(n) = T(n-1) + (2n-2) for n > 2T(1) = 0, T(2) = 0 and T(2) = 3
The recurrence can be written as sum of series (2n – 2) + (2n-4) + (2n-6) + (2n-8) + .... 3 and solution of this recurrence is n^2 – n + 1.
2) The length of the path from v5 to v6 in the MST of previous question with n = 10 is(A) 11(B) 25(C) 31(D) 41
Answer: (C)Any MST which has more than 5 nodes will have the same distance between v5 and v6 as the basic structure of all MSTs (with more than 5 nodes) would be following.
 (v1) _ (v2) _ (v4) _  (v6) _ .  . (more even numbered nodes)
    |
 (v3)
    |
 (v5)
    |
    .
    .
(more odd numbered nodes)

Distance between v5 and v6 = 3 + 4 + 6 + 8 + 10 = 31
3) Consider two binary operators ‘↑ ‘ and ‘↓’ with the precedence of operator ↓ being lower than that of the ↑ operator. Operator ↑ is right associative while operator ↓ is left associative. Which one of the following represents the parse tree for expression (7 ↓ 3 ­↑ 4 ­↑ 3 ↓ 2)?
Answer: (B)Let us consider the given expression (7 ↓ 3 ↑ 4 ↑ 3 ↓ 2).
Since the precedence of ↑ is higher, the sub-expression ([3 ↑ 4 ↑ 3) will be evaluated first. In this sub-expression, 4 ↑ 3 would be evaluated first because ↑ is right to left associative. So the expression is evaluated as ((7 ↓ (3 ↑ (4 ↑ 3))) ↓ 2). Also, note that among the two ↓ operators, first one is evaluated before the second one because the associativity of ↓ is left to right.
Please see GATE Corner for all previous year paper/solutions/explanations, syllabus, important dates, notes, etc.
Please write comments if you find any of the answers/explanations incorrect, or you want to share more information about the topics discussed above.
GATE-CS-2011
GATE-CS-DS-&-Algo
GATE CS
MCQ
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
PHP | imagerotate() Function

25 Oct, 2019
The imagerotate() function is an inbuilt function in PHP which is used to rotate an image with a given angle in degrees. The rotation center of the image is center.
Syntax:
resource imagerotate( $image, $angle, $bgd_color, $ignore_transparent = 0 ) 
Parameters: This function accepts four parameters as mentioned above and described below:
$image: It is returned by one of the image creation functions, such as imagecreatetruecolor(). It is used to create size of image.
$angle: This parameter holds the rotation angle in degrees. The rotation angle is used to rotate an image in anticlockwise direction.
$bgd_color: This parameter holds the background color of uncovered zone after rotation.
$ignore_transparent: If this parameter set and non-zero then transparent colors are ignored.
Return Value: This function returns an image resource for the rotated image on success, or False on failure.
Below programs illustrate the imagerotate() function in PHP:
Program 1:
<?php     // Assign image file to variable $image_name = 'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-15.png';      // Load image file $image = imagecreatefrompng($image_name);    // Use imagerotate() function to rotate the image$img = imagerotate($image, 180, 0);  // Output image in the browser header("Content-type: image/png");   imagepng($img);   ?> 
Output:
Program 2:
<?php     // It create the size of image or blank image. $image = imagecreatetruecolor(500, 300);      // Set the background color of image. $bg = imagecolorallocate($image, 205, 220, 200);      // Fill background with above selected color. imagefill($image, 0, 0, $bg);     // Set the color of an ellipse. $col_ellipse = imagecolorallocate($image, 0, 102, 0);      // Function to draw the filled ellipse. imagefilledellipse($image, 250, 150, 400, 250, $col_ellipse);   // Use imagerotate() function to rotate the image$img = imagerotate($image, 90, 0);  // Output image in the browser header("Content-type: image/png");   imagepng($img);   ?> 
Output:
Reference: https://www.php.net/manual/en/function.imagerotate.php
Akanksha_Rai
PHP-function
PHP
Web Technologies
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to get a Date from year, month and day in Java?

The of() method of the java.time.LocalDate class accepts the values of the year, month, and day of month as parameters, creates and returns an object of the LocalDate.
Live Demo
import java.time.LocalDate;
public class Test {
   public static void main(String[] args) {
      LocalDate date = LocalDate.of(2014, 9, 11);
      System.out.println("Date Value: "+date);
   }
}
Date Value: 2014-09-11
Date Value: 2014-09-11
One of the constructors of the java.util.GregorianCalendar class accepts the values of year, month and day of month as values and creates a Calendar object representing it.
import java.util.*;
class Test {  
   public static void main(String args[]){
      //Creating a calendar object
      Calendar cal = new GregorianCalendar(2020, 07, 18);
      int day = cal.get(Calendar.DAY_OF_MONTH);
      int month = cal.get(Calendar.MONTH);
      int year = cal.get(Calendar.YEAR);
      System.out.println("Day: " + day);
      System.out.println("Month: " + month);
      System.out.println("Year: " + year);
    }
}
Day: 18
Month: 7
Year: 2020
One of the constructors of this class accepts a String value representing the desired date format and creates SimpleDateFormat object. To parse/convert a string as a Date object −
Instantiate this class by passing desired format string.
Parse the date string using the parse() method.
Live Demo
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class Sample {
   public static void main(String args[]) throws ParseException {  
      String date_string = "2007-25-06";
      //Instantiating the SimpleDateFormat class
      SimpleDateFormat formatter = new SimpleDateFormat("yyyy-dd-MM");      
      //Parsing the given String to Date object
      Date date = formatter.parse(date_string);      
      System.out.println("Date value: "+date);
   }
}
Date value: Mon Jun 25 00:00:00 IST 2007
turtle.setpos() and turtle.goto() functions in Python - GeeksforGeeks

17 Jul, 2020
The turtle module provides turtle graphics primitives, in both object-oriented and procedure-oriented ways. Because it uses Tkinter for the underlying graphics, it needs a version of Python installed with Tk support.
This method is used to move the turtle to an absolute position. This method has Aliases: setpos, setposition, goto.
Syntax: turtle.setpos(x, y=None) or turtle.setposition(x, y=None) or turtle.goto(x, y=None)
Parameters:
x: x coordinate of a Vec2D-vector 
y: y coordinate of a Vec2D-vector
Below is the implementation of above method with some examples :
Example 1:
Python3
# import packageimport turtle   # forward turtle by 100turtle.forward(100)  # stamp the turtle shapeturtle.stamp()  # set the position by using setpos()turtle.up()turtle.setpos(-50,50)turtle.down()  # forward turtle by 100turtle.forward(100)  # stamp the turtle shapeturtle.stamp()  # set the position by using goto()turtle.up()turtle.goto(-50,-50)turtle.down()  # forward turtle by 100turtle.forward(100)
Output :
Example 2 :
Python3
# import packageimport turtle   # method to raw pattern# of circle with rad radiusdef draw(rad):          # draw circle    turtle.circle(rad)          # set the position by using setpos()    turtle.up()    turtle.setpos(0,-rad)    turtle.down()  # loop for patternfor i in range(5):    draw(20+20*i)
Output :
Python-turtle
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 | Pandas dataframe.groupby()
Create a directory in Python
Defaultdict in Python
Python | Get unique values from a list
Insert Image in a Jupyter Notebook - GeeksforGeeks

28 Nov, 2021
In this article, we will discuss how to insert images in a Jupyter Notebook. There are a few ways to insert images. These are –
Direct insertion using the edit menu.
Embedding in a markdown cell
By python code ( embedding an image in a code cell).
Step 1:  This method is the easiest. first, change the type of the cell to  -> markdown.
Step 2: After that click edit in the jupyter notebook menu. after that click ‘insert image’. Edit -> insert image.
Step 3: After that, a dialogue box opens up and asks us to locate the file. Click on ‘ok’.
There are different ways to embed an image in markdown.  below is an example of direct embedding:
Python3
![SNOWFALL](snowfall4.jpeg)
Output:
A code cell can also be used to embed images. To display the image, the Ipython.display() method necessitates the use of a function. In the notebook, you can also specify the width and height of the image.
Python3
# import image modulefrom IPython.display import Image  # get the imageImage(url="snowfall4.jpeg", width=300, height=300)
Output:
Jupyter-notebook
Picked
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
Defaultdict in Python
Python Classes and Objects
Create a directory in Python
Python | os.path.join() method
Python | Pandas dataframe.groupby()
Python | Get unique values from a list