code-rag-bench/online-tutorials huggingface dataset:
Count positive and negative numbers in a list in Python program

In this article, we will learn about the solution to the problem statement given below.
Problem statement − We are given a list iterable, we need to count positive and negative numbers in it and display them.
Here we need to iterate each element in the list using a for loop and check whether num>=0, to filter the positive numbers. If the condition evaluates to be true, then increase pos_count otherwise, increase neg_count.
 Live Demo
list1 = [1,-2,-4,6,7,-23,45,-0]
pos_count, neg_count = 0, 0
# enhanced for loop  
for num in list1:
   # check for being positive
   if num >= 0:
      pos_count += 1
   else:
      neg_count += 1
print("Positive numbers in the list: ", pos_count)
print("Negative numbers in the list: ", neg_count)
Positive numbers in the list: 5
Negative numbers in the list: 3
Here we need to iterate each element in the list using a for loop and check whether num>= 0, to filter the positive numbers. If the condition evaluates to be true, then increase pos_count otherwise, increase neg_count.
 Live Demo
list1 = [1,-2,-4,6,7,-23,45,-0]
pos_count, neg_count = 0, 0
num = 0
# while loop
while(num < len(list1)):
   # check
   if list1[num] >= 0:
      pos_count += 1
   else:
      neg_count += 1
   # increment num
   num += 1
print("Positive numbers in the list: ", pos_count)
print("Negative numbers in the list: ", neg_count)
Positive numbers in the list: 5
Negative numbers in the list: 3
Here we take the help of filter and lambda expressions we can directly differentiate between positive and negative numbers.
 Live Demo
list1 = [1,-2,-4,6,7,-23,45,-0]
neg_count = len(list(filter(lambda x: (x < 0), list1)))
pos_count = len(list(filter(lambda x: (x >= 0), list1)))
print("Positive numbers in the list: ", pos_count)
print("Negative numbers in the list: ", neg_count)
Positive numbers in the list: 5
Negative numbers in the list: 3
All the variables are declared in the local scope and their references are seen in the figure above.
In this article, we have learned how to count positive and negative numbers in a list.
Standard Size of character ('a') in C/C++ on Linux

In C++ the size of the character literal is char. In C the type of character literal is integer (int). So in C the sizeof(‘a’) is 4 for 32bit architecture, and CHAR_BIT is 8. But the sizeof(char) is one byte for both C and C++.
 Live Demo
#include<stdio.h>
main() {
   printf("%d", sizeof('a'));
}
1
 Live Demo
#include<iostream>
using namespace std;
main() {
   cout << sizeof('a');
}
1
In both cases, we are doing the same. But in C sizeof(‘a’) returns 4 as it is treated as an integer. But in C++ it is returning 1. It is treated as a character.
Display specific table names with MySQL LIKE Operator

To display specific table names with LIKE operator, the syntax is as follows −
select table_name as `anyAliasName`
    from information_schema.tables
where table_name like ‘yourValue%';
Let us implement the above syntax to display specific table names with LIKE operator −
mysql> select table_name as `DemoTable1600`
   -> from information_schema.tables
   -> where table_name like 'DemoTable160_%';
This will produce the following output
+---------------+
| DemoTable1600 |
+---------------+
| demotable1600 |
| demotable1601 |
| demotable1602 |
| demotable1603 |
| demotable1604 |
| demotable1605 |
| demotable1606 |
| demotable1607 |
+---------------+
8 rows in set (0.01 sec)
GATE | GATE-CS-2006 | Question 44 - GeeksforGeeks

28 Jun, 2021
Station A uses 32 byte packets to transmit messages to Station B using a sliding window protocol. The round trip delay between A and B is 80 milliseconds and the bottleneck bandwidth on the path between A and B is 128 kbps. What is the optimal window size that A should use?(A) 20(B) 40(C) 160(D) 320Answer: (B)Explanation:
Round Trip propagation delay = 80ms 
Frame size = 32*8 bits
Bandwidth = 128kbps
Transmission Time = 32*8/(128) ms = 2 ms

Let n be the window size.

UtiliZation = n/(1+2a) where a 
            = Propagation time / 
                transmission time
            = n/(1+80/2)

For maximum utilization: n = 41 
which is close to option (B)

Source : Question 1 of https://www.geeksforgeeks.org/computer-networks-set-11/Quiz of this Question
GATE-CS-2006
GATE-GATE-CS-2006
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-2015 (Set 1) | Question 65
GATE | GATE CS 2010 | Question 45
GATE | GATE-CS-2015 (Set 3) | Question 65
C++ Program to count Vowels in a string using Pointer
GATE | GATE-CS-2004 | Question 3
GATE | GATE-CS-2015 (Set 1) | Question 42
GATE | GATE CS 2011 | Question 65
GATE | GATE-CS-2014-(Set-3) | Question 65
GATE | GATE CS 2012 | Question 65
JavaScript DOM CSS

