code-rag-bench/online-tutorials huggingface dataset:
Bootstrap 4 .card-img-top class

Use the card-img-top class in Bootstrap to set the image at the top inside a card −
<img class="card-img-top" src="Image-Source" alt="ALT-TEXT" style="width:100%">
After that add the card and card body −
<div class="card-body">
  <h4 class="card-title">Swift 4</h4>
  <p class="card-text">Learn Swift 4</p>
  <a href="#" class="btn btn-primary">Begin</a>
</div>
You can try to run the following code to implement the card-img-top class in Bootstrap 4 −
Live Demo
<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Bootstrap Example</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
  </head>

<body>
  <div class="container">
    <h3>SWIFT 4 Tutorial</h3>
    <p>Video Tutorial on Switft 4</p>
    <div class="card" style="width:350px">
      <img class="card-img-top" src="https://www.tutorialspoint.com/assets/videotutorials/courses/swift_4_online_training/380_course_210_image.jpg" alt="Swift4" style="width:100%">
      <div class="card-body">
        <h4 class="card-title">Swift 4</h4>
        <p class="card-text">Learn Swift 4</p>
        <a href="#" class="btn btn-primary">Begin</a>
      </div>
    </div>
  </div>

</body>
</html>
Difference between find() and findOne() methods in MongoDB?

The findOne() returns first document if query matches otherwise returns null. The find() method does not return null, it returns a cursor.
Let us implement the concept of find() and findOne() and create a collection with documents −
> db.createCollection('emptyCollection');
{ "ok" : 1 }
Let us count how many documents are in the above collection −
> db.emptyCollection.count();
This will produce the following output −
0
There is no document present in the above collection.
Following is the query to check the result with findOne() −
> if(db.emptyCollection.findOne()){print("Returns Cursor")} else {print("Not returning cursor")}
This will produce the following output −
Not returning cursor
Following is the query to check the result with find() −
> if(db.emptyCollection.find()){print("Returns Cursor")} else {print("Not returning cursor")}
This will produce the following output −
Returns Cursor
MATLAB - Polynomials

MATLAB represents polynomials as row vectors containing coefficients ordered by descending powers. For example, the equation P(x) = x4 + 7x3 - 5x + 9 could be represented as −
p = [1 7 0  -5 9];
The polyval function is used for evaluating a polynomial at a specified value. For example, to evaluate our previous polynomial p, at x = 4, type −
p = [1 7 0  -5 9];
polyval(p,4)
MATLAB executes the above statements and returns the following result −
ans = 693

MATLAB also provides the polyvalm function for evaluating a matrix polynomial. A matrix polynomial is a polynomial with matrices as variables.
For example, let us create a square matrix X and evaluate the polynomial p, at X −
p = [1 7 0  -5 9];
X = [1 2 -3 4; 2 -5 6 3; 3 1 0 2; 5 -7 3 8];
polyvalm(p, X)
MATLAB executes the above statements and returns the following result −
ans =
      2307       -1769        -939        4499
      2314       -2376        -249        4695
      2256       -1892        -549        4310
      4570       -4532       -1062        9269

The roots function calculates the roots of a polynomial. For example, to calculate the roots of our polynomial p, type −
p = [1 7 0  -5 9];
r = roots(p)
MATLAB executes the above statements and returns the following result −
r =
   -6.8661 + 0.0000i
   -1.4247 + 0.0000i
   0.6454 + 0.7095i
   0.6454 - 0.7095i

The function poly is an inverse of the roots function and returns to the polynomial coefficients. For example −
p2 = poly(r)
MATLAB executes the above statements and returns the following result −
p2 =

   Columns 1 through 3:

      1.00000 + 0.00000i   7.00000 + 0.00000i   0.00000 + 0.00000i

   Columns 4 and 5:

      -5.00000 - 0.00000i   9.00000 + 0.00000i

The polyfit function finds the coefficients of a polynomial that fits a set of data in a least-squares sense. If x and y are two vectors containing the x and y data to be fitted to a n-degree polynomial, then we get the polynomial fitting the data by writing −
p = polyfit(x,y,n)
Create a script file and type the following code −
x = [1 2 3 4 5 6]; y = [5.5 43.1 128 290.7 498.4 978.67];   %data
p = polyfit(x,y,4)   %get the polynomial

% Compute the values of the polyfit estimate over a finer range, 
% and plot the estimate over the real data values for comparison:
x2 = 1:.1:6;          
y2 = polyval(p,x2);
plot(x,y,'o',x2,y2)
grid on
When you run the file, MATLAB displays the following result −
p =
   4.1056  -47.9607  222.2598 -362.7453  191.1250

And plots the following graph −

    30 Lectures 
     4 hours 

 Nouman Azam

    127 Lectures 
     12 hours 

 Nouman Azam

    17 Lectures 
     3 hours 

 Sanjeev

    37 Lectures 
     5 hours 

 TELCOMA Global

    22 Lectures 
     4 hours 

 TELCOMA Global

    18 Lectures 
     3 hours 

 Phinite Academy
 Print
 Add Notes
 Bookmark this page
HTML contenteditable Attribute

The contenteditable attribute in HTML is used to set whether the content is editable or not using boolean values true or false. This attribute can be used with any element since it is a Global Attribute.
Following is the syntax −
<element contenteditable =”true|false”>
Above, set true if you want the element to be editable, else false. 
Let us now see an example to implement the contenteditable attribute in HTML −
 Live Demo
<!DOCTYPE html>
<html>
<body>
   <h2 contenteditable="true">Demo Heading</h2>
   <p contenteditable="true">This is a demo line.</p>
