code-rag-bench/online-tutorials huggingface dataset:
PyQt5 QScrollBar – Setting Value - GeeksforGeeks

04 Aug, 2021
In this article we will see how we can set the value of QScrollBar. QScrollBar is a control that enables the user to access parts of a document that is larger than the widget used to display it. Slider is the scroll-able object inside the bar. Value is basically depend upon the slider position, scroll bar value changes according to the position of the slider, value increases when slider goes down and decreases when slider moves up. 
In order to do this we will use setValue method with the scroll bar object.Syntax : scroll.setValue(n)Argument : It takes integer as argumentReturn : It returns None  
Example : Below 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, 500, 400)         # calling method        self.UiComponents()         # showing all the widgets        self.show()       # method for components    def UiComponents(self):         scroll = QScrollBar(self)         # setting geometry of the scroll bar        scroll.setGeometry(100, 50, 30, 200)         # setting value of scroll bar        scroll.setValue(25)         # making its background color to green        scroll.setStyleSheet("background : lightgrey;")         # creating a label        label = QLabel("GeesforGeeks", self)         # setting geometry to the label        label.setGeometry(200, 100, 300, 80)         # making label multi line        label.setWordWrap(True)  # create pyqt5 appApp = QApplication(sys.argv) # create the instance of our Windowwindow = Window() # start the appsys.exit(App.exec())
Output :  
 
kalrap615
Python PyQt-QScrollBar
Python-gui
Python-PyQt
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Python | os.path.join() method
Python | Pandas dataframe.groupby()
Create a directory in Python
Defaultdict in Python
Python | Get unique values from a list
Reverse a Stack using C#

Set a stack and add elements to it.
Stack st = new Stack();
st.Push('P');
st.Push('Q');
st.Push('R');
Now set another stack to reverse it.
Stack rev = new Stack();
Until the count of ths Stack is not equal to 0, use the Push and Pop method to reverse it.
while (st.Count != 0) {
   rev.Push(st.Pop());
}
The following is the complete code −
 Live Demo
using System;
using System.Collections;

namespace CollectionsApplication {
   public class Program {
      public static void Main(string[] args) {
         Stack st = new Stack();
         Stack rev = new Stack();
         st.Push('P');
         st.Push('Q');
         st.Push('R');
         Console.WriteLine("Current stack: ");
         foreach(char c in st) {
            Console.Write(c + " ");
         }
         Console.WriteLine();
         while (st.Count != 0) {
            rev.Push(st.Pop());
         }
         Console.WriteLine("Reversed stack: ");
         foreach(char c in rev) {
            Console.Write(c + " ");
         }
      }
   }
}
Current stack:
R Q P
Reversed stack:
P Q R
HTML | File Paths

12 Aug, 2021
A file path specifies the location of a file inside a web folder structure. Its like an address of a file which helps the web browser to access the files. File paths are used to link external resources such as images, videos, style sheets, JavaScript, displaying other web pages etc.To insert a file in a web page its source must be known. For example, the syntax (<img src=” ” alt=” “>) is used to insert an image file, where the path of the file is mentioned in the source (src). File paths are of two types:  
Absolute File Paths
Relative File Paths
Absolute File Paths: It describes the full address(URL) to access an internet file.  
<img src=”https://media.geeksforgeeks.org/wp-content/uploads/geek.png” alt=”My Image”>
 Example:  
html
<!DOCTYPE html><html>    <head>        <title>Absolute file path</title>    </head>    <body>        <img src="https://media.geeksforgeeks.org/wp-content/uploads/geek.png"        alt="My Image" style="width:400px">    </body></html>                   
Output:  
Relative File Path: It describes the path of the file relative to the location of the current web page file. Example 1: It shows the path of the file present in the same folder of the current web page file.  
html
<!DOCTYPE html><html>    <head>        <title>Relative file path</title>    </head>    <body>        <h2>File present in the same folder</h2>        <img src="images/geeks.jpg" alt="My Image" style="width:400px">    </body></html>                   
Output:  
Example 2: It shows the path of the file present in a folder above the folder of the current web page file. The image file present in a folder called images and current web page file exists inside a sub folder, then the code will be as follows:  
html
<!DOCTYPE html><html>    <head>        <title>Relative file path</title>    </head>    <body>        <h2>File present in a folder above the current folder</h2>        <img src="../images/geeks.jpg" alt="My Image" style="width:400px">    </body></html>                   
Output:  
Example 3: It shows the path of the file present in a folder which is located at the root of the current sub directories.  
html
<!DOCTYPE html><html>    <head>        <title>Relative file path</title>    </head>    <body>        <h2>File present in a folder which is located at<br>        the root of the current subdirectories</h2>        <img src="/images/picture.jpg" alt="My Image" style="width:400px">    </body></html>                   
Output:  
Supported Browser:
Google Chrome
Microsoft Edge
Firefox
Opera
Safari 
CSS is the foundation of webpages, is used for webpage development by styling websites and web apps.You can learn CSS from the ground up by following this CSS Tutorial and CSS Examples.
 
Akanksha_Rai
ysachin2314
HTML-Basics
Picked
CSS
HTML
Web technologies Questions
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
PyCairo – Saving SVG Image file to PNG file