The HTML DOM allows JavaScript to change the style of HTML elements.
To change the style of an HTML element, use this syntax:
The following example changes the style of a <p> element:
The HTML DOM allows you to execute code when an event occurs.
Events are generated by the browser when "things happen" to HTML elements:
An element is clicked on
The page has loaded
Input fields are changed
You will learn more about events in the next chapter of this tutorial.
This example changes the style of the HTML element with id="id1", when the 
user clicks a button:
Visibility
How to make an element invisible. Do you want to show the element or not?
For all HTML DOM style properties, look at our complete
HTML DOM Style Object Reference.
Change the text color of the <p> element to "red".
<p id="demo"></p>

<script>
document.getElementById("demo") = "red";
</script>

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.
Java Program to remove the leading and trailing quotes from a string

Firstly, let us consider a string with quotes
String originalStr = "\"Demo Text\"";
Now, consider the following logic for the beginning quote.
if (originalStr.startsWith("\"")) {
   originalStr = originalStr.substring(1, originalStr.length());
}
Now, consider the following logic for the ending quote.
if (originalStr.endsWith("\"")) {
   originalStr = originalStr.substring(0, originalStr.length() - 1);
}
 Live Demo
public class Demo {
   public static void main(String[] args) {
      String originalStr = "\"Demo Text\"";
      System.out.println("String with double quotes= "+originalStr);
      if (originalStr.startsWith("\"")) {
         originalStr = originalStr.substring(1, originalStr.length());
      }
      if (originalStr.endsWith("\"")) {
         originalStr = originalStr.substring(0, originalStr.length() - 1);
      }
      System.out.println("String after removing double quotes = "+originalStr);
   }
}
String with double quotes= "Demo Text" String after removing double quotes = Demo Text
How to add a navigation menu on an image with CSS?

Following is the code to add a navigation menu on an image using CSS −
 Live Demo
<!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>
body{
   margin:0px;
   margin-top:10px;
   padding: 0px;
}
nav{
   width: 50%;
   background-color: rgb(23, 104, 43);
   overflow: auto;
   height: auto;
}
.links {
   display: inline-block;
   text-align: center;
   padding: 14px;
   color: rgb(255, 255, 255);
   text-decoration: none;
   font-size: 17px;
}
.links:hover {
   background-color: rgb(129, 123, 123);
}
.selected{
   background-color: rgb(0, 56, 42);
}
.image-nav{
   background:url('https://i.picsum.photos/id/652/1366/1366.jpg');
   min-height: 400px;
   padding: 20px;
   background-position: center;
   background-repeat: no-repeat;
   background-size: cover;
   width: 70%;
}
</style>
</head>
<body>
<div class="image-nav">
<nav>
<a class="links selected" href="#">Home</a>
<a class="links" href="#">Login</a>
<a class="links" href="#"> Register</a>
<a class="links" href="#">Contact Us</a>
<a class="links" href="#">More Info</a>
</nav>
</div>
</body>
</html>
The above code will produce the following output −
Byte compare() method in Java with examples - GeeksforGeeks

05 Dec, 2018
The compare() method of Byte class is a built in method in Java which is used to compare two byte values.
Syntax
Byte.compare(byte a, byte b)
Parameters: It takes two byte value ‘a’ and ‘b’ as input in the parameters which are to be compared.
Return Value: It returns an int value. It returns:
0 if ‘a is equal to ‘b,
a positive value ‘a’ is greater than ‘b’,
a negative value ‘b’ is greater than ‘a’
Below is the implementation of compare() method in Java:
Example 1:
// Java code to demonstrate// Byte compare() method  class GFG {    public static void main(String[] args)    {          // byte value 'a'        byte a = 20;          // byte value 'b'        byte b = 20;          // compare method of Byte class        int output = Byte.compare(a, b);          // printing the output        System.out.println("Comparing " + a                           + " and " + b + " : "                           + output);    }}
Comparing 20 and 20 : 0

Example 2:
// Java code to demonstrate// Byte compare() method  class GFG {    public static void main(String[] args)    {          // byte value 'a'        byte a = 20;          // byte value 'b'        byte b = 10;          // compare method of Byte class        int output = Byte.compare(a, b);          // printing the output        System.out.println("Comparing " + a                           + " and " + b + " : "                           + output);    }}
Comparing 20 and 10 : 10

Example 3:
// Java code to demonstrate// Byte compare() method  class GFG {    public static void main(String[] args)    {          // byte value 'a'        byte a = 10;          // byte value 'b'        byte b = 20;          // compare method of Byte class        int output = Byte.compare(a, b);          // printing the output        System.out.println("Comparing " + a                           + " and " + b + " : "                           + output);    }}
Comparing 10 and 20 : -10

Java - util package
Java-Byte
Java-Functions
java-lang-reflect-package
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Interfaces in Java
ArrayList in Java
Initialize an ArrayList in Java
Singleton Class in Java
Overriding in Java
Collections in Java
Multithreading in Java
Set in Java
LinkedList in Java
Stream In Java
How to place two divs next to each other in HTML? 

With CSS properties, you can easily put two <div> next to each other in HTML. Use the CSS property float to achieve this.
With that, add height:100px and set margin.
You can try to run the following code to place two <div> side by side −
Live Demo
<!DOCTYPE html>
<html>
<head>
<title>HTML div</title>
</head>
<body>
<div style="width: 100px; float:left; height:100px; background:gray; margin:10px">
First DIV
</div>
<div style="width: 100px; float:left; height:100px; background:yellow; margin:10px">
Second DIV
</div>
</body>
</html>
Java static block

