code-rag-bench/online-tutorials huggingface dataset:
What is the use of the "requires" clause in a module-info file in Java 9?

A module is an important concept introduced in Java 9. By using this concept, we can able to divide code into smaller components called modules. Therefore, each module has its own responsibility and declare its dependency on other modules to work properly. In order to declare a module, we need to include the "module-info.java" file to root source code.
There are few types of "requires" clause in "module-info" file
1) 
requires <module>: By default, a module doesn't know other modules present in a module-path. So, it is necessary to add a line in our module-info.java: "requires" each time when we want to access another module.
module com.tutorialspoint.gui {
   requires com.tutorialspoint.model;
   requires java.desktop;
}
2) requires transitive <module>: In the case of our module "com.tutorialspoint.model": returns exported interface types of module "com.core". Therefore, any module that wants to use then it also requires "com.core" to access the classes of this second module with compilation errors. Java 9 allows the keyword "transitive" to indicate that by transitivity. Users "com.tutorialspoint.model" can be able to access "com. core" that allows implementation changes easily.
module com.tutorialspoint.model {
   requires transitive com.core;
}
3) requires static <module>: The keyword "requires static" represents the concept of optional dependence such a module is:
mandatory at compilation: a compilation error can be raised if the module is not present in the path module at compilation.
optional at runtime: the module can't be taken into account in the sanity check phase when an application is started. The application starts even if the module is not present.
For instance, we want to propose the persistence of the data of an application, either in an oracle database or h2database.
module com.tutorialspoint.model {
   requires static ojdbc
   requires static h2daabase.h2; 
}
GATE | GATE-CS-2015 (Set 3) | Question 65 - GeeksforGeeks

28 Jun, 2021
Consider a network connecting two systems located 8000 kilometers apart. The bandwidth of the network is 500 × 106 bits per second. The propagation speed of the media is 4 × 106 meters per second. It is needed to design a Go-Back-N sliding window protocol for this network. The average packet size is 107 bits. The network is to be used to its full capacity. Assume that processing delays at nodes are negligible. Then, the minimum size in bits of he sequence number field has to be ________.(A) 2(B) 4(C) 8(D) 16Answer: (C)Explanation:
Propagation time = (8000 * 1000)/ (4 * 10^6)
                 = 2 seconds

Total round trip propagation time = 4 seconds

Transmission time for one packet = (packet size) / (bandwidth)
                                 = (10^7) / (500 * 10^6)
                                 = 0.02 seconds

Total number of packets that can be transferred before an 
acknowledgement comes back = 4 / 0.02 = 200

Maximum possible window size is 200.  

In Go-Back-N, maximum sequence number should be one more than
window size.

So total 201 sequence numbers are needed. 201 different sequence
numbers can be represented using 8 bits.
Quiz of this Question
GATE-CS-2015 (Set 3)
GATE-GATE-CS-2015 (Set 3)
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
GATE | GATE-CS-2014-(Set-1) | Question 30
GATE | GATE-CS-2001 | Question 23
GATE | GATE-CS-2015 (Set 1) | Question 65
GATE | GATE CS 2010 | Question 45
GATE | GATE-CS-2015 (Set 3) | Question 65
GATE | GATE-CS-2004 | Question 3
GATE | GATE-CS-2014-(Set-1) | Question 65
C++ Program to count Vowels in a string using Pointer
GATE | GATE-CS-2015 (Set 1) | Question 42
GATE | GATE-CS-2014-(Set-3) | Question 65
Get execution stats in MongoDB for a collection