</body>
</html>
This will produce the following output. Displaying the heading and p elements are now editable −
Now, we can edit the heading and content. Therefore, let us change the heading and display the screenshot −
In the above example, we have set a heading and some text −
<h2 contenteditable="true">Demo Heading</h2>
<p contenteditable="true">This is a demo line.</p>
We have made the heading and the content as editable using the contenteditable property. On setting it true, you will be able to edit it on the web page itself −
h2 contenteditable="true"
How to Insert Rows with NULL Values in SQL? - GeeksforGeeks

09 Nov, 2021
In SQL, due to lack of data, we sometimes need to insert rows with NULL values in the tables. Here, the keyword NULL(without quotes) is used to represent no data. There are some key points of Null value: 
NULL value is different from a zero value.
A NULL value is used to represent a missing value, but that it usually has one of three different interpretations:The value unknown (value exists but is not known)Value not available (exists but is purposely withheld)Attribute not applicable (undefined for this tuple)
The value unknown (value exists but is not known)
Value not available (exists but is purposely withheld)
Attribute not applicable (undefined for this tuple)
It is often not possible to determine which of the meanings is intended. Hence, SQL does not distinguish between the different meanings of NULL.
Syntax:
INSERT INTO TABLE_NAME values
(COLUMN_VALUE,NULL,........);
Step 1: Create a Database. For this use the below command to create a database named GeeksForGeeks.
Query:
CREATE DATABASE GeeksForGeeks
Output:
Step 2: Use the GeeksForGeeks database. For this use the below command.
Query:
USE GeeksForGeeks
Output:
Step 3: Create a table WORKER inside the database GeeksForGeeks. This table has 4 columns namely STUDENT_ID, STUDENT_NAME,  STUDENT_STANDARD, ENGLISH, MATHS, and PHYSICS containing student id, student name, standard, and marks of various subjects.
Query:
CREATE TABLE WORKER(
W_NAME VARCHAR(20),
CITY VARCHAR(20),
AGE INT);
Output:
Step 4: Display the structure of the WORKER table.
Query:
EXEC SP_COLUMNS 'WORKER';
Output:
Step 5: Insert 10 rows into the WORKER table.
Query:
INSERT INTO WORKER VALUES('SAM','ONTARIO',NULL);
INSERT INTO WORKER VALUES('TIM',NULL,56);
INSERT INTO WORKER VALUES(NULL,'CAIRO',43);
INSERT INTO WORKER VALUES(NULL,'MUMBAI',NULL);
INSERT INTO WORKER VALUES(NULL,NULL,NULL);
Output:
Step 6: Display all the rows of the WORKER table including the 0(zero) values.
Query:
SELECT * FROM WORKER;
Output:
Thus, in this way, we can insert NULL values into a table.
Picked
SQL-Query
SQL-Server
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Update Multiple Columns in Single Update Statement in SQL?
What is Temporary Table in SQL?
SQL Query to Find the Name of a Person Whose Name Starts with Specific Letter
SQL using Python
SQL | Subquery
How to Write a SQL Query For a Specific Date Range and Date Time?
SQL Query to Convert VARCHAR to INT
SQL Query to Delete Duplicate Rows
SQL indexes
SQL Query to Compare Two Dates
How to precompile a COBOL-DB2 program?

Precompilation is the process through which the SQL statements used in the COBOL-DB2 program are replaced by appropriate COBOL calls. The precompilation is necessary before the actual compilation because the COBOL compiler cannot recognize the DB2 SQL statements and will throw errors due to them.
DB2 utility DSNHPC is used for the precompilation. The inputs to the precompilation JCL step are DCLGEN (in SYSLIB) for the respective tables which are used in COBOL-DB2 program and COBOL-DB2 source program (in SYSIN).
//STEP010 EXEC PGM=IKJEFT01
//SYSIN DD DSN=DIS.TEST.COBOL(PSNEW2),DISP=SHR
//SYSLIB DD DSN=DIS.TEST.DCLGEN(PSDC2), DISP=SHR
//DBRMLIB DD DSN=DIS.TEST.DBRMLIB(PSNEW2),DISP=SHR
//SYSCIN DD DSN=DIS.TEST.COBL(PSCOB2), DISP=(NEW,CATLG,DEL), SPACE=(20, (90,90))
//SYSOUT DD SYSOUT=*
Once we execute this JCL step we will receive below two main elements −
DBRM is received in DBRMLIB that contains all the SQL statements which were present in the program. The DBRM is further used in the BIND step to obtain a PLAN or a PACKAGE.
DBRM is received in DBRMLIB that contains all the SQL statements which were present in the program. The DBRM is further used in the BIND step to obtain a PLAN or a PACKAGE.
The modified COBOL source program is received in SYSCIN that has all the SQL statements replaced by COBOL calls. This modified source is further compiled and link edited.
The modified COBOL source program is received in SYSCIN that has all the SQL statements replaced by COBOL calls. This modified source is further compiled and link edited.
Convert list of string to list of list in Python

In this article we will see how to create a list of lists which contain string data types. The inner list themselves or of string data type and they may contain numeric or strings as their elements.
We use these two methods which will first separate out the lists and then convert each element of the list to a string.
 Live Demo
list1 = [ '[0, 1, 2, 3]','["Mon", "Tue", "Wed", "Thu"]' ]
print ("The given list is : \n" + str(list1))
print("\n")
# using strip() + split()
result = [k.strip("[]").split(", ") for k in list1]
print ("Converting list of string to list of list : \n" + str(result))
Running the above code gives us the following result −
The given list is :
['[0, 1, 2, 3]', '["Mon", "Tue", "Wed", "Thu"]']
Converting list of string to list of list :
[['0', '1', '2', '3'], ['"Mon"', '"Tue"', '"Wed"', '"Thu"']]
In this approach, we will use string slicing and then split the string to get the list of lists. Here the split function is applied along with a for loop.
 Live Demo