static keyword can be used to create a block to be used to initialize static variables.
 This static block executes when classloader loads the class. A static block is invoked before main() method. You can verify the same using.
Live Demo
public class Tester {
   static {
      System.out.println("In static block");
   }
   public static void main(String[] arguments) {
      System.out.println("In main");
   }
}
How to uninstall software using WMI in PowerShell?

There are mainly 3 methods by which you can uninstall software using PowerShell.
WMI Method.
WMI Method.
Using Package provider
Using Package provider
Uninstallation String.
Uninstallation String.
We will discuss here the WMI method to uninstall software.
With WMI class Win32_Product you can retrieve the list of software uninstalled in your local or the remote systems. If you need specific software, you can filter by its name. For example,
Get-WmiObject Win32_Product -Filter "Name='Vmware tools'"
Or You can retrieve the name of the installed software using the Where-Object pipeline command.
Get-WmiObject Win32_Product | Where{$_.Name -eq "Vmware tools"}
PS C:\Users\Administrator> Get-WmiObject Win32_Product | Where{$_.Name -eq
"Vmware tools"}
IdentifyingNumber : {D533345C-7F8D-4807-AE80-E06CE2045B0E}
Name              : VMware Tools
Vendor            : VMware, Inc.
Version           : 11.0.6.15940789
Caption           : VMware Tools
Below are the supported methods for this WMI object command.
Get-WmiObject Win32_Product -Filter "Name='Vmware tools'" | gm -MemberType Method
| Select Name, MemberType
Name          MemberType
----          ----------
Configure       Method
Reinstall       Method
Uninstall       Method
Upgrade         Method
There is an Uninstall() method supported by this command. We can use this method to uninstall the software. For example,
$vtools = Get-WmiObject win32_product -Filter "Name='Vmware tools'"
$vtools.Uninstall()
Major Activities of an Operating System with Regard to Secondary Storage Management

Secondary storage devices are non-volatile devices where the data is stored for long-term storage. Disks are the mainly used secondary storage devices. They provide the bulk of secondary storage in operating systems today.
The main activity that is performed in secondary storage management is disk scheduling. There are many disk scheduling algorithms. However, the important ones are FCFS scheduling, SSTF scheduling, SCAN scheduling and LOOK scheduling.
All the disk scheduling algorithms are explained using the following requests for the disk -
10, 95, 23, 78, 80
In first come first served scheduling, the requests are serviced in their coming order. This algorithm is fair as it allows all requests a chance but it does not provide the fastest possible service. An example of FCFS scheduling is given below -
In the above example, the requests are serviced in the order they appear i.e 10, 95, 23, 78, 80. The seek head is initially positioned at 50 and it starts from there.
The requests that are closest to the current head are served first before moving away in shortest seek time first scheduling algorithm. A problem with the SSTF algorithm is that it may cause starvation for some requests.
An example of SSTF scheduling is given below -
In the above example, the requests are serviced in the order 23, 10, 78, 80, 95. The seek head is initially positioned at 50 and it starts from there. 23 is closest to 50 so it is serviced first. Then 10 is closer to 23 than 78 so it is serviced next. After this 78, 80 and 95 are serviced.
In this scheduling algorithm, the head moves towards one direction while servicing all the requests in that direction until it reaches the end of the disk. After that it starts moving towards the other direction. In this way, the head continuously scans back and forth across the disk.
An example of SCAN scheduling is given below -
In the above example, the requests are serviced in the order 23, 10, 78, 80, 95. The head is initially at 50 and moves towards the left while servicing requests 23 and 10. When it reaches the end of the disk, it starts moving right and services 78, 80 and 95 as they occur.
m is similar to SCAN scheduling but is its practical version. In this algorithm, the head moves towards one direction while servicing all the requests in that direction until it reaches the last request. After that, it starts moving towards the other direction. An example of LOOK scheduling is given below -
In the above example, the requests are serviced in the order 23, 10, 78, 80, 95. The head is initially at 50 and moves towards the left while servicing requests 23 and 10. When it reaches the last request on the left i.e. 10, it starts moving right and services 78, 80 and 95 as they occur.
How to add a TextView to a LinearLayout dynamically in Android using Kotlin?

This example demonstrates how to add a TextView to a LinearLayout dynamically in Android using Kotlin.
Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.
Step 2 − Add the following code to res/layout/activity_main.xml.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:tools="http://schemas.android.com/tools"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:orientation="vertical"
   android:id="@+id/linearLayout"
   android:padding="16sp"
   tools:context=".MainActivity">