12 Nov, 2020
In this article, we will see how we can save an SVG file to a PNG file using PyCairo in Python. We can create an SVG file using SVGSurface method. An SVG file is a graphics file that uses a two-dimensional vector graphic format created by the World Wide Web Consortium (W3C). It describes images using a text format that is based on XML. SVG files are developed as a standard format for displaying vector graphics on the web.
PNG : Portable Network Graphics is a raster-graphics file format that supports lossless data compression. PNG was developed as an improved, non-patented replacement for Graphics Interchange Format. PNG supports palette-based images, grayscale images, and full-color non-palette-based RGB or RGBA images.
PyCairo : Pycairo is a Python module providing bindings for the cairo graphics library. This library is used for creating SVG i.e vector files in python. The easiest and quickest way to open an SVG file to view it (read-only) is with a modern web browser like Chrome, Firefox, Edge, or Internet Explorer—nearly all of them should provide some sort of rendering support for the SVG format.  
In order to this we will use write_to_png method with the SVGSurface objectSyntax : surface.write_to_png(‘geeks.png’)Argument : File name to be savedReturn : It returns None 
Below is the implementation. 
Python3
# importing pycairoimport cairo  # creating a SVG surface# here geek is file name & 700, 700 is dimensionwith cairo.SVGSurface("geek.svg", 700, 700) as surface:      # creating a cairo context object    context = cairo.Context(surface)      # creating a rectangle(square) for left eye    context.rectangle(100, 100, 100, 100)      # creating a rectangle(square) for right eye    context.rectangle(500, 100, 100, 100)      # creating position for the curves    x, y, x1, y1 = 0.1, 0.5, 0.4, 0.9    x2, y2, x3, y3 = 0.4, 0.1, 0.9, 0.6      # setting scale of the context    context.scale(700, 700)      # setting line width of the context    context.set_line_width(0.04)      # move the context to x,y position    context.move_to(x, y)      # draw the curve for smile    context.curve_to(x1, y1, x2, y2, x3, y3)      # setting color of the context    context.set_source_rgba(0.4, 1, 0.4, 1)      # stroke out the color and width property    context.stroke()      # Save as a SVG and PNG    surface.write_to_png('geek.png')    # printing message when file is savedprint("File Saved")
Output : 
 
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Convert String to Double in Java

22 Apr, 2022
Here, we will convert String to Double in Java. There are 3 methods for this conversion as mentioned below:
Illustration:  
Input : String = "20.156"
Output: 20.156
Input  : String = "456.21"
Output : 456.21
Using parseDouble() method of Double classUsing valueOf() method of Double classUsing constructor of Double class 
Using parseDouble() method of Double class
Using valueOf() method of Double class
Using constructor of Double class 
Syntax: 
double str1 = Double.parseDouble(str); 
Example:
Java
// Java program to convert String to Double// Using parseDouble() Method of Double Class // Main classpublic class GFG {     // Main driver method    public static void main(String args[])    {         // Create and initializing a string        String str = "2033.12244";         // Converting the above string into Double        // using parseDouble() Method        double str1 = Double.parseDouble(str);         // Printing string as Double type        System.out.println(str1);    }}
2033.12244
 
Syntax:
double str1 = Double.valueOf(str); 
Example:
Java
// Java program to convert String to Double// using valueOf() Method of Double Class // Main classpublic class GFG {     // Main driver method    public static void main(String args[])    {         // Creating and initializing a string        String str = "2033.12244";         // Converting the above string to Double type        double str1 = Double.valueOf(str);         // Printing above string as double type        System.out.println(str1);    }}
2033.12244
 
Syntax:
Double str1 = new Double(str); 
Example:
Java
// Java program to convert String to Double// Using Constructor of Double class // Main classpublic class GFG {     // Main driver method    public static void main(String args[])    {         // Creating and initializing a string        String str = "2033.12244";         // Converting above string into double type        Double str1 = new Double(str);         // print above string as Double type        System.out.println(str1);    }}
2033.12244
 
solankimayank
Java-Double
Java-String-Programs
Java-Strings
Technical Scripter 2018
Java
Technical Scripter
Java-Strings
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Object Oriented Programming (OOPs) Concept in Java
How to iterate any Map in Java
Interfaces in Java
HashMap in Java with Examples
ArrayList in Java
Stream In Java
Collections in Java
Multidimensional Arrays in Java
Singleton Class in Java
Stack Class in Java
How to find first value from any table in SQL Server

23 Nov, 2020
We could use FIRST_VALUE() in SQL Server to find the first value from any table. FIRST_VALUE() function used in SQL server is a type of window function that results in the first value in an ordered partition of the given data set.
Syntax :
SELECT *,
FROM tablename;
FIRST_VALUE ( scalar_value )  
OVER (  
  [PARTITION BY partition_value ]
  ORDER BY sort_value [ASC | DESC]
  ) AS columname ; 

Syntax descriptions :
scalar_value –scalar_value is a value examined over the value of the first row in an ordered partition of the provided data set.
PARTITION BY –PARTITION BY is optional, it differs the rows of the provided data set into the partitions where the FIRST_VALUE() function is used.
ORDER BY –ORDER BY states the order of the rows in each of the  partition where the  FIRST_VALUE()function is used.
Examples :
Let us suppose we have a table named ‘geek_demo’:
SELECT TOP 1000 [Name]
     ,[City], [Year]
FROM [geek_demo];
Example-1 : 
Find FIRST VALUE without PARTITION BY clause.
To find the first city for the table ‘geek-demo’ use below query:
SELECT [Name],   [Year],
        FIRST_VALUE(City) OVER (
          ORDER BY City ASC
      ) AS  First_City