list1 = [ '[0, 1, 2, 3]','["Mon", "Tue", "Wed", "Thu"]' ]
print ("The given list is : \n" + str(list1))
print("\n")
# using split()
result = [i[1 : -1].split(', ') for i in list1]
print ("Converting list of string to list of list : \n" + str(result))
Running the above code gives us the following result −
The given list is :
['[0, 1, 2, 3]', '["Mon", "Tue", "Wed", "Thu"]']
Converting list of string to list of list :
[['0', '1', '2', '3'], ['"Mon"', '"Tue"', '"Wed"', '"Thu"']]
C# | Math Class - GeeksforGeeks

05 Mar, 2021
In C#, Math class comes under the System namespace. It is used to provide static methods and constants for logarithmic, trigonometric, and other useful mathematical functions. It is a static class and inherits the object class.
public static class Math
A field is a variable that is declared in a class or struct. These are considered as the members of their containing type. Fields may be static or instance fields. Math class contains the two fields i.e. E and PI.
Math.E Field: This field represents the natural logarithmic base, specified by the constant, e.Math.PI Field: It represents the ratio of the circumference of a circle to its diameter, specified by the constant, PI(π).
Math.E Field: This field represents the natural logarithmic base, specified by the constant, e.
Math.PI Field: It represents the ratio of the circumference of a circle to its diameter, specified by the constant, PI(π).
Example:
// C# program to demonstrate the// value of Math Class Fieldsusing System;  class GFG {      // Main method    static void Main()    {          // To find E constant values        double e = Math.E;          // Print result        Console.WriteLine("Math.E = " + e);          // To find PI constant values        double pi_value = Math.PI;          // Print result        Console.WriteLine("Math.PI = " + pi_value);    }}
Output:
Math.E = 2.71828182845905
Math.PI = 3.14159265358979

You can read more about fields from C# | Math Class Fields with Examples.
Example:
// C# program to illustrate the// Math class methodsusing System;  public class GFG {      // Main method    static public void Main()    {          // using Floor() Method        Console.WriteLine("Floor value of 123.123: "                             + Math.Floor(123.123));          // using Asin() Method        Console.WriteLine("Asin value of 0.35: "                             + Math.Asin(0.35));          // using Sqrt() Method        Console.WriteLine("Square Root of 81: "                              + Math.Sqrt(81));          // using Round() Method        Console.WriteLine("Round value of 14.6534: "                             + Math.Round(14.6534));    }}
Output:
Floor value of 123.123: 123
Asin value of 0.35: 0.35757110364551
Square Root of 81: 9
Round value of 14.6534: 15

CSharp-Math
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
C# Dictionary with examples
C# | Method Overriding
C# | Class and Object
C# | Constructors
C# | String.IndexOf( ) Method | Set - 1
Extension Method in C#
C# | Delegates
Introduction to .NET Framework
C# | Data Types
Difference between Ref and Out keywords in C#
Python calendar module | itermonthdates() method

12 May, 2021
Calendar module allows to output calendars like program, and provides additional useful functions related to the calendar. Functions and classes defined in Calendar module use an idealized calendar, the current Gregorian calendar extended indefinitely in both directions. itermonthdates() method returns an iterator for the month (1–12) in the year. This iterator will return all days for the month and all days before the start of the month or after end of the month that are required to get a complete week. 
Syntax: itermonthdates(year, month)

Parameter: 
year: year of the calendar
month: month of the calendar

Returns: an iterator for the month.
Code #1:  
Python3
# Python program to demonstrate working# of itermonthdates() method # importing calendar modulefrom calendar import Calendar obj = calendar.Calendar() # iterating with itermonthdatesfor day in obj.itermonthdates(2018, 9):    print(day)
Output:  
2018-08-27
2018-08-28
2018-08-29
2018-08-30
2018-08-31
.
.
.
2018-09-26
2018-09-27
2018-09-28
2018-09-29
2018-09-30
  Code #2:  
Python3
# Python program to demonstrate working# of itermonthdates() method # importing calendar moduleimport calendar # use with firstweekday = 5obj = calendar.Calendar(firstweekday = 5) # iterating with itermonthdatesfor day in obj.itermonthdates(2018, 4):    print(day)
Output:  
2018-08-30
2018-08-31
2018-09-01
2018-09-02
2018-09-03
.
.
2018-09-30
2018-10-01
2018-10-02
2018-10-03
2018-09-01
2018-09-02
2018-09-03
.
.
2018-09-28
.
.
0018-03-31
0018-04-01
0018-04-02
.
.
2018-04-28
2018-04-29
2018-04-30
2018-05-01
2018-05-02
 
anikakapoor
Python Calander-module
python-modules
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
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
Iterate over a list in Python
Python Classes and Objects
Convert integer to string in Python
Numpy | String Operations - GeeksforGeeks

19 Apr, 2020
This module is used to perform vectorized string operations for arrays of dtype numpy.string_ or numpy.unicode_. All of them are based on the standard string functions in Python’s built-in library.
String Operations –numpy.lower() : This function returns the lowercase string from the given string. It converts all uppercase characters to lowercase. If no uppercase characters exist, it returns the original string.
Output :
['geeks' 'for']
geeks

 numpy.split() : This function returns a list of strings after breaking the given string by the specified separator.
Output :
['geeks', 'for', 'geeks']
['geeks', 'for', 'geeks']

 numpy.join() : This function is a string method and returns a string in which the elements of sequence have been joined by str separator.
