code-rag-bench/online-tutorials huggingface dataset:
Program to convert Degree to Radian - GeeksforGeeks

26 Feb, 2021
Given the angle in degree, the task is to convert this into radians.Examples:  
Input: degree = 45 
Output: radian = 0.785398

Input: degree = 58
Output: radian = 1.01229
 
Approach: Radian: The Radian is the SI unit for measuring angles, used mainly in trigonometry. A radian is defined by an arc of a circle. A full circle is just over 6 radians (Roughly 6.28). One radian is just under 57.3 degrees.Degree: A degree, usually denoted by ° (the degree symbol), is a measurement of a plane angle, defined so that a full rotation is 360 degrees. Because a full rotation equals 2*pi radians, one degree is equivalent to pi/180 radians. The formula to convert radian to degree is:  
radian = degree * (pi/180) 
where pi = 22/7
Below is the implementation of the above approach:  
C++
Java
Python3
C#
Javascript
// C++ program to convert degree to radian #include <iostream>#include <math.h>using namespace std; // Function for conversiondouble Convert(double degree){    double pi = 3.14159265359;    return (degree * (pi / 180));} // Driver codeint main(){    double degree = 30;    double radian = Convert(degree);    cout << radian;    return 0;}
// Java program to convert degree to radianimport java.io.*;import java.util.*; class GFG {     // Function for conversionstatic double Convert(double degree){    double pi = 3.14159265359;         return (degree * (pi / 180));} // Driver codepublic static void main(String[] args){    double degree = 30;    double radian = Convert(degree);         System.out.printf("%.6f", radian);}} // This code is contributed by coder001   
# Python3 program to convert degree to radian # Function for conversiondef Convert(degree):     pi = 3.14159265359;    return (degree * (pi / 180)); # Driver codedegree = 30;radian = Convert(degree);print(radian); # This code is contributed by Code_Mech
// C# program to convert degree to radianusing System; class GFG{     // Function for conversionstatic double Convert(double degree){    double pi = 3.14159265359;         return (degree * (pi / 180));} // Driver codepublic static void Main(){    double degree = 30;    double radian = Convert(degree);         Console.Write("{0:F6}", radian);}} // This code is contributed by Code_Mech
<script> // Javascript program to convert degree to radian // Function for conversionfunction Convert(degree){    let pi = 3.14159265359;    return (degree * (pi / 180));} // Driver code     let degree = 30;    let radian = Convert(degree);    document.write(radian);  // This code is contributed Mayank Tyagi </script>
0.523599
 
coder001
Code_Mech
mayanktyagi1709
Mathematical
School Programming
Write From Home
Mathematical
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Program to find GCD or HCF of two numbers
Merge two sorted arrays
Modulo Operator (%) in C/C++ with Examples
Prime Numbers
Program to find sum of elements in a given array
Python Dictionary
Arrays in C/C++
Inheritance in C++
Reverse a string in Java
Interfaces in Java
Bootstrap panel-title class

Add panel title in Bootstrap to add a title to the panel using the .panel-title class.
You can try to run the following code to implement the .panel-title class
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <title>Bootstrap Example</title>
      <link href = "/bootstrap/css/bootstrap.min.css" rel = "stylesheet">
      <script src = "/scripts/jquery.min.js"></script>
      <script src = "/bootstrap/js/bootstrap.min.js"></script>
   </head>
   <body>
      <div class = "panel panel-default">
         <div class = "panel-heading">
            <h3 class = "panel-title">
               Panel with title
            </h3>
         </div>
         <div class = "panel-body">
            Panel content
         </div>
      </div>
   </body>
</html>
Private Variables in C#

Private access specifier allows a class to hide its member variables and member functions from other functions and objects. Only functions of the same class can access its private members. Even an instance of a class cannot access its private members.
Create a private variable −
private double length;
Let us see an example. Here, if we will try to access the length variable which is set private, then the following error would generate.
BoxApplication.Box.length' is inaccessible due to its protection level
Let us see the complete example now −
using System;

namespace BoxApplication {
   class Box {
      private double length; // Length of a box
      private double breadth; // Breadth of a box
      private double height; // Height of a box

      public void setLength( double len ) {
         length = len;
      }

      public void setBreadth( double bre ) {
         breadth = bre;
      }

      public void setHeight( double hei ) {
         height = hei;
      }

      public double getVolume() {
         return length * breadth * height;
      }
   }

   class Boxtester {
      static void Main(string[] args) {
         Box Box1 = new Box(); // Declare Box1 of type Box
         Box Box2 = new Box();
         double volume;

         // ACcessing private variables outside the class gives an error.
         // Box1.length = 10;

         Box1.setLength(6.0);
         Box1.setBreadth(7.0);
         Box1.setHeight(5.0);

         // box 2 specification
         Box2.setLength(12.0);
         Box2.setBreadth(13.0);
         Box2.setHeight(10.0);

         // volume of box 1
         volume = Box1.getVolume();
         Console.WriteLine("Volume of Box1 : {0}" ,volume);

         // volume of box 2
         volume = Box2.getVolume();
         Console.WriteLine("Volume of Box2 : {0}", volume);

         Console.ReadKey();
      }
   }
}
How to add a class to DOM element in JavaScript?

To add a class to a DOM element, you first need to find it using a querySelector like querySelector, getElementById, etc. Then you need to add the class. For example, if you have the following HTML −
<!DOCTYPE html>
<html>
   <head></head>
   <body>
      <p id="para">This is some text</p>
   </body>