FROM geek_demo;
Output :
Example-2 : 
Find FIRST VALUE with PARTITION BY clause.
To find the first city according to the year for the table ‘geek-demo’ use below query:
SELECT TOP 1000 [Name] , [Year] ,
        FIRST_VALUE(City) OVER (
        PARTITION BY Year
          ORDER BY City ASC
      ) AS  First_City
FROM geek_demo;
Output :
DBMS-SQL
SQL-Server
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
sync command in Linux with Examples

18 Jan, 2022
sync command in Linux is used to synchronize cached writes to persistent storage. If one or more files are specified, sync only them, or their containing file systems. 
Syntax:  
sync [OPTION] [FILE]...
Note: Nothing is being shown in the screenshots just because sync command makes the cache in the background. 
Example: It will be going to sync all cached file data that belongs to the current user. 
Options: 
sync -d: This option sync only file data, no unneeded metadata. Example: 
Example: 
sync -d /home/algoscale/Desktop/aricleslist.txt /home/algoscale/Desktop/advance.html
 
sync -f: This option will sync the file systems which contains the files. Example: 
Example: 
sync -f /home/algoscale/Desktop/aricleslist.txt
 
sync –help: This option display the help text and exit. 
sync --help
 
sync –version: This option will output version information and exit. 
sync --version
 
sumitgumber28
linux-command
Linux-misc-commands
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install Code Blocks for C++ on Linux?

06 Oct, 2021
Code::Blocks is a free IDE( an integrated development environment), for C/C++ and FORTRAN languages. It is a cross-platform IDE and available for Windows, Mac, and Linux, In this article, we are going to discuss various methods using which we can install Code Blocks on Linux.:
Follow the below steps to install Code Blocks for C++ on Linux using the apt install terminal command:
Step 1: Before starting the actual installation, we must have the GCC compiler installed on our system. To install GCC run the following command in your terminal.
sudo apt install g++
Output:
installing GCC compiler.
As we have already installed the GCC compiler it is displaying, g++ is already installed with the newer version.
 Step 2: Now, we just have to install the code blocks using the following command and confirm the installation by pressing “Y”:
sudo apt install codeblocks
Output:
installing codeblocks
 Step 3: To open the code blocks navigate to the activities launcher (search) and type code blocks, you will see code blocks icons, click on the icon to install the code block.
Opening Code blocks
Follow the below steps to install Code Blocks for C++ on Linux:
 Step 1: Open up the software manager that you have using the activity launcher.
Installing through the software center
Step 2: Search for Code blocks and click on the code blocks.
Downloading code blocks
Step 3: Select the first one the Code::Blocks and click on the install button, wait for the installation to be finished, then open the code blocks
installing code blocks.
how-to-install
Picked
How To
Installation Guide
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Set Git Username and Password in GitBash?
How to Install Jupyter Notebook on MacOS?
How to Install and Use NVM on Windows?
How to Install Python Packages for AWS Lambda Layers?
How to Add External JAR File to an IntelliJ IDEA Project?
Installation of Node.js on Linux
Installation of Node.js on Windows
How to Install Jupyter Notebook on MacOS?
How to Install and Use NVM on Windows?
How to Install Python Packages for AWS Lambda Layers?
A C Programming Language Puzzle - GeeksforGeeks

