code-rag-bench/online-tutorials huggingface dataset:
Differentiate the modulo and division by using C Programming language?

Modulo − Represents as % operator.
 And gives the value of the remainder of an integer division.
Division − represents as / operator.
 And gives the value of the quotient of a division.
#include<stdio.h>
int main(){
   int a,b,c;
   printf("enter a,b,c values:");
   scanf("%d%d%d,&a,&b,&c);
   printf("a/b=%d a%b=%d\n",a/b,a%b);
   printf("(a+10)%b=%d (a+10)/b=%d\n",(a+10)%b,(a+10)/b);
}
enter a,b,c values:2 4 6
a/b=0 ab=2
(a+10)b=0 (a+10)/b=3
Applying pointer variables to perform modulo and division operation −
 Live Demo
#include<stdio.h>
void main(){
   //Declaring pointers and variables//
   int num1,num2;
   int *p1,*p2;
   p1=&num1;
   p2=&num2;
   int div,mod;
   //Reading User I/p//
   printf("Enter the values of num1 & num2: ");
   scanf("%d,%d",&num1,&num2);
   div=*p1/ *p2;
   mod=*p1%*p2;
   //Printing O/p//
   printf("Division value = %d\n",div);
   printf("Modulus value = %d\n",mod);
}
Enter the values of num1 & num2: 30,20
Division value = 1
Modulus value = 10
Date Class in C#

To set dates in C#, use DateTime class. The DateTime value is between 12:00:00 midnight, January 1, 0001 to 11:59:59 P.M., December 31, 9999 A.D.
Let’s create a DateTime object.
 Live Demo
using System;
class Test {
   static void Main() {
      DateTime dt = new DateTime(2018, 7, 24);
      Console.WriteLine (dt.ToString());
   }
}
7/24/2018 12:00:00 AM
Let us now get the current date and time.
 Live Demo
using System;
class Test {
   static void Main() {
      Console.WriteLine (DateTime.Now.ToString());
   }
}
9/17/2018 5:49:21 AM
Now using the method Add(), we will add days in a date with the DateTime structure.
 Live Demo
using System;
class Test {
   static void Main() {
      DateTime dt1 = new DateTime(2018, 7, 23, 08, 20, 10);
      Console.WriteLine ("Old Date: "+dt1.ToString());
      DateTime dt2 = dt1.AddDays(7);
      Console.WriteLine ("New Date: "+dt2.ToString());
   }
}
Old Date: 7/23/2018 8:20:10 AM
New Date: 7/30/2018 8:20:10 AM
How to use #if..#elif...#else...#endif directives in C#?

All preprocessor directives begin with #, and only white-space characters may appear before a preprocessor directive on a line. Preprocessor directives are not statements, so they do not end with a semicolon (;).
The #if directive allows testing a symbol or symbols to see if they evaluate to true.
It allows to create a compound conditional directive, along with #if.
It allows creating a compound conditional directive.
The #endif specifies the end of a conditional directive.
The following is an example showing the usage of #if, #elif, #else and #endif directives −
 Live Demo
#define One
#undef Two

using System;

namespace Demo {
   class Program {
      static void Main(string[] args) {
         #if (One && TWO)
         Console.WriteLine("Both are defined");
         #elif (ONE && !TWO)
         Console.WriteLine("ONE is defined and TWO is undefined");
         #elif (!ONE && TWO)
         Console.WriteLine("ONE is defined and TWO is undefined");
         #else
         Console.WriteLine("Both are undefined");
         #endif
      }
   }
}
Both are undefined
C++ Vector Library - size() Function

The C++ function std::vector::size() returns the number of elements present in the vector.
Following is the declaration for std::vector::size() function form std::vector header.
size_type size() const;

size_type size() const noexcept;

None
Returns the actual objects present in vector, which may be differ than storage capacity of vector.
This member function never throws exception.
Constant i.e. O(1)
The following example shows the usage of std::vector::size() function.
#include <iostream>
#include <vector>

using namespace std;

int main(void) {
   vector<int> v;

   cout << "Initial vector size = " << v.size() << endl;

   v.resize(128);
   cout << "Vector size after resize = " << v.size() << endl;

   return 0;
}
Let us compile and run the above program, this will produce the following result −
Initial vector size = 0
Vector size after resize = 128

 Print
 Add Notes
 Bookmark this page
C++ Fstream Library - rdbuf Function

It returns a pointer to the internal filebuf object.
Following is the declaration for fstream::rduf.
filebuf* rdbuf() const;
It returns a pointer to the internal filebuf object.
Strong guarantee − if an exception is thrown, there are no changes in the stream buffer.
It accesses the stream object.
It accesses the stream object.
It concurrent access to the same stream object may cause data races.
It concurrent access to the same stream object may cause data races.
In below example explains about fstream rdbuf function.
#include <fstream>
#include <cstdio>

int main () {
   std::fstream src,dest;
   src.open ("test.txt");
   dest.open ("copy.txt");

   std::filebuf* inbuf  = src.rdbuf();
   std::filebuf* outbuf = dest.rdbuf();

   char c = inbuf->sbumpc();
   while (c != EOF) {
      outbuf->sputc (c);
      c = inbuf->sbumpc();
   }

   dest.close();
   src.close();

   return 0;
}
 Print
 Add Notes
 Bookmark this page
Keyword arguments in Python

Keyword arguments are related to the function calls. When you use keyword arguments in a function call, the caller identifies the arguments by the parameter name.
This allows you to skip arguments or place them out of order because the Python interpreter is able to use the keywords provided to match the values with parameters. You can also make keyword calls to the printme() function in the following ways −
 Live Demo
#!/usr/bin/python
# Function definition is here
def printme( str ):
"This prints a passed string into this function"
print str
return;
# Now you can call printme function
printme( str = "My string")
When the above code is executed, it produces the following result −
My string

The following example gives more clear picture. Note that the order of parameters does not matter.
 Live Demo
#!/usr/bin/python
# Function definition is here
def printinfo( name, age ):
"This prints a passed info into this function"
print "Name: ", name
print "Age ", age
return;
# Now you can call printinfo function
printinfo( age=50, name="miki" )
When the above code is executed, it produces the following result −
Name: miki
Age 50
Job Sequencing with Deadline

In job sequencing problem, the objective is to find a sequence of jobs, which is completed within their deadlines and gives maximum profit.
Let us consider, a set of n given jobs which are associated with deadlines and profit is earned, if a job is completed by its deadline. These jobs need to be ordered in such a way that there is maximum profit.
It may happen that all of the given jobs may not be completed within their deadlines.
Assume, deadline of ith job Ji is di and the profit received from this job is pi. Hence, the optimal solution of this algorithm is a feasible solution with maximum profit.
Thus, D(i)>0 for 1⩽i⩽n.
Initially, these jobs are ordered according to profit, i.e. p1⩾p2⩾p3⩾...⩾pn.
Algorithm: Job-Sequencing-With-Deadline (D, J, n, k) 
D(0) := J(0) := 0 
k := 1 
J(1) := 1   // means first job is selected 
for i = 2 ... n do 
   r := k 
   while D(J(r)) > D(i) and D(J(r)) ≠ r do 
      r := r – 1 
   if D(J(r)) ≤ D(i) and D(i) > r then 
      for l = k ... r + 1 by -1 do 
         J(l + 1) := J(l) 
         J(r + 1) := i 
         k := k + 1 

In this algorithm, we are using two loops, one is within another. Hence, the complexity of this algorithm is O(n2).
Let us consider a set of given jobs as shown in the following table. We have to find a sequence of jobs, which will be completed within their deadlines and will give maximum profit. Each job is associated with a deadline and profit.
To solve this problem, the given jobs are sorted according to their profit in a descending order. Hence, after sorting, the jobs are ordered as shown in the following table.
From this set of jobs, first we select J2, as it can be completed within its deadline and contributes maximum profit.
Next, J1 is selected as it gives more profit compared to J4.
Next, J1 is selected as it gives more profit compared to J4.
In the next clock, J4 cannot be selected as its deadline is over, hence J3 is selected as it executes within its deadline.
In the next clock, J4 cannot be selected as its deadline is over, hence J3 is selected as it executes within its deadline.
The job J5 is discarded as it cannot be executed within its deadline.
The job J5 is discarded as it cannot be executed within its deadline.
Thus, the solution is the sequence of jobs (J2, J1, J3), which are being executed within their deadline and gives maximum profit.
Total profit of this sequence is 100 + 60 + 20 = 180.

    102 Lectures 
     10 hours 

 Arnab Chakraborty

    30 Lectures 
     3 hours 

 Arnab Chakraborty

    31 Lectures 
     4 hours 

 Arnab Chakraborty

    43 Lectures 
     1.5 hours 

 Manoj Kumar

    7 Lectures 
     1 hours 

 Zach Miller

    54 Lectures 
     4 hours 

 Sasha Miller
 Print
 Add Notes
 Bookmark this page
GitLab - Referencing Issues

GitLab can be able to refer the specific issue from the commit message to solve a specific problem. In this chapter, we will discuss about how to reference a issue in the GitLab −
Step 1 − To reference a issue, you need to have an issue number of a created issue. To create an issue, refer the creating issue chapter.
Step 2 − To see the created issue, click on the List option under Issues tab −
Step 3 − Before making the changes in your local repository, check whether it is up to date or not by using the below command −
git checkout master && git pull
The git pull command downloads the latest changes from the remote server and integrates directly into current working files.
Step 4 − Now, create a new branch with the name issue-fix by using the git checkout command −
git checkout -b issue-fix
Step 5 − Now, add some content to the README.md file to fix the bug −
echo "fix this bug" >> README.md
Step 6 − Enter the commit message for the above change with the below command −
git commit -a
This command opens the below screen and press Insert key on the keyboard to add a commit message for the issue-fix branch.
Now press the Esc key, then colon(:) and type wq to save and exit from the screen.
Step 7 − Now push the branch to remote repository by using the below command −
git push origin issue-fix
Step 8 − Login to your GitLab account and create a new merge request. You can refer the merge request chapter for the creation of merge request.
Step 9 − Once you create the merge request, you will be redirected to the merge request page. When you click on the Close merge request button (refer the screenshot in the step (6) of merge request chapter), you will see the Closed option after closing merge request.
 Print
 Add Notes
 Bookmark this page
How to set icon to a window in PyQt5 ?

26 Mar, 2020
When we design a PyQt5 application we see an icon on the top left corner, by default it looks like this :
In this tutorial, we will see how to change the icon according to the user need, in order to do this we use setWindowIcon() method and to load the icon QIcon will be used which belongs to QtGui class.
Syntax : setWindowIcon(QtGui.QIcon(‘icon.png’))
Argument :bIt takes file name if file is in same folder else file path.
Code :
# importing the required libraries  from PyQt5.QtWidgets import * from PyQt5 import QtCorefrom PyQt5 import QtGuiimport sys    class Window(QMainWindow):    def __init__(self):        super().__init__()          self.setWindowIcon(QtGui.QIcon('logo.png'))        # set the title        self.setWindowTitle("Icon")          # setting  the geometry of window        self.setGeometry(0, 0, 400, 300)          # creating a label widget        self.label = QLabel("Icon is set", self)          # moving position        self.label.move(100, 100)          # setting up border        self.label.setStyleSheet("border: 1px solid black;")              # show all the widgets        self.show()    # create pyqt5 appApp = QApplication(sys.argv)  # create the instance of our Windowwindow = Window()  # start the appsys.exit(App.exec())
Output :
Python-gui
Python-PyQt
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Iterate over a list in Python
Convert integer to string in Python
Python OOPs Concepts
C Program to Multiply two Floating Point Numbers

22 Apr, 2022
Given two floating numbers A and B. The task is to write a program to find the product of these two numbers.  Examples:
Input: A = 2.12, B = 3.88 Output: 8.225600 Input: A = 3.78, B = 6.32 Output: 23.889601
In the below program to multiply two floating point numbers, the user is first asked to enter two floating numbers and the input is scanned using the scanf() function and stored in the variables and . Then, the variables and are multiplied using the arithmetic operator and the product is stored in the variable product. Below is the C program to multiply two floating point numbers: 
C
// C program to multiply two floating point numbers#include <stdio.h> int main(){    float A, B, product = 0.0f;     // Ask user to enter the two numbers    printf("Enter two floating numbers A and B : \n");     // Read two numbers from the user || A = 2.12, B = 3.88    scanf("%f%f", &A, &B);     // Calculate the multiplication of A and B    // using '*' operator    product = A * B;     // Print the product    printf("Product of A and B is: %f", product);     return 0;}
Time Complexity: O(1), as we are not using any loops.
Auxiliary Space: O(1), as we are not using any extra space.
gulshankumarar231
rohitsingh07052
C Language
C Programs
School Programming
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Unordered Sets in C++ Standard Template Library
What is the purpose of a function prototype?
Operators in C / C++
Exception Handling in C++
TCP Server-Client implementation in C
Strings in C
Arrow operator -> in C/C++ with Examples
Basics of File Handling in C
UDP Server-Client implementation in C
Header files in C/C++ and its uses
SAP UI5 - Data binding

In SAP UI5, data binding concept is used to update the data automatically by binding the data with the controls that holds the application data. Using data binding, you can bind simple controls like text field, simple button to application data, and data is automatically updated when there is a new value.
Using two-way data binding, application data is updated when the value of bound control changes. The value can be changed via different methods, like user input, etc.
In SAP UI5, different data models can be used for data binding. These data models support different features −
JSON model is used to bind JavaScript objects to controls. This data model is a client-side model and is suggested for small data sets. It doesn’t provide any mechanism for serverside paging or loading.
Key features include −
JSON model for data binding supports data in JavaScript notation format.
It supports two-way data binding.
Creating a model instance −
Var oModel = new sap.ui.model.json.JSONModel(dataUrlorData);

XML model of data binding allows you to bind the controls to XML data. It is used for clientside objects and for small data sets. It doesn’t provide any mechanism for server-side paging or loading.
Key features include −
XML model of data binding supports XML data.
It also supports two-way data binding.
Creating a model instance −
Var oModel = new sap.ui.model.xml.XMLModel(dataUrlorData);

OData model is a server-side model, so entire data is available at the server side. Client side can see only rows and fields and you can’t use sorting and filtering at the client side. There is a need to send this request to the server to complete these tasks.
Data binding in OData model is one way but you can enable two-way binding using experimental write support.
Key features include −
OData model of data binding supports Odata compliant data.
This data model allows you to create OData requests and handle responses.
It supports experimental two-way binding.
Creating a model instance −
Var oModel = new sap.ui.model.odata.ODataModel (dataUrl [,useJSON, user, pass]);

You can use the setModel method to assign the model to specific controls or core.
Sap.ui.getcore().setModel(oModel);

To bind a model to view −
Var myView = sap.ui.view({type:sap.ui.core.mvc.ViewType.JS, viewname:”view name”});
myView.setModel(oModel);

To bind a model to a control −
Var oTable = sap.ui.getCore().byId(“table”);
oTable.setModel(oModel);

You can bind the properties of a control to model properties. You can bind the properties of a model to a control using bindproperty method −
oControl.bindProperty(“controlProperty”, “modelProperty”);
or by using below methodvar
oControl = new sap.ui.commons.TextView({
   controlProperty: “{modelProperty}”
});

You can use aggregation binding to bind a collection of values like binding multiple rows to a table. To use aggregation, you have to use a control that acts as a template.
You can define aggregation binding using bindAgregation method.
oComboBox.bindaggregation( “items”, “/modelaggregation”, oItemTemplate);
Install Pygame in MacOS

09 May, 2021
PyGame is a collection of modules that break through the language of Python applications. These modules are designed to edit video games. PyGame, therefore, includes computer graphics and audio libraries created for the use and language of Python programs.
At first, open the Terminal which is located at Applications -> Utilities -> Terminal and make sure that the Python3 is installed in your system. If it is not installed then type the below command.
brew install python3
XCode: The first step for PyGame is to install Apple’s Xcode program. In your Terminal app, enter and run the following command to install XCode.
xcode-select --install
Be sure to click on all the verification recommendations that require XCode
We can now install the latest version of PyGame. Type the following command in Terminal and press Enter.
pip3 install pygame
To test if PyGame has been installed on your Mac, open terminal and type python, and import pygame as follows
If you don’t see any errors, it means that PyGame has been successfully installed on your Mac.
Picked
Python-PyGame
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Python | os.path.join() method
How to drop one or multiple columns in Pandas Dataframe
Introduction To PYTHON
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | datetime.timedelta() function
Python | Get unique values from a list
Python | All occurrences of substring in string

25 Jun, 2019
Many times while working with strings, we have problems dealing with substrings. This may include the problem of finding all positions of a particular substrings in a string. Let’s discuss certain ways in which this task can be performed.
Method #1 : Using list comprehension + startswith()This task can be performed using the two functionalities. The startswith function primarily performs the task of getting the starting indices of substring and list comprehension is used to iterate through the whole target string.
# Python3 code to demonstrate working of# All occurrences of substring in string# Using list comprehension + startswith()  # initializing string test_str = "GeeksforGeeks is best for Geeks"  # initializing substringtest_sub = "Geeks"  # printing original string print("The original string is : " + test_str)  # printing substring print("The substring to find : " + test_sub)  # using list comprehension + startswith()# All occurrences of substring in string res = [i for i in range(len(test_str)) if test_str.startswith(test_sub, i)]  # printing result print("The start indices of the substrings are : " + str(res))
The original string is : GeeksforGeeks is best for Geeks
The substring to find : Geeks
The start indices of the substrings are : [0, 8, 26]

 
Method #2 : Using re.finditer()The finditer function of the regex library can help us perform the task of finding the occurrences of the substring in the target string and the start function can return the resultant index of each of them.
# Python3 code to demonstrate working of# All occurrences of substring in string# Using re.finditer()import re  # initializing string test_str = "GeeksforGeeks is best for Geeks"  # initializing substringtest_sub = "Geeks"  # printing original string print("The original string is : " + test_str)  # printing substring print("The substring to find : " + test_sub)  # using re.finditer()# All occurrences of substring in string res = [i.start() for i in re.finditer(test_sub, test_str)]  # printing result print("The start indices of the substrings are : " + str(res))
The original string is : GeeksforGeeks is best for Geeks
The substring to find : Geeks
The start indices of the substrings are : [0, 8, 26]

Python string-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Different ways to create Pandas Dataframe
Enumerate() in Python
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python | Convert string dictionary to dictionary
Python Program for Fibonacci numbers
Python | Math operations for Data analysis

18 Aug, 2021
Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric Python packages. Pandas is one of those packages and makes importing and analyzing data much easier.There are some important math operations that can be performed on a pandas series to simplify data analysis using Python and save a lot of time.
To get the data-set used, click here. 
s=read_csv("stock.csv", squeeze=True)
#reading csv file and making series
Returns mean of all values in series. Equals to s.sum()/s.count()  
 
Returns series with frequency of each value  
 
Returns a series with information like mean, mode, etc depending on dtype of data passed  
 
Code #1: 
Python3
# import pandas for reading csv fileimport pandas as pd #reading csv files = pd.read_csv("stock.csv", squeeze = True) #using count functionprint(s.count()) #using sum functionprint(s.sum()) #using mean functionprint(s.mean()) #calculation averageprint(s.sum()/s.count()) #using std functionprint(s.std()) #using min functionprint(s.min()) #using max functionprint(s.max()) #using count functionprint(s.median()) #using mode functionprint(s.mode())
Output:  
3012
1006942.0
334.3100929614874
334.3100929614874
173.18720477113115
49.95
782.22
283.315
0    291.21
Code #2: 
Python3
# import pandas for reading csv fileimport pandas as pd #reading csv files = pd.read_csv("stock.csv", squeeze = True) #using describe functionprint(s.describe()) #using count functionprint(s.idxmax()) #using idxmin functionprint(s.idxmin()) #count of elements having value 3print(s.value_counts().head(3))
Output: 
dtype: float64
count    3012.000000
mean      334.310093
std       173.187205
min        49.950000
25%       218.045000
50%       283.315000
75%       443.000000
max       782.220000
Name: Stock Price, dtype: float64

3011
11
291.21    5
288.47    3
194.80    3
Name: Stock Price, dtype: int64
Unexpected Outputs and Restrictions:
.sum(), .mean(), .mode(), .median() and other such mathematical operations are not applicable on string or any other data type than numeric value..sum() on a string series would give an unexpected output and return a string by concatenating every string.
.sum(), .mean(), .mode(), .median() and other such mathematical operations are not applicable on string or any other data type than numeric value.
.sum() on a string series would give an unexpected output and return a string by concatenating every string.
sagar0719kumar
gulshankumarar231
python-modules
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Iterate over a list in Python
How to iterate through Excel rows in Python?
Rotate axis tick labels in Seaborn and Matplotlib
Enumerate() in Python
Deque in Python
Queue in Python
Read a file line by line in Python
Defaultdict in Python
Python Dictionary
Stack in Python
What is the meaning of the ‘detached HEAD’ state in git?

Explanation − In git HEAD is a reference pointer and points to the current commit in the current branch. The below diagram shows that there are two commits ‘Commit#1’ and ‘Commit#2’, where ‘Commit#2’ is the latest commit. Every commit in Git will have a reference to its previous commit. Here, ‘Commit#2’ will have a reference to ‘Commit#1’. The current branch is master. The master pointer points to the latest commit i.e., ‘Commit#2’. The HEAD points to the master. In other words, the HEAD points to the last commit via the master.
To check where the HEAD is pointing to, we can use the following command in Git bash
$ cat .git/HEAD
ref: refs/heads/master
The output clearly shows that the HEAD refers to the master.
In the above example, HEAD points to a branch, which in turn points to a commit. In short, the HEAD points to the commit indirectly. In such a case, the HEAD is said to be attached.
When the HEAD pointer is moved from its default position, we get a warning “detached HEAD state”. This simply means that HEAD is not pointing to any branch, rather it now points to a specific commit. In other words, if the HEAD points to a specific commit, it is said to be detached.
Let us understand this with an example. Execute the following command in the Git bash terminal to view the commit history −
$ git log −−oneline
The output given below indicates that there are 3 commits and the HEAD pointer currently points to master
089ddf4 (HEAD −>master) new line
c81c9ab This is a short description 8a3d6ed first commit
Now let us move the HEAD pointer from its default position and make it point to one of the commit hashes displayed in the output. Here, we will make the HEAD point to the commit hash ‘8a3d6ed’ using the git checkout command.
$ git checkout 8a3d6ed
The output is as shown in the following screenshot.
dell@DESKTOP−N961NR5 MINGw64 /e/tut_repo (master)
$ git checkout 8a3d6ed
Note: switching to '8a3d6ed' .

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can di scard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using −c with the switch command. Example:

   git switch −c
Or undo this operation with:
   git switch −

Turn off this advice by setting config variable advice . detachedHead to fal se

HEAD is now at 8a3d6ed first commit
dell@DESKTop−N961NR5 MINGW64 /e/tut_repo ((8a3d6ed.. .))
The warning indicates that the HEAD is detached. This means that HEAD is now pointing to the commit ‘8a3d6ed’. Let us verify this by executing the following command −
$ cat .git/HEAD
The above command will return the contents of the HEAD pointer.
8a3d6ed9e95a94bc78d497fa20bc3d84a7e762fd
How to set background image of a webpage?

To set the background image of a webpage, use the CSS style. Under the CSS <style> tag, add the property background-image. The property sets a graphic such as jpg, png, svg, gif, etc. HTML5 do not support the <body> background attribute, so CSS is used to change set background image.
You can try the following code to set the background image of a web page in HTML
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <style>
         body {
            background-image: url("/videotutorials/images/tutor_connect_home.jpg");
         }
      </style>
   </head>

   <body>
      <h1>Connect with Tutors</h1>
   </body>
</html>
How to create a graph in R using ggplot2 with all the four quadrants?

The default graph created by using ggplot2 package shows the axes labels depending on the starting and ending values of the column of the data frame or vector but we might want to visualize it just like we do in paper form of graphs that shows all of the four quadrants. This can be done by using xlim, ylim, geom_hline, and geom_vline functions with ggplot function of ggplot2 package.
Consider the below data frame −
 Live Demo
x<-1:5
y<-5:1
df<-data.frame(x,y)
df
  x y
1 1 5
2 2 4
3 3 3
4 4 2
5 5 1
Loading ggplot2 package and creating point chart between x and y−
library(ggplot2) ggplot(df,aes(x,y))+geom_point()
Creating point chart between x and y by showing all four quadrants −
ggplot(df,aes(x,y))+geom_point()+xlim(-6,6)+ylim(-6,6)+geom_hline(yintercept=0)+geom_vline(xintercept=0)
Tailwind CSS Background Opacity - GeeksforGeeks

23 Mar, 2022
This class accepts lots of value in tailwind CSS in which all the properties are covered in class form. The bg-opacity is the class of an element that describes the transparency of the element. It is the alternative to the CSS Opacity / Transparency.
Background Opacity class:
background-opacity-0: Control the opacity of an element’s background using the background-opacity-{amount} utilities.
Note: The number of the opacity can be changeable from 0 to 100 with the span of 5.
Syntax:
<element class="bg-{opacity}">...</element>
Example:
HTML
<!DOCTYPE html> <head>     <link href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css"           rel="stylesheet"> </head>   <body class="text-center mx-4 space-y-2">     <h1 class="text-green-600 text-5xl font-bold">        GeeksforGeeks    </h1>     <b>Tailwind CSS Background Opacity Class</b>     <div class="mx-14 bg-green-200 grid grid-rows-4                grid-flow-col text-justify p-4">                 <p class="bg-green-800                  bg-opacity-100 p-2">         A Computer Science Portal for Geeks       </p>       <p class="bg-green-800                  bg-opacity-75 p-2">         A Computer Science Portal for Geeks       </p>       <p class="bg-green-800                  bg-opacity-50 p-2">         A Computer Science Portal for Geeks       </p>       <p class="bg-green-800                  bg-opacity-25 p-2">         A Computer Science Portal for Geeks       </p>       <p class="bg-yellow-800                  bg-opacity-100 p-2">         A Computer Science Portal for Geeks       </p>       <p class="bg-yellow-800                  bg-opacity-75 p-2">         A Computer Science Portal for Geeks       </p>         <p class="bg-yellow-800                  bg-opacity-50 p-2">         A Computer Science Portal for Geeks       </p>       <p class="bg-yellow-800                  bg-opacity-25 p-2">         A Computer Science Portal for Geeks       </p>       <p class="bg-pink-800                  bg-opacity-100 p-2">         A Computer Science Portal for Geeks       </p>       <p class="bg-pink-800                  bg-opacity-75 p-2">         A Computer Science Portal for Geeks       </p>       <p class="bg-pink-800                  bg-opacity-50 p-2">         A Computer Science Portal for Geeks       </p>       <p class="bg-pink-800                  bg-opacity-25 p-2">         A Computer Science Portal for Geeks       </p>    </div></body>   </html> 
Output:
Background opacity class
Tailwind CSS
Tailwind-Background
CSS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to insert spaces/tabs in text using HTML/CSS?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to update Node.js and NPM to next version ?
How to create footer to stay at the bottom of a Web page?
How to apply style to parent if it has child with CSS?
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
tf.transpose() function in TensorFlow - GeeksforGeeks

01 Jun, 2020
tf.transpose() is a function provided in TensorFlow. This function is used to transpose the input tensor.
Syntax: tf.transpose(input_tensor, perm, conjugate)
Parameters:input_tensor: as the name suggests it is the tensor which is to be transposed.Type: Tensor
perm: This parameters specifies the permutation according to which the input_tensor is to be transposed.Type: Vector
conjugate: This parameters is set to True if the input_tensor is of type complex.Type: Boolean
Example 1:
import tensorflow as geek    x = geek.constant([[1, 2, 3, 4],                   [5, 6, 7, 8]])transposed_tensor = geek.transpose(x)
Output :
array([[1, 5],
       [2, 6],
       [3, 7],
       [4, 8]])

Example 2: With using perm parameter:
When this parameter is passes the tensor is transposed along the given axis. In simple words it defines the output shape of the transposed tensor.
import tensorflow as geek    x = geek.constant([[[ 1, 2, 3],                    [ 4, 5, 6]],                   [[ 7, 8, 9],                    [ 10, 11, 12]],                   [[ 13, 14, 15],                    [ 16, 17, 18]],                   [[ 19, 20, 21],                    [ 22, 23, 24]]])transposed_tensor = geek.transpose(x, perm = [0, 2, 1])
Output:
array([[[ 1,  4],
        [ 2,  5],
        [ 3,  6]],

       [[ 7, 10],
        [ 8, 11],
        [ 9, 12]],

       [[13, 16],
        [14, 17],
        [15, 18]],

       [[19, 22],
        [20, 23],
        [21, 24]]])
shape (4, 3, 2)

The shape is (4, 3, 2) because our perm was [0, 2, 1]. The following is the mapping from perm to input tensor shape.
0 => 4
2 => 3
1 => 2
Example 3: Now we will study the conjugate parameterIt is set to True when we have complex variables in our tensor.
import tensorflow as geek    x = geek.constant([[1 + 1j, 2 + 2j, 3 + 3j],                   [4 + 4j, 5 + 5j, 6 + 6j]])transposed_tensor = geek.transpose(x)
Output:
array([[1 + 1j, 4 + 4j],
       [2 + 2j, 5 + 5j],
       [3 + 3j, 6 + 6j]])

Tensorflow
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Read a file line by line in Python
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Iterate over a list in Python
Python String | replace()
*args and **kwargs in Python
Reading and Writing to text files in Python
Create a Pandas DataFrame from Lists
Draw Spiraling Square using Turtle in Python - GeeksforGeeks

18 Aug, 2020
Prerequisite: Python Turtle Basic
Turtle is an inbuilt module of python. It enables us to draw any drawing by a turtle, methods defined in the turtle module and by using some logical loops. To draw something on the screen(cardboard) just move the turtle(pen). To move turtle(pen) there are some functions i.e forward(), backward(), etc.
Approach to draw a Spiraling Square of size n:  
Import turtle and create a turtle instance.
Using for loop(i = 0 to i < n * 4) and repeat below stepturtle.forward(i * 10).turtle.right(90).
turtle.forward(i * 10).
turtle.right(90).
Close the turtle instance.
Below is the implementation:
Python3
# importing turtle moduleimport turtle  # size n = 10  # creating instance of turtlepen = turtle.Turtle()  # loop to draw a sidefor i in range(n * 4):        # drawing side of    # length i*10    pen.forward(i * 10)          # changing direction of pen    # by 90 degree in clockwise    pen.right(90)  # closing the instanceturtle.done()
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 | Get unique values from a list
Create a directory in Python
Defaultdict in Python
Python | Pandas dataframe.groupby()
Logical Not ! operator in C with Examples - GeeksforGeeks

15 Oct, 2019
! is a type of Logical Operator and is read as “NOT” or “Logical NOT“. This operator is used to perform “logical NOT” operation, i.e. the function similar to Inverter gate in digital electronics.
Syntax:
!Condition

// returns true if the conditions is false
// else returns false

Below is an example to demonstrate ! operator:
Example:
// C program to demonstrate working// of logical NOT '!' operators  #include <stdio.h>  int main(){      // Taking a variable a    // and set it to 0 (false)    int a = 0;      // logical NOT example      // Since 0 is considered to be false    // !a will yield true    if (!a)        printf("Condition yielded True\n");    else        printf("Condition yielded False\n");      // set a to non-zero value (true)    a = 1;      // Since a non-zero value is considered to be true    // !a will yield false    if (!a)        printf("Condition yielded True\n");    else        printf("Condition yielded False\n");      return 0;}
Condition yielded True
Condition yielded False

C-Operators
C Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
TCP Server-Client implementation in C
Exception Handling in C++
Multithreading in C
'this' pointer in C++
Arrow operator -> in C/C++ with Examples
Ways to copy a vector in C++
Smart Pointers in C++ and How to Use Them
Multiple Inheritance in C++
Understanding "extern" keyword in C
How to split a string in C/C++, Python and Java?
Python - Uniform Distribution in Statistics - GeeksforGeeks

10 Jan, 2020
scipy.stats.uniform() is a Uniform continuous random variable. It is inherited from the of generic methods as an instance of the rv_continuous class. It completes the methods with details specific for this particular distribution.
Parameters :
q : lower and upper tail probabilityx : quantilesloc : [optional]location parameter. Default = 0scale : [optional]scale parameter. Default = 1size : [tuple of ints, optional] shape or random variates.moments : [optional] composed of letters [‘mvsk’]; ‘m’ = mean, ‘v’ = variance, ‘s’ = Fisher’s skew and ‘k’ = Fisher’s kurtosis. (default = ‘mv’).
Results : Uniform continuous random variable
Code #1 : Creating Uniform continuous random variable
# importing library  from scipy.stats import uniform     numargs = uniform .numargs a, b = 0.2, 0.8rv = uniform (a, b)     print ("RV : \n", rv)  
Output :
RV : 
 scipy.stats._distn_infrastructure.rv_frozen object at 0x000002A9D9F1E708

Code #2 : Uniform continuous variates and probability distribution
import numpy as np quantile = np.arange (0.01, 1, 0.1)   # Random Variates R = uniform .rvs(a, b, size = 10) print ("Random Variates : \n", R)   # PDF x = np.linspace(uniform.ppf(0.01, a, b),                uniform.ppf(0.99, a, b), 10)R = uniform.pdf(x, 1, 3)print ("\nProbability Distribution : \n", R) 
Output :
Random Variates : 
 [0.30819979 0.95991962 0.70622125 0.60895239 0.72550267 0.73555393
 0.3757751  0.88295358 0.50726709 0.57936421]

Probability Distribution : 
 [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]

Code #3 : Graphical Representation.
import numpy as np import matplotlib.pyplot as plt      distribution = np.linspace(0, np.minimum(rv.dist.b, 3)) print("Distribution : \n", distribution)      plot = plt.plot(distribution, rv.pdf(distribution)) 
Output :
Distribution : 
 [0.         0.02040816 0.04081633 0.06122449 0.08163265 0.10204082
 0.12244898 0.14285714 0.16326531 0.18367347 0.20408163 0.2244898
 0.24489796 0.26530612 0.28571429 0.30612245 0.32653061 0.34693878
 0.36734694 0.3877551  0.40816327 0.42857143 0.44897959 0.46938776
 0.48979592 0.51020408 0.53061224 0.55102041 0.57142857 0.59183673
 0.6122449  0.63265306 0.65306122 0.67346939 0.69387755 0.71428571
 0.73469388 0.75510204 0.7755102  0.79591837 0.81632653 0.83673469
 0.85714286 0.87755102 0.89795918 0.91836735 0.93877551 0.95918367
 0.97959184 1.        ]
  
Code #4 : Varying Positional Arguments
import matplotlib.pyplot as plt import numpy as np   x = np.linspace(0, 5, 100)      # Varying positional arguments y1 = uniform.pdf(x, a, b) y2 = uniform.pdf(x, a, b) plt.plot(x, y1, "*", x, y2, "r--") 
Output :
Python scipy-stats-functions
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Read a file line by line in Python
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Iterate over a list in Python
Python String | replace()
Reading and Writing to text files in Python
*args and **kwargs in Python
Convert integer to string in Python
How can you delete a record from a table using MySQL in Python?

We may at times need to delete certain rows from a table. Suppose, we have a table of details of students in the class. It is possible that one of the students left the class and hence, we do not require the details of that particular student. Hence, we need to delete that particular row or record from the table.
The “DELETE FROM” statement in MySQL is used to delete a row or record from the table, The “WHERE” clause is used to specify the row to be deleted. If WHERE clause is not used, then all the records will be deleted.
Delete all the rows −
DELETE FROM table_name
Delete a specific row −
DELETE FROM table_name WHERE condition
import MySQL connector
import MySQL connector
establish connection with the connector using connect()
establish connection with the connector using connect()
create the cursor object using cursor() method
create the cursor object using cursor() method
create a query using the appropriate mysql statements
create a query using the appropriate mysql statements
execute the SQL query using execute() method
execute the SQL query using execute() method
commit the changes made using the commit() method
commit the changes made using the commit() method
close the connection
close the connection
Suppose we have a table named “Student” as follows −
+----------+---------+-----------+------------+
|    Name  | Class   |    City   |    Marks   |
+----------+---------+-----------+------------+
|    Karan |    4    | Amritsar  |    95      |
|    Sahil |    6    | Amritsar  |    93      |
|    Kriti |    3    | Batala    |    88      |
|   Khushi |    9    | Delhi     |    90      |
|    Kirat |    5    | Delhi     |    85      |
+----------+---------+-----------+------------+
Suppose, we have the above table of students and we want to delete the record of Kriti from the above table.
import mysql.connector

db=mysql.connector.connect(host="your host", user="your username", password="your
password",database="database_name")

cursor=db.cursor()

query="DELETE FROM Students WHERE Name='Kriti'"
cursor.execute(query)
db.commit()
query="SELECT * FROM Students"
cursor.execute(query)
for row in cursor:
   print(row)
db.close()
The above code deletes a row from the table and prints the remaining rowsof the table.
(‘Karan’, 4 ,’Amritsar’ , 95)
(‘Sahil’ , 6, ‘Amritsar’ ,93)
(‘Amit’ , 9, ‘Delhi’ , 90)
(‘Priya’ , 5, ‘Delhi’ ,85)
The db.commit() in the above code is important. It is used to commit the changes made to the table. Without using commit(), no changes will be made in the table.
Java program to convert a Set to an array

The Set object provides a method known as toArray(). This method accepts an empty array as argument, converts the current Set to an array and places in the given array. To convert a Set object to an array −
 Create a Set object.
 Add elements to it.
 Create an empty array with size of the created Set.
 Convert the Set to an array using the toArray() method, bypassing the above-created array as an argument to it.
 Print the contents of the array.
Live Demo
import java.util.HashSet;
import java.util.Set;
public class SetToArray {
   public static void main(String args[]){
      Set<String> set = new HashSet<String>();
      set.add("Apple");
      set.add("Orange");
      set.add("Banana");

      System.out.println("Contents of Set ::"+set);
      String[] myArray = new String[set.size()];
      set.toArray(myArray);

      for(int i=0; i<myArray.length; i++){
         System.out.println("Element at the index "+(i+1)+" is ::"+myArray[i]);
      }
   }
}
Contents of Set ::[Apple, Orange, Banana]
Element at the index 1 is ::Apple
Element at the index 2 is ::Orange
Element at the index 3 is ::Banana
Java Program to get prime numbers using the Sieve of Eratosthenes algorithm

To find all prime numbers up to any given limit, use the Sieve of Eratosthenes algorithm. At first we have set the value to be checked −
int val = 30;
Now, we have taken a boolean array with a length one more than the val −
boolean[] isprime = new boolean[val + 1];
Loop through val and set numbers as TRUE. Also, set 0 and 1 as false since both these number are not prime −
isprime[0] = false;
isprime[1] = false;
Following is an example showing rest of the steps to get prime numbers using the Sieve of Eratosthenes algorithm −
 Live Demo
public class Demo {
   public static void main(String[] args) {
      // set a value to check
      int val = 30;
      boolean[] isprime = new boolean[val + 1];
      for (int i = 0; i <= val; i++)
      isprime[i] = true;
      // 0 and 1 is not prime
      isprime[0] = false;
      isprime[1] = false;
      int n = (int) Math.ceil(Math.sqrt(val));
      for (int i = 0; i <= n; i++) {
         if (isprime[i])
         for (int j = 2 * i; j <= val; j = j + i)
         // not prime
         isprime[j] = false;
      }
      int myPrime;
      for (myPrime = val; !isprime[myPrime]; myPrime--) ; // empty loop body
      System.out.println("Largest prime less than or equal to " + val + " = " + myPrime);
   }
}
Largest prime less than or equal to 30 = 29
How do we compare the elements of two lists in Python?

The method cmp() compares elements of two lists. If elements are of the same type, it performs the compare and returns the result. If elements are different types, it checks to see if they are numbers. If they are numbers, it performs type coercion if necessary and compares. If either element is a number, then the other element is "larger" (numbers are "smallest"). Otherwise, types are sorted alphabetically by name.
If we reached the end of one of the lists, the longer list is "larger." If we exhaust both lists and share the same data, the result is a tie, meaning that 0 is returned.
list1 = [123, 'xyz']
list2 = [456, 'abc']
print(cmp(list1, list2))
print(cmp(list2, list1))
list2 = [123, 'xyz']
print(cmp(list1, list2))
This will give the output −
-1
1
0