Output :
g-e-e-k-s
['g-e-e-k-s', 'g:e:e:k:s']

 
String Information –numpy.count() : This function returns the number of occurrences of a substring in the given string.
Output :
[1, 0, 1]
[0, 1, 0]

 numpy.rfind() : This function returns the highest index of the substring if found in given string. If not found then it returns -1.
Output :
[0, -1, 0]
[-1, 0, -1]

 numpy.isnumeric() : This function returns “True” if all characters in the string are numeric characters, Otherwise, It returns “False”.
Output :
False
False

 
String Comparison –numpy.equal(): This function checks for string1 == string2 elementwise.
Output :
False

 numpy.not_equal(): This function checks whether two string is unequal or not.
Output :
True

 numpy.greater(): This function checks whether string1 is greater than string2 or not.
Output :
True

 
Writing code in comment? Please use ide.geeksforgeeks.org, generate link and share the link here.
Python Program for Breadth First Search or BFS for a Graph
Best Time to Buy and Sell Stock
Must Do Coding Questions for Product Based Companies
How to calculate MOVING AVERAGE in a Pandas DataFrame?
Session vs Token Based Authentication
Difference Between Default VLAN and Native VLAN
How to insert a pandas DataFrame to an existing PostgreSQL table?
What is "network ID" and "host ID" in IP Addresses?
Create a dictionary with list comprehension in Python
What is Transmission Control Protocol (TCP)?
PyQt5 - setCheckState() method for Check Box - GeeksforGeeks

22 Apr, 2020
When we create a check box it has only two states that are checked and un-checked, although we can add an intermediate state using setTristate method. We can set check box to be checked or un-checked using setChecked but with this method we are unable to set check box to intermediate state.
setCheckState method is used to set the state of the check box it can be checked or un-checked even it can set intermediate state, it takes CheckState object as argument.
Syntax : checkbox.setCheckState(1)
Argument : It takes CheckState object as argument.
Action performed:If we pass 0 to it, it set un-checked state to check boxIf we pass 1 to it, it set intermediate state to check boxIf we pass any other integer to it, it set checked state to check box
Below is the implementation.
# importing librariesfrom PyQt5.QtWidgets import * from PyQt5 import QtCore, QtGuifrom PyQt5.QtGui import * from PyQt5.QtCore import * import sys    class Window(QMainWindow):      def __init__(self):        super().__init__()          # setting title        self.setWindowTitle("Python ")          # setting geometry        self.setGeometry(100, 100, 600, 400)          # calling method        self.UiComponents()          # showing all the widgets        self.show()      # method for widgets    def UiComponents(self):          # creating the check-box        checkbox = QCheckBox('Geek ?', self)          # setting geometry of check box        checkbox.setGeometry(200, 150, 100, 40)          # making check box as tristate        checkbox.setTristate(True)          # setting check box state        checkbox.setCheckState(1)    # 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.
Comments
Old Comments
Box Plot in Python using Matplotlib
Python | Get dictionary keys as a list
Bar Plot in Matplotlib
Multithreading in Python | Set 2 (Synchronization)
Python Dictionary keys() method
loops in python
Python - Call function from another file
Ways to filter Pandas DataFrame by column values
Python | Convert set into a list
Python program to find number of days between two given dates
Sum of Two or Multiple DataFrame Columns in R - GeeksforGeeks

23 Sep, 2021
In this article, we will discuss how to perform some of two and multiple dataframes columns in R programming language.
Database in use:
The columns whose sum has to be calculated can be called through the $ operator and then we can perform the sum of two dataframe columns by using “+” operator.
Syntax:
dataframe$column1 + dataframe$column2
where
dataframe is the input dataframe
column1 is one column in the dataframe
column2 is another column in the dataframe
Example: R program to add two columns in dataframe
R
# create a dataframe with subjects marksdata=data.frame(sub1=c(90,89,78,89),                sub2=c(100,90,86,84),                sub3=c(89,90,98,99),                sub4=c(86,78,87,99))  # add column1 and column2print(data$sub1 + data$sub2)  # add column1 and column3print(data$sub1 + data$sub3)  # add column1 and column4print(data$sub1 + data$sub4)  # add column2 and column4print(data$sub2 + data$sub4)
Output:
[1] 190 179 164 173
[1] 179 179 176 188
[1] 176 167 165 188
[1] 186 168 173 183
We can calculate the sum of multiple columns by using rowSums() and c() Function. we simply have to pass the name of the columns.
Syntax:
rowSums(dataframe[ , c(“column1”, “column2”, “column n”)])
where
dataframe is the input dataframe
c() represents the number of columns to be specified to add
Example: R program to add multiple columns
Python3
# create a dataframe with subjects marksdata = data.frame(sub1=c(90, 89, 78, 89),                   sub2=c(100, 90, 86, 84),                   sub3=c(89, 90, 98, 99),                  sub4=c(86, 78, 87, 99))  # add column1, column2 and column 4print(rowSums(data[, c("sub1", "sub2", "sub4")]))  # add column1, column2 and column 3print(rowSums(data[, c("sub1", "sub2", "sub3")]))  # add column4, column2 and column 3print(rowSums(data[, c("sub4", "sub2", "sub3")]))
Output:
[1] 276 257 251 272
[1] 279 269 262 272
[1] 275 258 271 282
Picked
R DataFrame-Programs
R-DataFrame
R Language
R Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Change Color of Bars in Barchart using ggplot2 in R
How to Change Axis Scales in R Plots?
Group by function in R using Dplyr
How to Split Column Into Multiple Columns in R DataFrame?
How to filter R DataFrame by values in a column?
How to filter R dataframe by multiple conditions?
Count Unique Values in R
How to Split Column Into Multiple Columns in R DataFrame?
Count Number of Characters in String in R
Drop column(s) by name from a given DataFrame in R
How do I get the background color of a Tkinter Canvas widget?