</LinearLayout>
Step 3 − Add the following code to src/MainActivity.kt
import android.graphics.Color
import android.os.Bundle
import android.widget.LinearLayout
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
class MainActivity : AppCompatActivity() {
   override fun onCreate(savedInstanceState: Bundle?) {
      super.onCreate(savedInstanceState)
      setContentView(R.layout.activity_main)
      title = "KotlinAp"
      val linearLayout: LinearLayout = findViewById(R.id.linearLayout)
      val textView = TextView(this)
      textView.text = "I am added dynamically to the view"
      val params = LinearLayout.LayoutParams(
         LinearLayout.LayoutParams.MATCH_PARENT,
         LinearLayout.LayoutParams.MATCH_PARENT
      )
      textView.layoutParams = params
      textView.textSize = 24F
      textView.setTextColor(Color.RED)
      linearLayout.addView(textView)
   }
}
Step 4 − Add the following code to androidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.q11">
   <application
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:supportsRtl="true"
      android:theme="@style/AppTheme">
      <activity android:name=".MainActivity">
         <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
         </intent-filter>
      </activity>
   </application>
</manifest>
Let's try to run your application. I assume you have connected your actual Android Mobile device with your computer. To run the app from android studio, open one of your project's activity files and click the
Run icon from the toolbar. Select your mobile device as an option and then check your mobile device which will display your default screen
How to convert Varchar to Double in SQL?

You can convert varchar to double using CAST() function. The syntax is as follows:
SELECT yourColumnName1,yourColumnName2,......N, CAST(yourColumnName AS DECIMAL(TotalDigit,DigitAfterDecimalPoint)) anyVariableName FROM yourtableName
ORDER BY anyVariableName DESC;
To understand the above syntax, let us create a table. The query to create a table is as follows:
mysql> create table VarcharToDouble
   -> (
   -> Id int NOT NULL AUTO_INCREMENT,
   -> Name varchar(10),
   -> Amount varchar(10) ,
   -> PRIMARY KEY(Id)
   -> );
Query OK, 0 rows affected (0.67 sec)
Insert some records in the table using insert command. The query is as follows:
mysql> insert into VarcharToDouble(Name,Amount) values('John','456.78');
Query OK, 1 row affected (0.14 sec)
mysql> insert into VarcharToDouble(Name,Amount) values('Larry','8465.98');
Query OK, 1 row affected (0.18 sec)
mysql> insert into VarcharToDouble(Name,Amount) values('Mike','9083.45');
Query OK, 1 row affected (0.12 sec)
mysql> insert into VarcharToDouble(Name,Amount) values('Sam','46475.50');
Query OK, 1 row affected (0.19 sec)
mysql> insert into VarcharToDouble(Name,Amount) values('Carol','10003.35');
Query OK, 1 row affected (0.17 sec)
Display all records from the table using select statement. The query is as follows:
mysql> select *from VarcharToDouble;
The following is the output:
+----+-------+----------+
| Id | Name  | Amount   |
+----+-------+----------+
|  1 | John  | 456.78   |
|  2 | Larry | 8465.98  |
|  3 | Mike  | 9083.45  |
|  4 | Sam   | 46475.50 |
|  5 | Carol | 10003.35 |
+----+-------+----------+
5 rows in set (0.00 sec)
Here is the query to convert varchar to double using CAST():
mysql> select Id,Name, CAST(Amount AS DECIMAL(10,2)) TotalAmount from VarcharToDouble
   -> order by TotalAmount desc;
The following is the output:
mysql> select Id,Name, CAST(Amount AS DECIMAL(10,2)) TotalAmount from VarcharToDouble
   -> order by TotalAmount desc;
LocalDate format() method in Java - GeeksforGeeks

28 Nov, 2018
The format() method of LocalDate class in Java method formats this date using the specified formatter.
Syntax:
public String format(DateTimeFormatter formatter)

Parameter: This method accepts a parameter obj which specifies the formatter to be used and it is not null.
Exceptions: The function throws only DateTimeException which occurs during an error in printing.
Return Value: It returns the formatted date string and not null.
Below programs illustrate the format() method of LocalDate in Java:
Program 1:
// Program to illustrate the format() method  import java.util.*;import java.time.*;import java.time.format.DateTimeFormatter;  public class GfG {    public static void main(String[] args)    {          // Parses the date        LocalDate dt = LocalDate.parse("2018-11-01");        System.out.println(dt);          // Function call        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/YYYY");        System.out.println(formatter.format(dt));    }}
2018-11-01
01/11/2018

Program 2: To illustrate the exception.
// Program to illustrate the format() method// Exception Program  import java.util.*;import java.time.*;import java.time.format.DateTimeFormatter;  public class GfG {    public static void main(String[] args)    {        try {            // Parses the date            LocalDate dt = LocalDate.parse("2018-01-32");            System.out.println(dt);              // Function call            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/YYYY");            System.out.println(formatter.format(dt));        }        catch (Exception e) {            System.out.println(e);        }    }}
java.time.format.DateTimeParseException: 
Text '2018-01-32' could not be parsed: Invalid value for DayOfMonth (valid values 1 - 28/31): 32

Reference: https://docs.oracle.com/javase/10/docs/api/java/time/LocalDate.html#format(java.time.format.DateTimeFormatter)
Java-Functions
Java-LocalDate
Java-time package
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Initialize an ArrayList in Java
Interfaces in Java
ArrayList in Java
Multidimensional Arrays in Java
Stack Class in Java
Singleton Class in Java
LinkedList in Java
Collections in Java
Set in Java
Overriding in Java
Draw an Olympic Symbol in Python using Turtle - GeeksforGeeks