To get stats, use explain() in MongoDB. Let us create a collection with documents −
> db.demo157.insertOne({"Status":"Active"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e354fdffdf09dd6d08539fc")
}
> db.demo157.insertOne({"Status":"InActive"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e354fe3fdf09dd6d08539fd")
}
Display all documents from a collection with the help of find() method −
> db.demo157.find();
This will produce the following output −
{ "_id" : ObjectId("5e354fdffdf09dd6d08539fc"), "Status" : "Active" }
{ "_id" : ObjectId("5e354fe3fdf09dd6d08539fd"), "Status" : "InActive" }
Following is how to implement explain() in MongoDB −
> db.demo157.find({Status: { $in: ['Active','InActive'] }}).explain("executionStats");
This will produce the following output −
{
   "queryPlanner" : {
      "plannerVersion" : 1,
      "namespace" : "test.demo157",
      "indexFilterSet" : false,
      "parsedQuery" : {
         "Status" : {
            "$in" : [
               "Active",
               "InActive"
            ]
         }
      },
      "winningPlan" : {
         "stage" : "COLLSCAN",
         "filter" : {
            "Status" : {
               "$in" : [
                  "Active",
                  "InActive"
               ]
            }
         },
         "direction" : "forward"
      },
      "rejectedPlans" : [ ]
   },
   "executionStats" : {
      "executionSuccess" : true,
      "nReturned" : 2,
      "executionTimeMillis" : 18,
      "totalKeysExamined" : 0,
      "totalDocsExamined" : 2,
      "executionStages" : {
         "stage" : "COLLSCAN",
         "filter" : {
            "Status" : {
               "$in" : [
                  "Active",
                  "InActive"
               ]
            }
         },
         "nReturned" : 2,
         "executionTimeMillisEstimate" : 0,
         "works" : 4,
         "advanced" : 2,
         "needTime" : 1,
         "needYield" : 0,
         "saveState" : 0,
         "restoreState" : 0,
         "isEOF" : 1,
         "invalidates" : 0,
         "direction" : "forward",
         "docsExamined" : 2
      }
   },
   "serverInfo" : {
      "host" : "DESKTOP-QN2RB3H",
      "port" : 27017,
      "version" : "4.0.5",
      "gitVersion"
      "3739429dd92b92d1b0ab120911a23d50bf03c412"
   },
   "ok" : 1
}
ggplot2 - Installation of R

R packages come with various capabilities like analyzing statistical information or getting in depth research of geospatial data or simple we can create basic reports.
Packages of R can be defined as R functions, data and compiled code in a well-defined format. The folder or directory where the packages are stored is called the library.
As visible in the above figure, libPaths() is the function which displays you the library which is located, and the function library shows the packages which are saved in the library.
R includes number of functions which manipulates the packages. We will focus on three major functions which is primarily used, they are −
Installing Package  
Loading a Package
Learning about Package
The syntax with function for installing a package in R is −
Install.packages(“<package-name>”)

The simple demonstration of installing a package is visible below. Consider we need to install package “ggplot2” which is data visualization library, the following syntax is used −
Install.packages(“ggplot2”)

To load the particular package, we need to follow the below mentioned syntax −
Library(<package-name>)

The same applies for ggplot2 as mentioned below −
library(“ggplot2”)

The output is depicted in snapshot below −
To understand the need of required package and basic functionality, R provides help function which gives the complete detail of package which is installed.
The complete syntax is mentioned below −
help(ggplot2)

 Print
 Add Notes
 Bookmark this page
How can I insert default value in MySQL ENUM data type?

We can do it with the help of the DEFAULT attribute of the ENUM data type. The DEFAULT attribute causes an ENUM data type to have a default value when a value is not specified. In other words, we can say that INSERT statement does not have to include a value for this field because if it does not include then the value following DEFAULT will be inserted. Functions are not allowed in the DEFAULT expression. For ENUM data type the DEFAULT values include NULL and empty string (‘’).
mysql> Create table enum123(Rollno INT, Name Varchar(20), result ENUM('Pass','Fail') DEFAULT 'Fail');
Query OK, 0 rows affected (0.12 sec)

mysql> Insert into enum123(Rollno, Name) Values(25, 'Raman');
Query OK, 1 row affected (0.13 sec)
We have not inserted any value in ‘result’ column hence it will pick the word following DEFAULT as the value. In this case by default value ‘fail’ would be inserted.
mysql> Select * from enum123;
+---------+--------+--------+
| Rollno  | Name   | result |
+---------+--------+--------+
| 25      | Raman  |   Fail |
+---------+--------+--------+
1 row in set (0.00 sec)
React ES6 Spread Operator

The JavaScript spread operator (...) allows us to quickly copy all or part of an existing array or object into another array or object.
const numbersOne = [1, 2, 3];
const numbersTwo = [4, 5, 6];
const numbersCombined = [...numbersOne, ...numbersTwo];

Try it Yourself »

The spread operator is often used in combination with destructuring.
Assign the first and second items from numbers to variables and put the rest in an array:
const numbers = [1, 2, 3, 4, 5, 6];

const [one, two, ...rest] = numbers;

Try it Yourself »

We can use the spread operator with objects too:
Combine these two objects:
const myVehicle = {
  brand: 'Ford',
  model: 'Mustang',
  color: 'red'
}

const updateMyVehicle = {
  type: 'car',
  year: 2021, 
  color: 'yellow'
}

const myUpdatedVehicle = {...myVehicle, ...updateMyVehicle}

Try it Yourself »

Notice the properties that did not match were combined, but the property that did match, color, was overwritten by the last object that was passed, updateMyVehicle. The resulting color is now yellow.
Use the spread operator to combine the following arrays.
const arrayOne = ['a', 'b', 'c'];
const arrayTwo = [1, 2, 3];
const arraysCombined = [];

Start the Exercise
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.
HTML <time> Tag - GeeksforGeeks

17 Mar, 2022
The <time> tag is used to display the human-readable date/time. It can also be used to encode dates and times in a machine-readable form. The main advantage for users is that they can offer to add birthday reminders or scheduled events in their calendar’s and search engines can produce smarter search results.
Syntax: 
<time attribute> Time... </time>
Attributes: This tag contains an optional attribute datetime which is used to define the date/time in a machine-readable form of the <time> element.Example: 
HTML
<!DOCTYPE html><html>    <body>        <h1>GeeksforGeeks</h1>        <h2><time> Tag</h2>            <p>I Wake up at <time>6.00</time> in every morning.</p>                <p>Jawahar lal Nehru birthday is celebrated on         <time datatime="2018--11-14 12:00">children's day.</time>        </p>        </body></html>
Output:  
Supported Browsers:
Google Chrome 6.0 and above
Internet Explorer 9.0 and above
Firefox 4.0 and above
Opera 11.1 and above
Safari 5.0 and above
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
arorakashish0911
shubhamyadav4
clintra
jochenhansoul
HTML-Tags
Technical Scripter 2018
HTML
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
How to set input type date in dd-mm-yyyy format using HTML ?
REST API (Introduction)
How to Insert Form Data into Database using PHP ?
CSS to put icon inside an input element in a form
HTML Cheat Sheet - A Basic Guide to HTML
Difference between Cellpadding and Cellspacing

31 Jul, 2020
Cellpadding:Cellpadding specifies the space between the border of a table cell and its contents (i.e) it defines the whitespace between the cell edge and the content of the cell.Syntax:<table cellpadding="value" >.....</table>
where, value determines the padding 
(space between the border of a table and its content)
Cellpadding:
Cellpadding specifies the space between the border of a table cell and its contents (i.e) it defines the whitespace between the cell edge and the content of the cell.
Syntax:
<table cellpadding="value" >.....</table>
where, value determines the padding 
(space between the border of a table and its content)
Cellspacing:Cellspacing specifies the space between cells (i.e) it defines the whitespace between the edges of the adjacent cells.Syntax:<table cellspacing="value" >.....</table>
where, value determines the padding 
(space between adjacent cells)
Cellspacing:
Cellspacing specifies the space between cells (i.e) it defines the whitespace between the edges of the adjacent cells.
Syntax:
<table cellspacing="value" >.....</table>
where, value determines the padding 
(space between adjacent cells)
Example:
<!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <meta name="viewport"           content="width=device-width,                    initial-scale=1.0">    <title>Document</title>    <style>        span{          text-decoration-style: solid;          width: 25px;          font-size: x-large;          color: blueviolet;        }      </style></head><body><table border="1"        cellpadding="4"       cellspacing="5">  <thead>  <td><span>Name</span></td>  <td><span>Age</span></td>  </thead>  <tbody>  <tr>    <td>Rani</td>    <td>30</td>  </tr>   <tr>    <td>Rajan</td>    <td>35</td>  </tr>  <tr>    <td>Akshaya</td>    <td>17</td>  </tr>  <tr>    <td>Ashick</td>    <td>13</td>  </tr>  </tbody></table></body></html>
Output:
Difference between cellpadding and cellspacing:
Cellpadding
Cellspacing
HTML-Basics
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to convert array values to lowercase in PHP ?

24 Jun, 2021
Given an array containing uppercase string elements and the task is to convert the array elements (uppercase) into lowercase. There are two ways to convert array values to lowercase in PHP.  
Using foreach loop
Using array_map() function
Using foreach loop: In this approach, an iterator iterates through the value of an array individually and convert each array elements into lowercase and stores the converted values to the original array.Program:  
PHP
<?php // Declare an array$arr = array('GFG', 'GEEK',        'GEEKS', 'GEEKSFORGEEKS'); $j = 0; // Iterate loop to convert array// elements into lowercase and// overwriting the original arrayforeach( $arr as $element ) {    $arr[$j] = strtolower($element);         $j++;} // Display the content of arrayforeach( $arr as $element )    echo $element . "\n"; ?>
gfg
geek
geeks
geeksforgeeks
 
Using array_map() function: In this approach, the array_map() function is used to accept two parameters callback and an array. Syntax:  
array array_map( callable callback, array array )
Here callback is a function to be called for operation on an array. This function can be an inbuilt function or an user-defined function whereas array is list of values on which operation to be performed.Program 2:  
PHP
<?php // Declare an array$arr = array('GFG', 'GEEK',        'GEEKS', 'GEEKSFORGEEKS'); $arr = array_map( 'strtolower', $arr ); // Display the content of arrayforeach( $arr as $element )    echo $element . "\n"; ?>
gfg
geek
geeks
geeksforgeeks
 
AshokJaiswal
Picked
PHP
PHP Programs
Web Technologies
Web technologies Questions
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
What is thread safe or non-thread safe in PHP ? - GeeksforGeeks

17 Jul, 2019
Thread-safe: It is used to ensure that when the shared data structure which is manipulated by different threads are prevented from entering the race condition. Thread-safety is recommended when the web server run multiple threads of execution simultaneously for different requests. In Thread Safety binary can work in a multi-threaded web server context. Thread Safety works by creating a local storage copy in each thread so that the data will not collide with another thread.For example:
Apache + LoadModule
IIS
Non-thread-safe: It does not check the safety of the threads which makes it faster to run but at the same time, it becomes more unstable and crashes very frequently. It refers to a single thread only builds. In non-thread safe version binaries widespread use in the case of interaction with a web server through the FastCGI protocol, by not utilizing multi-threading.For example:
Apache + FastCGI
IIS + FastCGI
So it depends on the way that you want to use PHP. AFAIR running PHP with the fastCGI is the preferable way. If you are unknown which version of PHP is installed in your system then there is an easy way to know that.Check the version of installed PHP Thread safe or Non Thread Safe:Open a phpinfo() and search for the line Thread safety for a thread-safe build you should find enable.
On Windows:php -i|findstr "Thread"

php -i|findstr "Thread"

On *nix:php -i|grep Thread

php -i|grep Thread

In the both cases will display any oneThread Safety => enabled
//or
Thread Safety => disabled

Thread Safety => enabled
//or
Thread Safety => disabled

Picked
PHP
PHP Programs
Web Technologies
Web technologies Questions
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Insert Form Data into Database using PHP ?
How to convert array to string in PHP ?
How to Upload Image into Database and Display it using PHP ?
How to check whether an array is empty using PHP?
How to receive JSON POST with PHP ?
How to Insert Form Data into Database using PHP ?
How to convert array to string in PHP ?
How to call PHP function on the click of a Button ?
How to Upload Image into Database and Display it using PHP ?
How to check whether an array is empty using PHP?
Program to find longest consecutive run of 1 in binary form of a number in C++

Suppose we have a number n, we have to find the length of the longest consecutive run of 1s in its binary representation.
So, if the input is like n = 312, then the output will be 3, as 312 is 100111000 in binary and there are 3 consecutive 1s.
To solve this, we will follow these steps −
ret := 0, len := 0
ret := 0, len := 0
for initialize i := 0, when i < 32, update (increase i by 1), do:if n/2 is odd, then(increase len by 1)Otherwiselen := 0ret := maximum of ret and len
for initialize i := 0, when i < 32, update (increase i by 1), do:
if n/2 is odd, then(increase len by 1)
if n/2 is odd, then
(increase len by 1)
(increase len by 1)
Otherwiselen := 0
Otherwise
len := 0
len := 0
ret := maximum of ret and len
ret := maximum of ret and len
return ret
return ret
Let us see the following implementation to get better understanding:
Source Code (C++) −
 Live Demo
#include <bits/stdc++.h>
using namespace std;
class Solution {
   public:
   int solve(int n) {
      int ret = 0;
      int len = 0;
      for(int i = 0; i < 32; i++){
         if((n >> i) & 1){
            len++;
         }else{
            len = 0;
         }
         ret = max(ret, len);
      }
      return ret;
   }
};
main(){
   Solution ob;
   cout << ob.solve(312);
}
312
3
How to exponentially scale the Y axis with matplotlib?

To exponentially scale the Y-axis with matplotlib, we can take the following steps −
Set the figure size and adjust the padding between and around the subplots.
Inintialize a variable dt for steps.
Create x and y data points using numpy.
Plot the x and y data points using numpy.
Set the exponential scale for the Y-axis, using plt.yscale('symlog').
To display the figure, use show() method.
import numpy as np
import matplotlib.pyplot as plt

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

dt = 0.01

x = np.arange(-50.0, 50.0, dt)
y = np.arange(0, 100.0, dt)

plt.plot(x, y)
plt.yscale('symlog')

plt.show()
It will produce the following output
Count the total number of elements in the List in C#?

To count the total number of elements in the List, the code is as follows −
 Live Demo
using System;
using System.Collections.Generic;
public class Demo {
   public static void Main(String[] args) {
      List<String> list = new List<String>();
      list.Add("One");
      list.Add("Two");
      list.Add("Three");
      list.Add("Four");
      list.Add("Five");
      Console.WriteLine("Elements in List1...");
      foreach (string res in list) {
         Console.WriteLine(res);
      }
      Console.WriteLine("\nCount of elements in list = "+list.Count);
      list.Clear();
      Console.WriteLine("\nCount of elements in list (updated) = "+list.Count);
   }
}
This will produce the following output −
Elements in List1...
One
Two
Three
Four
Five
Count of elements in list = 5
Count of elements in list (updated) = 0
Let us now see another example −
 Live Demo
using System;
using System.Collections.Generic;
public class Demo {
   public static void Main(String[] args) {
      List<String> list = new List<String>();
      list.Add("100");
      list.Add("200");
      list.Add("300");
      list.Add("400");
      list.Add("500");
      Console.WriteLine("Count of elements in the list = "+list.Count);  
      Console.WriteLine("Enumerator iterates through the list elements...");
      List<string>.Enumerator demoEnum = list.GetEnumerator();
      while (demoEnum.MoveNext()) {
         string res = demoEnum.Current;
         Console.WriteLine(res);
      }
      list.Add("600");
      list.Add("700");
      Console.WriteLine("Count of elements in the list (updated) = "+list.Count);
   }
}
This will produce the following output −
Count of elements in the list = 5
Enumerator iterates through the list elements...
100
200
300
400
500
Count of elements in the list (updated) = 7
QlikView - Mapping Tables

Mapping table is a table, which is created to map the column values between two tables. It is also called a Lookup table, which is only used to look for a related value from some other table.
Let us consider the following input data file, which represents the sales values in different regions.
ProductID,ProductCategory,Region,SaleAmount
1,Outdoor Recreation,Europe,4579
2,Clothing,Europe,4125
3,Costumes & Accessories,South Asia,6521
4,Athletics,South Asia,4125
5,Personal Care,Australia,5124
6,Arts & Entertainment,North AMerica,1245
7,Hardware,South America,456
8,Home & Garden,South America,241
9,Food,South Asia,1247
10,Home & Garden,South Asia,5462
11,Office Supplies,Australia,577

The following data represents the countries and their regions.
Region,Country
Europe,Germany
Europe,Italy
South Asia,Singapore
South Asia,Korea
North AMerica,USA
South America,Brazil
South America,Peru
South Asia,China
South Asia,Sri Lanka

The above data is loaded to QlikView memory by using the script editor. Open the Script editor from the File menu or press Control+E. Choose the Table Files option from the Data from Files tab and browse for the file containing the above data. Click OK and ess Control+R to load the data into the QlikView's memory.
Let us create two table boxes for each of the above table as shown below. Here we cannot get the value of country in the Sales region report.
The following script produces the mapping table, which maps the region value from the sales table with the country value from the MapCountryRegion table.
On completing the above steps and creating a Table box to view the data, we get the country columns along with other columns from Sales table.

    70 Lectures 
     5 hours 

 Arthur Fong
 Print
 Add Notes
 Bookmark this page
How to create a speed converter with HTML and JavaScript?

To create a speed converter with HTML and JavaScript, the code is as follows −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<style>
   body {
      font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
   }
   input, span {
      font-size: 20px;
   }
</style>
</head>
<body>
<h1>Speed Converter</h1>
<h2>Type speed in Kilometer per hour to convert it into meter per hour</h2>
<p>
<label>Kilometer Per Hour</label>
<input
id="inputKm"
type="number"
placeholder="KilometersPerHour"
oninput="KmphtoMphConverter(this.value)"
onchange="KmphtoMphConverter(this.value)"/>
</p>
<p>Meters Per second: <span class="metersPerSecond"></span></p>
<script>
   function KmphtoMphConverter(speed) {
      document.querySelector(".metersPerSecond").innerHTML = speed * 0.277778;
   }
</script>
</body>
</html>
The above code will produce the following output −
On entering some speed in kph −
How can we create and use ENUM columns in MySQL?

For creating an ENUM column, the enumeration value must be a quoted string literals. We can create ENUM columns in MySQL with the help of the following syntax −
CREATE TABLE table_name(
   ...
   Col ENUM(‘Value1’,’Value2’,’Value3’),
   ...
);
In the above syntax, we have three enumeration values. It can be more than three also.
 Following is an example of creating a table with ENUM column −
mysql> Create table marks(id int Primary key NOT NULL, Name Varchar(255) NOT NULL, Result ENUM('Pass', 'Fail') NOT NULL);
Query OK, 0 rows affected (0.18 sec)
The query above will create a table named marks with an ENUM field.
mysql> Insert into marks(id, name, result) values(101,'Aarav','Pass');
Query OK, 1 row affected (0.07 sec)

mysql> Insert into marks(id, name, result) values(102,'Yashraj','Fail');
Query OK, 1 row affected (0.02 sec)
With the help of queries above we can insert the values in the table.
mysql> Select * from marks;
+-----+---------+--------+
| id  | Name    | Result |
+-----+---------+--------+
| 101 | Aarav   | Pass   |
| 102 | Yashraj | Fail   |
+-----+---------+--------+
2 rows in set (0.00 sec)
PyQt5 – How to align Text of Label - GeeksforGeeks

17 Jan, 2022
In this article, we will see how we can align text of labels in PyQt5 application, we can align text in three different ways which are left, right and Center.Syntax :  
label.setAlignment(QtCore.Qt.AlignLeft)
label.setAlignment(QtCore.Qt.AlignCenter)
label.setAlignment(QtCore.Qt.AlignRight)
In order to use use this we have to import Qtcore from PyQt5  
from PyQt5 import QtCore
Below is the implementation : 
Python3
# importing the required libraries from PyQt5.QtWidgets import *from PyQt5 import QtCorefrom PyQt5.QtGui import *import sys class Window(QMainWindow):    def __init__(self):        super().__init__()         # set the title        self.setWindowTitle("Label")         # setting  the geometry of window        self.setGeometry(0, 0, 400, 300)         # creating a label widget        self.label_1 = QLabel('Left', self)         # moving position        self.label_1.move(100, 100)         # setting up border        self.label_1.setStyleSheet("border: 1px solid black;")         # setting alignment to left        self.label_1.setAlignment(QtCore.Qt.AlignLeft)         # creating a label widget        self.label_2 = QLabel('Center', self)         # moving position        self.label_2.move(100, 130)         # setting up border        self.label_2.setStyleSheet("border: 1px solid black;")         # setting alignment to center        self.label_2.setAlignment(QtCore.Qt.AlignCenter)         # creating a label widget        self.label_3 = QLabel('Right', self)         # moving position        self.label_3.move(100, 160)         # setting up border        self.label_3.setStyleSheet("border: 1px solid black;")         # setting alignment to right        self.label_3.setAlignment(QtCore.Qt.AlignRight)         # show all the widgets        self.show()   # create pyqt5 appApp = QApplication(sys.argv) # create the instance of our Windowwindow = Window() # start the appsys.exit(App.exec())
Output :  
 
sagartomar9927
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
Java Examples - Method Overloading

How to overload methods ?
This example displays the way of overloading a method depending on type and number of parameters.
class MyClass {
   int height;
   MyClass() {
      System.out.println("bricks");
      height = 0;
   }
   MyClass(int i) {
      System.out.println("Building new House that is " + i + " feet tall");
      height = i;
   }
   void info() {
      System.out.println("House is " + height + " feet tall");
   }
   void info(String s) {
      System.out.println(s + ": House is " + height + " feet tall");
   }
}
public class MainClass {
   public static void main(String[] args) {
      MyClass t = new MyClass(0);
      t.info();
      t.info("overloaded method");
      
      //Overloaded constructor:
      new MyClass();
   }
}
The above code sample will produce the following result.
Building new House that is 0 feet tall.
House is 0 feet tall.
Overloaded method: House  is 0 feet tall.
bricks

The following is an another sample example of Method Overloading
public class Calculation {
   void sum(int a,int b){System.out.println(a+b);}
   void sum(int a,int b,int c){System.out.println(a+b+c);}

   public static void main(String args[]){
      Calculation cal = new Calculation();
      cal.sum(20,30,60);
      cal.sum(20,20);
   }
}
The above code sample will produce the following result.
110
40

 Print
 Add Notes
 Bookmark this page
All possible strings of any length that can be formed from a given string?

In this section we will see how to generate all possible strings of any length, this will take each combination of characters to make string. For example, if the string is ABC, then it will generate − {A, B, C, AB, BA, BC, CB, CA, AC, ABC, ACB, BAC, BCA, CAB, CBA}
Let us see the example to get the idea.
Begin
   n := length of the string str
   count is 2^n – 1
   for each number 0 to count, do
      sub_str := empty string
      for j in range 0 to n, do
         if jth bit of the counter is set, then
            concatenate jth character of str with sub_str
         end if
      done
      repeat:
         print sub_string
      until next permutation of sub_string is not completed
   done
End
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
void printAllString(string str) {
   int n = str.size();
   unsigned int count = pow(2, n);
   for (int counter = 1; counter <count; counter++) { //generate 2^n - 1 strings
      string subs = "";
      for (int j = 0; j < n; j++) {
         if (counter & (1<<j)) //when the jth bit is set, then add jth character
            subs.push_back(str[j]);
      }
      do{
         cout << subs << endl;
      }
      while (next_permutation(subs.begin(), subs.end()));
   }
}
A
B
AB
BA
C
AC
CA
BC
CB
ABC
ACB
BAC
BCA
CAB
CBA
D
AD
DA
BD
DB
ABD
ADB
BAD
BDA
DAB
DBA
CD
DC
ACD
ADC
CAD
CDA
DAC
DCA
BCD
BDC
CBD
CDB
DBC
DCB
ABCD
ABDC
ACBD
ACDB
ADBC
ADCB
BACD
BADC
BCAD
BCDA
BDAC
BDCA
CABD
CADB
CBAD
CBDA
CDAB
CDBA
DABC
DACB
DBAC
DBCA
DCAB
DCBA
Grant a user permission to only view a MySQL view?

To grant a user permission to only view a MySQL view, use the below syntax
GRANT SELECT ON yourDatabaseName.yourViewName TO ' yourUserName@'yourLocalHost';
First you need to display all the view names from a table. The syntax is as follows −
SHOW FULL TABLES IN yourDatabaseName WHERE TABLE_TYPE LIKE 'VIEW';
Now implement the above syntax to display all views from a database. Here I am using the database name ‘test’. The query is as follows −
mysql> SHOW FULL TABLES IN test WHERE TABLE_TYPE LIKE 'VIEW';
The following is the output −
+-------------------------------+------------+
| Tables_in_test                | Table_type |
+-------------------------------+------------+
| empidandempname_view          | VIEW       |
| empinfoview                   | VIEW       |
| lookuptable                   | VIEW       |
| view_student                  | VIEW       |
| viewemployeeidandemployeename | VIEW       |
+-------------------------------+------------+
5 rows in set (0.00 sec)
Display all user name and host from MySQL.user table. The query is as follows −
mysql> select user,host from MySQL.user;
The following is the output −
+------------------+-----------+
| user             | host      |
+------------------+-----------+
| Manish           | %         |
| User2            | %         |
| mysql.infoschema | %         |
| mysql.session    | %         |
| mysql.sys        | %         |
| root             | %         |
| Adam Smith       | localhost |
| User1            | localhost |
| am               | localhost |
+------------------+-----------+
9 rows in set (0.00 sec)
Grant the user as well as host. Now, use the database ‘test’ and view is ‘viewemployeeidandemployeename’. To grant it to ‘Adam Smith'@'localhost’, the following is the query −
mysql> GRANT SELECT ON test. viewemployeeidandemployeename TO ' Adam Smith'@'localhost';
Query OK, 0 rows affected (0.18 sec)
How to perform mouseover function in Selenium WebDriver using Java?

A mouse hover is done on an element to fire an event on that element. If we hover on the menus of a webpage the submenus appears. Thus this event gets triggered on hovering on an element.
It is evident from the above image that on hovering over the Packages menu the color of the text changed along with the tooltip display. Selenium has the Actions class that contains multiple APIs for mouse cursor movement.
The moveToElement() method is used to perform mouse movement. We have to import org.openqa.selenium.interactions.Actions for Action class. Along with moveToElement() we have to use the perform() method to make the mouse movement.
Code Implementation.
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.interactions.Actions;
public class MouseHover{
   public static void main(String[] args) {
      System.setProperty("webdriver.chrome.driver", "C:\\Users\\ghs6kor\\Desktop\\Java\\chromedriver.exe");
      WebDriver driver = new ChromeDriver();
      String url = "https://www.tutorialspoint.com/index.htm";
      driver.get(url);
      driver.manage().timeouts().implicitlyWait(12, TimeUnit.SECONDS);
      // identify element
      WebElement l=driver.findElement(By.xpath("//span[text()='Jobs']"));
      // Actions class with moveToElement()
      Actions a = new Actions(driver);
      a.moveToElement(l).perform();
      System.out.println("Tooltip: "+ l.getText());
      driver.quit();
   }
}
How to Remove the computer from the AD domain using PowerShell?

To remove the computer from the domain we need to use the Remove-Computer command.
Remove-Computer -ComputerName Test1-win2k16 `
                -UnjoinDomainCredential Labdomain\Administrator `
                -WorkgroupName WG -Restart -Force -PassThru
In the above example, the Computer name Test1-Win2k16 is going to remove from the domain with the domain credentials and it will be joined to WorkGroup named WG. If the system doesn’t restart due to any reason, you need to reboot the system manually.
Here the computer name is the String[]. So you can provide multiple computers to remove from the domain. For example,
Remove-Computer -ComputerName Test1-win2k16, Test1-Win2k12 `
                -UnjoinDomainCredential Labdomain\Administrator `
                -WorkgroupName WG -Restart -Force -PassThru
GATE | GATE CS 2008 | Question 55 - GeeksforGeeks

14 Sep, 2021
An LALR(1) parser for a grammar G can have shift-reduce (S-R) conflicts if and only if(A) the SLR(1) parser for G has S-R conflicts(B) the LR(1) parser for G has S-R conflicts(C) the LR(0) parser for G has S-R conflicts(D) the LALR(1) parser for G has reduce-reduce conflictsAnswer: (B)Explanation:Both LALR(1) and LR(1) parser uses LR(1) set of items to form their parsing tables. And LALR(1) states can be find by merging LR(1) states of LR(1) parser that have the same set of first components of their items.
i.e. if LR(1) parser has 2 states I and J with items A->a.bP,x and A->a.bP,y respectively, where x and y are look ahead symbols, then as these items are same with respect to their first component, they can be merged together and form one single state, let’s say K. Here we have to take union of look ahead symbols. After merging, State K will have one single item as A->a.bP,x,y . This way LALR(1) states are formed ( i.e. after merging the states of LR(1) ).
Now, S-R conflict in LR(1) items can be there whenever a state has items of the form :

A-> a.bB , p
C-> d. , b

i.e. it is getting both shift and reduce at symbol b, 
hence a conflict. 
Now, as LALR(1) have items similar to LR(1) in terms of their first component, shift-reduce form will only take place if it is already there in LR(1) states. If there is no S-R conflict in LR(1) state it will never be reflected in the LALR(1) state obtained by combining LR(1) states.
Note: But this process of merging may introduce R-R conflict, and then the Grammar won’t be LALR(1).
YouTubeGeeksforGeeks GATE Computer Science16.1K subscribersPYQ - Parsing and SDT (Continued) Part 4 with Joyojyoti Acharya | GeeksforGeeks GATEWatch laterShareCopy linkInfoShoppingTap to unmuteIf playback doesn't begin shortly, try restarting your device.You're signed outVideos you watch may be added to the TV's watch history and influence TV recommendations. To avoid this, cancel and sign in to YouTube on your computer.CancelConfirmMore videosMore videosSwitch cameraShareInclude playlistAn error occurred while retrieving sharing information. Please try again later.Watch on0:000:0016:55 / 58:40•Live•<div class="player-unavailable"><h1 class="message">An error occurred.</h1><div class="submessage"><a href="https://www.youtube.com/watch?v=LdMTs93sekg" target="_blank">Try watching this video on www.youtube.com</a>, or enable JavaScript if it is disabled in your browser.</div></div>Quiz of this Question
GATE-CS-2008
GATE-GATE CS 2008
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
GATE | GATE-IT-2004 | Question 71
GATE | GATE CS 2011 | Question 7
GATE | GATE-CS-2016 (Set 2) | Question 48
GATE | GATE CS 2010 | Question 24
GATE | GATE-CS-2015 (Set 3) | Question 65
GATE | GATE-CS-2016 (Set 1) | Question 65
GATE | GATE-CS-2014-(Set-3) | Question 38
GATE | GATE CS 2018 | Question 37
GATE | GATE-IT-2004 | Question 83
GATE | GATE-CS-2016 (Set 1) | Question 63
How to handle errors in middleware C# Asp.net Core?

Create a new folder named CustomExceptionMiddleware and a class
ExceptionMiddleware.cs inside it.
The first thing we need to do is to register our IloggerManager service and
RequestDelegate through the dependency injection.
The _next parameter of RequestDeleagate type is a function delegate that can process
our HTTP requests.
After the registration process, we need to create the InvokeAsync() method.
RequestDelegate can’t process requests without it.
The _next delegate should process the request and the Get action from our controller
should generate a successful response. But if a request is unsuccessful (and it is,
because we are forcing exception),
our middleware will trigger the catch block and call the HandleExceptionAsync
method.
public class ExceptionMiddleware{
   private readonly RequestDelegate _next;
   private readonly ILoggerManager _logger;
   public ExceptionMiddleware(RequestDelegate next, ILoggerManager logger){
      _logger = logger;
      _next = next;
   }
   public async Task InvokeAsync(HttpContext httpContext){
      try{
            await _next(httpContext);
      }
      catch (Exception ex){
         _logger.LogError($"Something went wrong: {ex}");
         await HandleExceptionAsync(httpContext, ex);
      }
   }
   private Task HandleExceptionAsync(HttpContext context, Exception exception){
      context.Response.ContentType = "application/json";
      context.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
      return context.Response.WriteAsync(new ErrorDetails(){
         StatusCode = context.Response.StatusCode,
         Message = "Internal Server Error from the custom middleware."
      }.ToString());
   }
}
Modify our ExceptionMiddlewareExtensions class with another static method −
public static void ConfigureCustomExceptionMiddleware(this IApplicationBuilder
app){
   app.UseMiddleware<ExceptionMiddleware>();
}
use this method in the Configure method in the Startup class −
app.ConfigureCustomExceptionMiddleware();
Scala Int round() method with example - GeeksforGeeks

30 Jan, 2020
The round() method is utilized to return the rounded value of the specified int value. This method is used to avoid accidental loss of precision from a detour through Float.
Method Definition: def round: Int
Return Type: It returns the rounded value of the specified int value.
Example #1:
// Scala program of Int round// method     // Creating object object GfG {          // Main method     def main(args:Array[String])     {                 // Applying round method         val result = (5).round                                // Displays output         println(result)             } }  
5

Example #2:
// Scala program of Int round// method     // Creating object object GfG {          // Main method     def main(args:Array[String])     {                 // Applying round method         val result = (5.8).round                                // Displays output         println(result)             } } 
6

Scala
Scala-Method
Scala
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Scala Map
Type Casting in Scala
Scala Lists
Scala List contains() method with example
Scala Tutorial – Learn Scala with Step By Step Guide
Scala String substring() method with example
Scala | Arrays
How to get the first element of List in Scala
Scala String replace() method with example
Lambda Expression in Scala
GATE | GATE-CS-2017 (Set 2) | Question 31 - GeeksforGeeks

10 Sep, 2021
Which of the following statements about the parser is/are correct?
I. Canonical LR is more powerful than SLR.
II. SLR is more powerful than LALR.
III. SLR is more powerful than canonical LR.

(A) I only(B) II only(C) III only(D) II and III onlyAnswer: (A)Explanation: LR parsers in term of power
CLR > LALR > SLR > LR(0)
Therefore, Option A is only correct option.
YouTubeGeeksforGeeks GATE Computer Science16.3K subscribersGATE PYQ - Parsing and SDT (Continued) Part 3 with Joyojyoti AcharyaWatch laterShareCopy linkInfoShoppingTap to unmuteIf playback doesn't begin shortly, try restarting your device.You're signed outVideos you watch may be added to the TV's watch history and influence TV recommendations. To avoid this, cancel and sign in to YouTube on your computer.CancelConfirmMore videosMore videosSwitch cameraShareInclude playlistAn error occurred while retrieving sharing information. Please try again later.Watch on0:000:001:02 / 52:18•Live•<div class="player-unavailable"><h1 class="message">An error occurred.</h1><div class="submessage"><a href="https://www.youtube.com/watch?v=Sn5eIxvrNBc" target="_blank">Try watching this video on www.youtube.com</a>, or enable JavaScript if it is disabled in your browser.</div></div>Quiz of this Question
GATE-CS-2017 (Set 2)
GATE-GATE-CS-2017 (Set 2)
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | Gate IT 2007 | Question 25
GATE | GATE-CS-2001 | Question 39
GATE | GATE-CS-2005 | Question 6
GATE | GATE MOCK 2017 | Question 21
GATE | GATE-CS-2006 | Question 47
GATE | GATE MOCK 2017 | Question 24
GATE | Gate IT 2008 | Question 43
GATE | GATE-CS-2009 | Question 38
GATE | GATE-CS-2000 | Question 41
GATE | GATE-CS-2003 | Question 90
Get Application Version using Python - GeeksforGeeks

02 Feb, 2021
Software versioning maybe thanks to reasoning the distinctive states of pc software package because it is developed and discharged. The version symbol is typically a word, a number, or both. For instance, version 1.0 is often accustomed to denote the initial unharness of a program. In this article, we will see how to get an application version number using Python.
Method 1: Here will use the win32api module.
Python extensions for Microsoft Windows Provide access to a lot of the Win32 API, the flexibility to make and use COM objects, and therefore the Pythonwin atmosphere.
Before getting started, we need to install the Module
pip install pywin32
Here we will use these methods:
GetFileVersionInfo: This method is used for retrieving the version information for a given file
GetFileVersionInfo(File Path, SubBlock, **attr)
LOWORD: An interface to the win32api LOWORD macro. Value is of integer datatype
LOWORD(val)
HIWORD: An interface to the win32api HIWORD macro. Value is of integer datatype
HIWORD(val)
Approach:
First we will parse file information using GetFileVersionInfo() method.
File information is in the form of a dictionary, we will fetch two information, one is msfileversion and another one is lsfileversion
Below is the implementation:
Python3
# Import Modulefrom win32api import *  def get_version_number(file_path):      File_information = GetFileVersionInfo(file_path, "\\")      ms_file_version = File_information['FileVersionMS']    ls_file_version = File_information['FileVersionLS']      return [str(HIWORD(ms_file_version)), str(LOWORD(ms_file_version)),            str(HIWORD(ls_file_version)), str(LOWORD(ls_file_version))]  file_path = r'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe'  version = ".".join(get_version_number(file_path))  print(version)
Output:
88.0.4324.104
Method 2: Using win32com
Here will use the win32com module. Before getting started we need to install the Module
pip install pypiwin32
Approach:
We will create an information parser that will parse the required information using Dispatch() method.
Then we will fetch the file version using the GetFileVersion() method.
Below is the implementation:
Python3
# Import Modulefrom win32com.client import *  def get_version_number(file_path):      information_parser = Dispatch("Scripting.FileSystemObject")    version = information_parser.GetFileVersion(file_path)    return version  file_path = r'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe'version = get_version_number(file_path)  print(version)
Output:
88.0.4324.104
python-utility
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python Classes and Objects
How to drop one or multiple columns in Pandas Dataframe
Python | Get unique values from a list
Defaultdict in Python
Python | os.path.join() method
Create a directory in Python
Python | Pandas dataframe.groupby()