Tkinter canvas widget is used for many different purposes such as adding objects, drawing shapes, images and complex visuals to a graphical interface in an application. We can also configure its style such as background color, foreground color, and other properties using the configure properties or passing attributes.
Suppose we want to inherit the background color of the Canvas widget in another widget or in some part of the application. This can be achieved by using my_canvas["background"] property. Further, we can use canvas["background"] to fetch the background color of the canvas widget.
# Import the required library
from tkinter import *
from tkinter import ttk

# Create an instance of tkinter frame
win = Tk()
win.geometry("700x350")

# Add a Canvas widget
canvas = Canvas(win, background= "white")

# Draw a rectangle in Canvas and inherit the background color of Canvas
canvas.create_rectangle(50,50,350,190, outline="black", fill= canvas["background"])
canvas.pack()
win.mainloop()
Executing the above code will display a window with a rectangle having the same background color as the canvas.
How do I convert a char to an int in C and C++?

In C language, there are three methods to convert a char type variable to an int. These are given as follows −
sscanf()
atoi()
Typecasting
Here is an example of converting char to int in C language,
 Live Demo
#include<stdio.h>
#include<stdlib.h>
int main() {
   const char *str = "12345";
   char c = 's';
   int x, y, z;

   sscanf(str, "%d", &x); // Using sscanf
   printf("\nThe value of x : %d", x);

   y = atoi(str); // Using atoi()
   printf("\nThe value of y : %d", y);

   z = (int)(c); // Using typecasting
   printf("\nThe value of z : %d", z);

   return 0;
}
Here is the output:
The value of x : 12345
The value of y : 12345
The value of z : 115
In C++ language, there are two following methods to convert a char type variable into an int −
stoi()
Typecasting
Here is an example of converting char to int in C++ language,
 Live Demo
#include <iostream>
#include <string>
using namespace std;
int main() {
   char s1[] = "45";
   char c = 's';

   int x = stoi(s1);
   cout << "The value of x : " << x;

   int y = (int)(c);
   cout << "\nThe value of y : " << y;

   return 0;
}
Here is the output
The value of x : 45
The value of y : 115
Converting a string to a date in JavaScript

The best format to represent a date is yyyy-mm-dd as this causes no
confusion and is pretty straight forward. In order to parse dates from
this string format to Date objects in JS, all you need to do is pass this
string to the Date constructor. For example,
let a = '2019-08-10';
console.log(new Date(a))
This will give the output −
Sat Aug 10 2019 05:30:00 GMT+0530 (India Standard Time)
Note that the new date is created at 0000 hrs UTC.
If you need to parse any other date formats, you can check out https://developer.mozilla.org as it provides details about using different formats to parse dates.
XPath - Wildcard

XPath defines the following wildcards on nodes to be used with the XPath expressions.
*
used to match any node.
.
used to match the current node in context.
@*
used to match any attribute
node()
used to match node of any type
This example creates a table of <student> element with their details, by iterating over each student.
<?xml version = "1.0"?>
<?xml-stylesheet type = "text/xsl" href = "students.xsl"?>
<class>
   <student rollno = "393">
      <firstname>Dinkar</firstname>
      <lastname>Kad</lastname>
      <nickname>Dinkar</nickname>
      <marks>85</marks>
   </student>
   <student rollno = "493">
      <firstname>Vaneet</firstname>
      <lastname>Gupta</lastname>
      <nickname>Vinni</nickname>
      <marks>95</marks>
   </student>
   <student rollno = "593">
      <firstname>Jasvir</firstname>
      <lastname>Singh</lastname>
      <nickname>Jazz</nickname>
      <marks>90</marks>
   </student>
</class>
<?xml version = "1.0" encoding = "UTF-8"?>
<xsl:stylesheet version = "1.0"
   xmlns:xsl = "http://www.w3.org/1999/XSL/Transform">
	
   <xsl:template match = "/">
      <html>
         <body>
            <h2>Students</h2>
            <xsl:apply-templates select = "class/*" />
         </body>
      </html>
   </xsl:template>

   <xsl:template match = "class/*">
      <xsl:apply-templates select = "@rollno" />
      <xsl:apply-templates select = "firstname" />
      <xsl:apply-templates select = "lastname" />
      <xsl:apply-templates select = "nickname" />
      <xsl:apply-templates select = "marks" />
      <br />
   </xsl:template>

   <xsl:template match = "@rollno">
      <span style = "font-size = 22px;">
         <xsl:value-of select = "." />
      </span>
      <br />
   </xsl:template>

   <xsl:template match = "firstname">
      First Name:<span style = "color:blue;">
         <xsl:value-of select = "." />
      </span>
      <br />
   </xsl:template>

   <xsl:template match = "lastname">
      Last Name:<span style = "color:green;">
         <xsl:value-of select = "." />
      </span>
      <br />
   </xsl:template>

   <xsl:template match = "nickname">
      Nick Name:<span style = "color:red;">
         <xsl:value-of select = "." />
      </span>
      <br />
   </xsl:template>

   <xsl:template match = "marks">
      Marks:<span style = "color:gray;">
         <xsl:value-of select = "." />
      </span>
      <br />
   </xsl:template>

</xsl:stylesheet>

    90 Lectures 
     20 hours 

 Arun Motoori

    23 Lectures 
     8 hours 

 Sanjay Kumar

    13 Lectures 
     1.5 hours 

 Sanjay Kumar

    24 Lectures 
     1.5 hours 

 Sanjay Kumar

    47 Lectures 
     3 hours 

 Krishna Sakinala
 Print
 Add Notes
 Bookmark this page