04 Apr, 2022
Prerequisites: Turtle Programming in Python
The Olympic rings are five interlaced rings, colored blue, yellow, black, green, and red on a white field. As shown in the below image.
import Turtle module
set the thickness for each ring
draw each circle with specific coordinates
Below is the implementation.
Python3
import turtle # object tr for turtletr = turtle.Turtle() # set thickness for each ringtr.pensize(5) tr.color("blue")tr.penup()tr.goto(-110, -25)tr.pendown()tr.circle(45) tr.color("black")tr.penup()tr.goto(0, -25)tr.pendown()tr.circle(45) tr.color("red")tr.penup()tr.goto(110, -25)tr.pendown()tr.circle(45) tr.color("yellow")tr.penup()tr.goto(-55, -75)tr.pendown()tr.circle(45) tr.color("green")tr.penup()tr.goto(55, -75)tr.pendown()tr.circle(45)
surinderdawra388
Python-turtle
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
How to get value of data attribute and use it in jQuery?

To get value of data attribute, use −
$(“yourSelector”).data()
The following is our input type with data attribute −
<input type="text" id="txtValue" src="" data-value="90">
Following is the code −
 Live Demo
<!DOCTYPE html>
<html lang="en">
<head>
   <meta charset="UTF-8">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <title>Document</title>
</head>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<body>
   <input type="text" id="txtValue" src="" data-value="90">
</body>
<script>
   var value = $('#txtValue').data('value');
   console.log("The value is=" + value);
</script>
</html>
The output is as follows −
HTML <object> data Attribute

Tha data attribute of the <object> element sets the URL of the resource, which can be audio, video, pdf, flash, etc. used by the object.
Following is the syntax:
<object data="url">
The url is the URL of the resource used by the object.
Let us now see an example to implement the data attribute of the <object> element:
 Live Demo
<!DOCTYPE html>
<html>
<body>
<h2>CSS Demonstrating Application</h2>
   <object data="https://www.tutorialspoint.com/flex/samples/CSSApplication.swf" height="400" width="600"></object>
</body>
</html>
In the above example, we have set the URL of the resource, which is a .swf file i.e. a flash file:
<object data="https://www.tutorialspoint.com/flex/samples/CSSApplication.swf" height="400" width="600"></object>
The external link we have used in the <object> element is:
https://www.tutorialspoint.com/flex/samples/CSSApplication.swf
LESS - Import Options Reference Keyword

The @import (reference) is used to import external files but it will not add imported styles to compiled CSS file. This was released in version 1.5.0.
The following example demonstrates the use of reference keyword in the LESS file −
<html>
   <head>
     <link rel = "stylesheet" href = "style.css" type = "text/css" />
     <title>Import Options Reference</title>
   </head>

   <body>
      <h1>Welcome to Tutorialspoint</h1>
      <p>LESS is a CSS pre-processor that enables customizable, 
      manageable and reusable style sheet for web site.</p>
   </body>
</html>
Next, create the style.less file.
@import (reference) "http://www.tutorialspoint.com/less/import_reference.less";
p {
   .style1;
}
The following code will import the import_reference.less file into style.less from the https://www.tutorialspoint.com/less/import_reference.less path −
.style1 {
   color: #A0A0A0;
   font-family: "Comic Sans MS";
   font-size: 20px;
}
You can compile the style.less to style.css by using the following command −
lessc style.less style.css

Execute the above command; it will create the style.css file automatically with the following code −
p {
   color: #A0A0A0;
   font-family: "Comic Sans MS";
   font-size: 20px;
}
Follow these steps to see how the above code works −
Save the above html code in the import_options_reference.html file.
Save the above html code in the import_options_reference.html file.
Open this HTML file in a browser, the following output will get displayed.
Open this HTML file in a browser, the following output will get displayed.
The reference has the extend method that pulls in a new selector at the place where you refer the @import statement and marks it as not referenced. For more information, click here.

    20 Lectures 
     1 hours 

 Anadi Sharma

    44 Lectures 
     7.5 hours 

 Eduonix Learning Solutions

    17 Lectures 
     2 hours 

 Zach Miller

    23 Lectures 
     1.5 hours 

 Zach Miller

    34 Lectures 
     4 hours 

 Syed Raza

    31 Lectures 
     3 hours 

 Harshit Srivastava
 Print
 Add Notes
 Bookmark this page
Date format validation using C# Regex

Use the DateTime.TryParseExact method in C# for Date Format validation.
They method converts the specified string representation of a date and time to its DateTime equivalent. It checks whether the entered date format is correct or not.
 Live Demo
using System;
using System.Globalization;

namespace Demo {
   class Program {
      static void Main(string[] args) {
         DateTime d;

         bool chValidity = DateTime.TryParseExact(
         "08/14/2018",
         "MM/dd/yyyy",
         CultureInfo.InvariantCulture,
         DateTimeStyles.None,
         out d);

         Console.WriteLine(chValidity);
      }
   }
}
True
Difference between == and is operator in python.

is and equals(==) operators are mostly same but they are not same. is operator defines if both the variables point to the same object whereas the == sign checks if the values for the two variables are the same.
# Python program to  
# illustrate the  
# difference between 
# == and is operator 
# [] is an empty list 
list1 = [] 
list2 = [] 
list3=list1 
  