</html>
You can find the element using either of the following 2 ways −
let myPara = querySelector('#para')[0];
let myPara = getElementById('para');
Then you can add a class to this element using −
let myPara = getElementById('para');
myPara.classList.add('myClass');
Select text after last slash in MySQL?

You need to use substring_index() function from MySQL to select text.
The syntax is as follows
SELECT substring_index(yourColumnName,'/',-1) AS anyAliasName FROM yourTableName;
To understand the above concept, let us create a table. The query to create a table is as follows
mysql> create table selectTextAfterLastSlashDemo
   - > (
   - > UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   - > UserPathDirectory varchar(200)
   - > );
Query OK, 0 rows affected (0.54 sec)
Insert some records in the table using insert command.
The query is as follows
mysql> insert into selectTextAfterLastSlashDemo(UserPathDirectory)
values('C:/MyFolder1/MyEntityFramework');
Query OK, 1 row affected (0.18 sec)
mysql> insert into selectTextAfterLastSlashDemo(UserPathDirectory)
values('D:/MySpringFrameworkDemo');
Query OK, 1 row affected (0.14 sec)
mysql> insert into selectTextAfterLastSlashDemo(UserPathDirectory)
values('E:/Java/MyRootFolder/Source/AllHibernateDemo');
Query OK, 1 row affected (0.14 sec)
mysql> insert into selectTextAfterLastSlashDemo(UserPathDirectory) values('C:/Program
Files/MySQL/Server 8.0');
Query OK, 1 row affected (0.20 sec)
mysql> insert into selectTextAfterLastSlashDemo(UserPathDirectory)
values('C:/John/Folder1/Folder2');
Query OK, 1 row affected (0.10 sec)
Display all records from the table using select statement.
The query is as follows
mysql> select *from selectTextAfterLastSlashDemo;
The following is the output displaying path in of the columns
+--------+----------------------------------------------+
| UserId | UserPathDirectory                            |
+--------+----------------------------------------------+
|     1 | C:/MyFolder1/MyEntityFramework                |
|     2 | D:/MySpringFrameworkDemo                      |
|     3 | E:/Java/MyRootFolder/Source/AllHibernateDemo  |
|     4 | C:/Program Files/MySQL/Server 8.0             |
|     5 | C:/John/Folder1/Folder2                       |
+--------+----------------------------------------------+
5 rows in set (0.00 sec)
Here is the query to get text after last slash
mysql> select substring_index(UserPathDirectory,'/',-1) as TextAfterLastSlash from
selectTextAfterLastSlashDemo;
The following is the output displaying the text after last slash
+-----------------------+
| TextAfterLastSlash    |
+-----------------------+
| MyEntityFramework     |
| MySpringFrameworkDemo |
| AllHibernateDemo      |
| Server 8.0            |
| Folder2               |
+-----------------------+
5 rows in set (0.00 sec)
How to create DefaultTableModel which is an implementation of TableModel

Let us create DefaultTableModel −
DefaultTableModel tableModel = new DefaultTableModel();
Now, set the model to JTable −
JTable table = new JTable(tableModel);
Add a column −
tableModel.addColumn("Languages");
Now, we will add rows to our table −
tableModel.insertRow(0, new Object[] { "CSS" });
tableModel.insertRow(0, new Object[] { "HTML5" });
The following is an example to create DefaultTableModel −
package my;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
public class SwingDemo {
   public static void main(String[] argv) throws Exception {
      DefaultTableModel tableModel = new DefaultTableModel();
      JTable table = new JTable(tableModel);
      tableModel.addColumn("Languages");
      tableModel.insertRow(0, new Object[] { "CSS" });
      tableModel.insertRow(0, new Object[] { "HTML5" });
      tableModel.insertRow(0, new Object[] { "JavaScript" });
      tableModel.insertRow(0, new Object[] { "jQuery" });
      tableModel.insertRow(0, new Object[] { "AngularJS" });
      tableModel.insertRow(tableModel.getRowCount(), new Object[] { "ExpressJS" });
      JFrame f = new JFrame();
      f.setSize(550, 350);
      f.add(new JScrollPane(table));
      f.setVisible(true);
   }
}
PyQt5 - QCalendarWidget - GeeksforGeeks

09 Aug, 2021
QCalendarWidget is the class that provides a monthly based calendar widget allowing the user to select a date, this class belongs to the QWidgets class. A calendar is a system of organizing days for social, religious, commercial, or administrative purposes. This is done by giving names to periods of time, typically days, weeks, months and years. A date is the designation of a single, specific day within such a system. Below is how QCalendarWidget looks like. 
Example : A window having a QCalendarWidget and user can see the various months and can select any dateBelow is the implementation  
Python3
# 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 components    def UiComponents(self):          # creating a QCalendarWidget object        calendar = QCalendarWidget(self)          # setting geometry to the calendar        calendar.setGeometry(50, 50, 400, 250)    # create pyqt5 appApp = QApplication(sys.argv)  # create the instance of our Windowwindow = Window()  # start the appsys.exit(App.exec())
Output :
 
clintra
Python PyQt-QCalendarWidget
Python-gui
Python-PyQt
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Python Dictionary
Read a file line by line in Python
Enumerate() in Python
How to Install PIP on Windows ?
Iterate over a list in Python
Different ways to create Pandas Dataframe
Python String | replace()
Python program to convert a list to string
Reading and Writing to text files in Python
sum() function in Python
JSTL - fn:contains() Function

The fn:contains() function determines whether an input string contains a specified substring.
The fn:contains() function has the following syntax −
boolean contains(java.lang.String, java.lang.String)

Following example explains the functionality of fn:contains() function −
<%@ taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c" %>
<%@ taglib uri = "http://java.sun.com/jsp/jstl/functions" prefix = "fn" %>

<html>
   <head>
      <title>Using JSTL Functions</title>
   </head>

   <body>
      <c:set var = "theString" value = "I am a test String"/>

      <c:if test = "${fn:contains(theString, 'test')}">
         <p>Found test string<p>
      </c:if>

      <c:if test = "${fn:contains(theString, 'TEST')}">
         <p>Found TEST string<p>
      </c:if>

   </body>
</html>
You will receive the following result −
Found test string


    108 Lectures 
     11 hours 

 Chaand Sheikh

    517 Lectures 
     57 hours 

 Chaand Sheikh

    41 Lectures 
     4.5 hours 

 Karthikeya T

    42 Lectures 
     5.5 hours 

 TELCOMA Global

    15 Lectures 
     3 hours 

 TELCOMA Global

    44 Lectures 
     15 hours 

 Uplatz
 Print
 Add Notes
 Bookmark this page
Bootstrap table-responsive class

Wrapping any .table in .table-responsive class, you will make the table scroll horizontally up to small devices (under 768px). When viewing on anything larger than 768px wide, you will not see any difference in these tables.
To make a responsive table, you can try to run the following code −
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <title>Bootstrap Table</title>
      <link href = "/bootstrap/css/bootstrap.min.css" rel="stylesheet">
      <script src = "/scripts/jquery.min.js"></script>
      <script src = "/bootstrap/js/bootstrap.min.js"></script>
   </head>
   <body>
      <div class = "table-responsive">
         <table class = "table">
            <thead>
               <tr>
                  <th>Subject</th>
                  <th>Marks</th>
                  <th>Student</th>
               </tr>
            </thead>
         <tbody>
            <tr class = "success">
               <td>Programming</td>
               <td>90</td>
               <td>Amit</td>
            </tr>
            <tr class = "active">
               <td>Web Dev</td>
               <td>92</td>
               <td>Yuvraj</td>
            </tr>
            <tr class = "warning">
               <td>Science</td>
               <td>95</td>
               <td>Sachin</td>
            </tr>
            <tr class = "danger">
               <td>Economics</td>
               <td>80</td>
               <td>Tony</td>
            </tr>
         </tbody>
      </table>
   </body>
</html>
Convert list of strings and characters to list of characters in Python

While dalign with lists, we may come across a situation where we have to process a string and get its individual characters for further processing. In this article we will see various ways to do that.
We design a for loop to go through each element of the list and another loop inside this to pick each character from the element which is a string.
 Live Demo
listA = ['Mon','d','ay']
# Given lists
print("Given list : \n", listA)
# Get characters
res = [i for ele in listA for i in ele]
# Result
print("List of characters: \n",res)
Running the above code gives us the following result −
Given list :
['Mon', 'd', 'ay']
List of characters:
['M', 'o', 'n', 'd', 'a', 'y']
The itertools module of python gives us the chain function. Using it we fetch each character from the strings of the list and put it into a new list.
 Live Demo
from itertools import chain
listA = ['Mon','d','ay']
# Given lists
print("Given list : \n", listA)
# Get characters
res = list(chain.from_iterable(listA))
# Result
print("List of characters: \n",res)
Running the above code gives us the following result −
Given list :
['Mon', 'd', 'ay']
List of characters:
['M', 'o', 'n', 'd', 'a', 'y']
The join method can be used to combine all the elements into a single string and then apply the list function which will store each character as a separate string.
 Live Demo
listA = ['Mon','d','ay']
# Given lists
print("Given list : \n", listA)
# Convert to int
res = list(''.join(listA))
# Result
print("List of characters: \n",res)
Running the above code gives us the following result −
Given list :
['Mon', 'd', 'ay']
List of characters:
['M', 'o', 'n', 'd', 'a', 'y']
How can we read data from an excel sheet in Selenium Webdriver?

We can read data from an excel sheet in Selenium webdriver in Python.
An excel workbook consists of multiple sheets and each sheet consists of cells and columns.
To work with excel in Python(with extension .xlsx, .xlsm, and so on) we have to utilize the OpenPyXL library. To install this package, we have to run the command: pip install openpyxl. Also, we have to add the statement import openpyxl in our code.
To open an excel workbook, the method is load_workbook and pass the path of the excel file as a parameter to this method. To identify the active sheet, we have to use the active method on the workbook object.
To read a cell, the method cell is applied on the active sheet and the row and column numbers are passed as parameters to this method. Then the value method is applied on a particular cell to read values within it.
Let us read the value at the third row and second column having the value D as shown below in an excel workbook of name Data.xlsx −
import openpyxl
#configure workbook path
b = openpyxl.load_workbook("C:\\Data.xlsx")
#get active sheet
sht = b.active
#get cell address within active sheet
cl = sht.cell (row = 3, column = 2)
#read value with cell
print("Reading value from row-3, col-2: ")
print (cl.value)
DAX Text - RIGHT function

Returns the last characters in a text string, based on the number of characters you specify.
RIGHT (<text>, [<num_times>]) 

text
The text string that contains the characters you want to extract, or a reference to a column that contains text.
If the referenced column does not contain text, it will be implicitly cast to text.
num_times
Optional.
The number of characters you want RIGHT to extract. If omitted, default is 1.
You can also use a reference to a column that contains numbers.
A text string or a calculated column of text strings.
RIGHT always counts each character, whether single byte or double byte, as 1, no matter what the default language setting is.
If num_chars = 0, BLANK is returned.
If num_chars < 0, #ERROR value is returned.
= RIGHT([Product],2) returns the right two characters of the values in the Product column.
= RIGHT([Product]) returns Blank values. 

    53 Lectures 
     5.5 hours 

 Abhay Gadiya

    24 Lectures 
     2 hours 

 Randy Minder

    26 Lectures 
     4.5 hours 

 Randy Minder
 Print
 Add Notes
 Bookmark this page
“volatile” qualifier in C

Here we will see what is the meaning of volatile qualifier in C++. The volatile qualifier is applied to a variable when we declare it. It is used to tell the compiler, that the value may change at any time. These are some properties of volatile.
The volatile keyword cannot remove the memory assignment
It cannot cache the variables in register.
The value cannot change in order of assignment.
Let us see, how we can use the volatile keyword.
volatile int a;
int volatile a;
Here these two declarations are correct. Like other datatypes, we can use volatile pointers, structures, unions etc. The volatile structures and unions can be volatile itself, and their member variables can also be of type volatile.
The volatile is used in different places. For memory mapped peripheral registers, some global variables, that are accessed by some other functions or interrupt service routines, or in some multi-threaded applications, the volatile can be used.
int main (){
   int value;
   value++;
}i
nt main (){
   volatile int value;
   value++;
}
There are two blocks of code. In the first block the volatile keyword is not present. So for the first case, the variable will be copied from memory to CPU register, then the operations are performed. In the second case the volatile is present. So in this case the variable will not be copied from memory to registers.
How to add a variable in HTML?

Use the <var> tag in HTML to add a variable. The HTML <var> tag is used to format text in a document. It can include a variable in a mathematical expression.
You can try to run the following code to add a variable in HTML −
<!DOCTYPE html>
<html>
   <head>
      <title>HTML var Tag</title>
   </head>
   <body>
      <p>The equations: <var>2x</var> - <var>4z</var> = <var>2y</var> + 3 and
         <var>x</var> + <var>5z</var> = <var>3y</var> + 6</p>
   </body>
</html>
How to deal with Internet Explorer and addEventListener problem "Object doesn't support this property or method" in JavaScript?

To deal with “Object doesn’t support this property or method” issue in JavaScript, while using events and Internet Explorer, update your code with this −
<html>
   <head>
      <meta http-equiv="X-UA-Compatible" content="IE=edge;" />
   </head>
   <body>
   ...
   </body>
</html>
You can also use attachEvent in IE to solve this issue like this −
if (ev.addEventListener) {
   ev.addEventListener('click', myText, false);
}
else if (ev.attachEvent) {
    ev.attachEvent('onclick', myText);
}
Convert Class in C#

The Convert Class has methods to convert a base data type to another base data type. Let us see some examples −
The Convert.ToBoolean() method in C# is used to convert a specified value to an equivalent Boolean value.
Following is the syntax −
public static bool ToBoolean (string val, IFormatProvider provider);
Above, Val is a string that contains the value of either TrueString or FalseString, whereas the provider is an object that supplies culture-specific formatting information.
Let us now see an example to implement the Convert.ToBoolean() method −
 Live Demo
using System;
using System.Globalization;
public class Demo {
   public static void Main(){
      CultureInfo cultures = new CultureInfo("en-US");
      String str = "true";
      Console.WriteLine("Converted bool value...");
      bool res = Convert.ToBoolean(str, cultures);
      Console.Write("{0}", res);
   }
}
This will produce the following output −
Converted bool value...
True
The Convert.ToDouble() method in C# converts the specified string representation of a number to an equivalent double-precision floating-point number, using the specified culture-specific formatting information.
Following is the syntax −
public static double ToDouble (string val, IFormatProvider provider);
Above, the value is a string that contains the number to convert, whereas the provider is an object that supplies culture-specific formatting information.
Let us now see an example to implement the Convert.ToDouble() method −
 Live Demo
using System;
using System.Globalization;
public class Demo {
   public static void Main(){
      String val = "876876, 878";
      NumberFormatInfo formatProvider = new NumberFormatInfo();
      formatProvider.NumberDecimalSeparator = ", ";
      formatProvider.NumberGroupSeparator = ".";
      formatProvider.NumberGroupSizes = new int[] { 2 };
      Console.WriteLine("Converted Decimal value...");
      double res = Convert.ToDouble(val, formatProvider);
      Console.Write("{0}", res);
   }
}
This will produce the following output −
Converted Decimal value...
876876.878
The Convert.ToDecimal() method in C# converts the specified string representation of a number to an equivalent decimal number, using the specified culture-specific formatting information.
Following is the syntax −
public static decimal ToDecimal (string val, IFormatProvider provider);
Above, Val is a string that contains a number to convert, whereas the provider is an object that supplies culture-specific formatting information.
Let us now see an example to implement the Convert.ToDecimal() method −
 Live Demo
using System;
using System.Globalization;
public class Demo {
   public static void Main(){
      CultureInfo cultures = new CultureInfo("en-US");
      String val = "8787";
      Console.WriteLine("Converted Decimal value...");
      decimal res = Convert.ToDecimal(val, cultures);
      Console.Write("{0}", res);
   }
}
This will produce the following output −
Converted Decimal value...
8787
CSS Web Fonts

Web fonts allow Web designers to use fonts that are not installed on the user's computer.
When you have found/bought the font you wish to use, just include the font 
file on your web server, and it will be automatically downloaded to the user when needed.
Your "own" fonts are defined within the CSS @font-face rule.
TrueType Fonts (TTF)
TrueType is a font standard developed in the late 1980s, by Apple and Microsoft. TrueType is the most common font format for both the Mac OS and Microsoft 
Windows operating systems.
OpenType Fonts (OTF)
OpenType is a format for scalable computer fonts. It was built on TrueType, 
and is a registered trademark of 
Microsoft. OpenType fonts are used commonly today on the major 
computer platforms.
The Web Open Font Format (WOFF)
WOFF is a font format for use in web pages. It was developed in 2009, and is 
now a W3C Recommendation. WOFF is essentially OpenType or TrueType with 
compression and additional metadata. The goal is to support font distribution 
from a server to a client over a network with bandwidth constraints.
The Web Open Font Format (WOFF 2.0)
TrueType/OpenType font that provides better compression than WOFF 1.0.
SVG Fonts/Shapes
SVG fonts allow SVG to be used as glyphs when displaying text. The SVG 1.1 
specification define a font module that allows the creation of fonts within an 
SVG document. You can also apply CSS to SVG documents, and the @font-face rule 
can be applied to text in SVG documents.
Embedded OpenType Fonts (EOT)
EOT fonts are a compact form of OpenType fonts designed by Microsoft for use 
as embedded fonts on web pages.
The numbers in the table specifies the first browser version that fully supports the 
font format.
*IE: The font format only works when set to be "installable".
In the @font-face rule; first define a name for the font (e.g. myFirstFont) and then point to the font file.
Tip: Always use lowercase letters for the font URL. Uppercase letters can give unexpected results in IE.
To use the font for an HTML element, refer to the name of the font (myFirstFont) through the font-family property:
You must add another @font-face rule containing descriptors for bold text:
The file "sansation_bold.woff" is another font file, that contains the bold characters for the Sansation font.
Browsers will use this whenever a piece of text with the font-family "myFirstFont" should render as bold.
This way you can have many @font-face rules for the same font.
Add a web font with the name "sansation" and the URL "sansation_light.woff".
<style>
 {
  font-family: ;
  : ;
}

body {
  font-family: sansation;
}
</style>

<body>
  <h1>This is a heading</h1>
  <p>This is a paragraph</p>
  <p>This is a paragraph</p>
</body>

Start the Exercise
The following table lists all the font descriptors that can be defined inside the @font-face rule:
We just launchedW3Schools videos
Get certifiedby completinga course today!
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com
Your message has been sent to W3Schools.
Mouse Position in Python Tkinter

Events are very useful to perform and manage multiple tasks in a large-scale application. We can bind a particular event with the keyboard buttons or mouse buttons using the bind(‘handler’, ‘callback’) method. Generally, the mouse pointer and its motion are tracked for the purpose of building a screensaver, 2D or 3D games. In order to print the coordinates of the pointer, we have to bind the Motion with a callback function that gets the position of the pointer in x and y variables.
#Import tkinter library
from tkinter import *
#Create an instance of tkinter frame or window
win= Tk()
#Set the geometry of tkinter frame
win.geometry("750x250")
def callback(e):
   x= e.x
   y= e.y
   print("Pointer is currently at %d, %d" %(x,y))
win.bind('<Motion>',callback)
win.mainloop()
Running the above code will print the actual position of the pointer whenever we hover on the window.
On the console, you will get to see the actual position of the mouse pointer as you hover the mouse on the screen.
Pointer is currently at 452, 225
Pointer is currently at 426, 200
Pointer is currently at 409, 187
Pointer is currently at 392, 174
Pointer is currently at 382, 168
Pointer is currently at 378, 163
Pointer is currently at 376, 159
Pointer is currently at 369, 150
Pointer is currently at 366, 141
Pointer is currently at 362, 130
How to change the line color in a Seaborn linear regression jointplot?

To change the line color in seaborn linear regression jointplot, we can use joint_kws in jointplot() method.
Set the figure size and adjust the padding between and around the subplots.
Create x and y data points using numpy to make a Pandas dataframe.
Use jointplot() method with joint_kws in the arguments.
To display the figure, use show() method.
import seaborn as sns
import numpy as np
from matplotlib import pyplot as plt
import pandas as pd

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

X = np.random.randn(1000,)
Y = 0.2 * np.random.randn(1000) + 0.5

df = pd.DataFrame(dict(x=X, y=Y))
g = sns.jointplot(x="x", y="y", data=df, kind='reg', height=3.5, joint_kws={'color':'green'})

plt.show()
Create Dismissal Alerts in Bootstrap

To create a dismissal alert −
Add a basic alert by creating a wrapper <div> and adding a class of .alert and one of the four contextual classes, for example, .alert-success, .alert-info, etc.
Also add optional .alert-dismissable to the above <div> class.
Add a close button.
You can try to run the following code to create dismissal alerts −
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <title>Bootstrap Example</title>
      <link href = "/bootstrap/css/bootstrap.min.css" rel = "stylesheet">
      <script src = "/scripts/jquery.min.js"></script>
      <script src = "/bootstrap/js/bootstrap.min.js"></script>
   </head>
   <body>
      <div class = "alert alert-success alert-dismissable">
         <button type = "button" class = "close" data-dismiss = "alert" aria-hidden = "true">
            ×
         </button>
         Success! Well done its submitted.
      </div>
      <div class = "alert alert-info alert-dismissable">
         <button type = "button" class = "close" data-dismiss = "alert" aria-hidden = "true">
            ×
         </button>
         Info! Take this info.
      </div>
   </body>
</html>
CSS - text-decoration

The  text-decoration property is used to add "decorations" to inline content.
none − No decoration should be added to the inline text.
none − No decoration should be added to the inline text.
underline − An underline is drawn beneath the inline text.
underline − An underline is drawn beneath the inline text.
overline − An overline is drawn above the inline text.
overline − An overline is drawn above the inline text.
line-through − A line should be drawn through the middle of the inline text.
line-through − A line should be drawn through the middle of the inline text.
blink − The inline text should blink on and off, analogous to the BLINK element introduced by Netscape.
blink − The inline text should blink on and off, analogous to the BLINK element introduced by Netscape.
All the HTML elements.
object.style.textDecoration = "underline";

Following is the example which demonstrates how to decorate a text.
NOTE − Blink property does not work with all the browsers.
<html>
   <head>
   </head>

   <body>
      <p style = "text-decoration:underline;">
         This will be underlined
      </p>
      
      <p style = "text-decoration:line-through;">
         This will be striked through.
      </p>
      
      <p style = "text-decoration:overline;">
         This will have a over line.
      </p>
      
      <p style = "text-decoration:blink;">
         This text will have blinking effect
      </p>
   </body>
</html> 
This will produce following result −

   This will be underlined


   This will be striked through.


   This will have a over line.


   This text will have blinking effect


    33 Lectures 
     2.5 hours 

 Anadi Sharma

    26 Lectures 
     2.5 hours 

 Frahaan Hussain

    44 Lectures 
     4.5 hours 

 DigiFisk (Programming Is Fun)

    21 Lectures 
     2.5 hours 

 DigiFisk (Programming Is Fun)

    51 Lectures 
     7.5 hours 

 DigiFisk (Programming Is Fun)

    52 Lectures 
     4 hours 

 DigiFisk (Programming Is Fun)
 Print
 Add Notes
 Bookmark this page
Dart - Classes And Objects - GeeksforGeeks

13 Aug, 2021
Dart is an object-oriented programming language, so it supports the concept of class, object ... etc. In Dart, we can define classes and objects of our own. We use the class keyword to do so. 
Syntax:  
class class_name {

   // Body of class
}
In the above syntax: 
Class is the keyword use to initialize the class.
class_name is the name of the class.
Body of class consists of fields, constructors, getter and setter methods, etc.
Objects are the instance of the class and they are declared by using new keyword followed by the class name.
Syntax:  
var object_name = new class_name([ arguments ]);
In the above syntax:  
new is the keyword use to declare the instance of the class
object_name is the name of the object and its naming is similar to the variable name in dart.
class_name is the name of the class whose instance variable is been created.
arguments are the input which are needed to be pass if we are willing to call a constructor.
After the object is created, there will be the need to access the fields which we will create. We use the dot(.) operator for that purpose.
Syntax:  
 // For accessing the property
object_name.property_name;

// For accessing the method
object_name.method_name();
Dart
// Creating Class named Gfgclass Gfg {     // Creating Field inside the class    String geek1;     // Creating Function inside class    void geek()    {        print("Welcome to $geek1");    }} void main(){    // Creating Instance of class    Gfg geek = new Gfg();     // Calling field name geek1 and assigning value    // to it using object of the class Gfg    geek.geek1 = 'GeeksforGeeks';     // Calling function name geek using object of the class Gfg    geek.geek();}
Output: 
Welcome to GeeksforGeeks
Explanation: Here we have first created the class named Gfg with a field geek1 and a function geek. Now in the main function, we have created an object of the class Gfg of name geek. Using this object we have assigned the value ‘GeeksforGeeks‘ to the string variable of the class and then we have called the geek function which has printed the output. 
Akanksha_Rai
sweetyty
Dart-OOPs
Dart
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Flutter - DropDownButton Widget
Flutter - Custom Bottom Navigation Bar
Flutter - Checkbox Widget
How to Append or Concatenate Strings in Dart?
Flutter - Flexible Widget
Dart Tutorial
ListView Class in Flutter
Operators in Dart
Flutter - BoxShadow Widget
Flutter - Stack Widget
How do we add bold text in HTML?

To display bold text, use the <strong> tag. The HTML <strong> tag is used for emphasizing an important text.
You can try to run the following code to implement <strong> tag in HTML −
<!Doctype html>
<html>
   <head>
      <title>HTML strong Tag</title>
   </head>
   <body>
      <p>This is an <strong>important</strong> text</p>
   </body>
</html>
Python Pillow - Flip and Rotate Images

While working on images using python image processing library, there are instances where you need to flip an existing image to get some more insights out of it, to enhance its visibility or because of your requirement.
Image module of the pillow library allows us to flip an image very easily. We are going to use the transpose (method) function from the Image module for flipping the images. Some of the mostly commonly used methods supported by ‘transpose()’ are − 
Image.FLIP_LEFT_RIGHT − For flipping the image horizontally
Image.FLIP_LEFT_RIGHT − For flipping the image horizontally
Image.FLIP_TOP_BOTTOM − For flipping the image vertically
Image.FLIP_TOP_BOTTOM − For flipping the image vertically
Image.ROTATE_90 − For rotating the image by specifying degree
Image.ROTATE_90 − For rotating the image by specifying degree
Following Python example reads an image, flips it horizontally, and displays the original and flipped image using standard PNG display utility −
# import required image module
from PIL import Image

# Open an already existing image
imageObject = Image.open("images/spiderman.jpg")

# Do a flip of left and right
hori_flippedImage = imageObject.transpose(Image.FLIP_LEFT_RIGHT)

# Show the original image
imageObject.show()

# Show the horizontal flipped image
hori_flippedImage.show()
Original image
Flipped image
Following Python example reads an image, flips it vertically, and displays the original and flipped image using standard PNG display utility −
# import required image module
from PIL import Image

# Open an already existing image
imageObject = Image.open("images/spiderman.jpg")

# Do a flip of left and right
hori_flippedImage = imageObject.transpose(Image.FLIP_LEFT_RIGHT)

# Show the original image
imageObject.show()

# Show vertically flipped image
Vert_flippedImage = imageObject.transpose(Image.FLIP_TOP_BOTTOM)
Vert_flippedImage.show()
Original Image
Flipped Image
Following Python example reads an image, rotates to a specified degree, and displays the original and rotated image using standard PNG display utility −
# import required image module
from PIL import Image

# Open an already existing image
imageObject = Image.open("images/spiderman.jpg")

# Do a flip of left and right
hori_flippedImage = imageObject.transpose(Image.FLIP_LEFT_RIGHT)

# Show the original image
imageObject.show()

#show 90 degree flipped image
degree_flippedImage = imageObject.transpose(Image.ROTATE_90)
degree_flippedImage.show()
Original Image
Rotated Image

    187 Lectures 
     17.5 hours 

 Malhar Lathkar

    55 Lectures 
     8 hours 

 Arnab Chakraborty

    136 Lectures 
     11 hours 

 In28Minutes Official

    75 Lectures 
     13 hours 

 Eduonix Learning Solutions

    70 Lectures 
     8.5 hours 

 Lets Kode It

    63 Lectures 
     6 hours 

 Abhilash Nelson
 Print
 Add Notes
 Bookmark this page
Convert string of time to time object in Java

Here is our string.
String strTime = "20:15:40";
Now, use the DateFormat to set the format for date.
DateFormat dateFormat = new SimpleDateFormat("hh:mm:ss");
Parse the string of time to time object.
Date d = dateFormat.parse(strTime);
The following is the complete example.
 Live Demo
import java.text.DateFormat;
import java.util.Date;
import java.text.SimpleDateFormat;
public class Demo {
    public static void main(String[] args) throws Exception {
       String strTime = "20:15:40";
       DateFormat dateFormat = new SimpleDateFormat("hh:mm:ss");
       Date d = dateFormat.parse(strTime);
       System.out.println("Resultant Date and Time = " + d);
    }
}
Resultant Date and Time = Thu Jan 01 20:15:40 UTC 1970
How to add HTTP headers 'X-Frame-Options' on iframe ? - GeeksforGeeks

28 Feb, 2020
Inline frame tag in HTML: The iframe tag is used to displaying or embedding another document within an HTML document. One of its attributes ‘src’ is used to specify the URL of the document which is to be displayed. A site’s X-frame Options can prevent allowing the display of one HTML document within another.
X-Frame Options: The X-Frame Options are not an attribute of the iframe or frame or any other HTML tags. It is a response header and is also referred to as HTTP security headers. This header tells the browser whether to render the HTML document in the specified URL or not. This plays an important role to prevent clickjacking attacks. Thus the X-Frame options cannot be set in the body of an HTML document. It is set by the domain from which the resource is requested. The X-Frame options available are:
deny: It prevents any URL being rendered within the containers like iframe, frame, objects, applets. Even if the page is from same site, when the X-Frame option is set to ‘deny’, it is not rendered.
SAMEORIGIN: It allows pages of same origin to be rendered. The page from the same site will be allowed to be displayed.
ALLOW-FROM uri: It allows the HTML documents from the specified uri only.
One can set the X-Frame Options in the web-config of the site which is to be loaded in an iframe.
For configuring in IIS write:
<httpProtocol>  <customHeaders>      <add name="X-Frame-Options" value="sameorigin"/>  </customHeaders></httpProtocol>
For configuring Apache:
Header always set X-Frame-Options "sameorigin"
Note: The browsers Edge (version 12 and above), Internet Explorer (version 8 and above) support ALLOW-FROM uri in X-Frame-Options.
HTTP-headers
Picked
Web Technologies
Web technologies Questions
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Top 10 Front End Developer Skills That You Need in 2022
How to fetch data from an API in ReactJS ?
Difference between var, let and const keywords in JavaScript
Convert a string to an integer in JavaScript
Differences between Functional Components and Class Components in React
How to set the default value for an HTML <select> element ?
How to set input type date in dd-mm-yyyy format using HTML ?
File uploading in React.js
How to Open URL in New Tab using JavaScript ?
Types of CSS (Cascading Style Sheet)
How to write binary data to a file using Python?

"Binary" files are any files where the format isn't made up of readable characters. Binary files can range from image files like JPEGs or GIFs, audio files like MP3s or binary document formats like Word or PDF. In Python, files are opened in text mode by default. To open files in binary mode, when specifying a mode, add 'b' to it.
f = open('my_file', 'w+b')
byte_arr = [120, 3, 255, 0, 100]
binary_format = bytearray(byte_arr)
f.write(binary_format)
f.close()
This opens a file in binary write mode and writes the byte_arr array contents as bytes in the binary file, my_file.
Display MongoDB with document and subdocument example and update

Following is the syntax showing document and subdocument −
db.yourCollectionName.insertOne(
   {
      yourFiledName:yourValue,
      yourFieldName : [
         {
            yourFiledName1,
            yourFiledName2,
            .
            .
            .
            N
         }
      ]
   }
);
Let us see an example create a collection with documents −
> db.demo706.insertOne(
...    {
...       PortalName: "GameApplication",
...       ApplicationConfiguration : [
...          {
...             "URL": "jdbc:mysql://localhost/customer_tracker?autoReconnect=true",
...             "USERNAME": "root",
...             "PASSWORD": "root"
...          }
...       ]
...    }
... );
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5ea6f557551299a9f98c93c6")
}
>
> db.demo706.insertOne(
...    {
...       PortalName: "WebMyBusinessApplication",
...       ApplicationConfiguration : [
...          {
...             "URL": "jdbc:oracle:thin:@localhost:1521:xe",
...             "USERNAME": "App",
...             "PASSWORD": "App"
...          }
...       ]
...    }
... );
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5ea6f558551299a9f98c93c7")
}
Display all documents from a collection with the help of find() method −
> db.demo706.find();
This will produce the following output −
{ "_id" : ObjectId("5ea6f557551299a9f98c93c6"), "PortalName" : "GameApplication", "ApplicationConfiguration" : [ { "URL" : "jdbc:mysql://localhost/customer_tracker?autoReconnect=true", "USERNAME" : "root", "PASSWORD" : "root" } ] }
{ "_id" : ObjectId("5ea6f558551299a9f98c93c7"), "PortalName" : "WebMyBusinessApplication", "ApplicationConfiguration" : [ { "URL" : "jdbc:oracle:thin:@localhost:1521:xe", "USERNAME" : "App", "PASSWORD" : "App" } ] }
Following is the query to update −
> db.demo706.update({PortalName: "WebMyBusinessApplication"},{$set:{"PortalName":"OnlineCustomerTracker"}});
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
Display all documents from a collection with the help of find() method −
> db.demo706.find();
This will produce the following output −
{ "_id" : ObjectId("5ea6f557551299a9f98c93c6"), "PortalName" : "GameApplication", "ApplicationConfiguration" : [ { "URL" : "jdbc:mysql://localhost/customer_tracker?autoReconnect=true", "USERNAME" : "root", "PASSWORD" : "root" } ] }
{ "_id" : ObjectId("5ea6f558551299a9f98c93c7"), "PortalName" : "OnlineCustomerTracker", "ApplicationConfiguration" : [ { "URL" : "jdbc:oracle:thin:@localhost:1521:xe", "USERNAME" : "App", "PASSWORD" : "App" } ] }
AWK - Logical Operators