How to rotate tick labels in a subplot in Matplotlib?

To rotate tick labels in a subplot, we can use set_xticklabels() or set_yticklabels() with rotation argument in the method.
Create a list of numbers (x) that can be used to tick the axes.
Create a list of numbers (x) that can be used to tick the axes.
Get the axis using subplot() that helps to add a subplot to the current figure.
Get the axis using subplot() that helps to add a subplot to the current figure.
Set ticks on the X and Y axes using set_xticks and set_yticks methods, respectively, and the list x (from step 1).
Set ticks on the X and Y axes using set_xticks and set_yticks methods, respectively, and the list x (from step 1).
Set tick labels with label lists (["one", "two", "three", "four"]) and rotation=45 using set_xticklabels() and set_yticklabels().
Set tick labels with label lists (["one", "two", "three", "four"]) and rotation=45 using set_xticklabels() and set_yticklabels().
To add space between axes and tick labels, we can use tick_params() method with pad argument that helps to add space. The argument direction(in) helps to put the ticks inside the axes. And, apply axis(both) parameters on both the axes.
To add space between axes and tick labels, we can use tick_params() method with pad argument that helps to add space. The argument direction(in) helps to put the ticks inside the axes. And, apply axis(both) parameters on both the axes.
To show the figure, use plt.show() method.
To show the figure, use plt.show() method.
import matplotlib.pyplot as plt
plt.rcParams["figure.figsize"] = [7.00, 3.50]
plt.rcParams["figure.autolayout"] = True
x = [1, 2, 3, 4]
ax1 = plt.subplot()
ax1.set_xticks(x)
ax1.set_yticks(x)
ax1.set_xticklabels(["one", "two", "three", "four"], rotation=45)
ax1.set_yticklabels(["one", "two", "three", "four"], rotation=45)
ax1.tick_params(axis="both", direction="in", pad=15)
plt.show()
How to add PDF in Tkinter GUI Python ? - GeeksforGeeks

13 Jan, 2021
In this article, We are going to see how to add a PDF file Tkinter GUI, For that, we don’t have a direct widget to do this. For that, We need to have python version 2.7 or more. And you need to install the ‘tkPDFViewer‘ library. This library allows you to embed the PDF file in your Tkinter GUI.
Installation:
To install this library you just have to type:
pip install tkPDFViewer
Initialize tk and geometry of our GUI.
Import tkPDFViewer.
Make the object of Class ShowPdf() from tkPDFViewer.
Using pdf_view method from ShowPdf() to place our pdf.
Pack the pdf_view in GUI.
Below is the implementation:
We are using this pdf for demonstration:
Code:
Python
# Importing tkinter to make gui in pythonfrom tkinter import*  # Importing tkPDFViewer to place pdf file in gui.# In tkPDFViewer library there is# an tkPDFViewer module. That I have imported as pdffrom tkPDFViewer import tkPDFViewer as pdf  # Initializing tkroot = Tk()  # Set the width and height of our root window.root.geometry("550x750")  # creating object of ShowPdf from tkPDFViewer.v1 = pdf.ShowPdf()  # Adding pdf location and width and height.v2 = v1.pdf_view(root,                 pdf_location = r"location",                  width = 50, height = 100)  # Placing Pdf in my gui.v2.pack()root.mainloop()
Output:
Python Tkinter-exercises
Python-tkinter
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Install PIP on Windows ?
How to drop one or multiple columns in Pandas Dataframe
Selecting rows in pandas DataFrame based on conditions
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | os.path.join() method
Python | Get unique values from a list
Defaultdict in Python
Create a directory in Python
Python | Pandas dataframe.groupby()
Java program to Print Odd and Even Number from an Array

In the loop check, the result of I %2 operation on each element, if 0 the element is even else the element is odd.
Live Demo
public class OddNumbersInAnArray {
   public static void main(String args[]){
      int[] myArray = {23, 93, 56, 92, 39};
      System.out.println("Even numbers in the given array are:: ");

      for (int i=0; i<myArray.length; i++){
         if(myArray[i]%2 == 0){
            System.out.println(myArray[i]);
         }
      }
      System.out.println("Odd numbers in the given array are:: ");

      for (int i=0; i<myArray.length; i++){
         if(myArray[i]%2 != 0){
            System.out.println(myArray[i]);
         }
      }
   }
}
Even numbers in the given array are::
56
92
Odd numbers in the given array are::
23
93
39
What is the use of ‘new’ keyword in C#?

Use the new keyword to create an instance of the array −
int [] a = new int[5];
The new operator is used to create an object or instantiate an object. Here in the example, an object is created for the class using the new −
 Live Demo
using System;

namespace CalculatorApplication {
   class NumberManipulator {
      public void swap(int x, int y) {
         int temp;

         temp = x; /* save the value of x */
         x = y; /* put y into x */
         y = temp; /* put temp into y */
      }
      static void Main(string[] args) {
         NumberManipulator n = new NumberManipulator();

         /* local variable definition */
         int a = 100;
         int b = 200;
         Console.WriteLine("Before swap, value of a : {0}", a);
         Console.WriteLine("Before swap, value of b : {0}", b);
         /* calling a function to swap the values */
         n.swap(a, b);
         Console.WriteLine("After swap, value of a : {0}", a);
         Console.WriteLine("After swap, value of b : {0}", b);
         Console.ReadLine();
      }
   }
}
Before swap, value of a : 100
Before swap, value of b : 200
After swap, value of a : 100
After swap, value of b : 200
HTML - <article> Tag