if (list1 == list2): 
   print("True") 
else: 
   print("False") 
  
if (list1 is list2): 
   print("True") 
else: 
   print("False") 
  
if (list1 is list3): 
   print("True") 
else:     
   print("False")
True
False
True
What is Type casting in C#?

Type casting is converting one type of data to another type. The two forms are −
Implicit type conversion − These conversions are performed by C# in a type-safe manner. For example, are conversions from smaller to larger integral types and conversions from derived classes to base classes.
Explicit type conversion− These conversions are done explicitly by users using the pre-defined functions. Explicit conversions require a cast operator.
The following are the built-in type conversion methods −
The following example convert integer to string type −
 Live Demo
using System;

namespace Demo {
   class Program {
      static void Main(string[] args) {
         int i = 20;

         Console.WriteLine(i.ToString());
         Console.ReadKey();
      }
   }
}
20
How to count values from a PHP array and show value only once in a foreach loop?

Let’s say the following is our PHP array 
$listOfNames = array('John','David','Mike','David','Mike','David');
We want the output to display the count of values in the above array like this −
Array ( [John] => 1 [David] => 3 [Mike] => 2 )
To get the count, use inbuilt function array_count_values().
The PHP code is as follows
 Live Demo
<!DOCTYPE html>
<html>
<body>
<?php
$listOfNames = array('John','David','Mike','David','Mike','David');
$frequencyOfEachName = array_count_values($listOfNames);
print_r( $frequencyOfEachName);
?>
</body>
</html>
This will produce the following output
Array ( [John] => 1 [David] => 3 [Mike] => 2 )
VBScript Exit Do statement

An Exit Do Statement is used when we want to Exit the Do Loops based on certain criteria. It can be used within both Do..While and Do..Until Loops.
When Exit Do is executed, the control jumps to next statement immediately after the Do Loop.
The syntax for Exit Do Statement in VBScript is −
 Exit Do

The below example uses Exit Do. If the value of the Counter reaches 10, the Do Loop is Exited and control jumps to the next statement immediately after the For Loop.
<!DOCTYPE html>
<html>
   <body>
      <script language = "vbscript" type = "text/vbscript">
         i = 0
         Do While i <= 100
            If i > 10 Then
               Exit Do   ' Loop Exits if i>10
            End If
            document.write("The Value of i is : " &i)
            document.write("<br></br>")
            i = i + 2
         Loop   
         
      </script>
   </body>
</html>
When the above code is executed, it prints the following output in the console.
The Value of i is : 0

The Value of i is : 2

The Value of i is : 4

The Value of i is : 6

The Value of i is : 8

The Value of i is : 10


    63 Lectures 
     4 hours 

 Frahaan Hussain
 Print
 Add Notes
 Bookmark this page
Get the storage size of a database in MongoDB?

To get the storage size of a database in MongoDB, use the stats() method.
At first, check the current database with the help of the following query −
> db;
The following is the output −
test
Here is the query to get the storage size of the database in MongoDB −
> db.stats()
The following is the output displaying the stats including the storage size −
The following is the output −
{
   "db" : "test",
   "collections" : 114,
   "views" : 0,
   "objects" : 391,
   "avgObjSize" : 83.0076726342711,
   "dataSize" : 32456,
   "storageSize" : 3211264,
   "numExtents" : 0,
   "indexes" : 120,
   "indexSize" : 2494464,
   "fsUsedSize" : 126172377088,
   "fsTotalSize" : 199229435904,
   "ok" : 1
}
Java Arrays

Arrays are used to store multiple values in a single variable, instead of declaring separate variables for each 
value.
To declare an array, define the variable type with square brackets:
String[] cars;

We have now declared a variable that holds an array of strings. To insert 
values to it, we can use an array literal - place the values in a 
comma-separated list, inside curly braces:
String[] cars = {"Volvo", "BMW", "Ford", "Mazda"};

To create an array of integers, you could write:
int[] myNum = {10, 20, 30, 40};

You access an array element by referring to the index number.
This statement accesses the value of the first element in cars:
String[] cars = {"Volvo", "BMW", "Ford", "Mazda"};
System.out.println(cars[0]);
// Outputs Volvo


Try it Yourself »

Note: Array indexes start with 0: [0] is the first element. [1] is the second 
element, etc.
To change the value of a specific element, refer to the index number:
cars[0] = "Opel";

String[] cars = {"Volvo", "BMW", "Ford", "Mazda"};
cars[0] = "Opel";
System.out.println(cars[0]);
// Now outputs Opel instead of Volvo


Try it Yourself »

 
To find out how many elements an array has, use the length property:
String[] cars = {"Volvo", "BMW", "Ford", "Mazda"};
System.out.println(cars.length);
// Outputs 4


Try it Yourself »

Create an array of type String called cars.
  = {"Volvo", "BMW", "Ford"};

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.
CSS text-rendering - GeeksforGeeks