AWK supports the following logical operators −
It is represented by &&. Its syntax is as follows −
expr1 && expr2

It evaluates to true if both expr1 and expr2 evaluate to true; otherwise it returns false. expr2 is evaluated if and only if expr1 evaluates to true. For instance, the following example checks whether the given single digit number is in octal format or not.
[jerry]$ awk 'BEGIN {
   num = 5; if (num >= 0 && num <= 7) printf "%d is in octal format\n", num 
}'
On executing this code, you get the following result −
5 is in octal format

It is represented by ||. The syntax of Logical OR is −
expr1 || expr2

It evaluates to true if either expr1 or expr2 evaluates to true; otherwise it returns false. expr2 is evaluated if and only if expr1 evaluates to false. The following example demonstrates this −
[jerry]$ awk 'BEGIN {
   ch = "\n"; if (ch == " " || ch == "\t" || ch == "\n") 
   print "Current character is whitespace." 
}'
On executing this code, you get the following result −
Current character is whitespace

It is represented by exclamation mark (!). The following example demonstrates this −
! expr1
It returns the logical compliment of expr1. If expr1 evaluates to true, it returns 0; otherwise it returns 1. For instance, the following example checks whether a string is empty or not.
[jerry]$ awk 'BEGIN { name = ""; if (! length(name)) print "name is empty string." }'
On executing this code, you get the following result −
name is empty string.

 Print
 Add Notes
 Bookmark this page
Scala Collections - Flatten Method

flatten() method is a member GenericTraversableTemplate trait, it  returns a single collection of elements by merging child collections.
The following is the syntax of flatten method.
def flatten[B]: Traversable[B]

Here, f: (A) ? GenTraversableOnce[B] is a predicate or condition to be applied on each element of the collection. This method returns the Option element containing the matched element of iterator which satisfiles the given condition.
Below is an example program of showing how to use flatten method −
object Demo {
   def main(args: Array[String]) = {
      val list = List(List(1,2), List(3,4))
      //apply operation
      val result = list.flatten
      //print result
      println(result)      
   }
}
Save the above program in Demo.scala. The following commands are used to compile and execute this program.
\>scalac Demo.scala
\>scala Demo

List(1, 2, 3, 4)


    82 Lectures 
     7 hours 

 Arnab Chakraborty

    23 Lectures 
     1.5 hours 

 Mukund Kumar Mishra

    52 Lectures 
     1.5 hours 

 Bigdata Engineer

    76 Lectures 
     5.5 hours 

 Bigdata Engineer

    69 Lectures 
     7.5 hours 

 Bigdata Engineer

    46 Lectures 
     4.5 hours 

 Stone River ELearning
 Print
 Add Notes
 Bookmark this page