The HTML <article> tag is used in a blog post, forum post, newspaper article etc. It specifies self-contained composition in a site, document, page or application.
<!DOCTYPE html>
<html>

   <head>
      <title>HTML Article Tag</title>
   </head>

   <body>
      <article>
         <h2>PHP</h2> 
         <p>PHP is PHP Hypertext Preprocessor</p>
      </article>
   </body>

</html>
This will produce the following result −
PHP is PHP Hypertext Preprocessor
This tag supports all the global attributes described in HTML Attribute Reference
This tag supports all the event attributes described in HTML Events Reference

    19 Lectures 
     2 hours 

 Anadi Sharma

    16 Lectures 
     1.5 hours 

 Anadi Sharma

    18 Lectures 
     1.5 hours 

 Frahaan Hussain

    57 Lectures 
     5.5 hours 

 DigiFisk (Programming Is Fun)

    54 Lectures 
     6 hours 

 DigiFisk (Programming Is Fun)

    45 Lectures 
     5.5 hours 

 DigiFisk (Programming Is Fun)
 Print
 Add Notes
 Bookmark this page
HTML | DOM Style backgroundColor Property - GeeksforGeeks

10 Jan, 2022
The backgroundColor property in HTML DOM is used to set or return the background-color of an element.Syntax: 
object.style.backgroundColor
It returns the background color of an element.
object.style.backgroundColor = "color|transparent|initial|
inherit"
It is used to set the background color of an element.
Parameter: There are four parameter accepted by backgroundColot property  
color: This property holds the background color.
transparent: Bydefault the background color is transparent.
initial: Set this property to it’s default
inherit: Inherits the property from it’s parent element
Return Values: It returns a string value, which representing the background color.
Example 1:  
html
<!DOCTYPE html><html> <head>    <title>      Style backgroundColor Property    </title>    <script>        /* script to set background color */        function geeks() {            document.body.style.backgroundColor =                                "lightgreen";        }    </script></head> <body style="text-align:center">     <h1 style="color:green;">            GeeksForGeeks        </h1>     <h2>            Style backgroundColor Property        </h2>     <button type="button" onclick="geeks()">      Submit    </button></body></html     
Output: 
Before: 
After: 
Example 2:  
html
<!DOCTYPE html><html> <head>    <title>        Style backgroundColor Property    </title>    <style>        #geeks {            width: 250px;            height: 100px;            background-color: coral;        }    </style></head> <body>    <center>        <h1 style="color:green;">            GeeksForGeeks        </h1>         <h2>            DOM Style backgroundColor Property        </h2>         <button onclick="geeks()">Submitt</button>         <div id="geeks">            <h1>GeeksForGeeks</h1>        </div>         <script>            function geeks() {                document.getElementById("geeks").style.backgroundColor =                                                          "lightgreen";            }        </script>    </center></body> </html>    
Output: 
Before: 
After: 
Supported Browsers: The browser supported by DOM style backgroundColor Property are listed below:  
Chrome 1.0
Internet Explorer4.0
Firefox 1.0
Safari 1.0
Opera 3.5 
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
Akanksha_Rai
ManasChhabra2
varshagumber28
HTML-DOM
HTML
Misc
Misc
Misc
HTML
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 set the default value for an HTML <select> element ?
Hide or show elements in HTML using display property
Top 10 algorithms in Interview Questions
vector::push_back() and vector::pop_back() in C++ STL
Overview of Data Structures | Set 1 (Linear Data Structures)
How to write Regular Expressions?
How to calculate absolute value in Python?

The abs() function of Python's standard library returns the absolute value of the given number. Absolute value of a number is the value without considering its sign. Hence absolute of 10 is 10, -10 is also 10. If the number is a complex number, abs() returns its magnitude.
>>> abs(11.11)
11.11
>>> abs(-11.11)
11.11
>>> abs(2+3j)
3.605551275463989
>>> abs(3-6j)
6.708203932499369
>>> abs(3-4j)
5.0
Stack clear() method in Java with Example

24 Dec, 2018
The Java.util.Stack.clear() method is used to remove all the elements from a Stack. Using the clear() method only clears all the element from the Stack and does not delete the Stack. In other words, we can say that the clear() method is used to only empty an existing Stack.
Syntax:
Stack.clear()
Parameters: The method does not take any parameter
Return Value: The function does not returns any value.
Below programs illustrate the Java.util.Stack.clear() method.
Example 1:
// Java code to illustrate clear()import java.util.*;  public class GFG {    public static void main(String args[])    {        // Creating an empty Stack        Stack<String> stack = new Stack<String>();          // Use add() method to add elements into the Stack        stack.add("Welcome");        stack.add("To");        stack.add("Geeks");        stack.add("4");        stack.add("Geeks");          // Displaying the Stack        System.out.println("Stack: " + stack);          // Clearing the Stack using clear() method        stack.clear();          // Displaying the final Stack after clearing;        System.out.println("The final Stack: " + stack);    }}
Stack: [Welcome, To, Geeks, 4, Geeks]
The final Stack: []

Example 2:
// Java code to illustrate clear()import java.util.*;  public class GFG {    public static void main(String args[])    {        // Creating an empty Stack        Stack<Integer> stack = new Stack<Integer>();          // Use add() method to add elements into the Queue        stack.add(10);        stack.add(15);        stack.add(30);        stack.add(20);        stack.add(5);          // Displaying the Stack        System.out.println("Stack: " + stack);          // Clearing the Stack using clear() method        stack.clear();          // Displaying the final Stack after clearing;        System.out.println("The final Stack: " + stack);    }}
Stack: [10, 15, 30, 20, 5]
The final Stack: []