27 Nov, 2020
Text-rendering is a property that allows you to choose what to optimize when rendering text. It sends the information to the rendering engine about what to optimize for while rendering text. 
It’s actually not a CSS property and is not defined in any CSS standard. It’s an SVG property but Gecko and Webkit browsers allow you to apply this property to the HTML elements. In doing so compromises among other aspects like speed, legibility(Clarity), and geometric precision.
Syntax:
text-rendering : auto | optimizeSpeed | 
                 optimizeLegibility | geometricPrecision;
Values:
auto: Browser makes predictions about when you can adjust speed, readability, and geometric accuracy while drawing text. Different browsers respond with different values.
optimizeSpeed: Browser prioritizes more the rendering speed compared to legibility and geometric precision while drawing text. It disables kerning and ligatures.
optimizeLegibility: Browser prioritizes more legibility compared to rendering speed and geometric precision while drawing text.  It enables kerning and optional ligatures.
geometricPrecision: The browser prioritizes more geometric precision compared to rendering speed and legibility while drawing text. Certain aspects of fonts like kerning, don’t scale linearly hence it can make text using those fonts look even better.
 Example :
HTML
<!DOCTYPE html><html>   <head>      <title>Geeks For Geeks</title>      <style>         .auto {         text-rendering: auto;         }         .optimizeSpeed{         text-rendering: optimizeSpeed;         }         .optimizeLegibility {         text-rendering: optimizeLegibility;         }         .geometricPrecision{         text-rendering: geometricPrecision;         }      </style>   </head>   <body>      <h2 style="color:#3FBF3F">text-rendering</h2>      <p class="auto">Welcome to GFG</p>        <p class="optimizeSpeed">Welcome to GFG</p>        <p class="optimizeLegibility">Welcome to GFG</p>        <p class="geometricPrecision">Welcome to GFG</p>     </body></html>
Output: 
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
CSS-Misc
Picked
CSS
HTML
Technical Scripter
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Design a web page using HTML and CSS
Form validation using jQuery
How to fetch data from localserver database and display on HTML table using PHP ?
How to Create Time-Table schedule using HTML ?
Search Bar using HTML, CSS and JavaScript
REST API (Introduction)
How to Insert Form Data into Database using PHP ?
Form validation using HTML and JavaScript
How to set input type date in dd-mm-yyyy format using HTML ?
How to set the default value for an HTML <select> element ?
Inorder Traversal of a Threaded Binary Tree in C++

Here we will see the threaded binary tree data structure. We know that the binary tree nodes may have at most two children. But if they have only one children, or no children, the link part in the linked list representation remains null. Using threaded binary tree representation, we can reuse that empty links by making some threads.
If one node has some vacant left or right child area, that will be used as thread. There are two types of threaded binary tree. The single threaded tree or fully threaded binary tree.
For fully threaded binary tree, each node has five fields. Three fields like normal binary tree node, another two fields to store Boolean value to denote whether link of that side is actual link or thread.
This is the fully threaded binary tree
inorder():
Begin
   temp := root
   repeat infinitely, do
   p := temp
   temp = right of temp
   if right flag of p is false, then
      while left flag of temp is not null, do
         temp := left of temp
      done
   end if
   if temp and root are same, then
      break
   end if
      print key of temp
   done
End
 Live Demo
#include <iostream>
#define MAX_VALUE 65536
using namespace std;
class N { //node declaration
   public:
      int k;
      N *l, *r;
      bool leftTh, rightTh;
};
class ThreadedBinaryTree {
   private:
   N *root;
   public:
   ThreadedBinaryTree() { //constructor to initialize the variables
      root= new N();
      root->r= root->l= root;
      root->leftTh = true;
      root->k = MAX_VALUE;
   }
   void insert(int key) {
      N *p = root;
      for (;;) {
      if (p->k< key) { //move to right thread
         if (p->rightTh)
            break;
         p = p->r;
      }
      else if (p->k > key) { // move to left thread
         if (p->leftTh)
            break;
         p = p->l;
      }
      else {
         return;
      }
   }
   N *temp = new N();
   temp->k = key;
   temp->rightTh= temp->leftTh= true;
   if (p->k < key) {
      temp->r = p->r;
      temp->l= p;
      p->r = temp;
      p->rightTh= false;
   }
   else {
      temp->r = p;
      temp->l = p->l;
      p->l = temp;
      p->leftTh = false;
   }
}
void inorder() { //print the tree
   N *temp = root, *p;
   for (;;) {
      p = temp;
      temp = temp->r;
      if (!p->rightTh) {
         while (!temp->leftTh) {
            temp = temp->l;
         }
      }
      if (temp == root)
         break;
         cout<<temp->k<<" ";
      }
      cout<<endl;
   }
};
int main() {
   ThreadedBinaryTree tbt;
   cout<<"Threaded Binary Tree\n";
   tbt.insert(56);
   tbt.insert(23);
   tbt.insert(89);
   tbt.insert(85);
   tbt.insert(20);
   tbt.insert(30);
   tbt.insert(12);
   tbt.inorder();
   cout<<"\n";
}
Threaded Binary Tree
12 20 23 30 56 85 89
How to handle python exception inside if statement?

The code can be written as follows to catch the exception
a, b=5, 0
try:
   if b != 0:
       print a/b
   else:
       a/b
       raise ZeroDivisionError
except Exception as e:
       print e