21 Jun, 2018
Give a = 12 and b = 36 write a C function/macro that returns 3612 without using arithmetic, strings and predefined functions.
We strongly recommend you to minimize your browser and try this yourself first.
Below is one solution that uses String Token-Pasting Operator (##) of C macros. For example, the expression “a##b” prints concatenation of ‘a’ and ‘b’.
Below is a working C code.
#include <stdio.h>#define merge(a, b) b##aint main(void){    printf("%d ", merge(12, 36));    return 0;}
Output:
3612
Thanks to an anonymous user to suggest this solution.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above
C-Macro & Preprocessor
cpp-macros
cpp-puzzle
C Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
TCP Server-Client implementation in C
Exception Handling in C++
Multithreading in C
Arrow operator -> in C/C++ with Examples
'this' pointer in C++
How to split a string in C/C++, Python and Java?
Smart Pointers in C++ and How to Use Them
How to dynamically allocate a 2D array in C?
UDP Server-Client implementation in C
Input-output system calls in C | Create, Open, Close, Read, Write
Groovy - equals()

The method determines whether the Number object that invokes the method is equal to the object that is passed as argument.
public boolean equals(Object o)

o - Any object.
The methods returns True if the argument is not null and is an object of the same type and with the same numeric value.
Following is an example of the usage of this method −
class Example { 
   static void main(String[] args) { 
      Integer x = 5; 
      Integer y = 10; 
      Integer z = 5; 
		
      //Comparison against an Integer of different value 
      System.out.println(x.equals(y));
		
      //Comparison against an Integer of same value 
      System.out.println(x.equals(z));  
   } 
}
When we run the above program, we will get the following result −
false 
true


    52 Lectures 
     8 hours 

 Krishna Sakinala

    49 Lectures 
     2.5 hours 

 Packt Publishing
 Print
 Add Notes
 Bookmark this page
Apache Pig - SIZE()

The SIZE() function of Pig Latin is used to compute the number of elements based on any Pig data type.
Given below is the syntax of the SIZE() function.
grunt> SIZE(expression)

The return values vary according to the data types in Apache Pig.
Assume that we have a file named employee.txt in the HDFS directory /pig_data/ as shown below.
employee.txt
1,John,2007-01-24,250
2,Ram,2007-05-27,220  
3,Jack,2007-05-06,170  
3,Jack,2007-04-06,100  
4,Jill,2007-04-06,220  
5,Zara,2007-06-06,300  
5,Zara,2007-02-06,350 

And we have loaded this file into Pig with the relation name employee_data as shown below.
grunt> employee_data = LOAD 'hdfs://localhost:9000/pig_data/ employee.txt' USING PigStorage(',')
   as (id:int, name:chararray, workdate:chararray, daily_typing_pages:int);
To calculate the size of the type of a particular column, we can use the SIZE() function.  Let’s calculate the size of the name type as shown below.
grunt> size = FOREACH employee_data GENERATE SIZE(name);
Verify the relation size using the DUMP operator as shown below.
grunt> Dump size;
It will produce the following output, displaying the contents of the relation size as follows. In the example, we have calculated the size of the name column. Since it is of varchar type, the SIZE() function gives you the number of characters in the name of each employee.
(4) 
(3) 
(4) 
(4) 
(4) 
(4) 
(4) 


    46 Lectures 
     3.5 hours 

 Arnab Chakraborty

    23 Lectures 
     1.5 hours 

 Mukund Kumar Mishra

    16 Lectures 
     1 hours 

 Nilay Mehta

    52 Lectures 
     1.5 hours 

 Bigdata Engineer

    14 Lectures 
     1 hours 

 Bigdata Engineer

    23 Lectures 
     1 hours 

 Bigdata Engineer
 Print
 Add Notes
 Bookmark this page
C++ program to print unique words in a file

A file is a memory location that stores word streams. In a file, there are various words. In this program, we will find all unique words from the file and print them.
A unique word means the number of occurrences of the word is one in the file.
For example,
Tutorials point is best for programming tutorials.
Here, the word tutorial occurs more than once, hence it is not unique. Rest all words are unique.
To check for unique words in the given file.
Using iterator with two variables : data and occurence.
Input : File
Step 1 : Read each line from the file and follow step 2
Step 2 : check for the occurence of the word in the data structure using interator.data.
   Step 2.1 : if data matches increase the occurrence by one corresponding to the data.
   Step 2.2 : if data does not match add new value and set its occurence to one.
Step 3: Iterate over the date structure. And check for occurence value of each value.
   Step 3.1 : If the occerence is equals to 1 then prints the data corresponding it else do nothing.
#include <bits/stdc++.h>
using namespace std;
int main(){
   char filename[] = "test.txt";
   ofstream fs("test.txt", ios::trunc);
   fs << "tutorials point is best for programming tutorials";
   fs.close();
   fstream fs("test.txt");
   map<string, int> mp;
   string word;
   while (fs >> word){
      if (!mp.count(word))
         mp.insert(make_pair(word, 1));
      else
         mp[word]++;
   }
   fs.close();
   for (map<string, int> :: iterator p = mp.begin();
   p != mp.end(); p++){
      if (p->second == 1)
         cout << p->first << endl;
   }
   return 0;
}
best
for
is
point
Programming
What are the differences between a dictionary and an array in C#?

Dictionary is a collection of keys and values in C#. Dictionary is included in the System.Collection.Generics namespace.
To declare a Dictionary −
IDictionary<int, int> d = new Dictionary<int, int>();
To add elements −
IDictionary<int, int> d = new Dictionary<int, int>();
d.Add(1,97);
d.Add(2,89);
d.Add(3,77);
d.Add(4,88);
Array stores a fixed-size sequential collection of elements of the same type. It consists of contiguous memory locations. The lowest address corresponds to the first element and the highest address to the last element.
To define Arrays −
int[] arr = new int[5];

To initialize and set elements to Arrays.
int[] arr = new int[10] {3, 5, 35, 87, 56, 99, 44, 36, 78};
DayOfWeek of() method in Java with Examples - GeeksforGeeks

19 Mar, 2019
The of() method of java.time.DayOfWeek is an in-built function in Java which returns an instance of DayOfWeek from an int value. The int value ranges between 1 (Monday) to 7 (Sunday).
Method Declaration:
public static DayOfWeek of(int dayOfWeek)

Syntax:
DayOfWeek dayOfWeekObject = DayOfWeek.of(int dayOfWeek)

Parameters: This method takes dayOfWeek as parameter where:
dayOfWeek – is the int value from 1 (Monday) to 7 (Sunday).
dayOfWeekObject – is an instance of the DayOfWeek object.
Return Value: The function returns an instance of DayOfWeek object.
Below programs illustrate the above method:Program 1:
// Java Program Demonstrate of()// method of DayOfWeekimport java.time.DayOfWeek;  class DayOfWeekExample {    public static void main(String[] args)    {        // Getting an instance of DayOfWeek from int value        DayOfWeek dayOfWeek = DayOfWeek.of(4);          // Printing the day of the week        // and its Int value        System.out.println("Day of the Week - "                           + dayOfWeek.name());        System.out.println("Int Value of "                           + dayOfWeek.name() + " - "                           + dayOfWeek.getValue());    }}
Day of the Week - THURSDAY
Int Value of THURSDAY - 4

Program 2:
// Java Program Demonstrate of()// method of DayOfWeekimport java.time.DayOfWeek;  class DayOfWeekExample {    public static void main(String[] args)    {        // Getting an instance of DayOfWeek from int value        DayOfWeek dayOfWeek = DayOfWeek.of(7);          // Printing the day of the week        // and its Int value        System.out.println("Day of the Week - "                           + dayOfWeek.name());        System.out.println("Int Value of "                           + dayOfWeek.name() + " - "                           + dayOfWeek.getValue());    }}
Day of the Week - SUNDAY
Int Value of SUNDAY - 7

Reference: https://docs.oracle.com/javase/8/docs/api/java/time/DayOfWeek.html#of-int-
Java - util package
Java-DayOfWeek
Java-Functions
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Initialize an ArrayList in Java
Object Oriented Programming (OOPs) Concept in Java
HashMap in Java with Examples
Interfaces in Java
How to iterate any Map in Java
ArrayList in Java
Multidimensional Arrays in Java
Stream In Java
Stack Class in Java
Singleton Class in Java
Allow wrapping of flex items in Bootstrap on different screens

To allow wrapping of flex items on different screens, use the flex-*-wrap class. The flex-wrap for varied screen sizes work for small, medium, large and extra large screens.
For example, use the flex-lg-wrap class to wrap flex items on large screen −
<div class="d-flex flex-lg-wrap bg-primary">
For small screen −
<div class="d-flex flex-sm-wrap bg-primary">
You can try to run the following code to implement the flex-*-wrap class to wrap flex items on small and large screen size −
Live Demo
<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Bootstrap Example</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
   </head>

   <body>
     <div class="container mt-3">
       <h3>Flex Examples</h3>
       <p>Wrap - Yes</p>
       <div class="d-flex flex-wrap bg-primary">
         <div class="p-2 border">Poland</div>
         <div class="p-2 border">Netherlands</div>
         <div class="p-2 border">Ireland</div>
         <div class="p-2 border">Brazil</div>
         <div class="p-2 border">India</div>
         <div class="p-2 border">US</div>
         <div class="p-2 border">Bangladesh</div>
         <div class="p-2 border">Russia</div>
         <div class="p-2 border">Morocco</div>
         <div class="p-2 border">UK</div>
         <div class="p-2 border">Australia</div>
         <div class="p-2 border">Denmark</div>
       </div>
       <br>
       <p>Will wrap on Small Screen</p>
       <div class="d-flex flex-sm-wrap bg-primary">
         <div class="p-2 border">Poland</div>
         <div class="p-2 border">Netherlands</div>
         <div class="p-2 border">Ireland</div>
         <div class="p-2 border">Brazil</div>
         <div class="p-2 border">India</div>
         <div class="p-2 border">US</div>
         <div class="p-2 border">Bangladesh</div>
         <div class="p-2 border">Russia</div>
         <div class="p-2 border">Morocco</div>
         <div class="p-2 border">UK</div>
         <div class="p-2 border">Australia</div>
         <div class="p-2 border">Denmark</div>
       </div><br>
       <p>Will Wrap on Large Screen</p>
       <div class="d-flex flex-lg-wrap bg-primary">
         <div class="p-2 border">Poland</div>
         <div class="p-2 border">Netherlands</div>
         <div class="p-2 border">Ireland</div>
         <div class="p-2 border">Brazil</div>
         <div class="p-2 border">India</div>
         <div class="p-2 border">US</div>
         <div class="p-2 border">Bangladesh</div>
         <div class="p-2 border">Russia</div>
         <div class="p-2 border">Morocco</div>
         <div class="p-2 border">UK</div>
         <div class="p-2 border">Australia</div>
         <div class="p-2 border">Denmark</div>
       </div><br>
    </div>

 </body>
</html>
PyQt5 - QSpinBox Widget

A QSpinBox object presents the user with a textbox which displays an integer with up/down button on its right. The value in the textbox increases/decreases if the up/down button is pressed.
By default, the integer number in the box starts with 0, goes upto 99 and changes by step 1. Use QDoubleSpinBox for float values.
Important methods of QSpinBox class are listed in the following table −
setMinimum()
Sets the lower bound of counter
setMaximum()
Sets the upper bound of counter
setRange()
Sets the minimum, maximum and step value
setValue()
Sets the value of spin box programmatically
Value()
Returns the current value
singleStep()
Sets the step value of counter
QSpinBox object emits valueChanged() signal every time when up/own button is pressed. The associated slot function can retrieve current value of the widget by value() method.
Following example has a label (l1) and spinbox (sp) put in vertical layout of a top window. The valueChanged() signal is connected to valuechange() method.
self.sp.valueChanged.connect(self.valuechange)

The valueChange() function displays the current value as caption of the label.
self.l1.setText("current value:"+str(self.sp.value()))

The complete code is as follows −
import sys
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *

class spindemo(QWidget):
   def __init__(self, parent = None):
      super(spindemo, self).__init__(parent)
      
      layout = QVBoxLayout()
      self.l1 = QLabel("current value:")
      self.l1.setAlignment(Qt.AlignCenter)
      layout.addWidget(self.l1)
      self.sp = QSpinBox()
		
      layout.addWidget(self.sp)
      self.sp.valueChanged.connect(self.valuechange)
      self.setLayout(layout)
      self.setWindowTitle("SpinBox demo")
		
   def valuechange(self):
      self.l1.setText("current value:"+str(self.sp.value()))

def main():
   app = QApplication(sys.argv)
   ex = spindemo()
   ex.show()
   sys.exit(app.exec_())
	
if __name__ == '__main__':
   main()
The above code produces the following output −

    146 Lectures 
     22.5 hours 

 ALAA EID
 Print
 Add Notes
 Bookmark this page
Updating a MySQL column that contains dot (.) in its name?

If the MySQL column contains dot (.) in its name, then you need to use backticks around the column name.
To understand the above concept, let us create a table. The query to create a table is as follows
mysql> create table UpdateDemo
   -> (
   -> UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   -> `User.FirstName.LastName` varchar(60)
   -> );
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 UpdateDemo(`User.FirstName.LastName`) values('John Smith');
Query OK, 1 row affected (0.14 sec)
mysql> insert into UpdateDemo(`User.FirstName.LastName`) values('Adam Smith');
Query OK, 1 row affected (0.12 sec)
mysql> insert into UpdateDemo(`User.FirstName.LastName`) values('Carol Taylor');
Query OK, 1 row affected (0.25 sec)
mysql> insert into UpdateDemo(`User.FirstName.LastName`) values('Mitchell Johnson');
Query OK, 1 row affected (0.19 sec)
mysql> insert into UpdateDemo(`User.FirstName.LastName`) values('David Brown');
Query OK, 1 row affected (0.16 sec)
mysql> insert into UpdateDemo(`User.FirstName.LastName`) values('Larry Miller');
Query OK, 1 row affected (0.22 sec)
Display all records from the table using select statement.
The query is as follows
mysql> select *from UpdateDemo;
The following is the output
+--------+-------------------------+
| UserId | User.FirstName.LastName |
+--------+-------------------------+
| 1      | John Smith              |
| 2      | Adam Smith              | 
| 3      | Carol Taylor            |
| 4      | Mitchell Johnson        |
| 5      | David Brown             |
| 6      | Larry Miller            |
+--------+-------------------------+
6 rows in set (0.00 sec)
Use backticks around the column name User.FirstName.LastName which contains (.).
The query is as follows
mysql> update UpdateDemo set `User.FirstName.LastName`='David Miller' where UserId=5;
Query OK, 1 row affected (0.19 sec)
Rows matched: 1 Changed: 1 Warnings: 0
Let us check the table record once again. The row with UserId=5 is successfully updated.
The query is as follows
mysql> select *from UpdateDemo;
The following is the output
+--------+-------------------------+
| UserId | User.FirstName.LastName |
+--------+-------------------------+
| 1      | John Smith              |
| 2      | Adam Smith              |
| 3      | Carol Taylor            |
| 4      | Mitchell Johnson        |
| 5      | David Miller            |
| 6      | Larry Miller            |
+--------+-------------------------+
6 rows in set (0.00 sec)
C++ Program Structure

The best way to learn a programming language is by writing programs. Typically, the first program beginners write is a program called "Hello World", which simply prints "Hello World" to your computer screen. Although it is very simple, it contains all the fundamental components C++ programs have. Let's look at the code for this program −
#include<iostream>
int main() {
   std::cout << "Hello World\n";
}
Let's dissect this program.
Line 1 − We start with the #include<iostream> line which essentially tells the compiler to copy the code from the iostream file(used for managing input and output streams) and paste it in our source file.  Header iostream, that allows performing standard input and output operations, such as writing the output of this program (Hello World) to the screen. Lines beginning with a hash sign (#) are directives read and interpreted by what is known as the preprocessor.
Line 2 − A blank line: Blank lines have no effect on a program.
Line 3 − We then declare a function called main with the return type of int. main() is the entry point of our program. Whenever we run a C++ program, we start with the main function and begin execution from the first line within this function and keep executing each line till we reach the end. We start a block using the curly brace({) here. This marks the beginning of main's function definition, and the closing brace (}) at line 5, marks its end. All statements between these braces are the function's body that defines what happens when main is called.
Line 4 − 
std::cout << "Hello World\n";
This line is a C++ statement. This statement has three parts: First, std::cout, which identifies the standard console output device. Second the insertion operator << which indicates that what follows is inserted into std::cout. Last, we have a sentence within quotes that we'd like printed on the screen. This will become more clear to you as we proceed in learning C++.
In short, we provide cout object with a string "Hello world\n" to be printed to the standard output device.
Note that the statement ends with a semicolon (;). This character marks the end of the statement.
Absolute sum of array elements - JavaScript

We are required to write a JavaScript function that takes in an array with both positive and negative numbers and returns the absolute sum of all the elements of the array.
We are required to do this without taking help of any inbuilt library function.
For example: If the array is −
const arr = [1, -5, -34, -5, 2, 5, 6];
Then the output should be −
58
Following is the code −
const arr = [1, -5, -34, -5, 2, 5, 6];
const absoluteSum = arr => {
   let res = 0;
   for(let i = 0; i < arr.length; i++){
      if(arr[i] < 0){
         res += (arr[i] * -1);
         continue;
      };
      res += arr[i];
   };
   return res;
};
console.log(absoluteSum(arr));
Following is the output in the console −
58
Get today's date in (YYYY-MM-DD) format in MySQL?

To get today’s date in (YYYY-MM-DD) format in MySQL, you can use CURDATE().
Following is the query to get the current date:
mysql> SELECT CURDATE();
This will produce the following output:
+------------+
| CURDATE()  |
+------------+
| 2019-04-09 |
+------------+
1 row in set (0.00 sec)
You can also use NOW() for this. Following is the query:
mysql> SELECT DATE(NOW());
This will produce the following output
+-------------+
| DATE(NOW()) |
+-------------+
| 2019-04-09  |
+-------------+
1 row in set (0.00 sec)
Python Program to Implement a Stack

When it is required to implement a stack using Python, a stack class is created, and an instance of this class is created. Methods to push, pop elements are defined and the instance is used to call these methods.
Below is a demonstration of the same −
 Live Demo
class Stack_struct:
   def __init__(self):
      self.items = []

   def check_empty(self):
      return self.items == []

   def add_elements(self, my_data):
      self.items.append(my_data)

   def delete_elements(self):
      return self.items.pop()

my_instance = Stack_struct()
while True:
   print('Push <value>')
   print('Pop')
   print('Quit')
   my_input = input('What operation would you like to perform ? ').split()

   my_op = my_input[0].strip().lower()
   if my_op == 'push':
      my_instance.add_elements(int(my_input[1]))
   elif my_op == 'pop':
      if my_instance.check_empty():
         print('The stack is empty')
      else:
         print('The deleted value is : ', my_instance.delete_elements())
   elif my_op == 'Quit':
      break
Push <value>
Pop
Quit
What operation would you like to perform ? Push 6
Push <value>
Pop
Quit
What operation would you like to perform ? Psuh 8
Push <value>
Pop
Quit
What operation would you like to perform ? Psuh 34
Push <value>
Pop
Quit
What operation would you like to perform ? Pop
The deleted value is : 6
Push <value>
Pop
Quit
The ‘Stack_struct’ class with required attributes is created.
The ‘Stack_struct’ class with required attributes is created.
It has an ‘init’ function that is used to create an empty list.
It has an ‘init’ function that is used to create an empty list.
Another method named ‘check_empty’ that checks to see if a list is empty.
Another method named ‘check_empty’ that checks to see if a list is empty.
Another method named ‘add_elements’ is defined that adds elements to the empty list.
Another method named ‘add_elements’ is defined that adds elements to the empty list.
A method named ‘delete_elements’ is defined, that deletes elements from the list.
A method named ‘delete_elements’ is defined, that deletes elements from the list.
An object of the ‘Stack_struct’ class is created.
An object of the ‘Stack_struct’ class is created.
The user input is taken for the operation that needs to be performed.
The user input is taken for the operation that needs to be performed.
Depending on the user’ choice, the operation is performed.
Depending on the user’ choice, the operation is performed.
Relevant output is displayed on the console.
Relevant output is displayed on the console.
NATURALLEFTOUTERJOIN function

Performs an outer join of a table with another table. The tables are joined on common columns (by name) in the two tables. The two tables should be related.
If the two tables have no common column names, or if there is no relationship between the two tables, an error is returned.
DAX NATURALLEFTOUTERJOIN function is new in Excel 2016.
NATURALLEFTOUTERJOIN (<leftJoinTable>, <rightJoinTable>) 

leftJoinTable
A table expression defining the table on the left side of the join.
rightJoinTable
A table expression defining the table on the right side of the join.
table which includes only rows from rightJoinTable for which the values in the common columns specified are also present in leftJoinTable. The table returned will have the common columns from the left table and the other columns from both the tables.
There is no sort order guarantee for the results.
There is no sort order guarantee for the results.
Columns being joined on must have the same data type in both tables.
Columns being joined on must have the same data type in both tables.
Only columns from the same source table (have the same lineage) are joined on. For example, Products[ProductID], WebSales[ProductdID], StoreSales[ProductdID] with many-to-one relationships between WebSales and StoreSales and the Products table based on the ProductID column, WebSales and StoreSales tables are joined on [ProductID].
Only columns from the same source table (have the same lineage) are joined on. For example, Products[ProductID], WebSales[ProductdID], StoreSales[ProductdID] with many-to-one relationships between WebSales and StoreSales and the Products table based on the ProductID column, WebSales and StoreSales tables are joined on [ProductID].
Strict comparison semantics are used during join. There is no type coercion; for example, 1 does not equal 1.0.
Strict comparison semantics are used during join. There is no type coercion; for example, 1 does not equal 1.0.
= SUMX (NATURALLEFTOUTERJOIN (Salesperson,Sales),[Sales Amount]) 

    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
fmt.Scanln() Function in Golang With Examples - GeeksforGeeks

05 May, 2020
In Go language, fmt package implements formatted I/O with functions analogous to C’s printf() and scanf() function. The fmt.Scanln() function in Go language scans the input texts which is given in the standard input, reads from there and stores the successive space-separated values into successive arguments. This function stops scanning at a newline and after the final item, there must be a newline or EOF. Moreover, this function is defined under the fmt package. Here, you need to import the “fmt” package in order to use these functions.
Syntax:
func Scanln(a ...interface{}) (n int, err error)

Here, “a ...interface{}” receives each given texts.
Returns: It returns the number of items successfully scanned.
Example 1:
// Golang program to illustrate the usage of// fmt.Scanln() function  // Including the main packagepackage main  // Importing fmtimport (    "fmt")  // Calling mainfunc main() {      // Declaring some variables    var name string    var alphabet_count int      // Calling Scanln() function for    // scanning and reading the input    // texts given in standard input    fmt.Scanln(&name)    fmt.Scanln(&alphabet_count)      // Printing the given texts    fmt.Printf("%s %d",                name, alphabet_count)  }
Input:
GFG 3

Output:
GFG 0

Example 2:
// Golang program to illustrate the usage of// fmt.Scanln() function  // Including the main packagepackage main  // Importing fmtimport (    "fmt")  // Calling mainfunc main() {      // Declaring some variables    var name string    var alphabet_count int      // Calling Scanln() function for    // scanning and reading the input    // texts given in standard input    fmt.Scanln(&name)    fmt.Scanln(&alphabet_count)      // Printing the given texts    fmt.Printf("%s %d",                name, alphabet_count)  }
Input:
GeeksforGeeks \n 13

Output:
GeeksforGeeks 0

In the above example, it can be seen that standard input takes the value of “GeeksforGeeks \n 13” but it returns output as “GeeksforGeeks 0” this is because of this function stop scannning at new line (\n).
Golang-fmt
Go Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
fmt.Sprintf() Function in Golang With Examples
strings.Replace() Function in Golang With Examples
How to Split a String in Golang?
Golang Maps
Slices in Golang
Arrays in Go
How to Trim a String in Golang?
How to convert a string in lower case in Golang?
How to compare times in Golang?
Different Ways to Find the Type of Variable in Golang
VBA - Nested If Statement

An If or ElseIf statement inside another If or ElseIf statement(s). The inner If statements are executed based on the outermost If statements. This enables VBScript to handle complex conditions with ease.
Following is the syntax of an Nested If statement in VBScript.
If(boolean_expression) Then
   Statement 1
   .....
   .....
   Statement n
   
   If(boolean_expression) Then
      Statement 1
      .....
      .....
      Statement n
   ElseIf (boolean_expression) Then
      Statement 1
      .....
      ....
      Statement n
   Else
      Statement 1
      .....
      ....
      Statement n
   End If
Else
   Statement 1
	.....
	....
   Statement n
End If

For demo purpose, let us find the type of a positive number with the help of a function.
Private Sub nested_if_demo_Click()
   Dim a As Integer
   a = 23
  
   If a > 0 Then
      MsgBox "The Number is a POSITIVE Number"
      
      If a = 1 Then
         MsgBox "The Number is Neither Prime NOR Composite"
      ElseIf a = 2 Then
         MsgBox "The Number is the Only Even Prime Number"
      ElseIf a = 3 Then
         MsgBox "The Number is the Least Odd Prime Number"
      Else
         MsgBox "The Number is NOT 0,1,2 or 3"
      End If
   ElseIf a < 0 Then
      MsgBox "The Number is a NEGATIVE Number"
   Else
      MsgBox "The Number is ZERO"
   End If
End Sub
When the above code is executed, it produces the following result.
The Number is a POSITIVE Number
The Number is NOT 0,1,2 or 3


    101 Lectures 
     6 hours 

 Pavan Lalwani

    41 Lectures 
     3 hours 

 Arnold Higuit

    80 Lectures 
     5.5 hours 

 Prashant Panchal

    25 Lectures 
     2 hours 

 Prashant Panchal

    26 Lectures 
     2 hours 

 Arnold Higuit

    92 Lectures 
     10.5 hours 

 Vijay Kumar Parvatha Reddy
 Print
 Add Notes
 Bookmark this page
Select and add result of multiplying two columns from a table in MySQL?

You can use aggregate function SUM() for this. Let us first create a table −
mysql> create table DemoTable
   (
   CustomerId int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   CustomerProductName varchar(100),
   CustomerProductQuantity int,
   CustomerPrice int
   );
Query OK, 0 rows affected (0.17 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable(CustomerProductName,CustomerProductQuantity,CustomerPrice) values('Product-1',5,400);
Query OK, 1 row affected (0.10 sec)

mysql> insert into DemoTable(CustomerProductName,CustomerProductQuantity,CustomerPrice) values('Product-2',3,100);
Query OK, 1 row affected (0.06 sec)

mysql> insert into DemoTable(CustomerProductName,CustomerProductQuantity,CustomerPrice) values('Product-1',2,300);
Query OK, 1 row affected (0.06 sec)

mysql> insert into DemoTable(CustomerProductName,CustomerProductQuantity,CustomerPrice) values('Product-1',5,50);
Query OK, 1 row affected (0.08 sec)

mysql> insert into DemoTable(CustomerProductName,CustomerProductQuantity,CustomerPrice) values('Product-3',6,10);
Query OK, 1 row affected (0.06 sec)

mysql> insert into DemoTable(CustomerProductName,CustomerProductQuantity,CustomerPrice) values('Product-2',10,20);
Query OK, 1 row affected (0.03 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+------------+---------------------+-------------------------+---------------+
| CustomerId | CustomerProductName | CustomerProductQuantity | CustomerPrice |
+------------+---------------------+-------------------------+---------------+
| 1          | Product-1           | 5                       | 400           |
| 2          | Product-2           | 3                       | 100           |
| 3          | Product-1           | 2                       | 300           |
| 4          | Product-1           | 5                       | 50            |
| 5          | Product-3           | 6                       | 10            |
| 6          | Product-2           | 10                      | 20            |
+------------+---------------------+-------------------------+---------------+
6 rows in set (0.00 sec)
Following is the query to select and add result of multiplying two columns (CustomerProductQuantity*CustomerPrice) from a table in MySQL.
mysql> select CustomerProductName,
SUM(CustomerProductQuantity*CustomerPrice) AS TOTAL_PRICE
from DemoTable
group by CustomerProductName;
This will produce the following output −
+---------------------+-------------+
| CustomerProductName | TOTAL_PRICE |
+---------------------+-------------+
| Product-1           | 2850        |
| Product-2           | 500         |
| Product-3           | 60          |
+---------------------+-------------+
3 rows in set (0.00 sec)