Java - util package
Java-Collections
Java-Functions
Java-Stack
Java
Java
Java-Collections
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to add space between two widgets placed in a grid in tkinter?

Let us assume that we are creating a tkinter application where two or more widgets are placed using a grid property. We have to add some space between the widgets in order to style their appearance. To provide space in the widgets, we can use padding property, as padding adds space to the outermost part of the widget. In order to add padding, assign the values to padx and pady.
#Import the required library
from tkinter import *
#create an instance of tkinter frame
win= Tk()
win.geometry("750x250")
#Create some Button widgets
Label(win, text= "New Line Text", font= ('Helvetica 20 bold')).grid(row=0, column=5, padx= 25, pady= 25)
Button(win, text= "Button 1").grid(row=0, column=1, padx= 50, pady= 80)
Button(win, text= "Button 2").grid(row=0, column=2, padx= 25, pady =36)
win.mainloop()
Add column names to dataframe in Pandas - GeeksforGeeks

01 Aug, 2020
Let us how to add names to DataFrame columns in Pandas.
Creating the DataFrame :
# importing the pandas libraryimport pandas as pd  # creating listsl1 =["Amar", "Barsha", "Carlos", "Tanmay", "Misbah"]l2 =["Alpha", "Bravo", "Charlie", "Tango", "Mike"]l3 =[23, 25, 22, 27, 29]l4 =[69, 54, 73, 70, 74]  # creating the DataFrameteam = pd.DataFrame(list(zip(l1, l2, l3, l4)))   # displaying the DataFrameprint(team)
Output :
Here we can see that the columns in the DataFrame are unnamed.
Adding column name to the DataFrame : We can add columns to an existing DataFrame using its columns attribute.
# adding column name to the respective columnsteam.columns =['Name', 'Code', 'Age', 'Weight']  # displaying the DataFrameprint(team)
 Output :
Now the DataFrame has column names.
Renaming column name of a DataFrame : We can rename the columns of a DataFrame by using the rename() function.
# reanming the DataFrame columnsteam.rename(columns = {'Code':'Code-Name',                        'Weight':'Weight in kgs'},             inplace = True)  # displaying the DataFrameprint(team)
Output :
We can see the names of the columns have been changed.
Python pandas-dataFrame
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Create a Pandas DataFrame from Lists
Box Plot in Python using Matplotlib
Python | Get dictionary keys as a list
Enumerate() in Python
Python Dictionary
Bar Plot in Matplotlib
Multithreading in Python | Set 2 (Synchronization)
Python Dictionary keys() method
loops in python
Python - Call function from another file
Longest Arithmetic Sequence in C++

Suppose we have an array A of integers, we have to return the length of the longest arithmetic subsequence in A. As you know that a subsequence of A is a list A[i_1], A[i_2], ..., A[i_k] with 0 <= i_1 < i_2 < ... < i_k <= A.length - 1, and that a sequence B is arithmetic when B[i+1] - B[i] are all the same value (for 0 <= i < B.length - 1). So if the input is like [9,4,7,2,10], then the output will be 3. As the longest subsequence is [4,7,10].
To solve this, we will follow these steps −
Make a map dp, n := size of A, set ret := 2
Make a map dp, n := size of A, set ret := 2
for i in range 0 to n – 1for j in range 0 to i – 1diff := A[j] – A[i]dp[i, diff] := 1 + dp[j, diff]ret := max of 1 + dp[i, diff] and ret
for i in range 0 to n – 1
for j in range 0 to i – 1diff := A[j] – A[i]dp[i, diff] := 1 + dp[j, diff]ret := max of 1 + dp[i, diff] and ret
for j in range 0 to i – 1
diff := A[j] – A[i]
diff := A[j] – A[i]
dp[i, diff] := 1 + dp[j, diff]
dp[i, diff] := 1 + dp[j, diff]
ret := max of 1 + dp[i, diff] and ret
ret := max of 1 + dp[i, diff] and ret
return ret
return ret
Let us see the following implementation to get better understanding −
 Live Demo
#include <bits/stdc++.h>
using namespace std;
class Solution {
   public:
   int longestArithSeqLength(vector<int>& A) {
      unordered_map <int, unordered_map <int, int> > dp;
      int n = A.size();
      int ret = 2;
      for(int i = 0; i < n; i++){
         for(int j = 0; j < i; j++){
            int diff = A[j] - A[i];
            dp[i][diff] = 1 + dp[j][diff];
            ret = max(1 + dp[i][diff], ret);
         }
      }
      return ret;
   }
};
main(){
   vector<int> v1 = {9,4,7,2,10};
   Solution ob;
   cout << (ob.longestArithSeqLength(v1));
}
[9,4,7,2,10]
3
How to append list to second list (concatenate lists) in Python?

This can be done in different ways −
l1=[1,2,3]
l2=[2,3,4]
l3=l1+l2
print ('new list', l3)
This will print
new list [1, 2, 3, 2, 3, 4]
l1=[1,2,3]
l1=[3,4,5]
l1.append(l2)
print ('appended list', l1)
Here’s the result
appended list [3, 4, 5, [2, 3, 4]]
l1=[1,2,3]
l1=[3,4,5]
l1.extend(l2)
print ('extended list', l1)
The output is as follows −
extended list [1, 2, 3, 3, 4, 5]
First concatenate list, then use set() function to eliminate duplicates and then use list() function to convert set to list
l1=[1,2,3]
l2=[3,4,5]
l=list(set(l1+l2))
print ('list without duplicates',l)
Resulting list object will be
list without duplicates [1, 2, 3, 4, 5]