We get the following output
C:/Users/TutorialsPoint1/~.py
integer division or modulo by zero
Prettify JSON data in textarea input in JavaScript?

For this, use JSON.parse() along with JSON.stringify().
 Live Demo
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initialscale=1.0">
<title>Document</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fontawesome/4.7.0/css/font-awesome.min.css">
</head>
<body>
<textarea id="prettyJSONFormat" cols=100 rows=20></textarea>
<button onclick="printTheJSONInPrettyFormat()">Click The Button To
get the Pretty JSON</button>
<script>
   function printTheJSONInPrettyFormat() {
      var badJSON = document.getElementById('prettyJSONFormat').value;
      var parseJSON = JSON.parse(badJSON);
      var JSONInPrettyFormat = JSON.stringify(parseJSON, undefined, 4);
      document.getElementById('prettyJSONFormat').value =
      JSONInPrettyFormat;
   }
</script>
</body>
</html>
To run the above program, just save the file name anyName.html(index.html) and right click on
the file and select the option open with live server in VS Code editor.
This will produce the following output −
Now, I am going to put some bad (unformatted) JSON. The sample JSON data is as follows −
After clicking the button, you will get the following sample output i.e. properly formatted JSON −
Java Examples - Parent Directory

How to get the parent directory of a file ?
Following example shows how to get the parent directory of a file by the use of file.getParent() method of File class.
import java.io.File;

public class Main {
   public static void main(String[] args) { 
      File file = new File("C:/File/demo.txt");
      String strParentDirectory = file.getParent();
      System.out.println("Parent directory is : " + strParentDirectory);
   }
}
The above code sample will produce the following result.
Parent directory is : File

The following is an another example to get the parent directory of a file
import java.io.File;
import java.util.Scanner;

public class CheckParentDirectory { 
   public static void main(String args[]) {
      Scanner scanner = new Scanner(System.in);
      System.out.println("Enter the file path");
      String filePath = scanner.next();
      File fileToTest = new File(filePath);
      
      if (!fileToTest.isDirectory()) {
         System.out.println("This is File");
         System.out.println("Parent Folder of this file is :" + fileToTest.getParent());
      } else {
         System.out.println("This is Directory");
         System.out.println(
            "Parent Folder of this directory is :" + fileToTest.getParent());
      } 
   }
}
The above code sample will produce the following result.
Enter the file path
C:\Apache24\htdocs\javaexamples\dir_modification.htm
This is File
Parent Folder of this file is :C:\Apache24\htdocs\javaexamples

 Print
 Add Notes
 Bookmark this page
std::bit_xor in C++ with Examples

01 May, 2020
The bit_xor is an inbuilt function in C++ which is used to perform bitwise_xor and return the result after applying the bitwise_xor operation on it’s arguments.
Header File:
#include <functional.h>

Template Class:
template <class T> struct bit_xor;

Parameters: It accepts a parameter T which is the type of the argument to be compared by the functional call.
Note:
Objects of this class can be used on standard algorithms such as transform or accumulate.Member functions ( ‘operator()’ ) returns the bit_xor of its arguments.
Objects of this class can be used on standard algorithms such as transform or accumulate.
Member functions ( ‘operator()’ ) returns the bit_xor of its arguments.
We must include the library ‘functional’ and ‘algorithm’ to use bit_xor and transform() respectively.
Below is the illustration of bit_xor in C++:Problem 1:
// C++ program to illustrate bit_xor in C++  #include <algorithm>#include <functional> // to include bit_xor#include <iostream>#include <iterator>using namespace std;  int main(){    // declaring the values    int A[] = { 1, 2, 3, 4, 5, 6 };    int B[] = { 6, 7, 8, 4, 5, 0 };    int n = 6;    // defining result    int result[n];      // transform is used to apply bitwise_xor    // on the arguments A and B    transform(A, end(A), B,              result, bit_xor<int>());      // printing the resulting array    cout << "A xor B = ";    for (const int& answer : result)        cout << ' ' << answer;      return 0;}
A xor B =  7 5 11 0 0 6

Program 2:
// C++ program to illustrate bit_xor in C++  #include <algorithm>#include <functional>#include <iostream>#include <iterator>using namespace std;  int main(){    // declaring the values    int A[] = { 0, 0xff, 15, 22 };    int B[] = { 1, 255, 0xfa, 0x16 };    int n = 4;    // defining result    int result[n];      // transform is used to apply bitwise_xor    // on the arguments A and B    transform(A, end(A), B,              result, bit_xor<int>());      // printing the resulting array    cout << "A xor B = ";    for (const int& answer : result)        cout << ' ' << answer;      return 0;}
A xor B =  1 0 245 0

Reference: https://en.cppreference.com/w/cpp/utility/functional/bit_xor
Bitwise-XOR
CPP-Functions
C++
C++ Programs
Write From Home
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Sorting a vector in C++
Polymorphism in C++
Friend class and function in C++
Pair in C++ Standard Template Library (STL)
std::string class in C++
Header files in C/C++ and its uses
Sorting a Map by value in C++ STL
Program to print ASCII Value of a character
How to return multiple values from a function in C or C++?
Shallow Copy and Deep Copy in C++